mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
Handle AcidBreathDamage immunity in standard way.
This commit is contained in:
@@ -266,7 +266,9 @@ void DefaultSpellMechanics::castNormal(const SpellCastEnvironment * env, const B
|
|||||||
|
|
||||||
//checking if creatures resist
|
//checking if creatures resist
|
||||||
handleResistance(env, ctx.attackedCres, ctx.sc);
|
handleResistance(env, ctx.attackedCres, ctx.sc);
|
||||||
//it is actual spell and can be reflected to single target, no recurrence
|
|
||||||
|
//reflection is applied only to negative spells
|
||||||
|
//if it is actual spell and can be reflected to single target, no recurrence
|
||||||
const bool tryMagicMirror = owner->isNegative() && owner->level && owner->getLevelInfo(0).range == "0";
|
const bool tryMagicMirror = owner->isNegative() && owner->level && owner->getLevelInfo(0).range == "0";
|
||||||
if(tryMagicMirror)
|
if(tryMagicMirror)
|
||||||
{
|
{
|
||||||
@@ -765,7 +767,7 @@ void DefaultSpellMechanics::handleImmunities(const CBattleInfoCallback * cb, con
|
|||||||
void DefaultSpellMechanics::handleResistance(const SpellCastEnvironment * env, std::vector<const CStack* >& attackedCres, BattleSpellCast& sc) const
|
void DefaultSpellMechanics::handleResistance(const SpellCastEnvironment * env, std::vector<const CStack* >& attackedCres, BattleSpellCast& sc) const
|
||||||
{
|
{
|
||||||
//checking if creatures resist
|
//checking if creatures resist
|
||||||
//resistance/reflection is applied only to negative spells
|
//resistance is applied only to negative spells
|
||||||
if(owner->isNegative())
|
if(owner->isNegative())
|
||||||
{
|
{
|
||||||
std::vector <const CStack*> resisted;
|
std::vector <const CStack*> resisted;
|
||||||
@@ -802,7 +804,6 @@ bool DefaultSpellMechanics::requiresCreatureTarget() const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<const CStack *> SpecialSpellMechanics::calculateAffectedStacks(const CBattleInfoCallback * cb, const SpellTargetingContext & ctx) const
|
std::vector<const CStack *> SpecialSpellMechanics::calculateAffectedStacks(const CBattleInfoCallback * cb, const SpellTargetingContext & ctx) const
|
||||||
{
|
{
|
||||||
return std::vector<const CStack *>();
|
return std::vector<const CStack *>();
|
||||||
|
|||||||
@@ -61,13 +61,13 @@ protected:
|
|||||||
virtual void applyBattleEffects(const SpellCastEnvironment * env, const BattleSpellCastParameters & parameters, SpellCastContext & ctx) const;
|
virtual void applyBattleEffects(const SpellCastEnvironment * env, const BattleSpellCastParameters & parameters, SpellCastContext & ctx) const;
|
||||||
|
|
||||||
virtual std::vector<const CStack *> calculateAffectedStacks(const CBattleInfoCallback * cb, const SpellTargetingContext & ctx) const;
|
virtual std::vector<const CStack *> calculateAffectedStacks(const CBattleInfoCallback * cb, const SpellTargetingContext & ctx) const;
|
||||||
virtual void handleImmunities(const CBattleInfoCallback * cb, const SpellTargetingContext & ctx, std::vector<const CStack *> & stacks) const;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void doDispell(BattleInfo * battle, const BattleSpellCast * packet, const CSelector & selector) const;
|
void doDispell(BattleInfo * battle, const BattleSpellCast * packet, const CSelector & selector) const;
|
||||||
private:
|
private:
|
||||||
void castNormal(const SpellCastEnvironment * env, const BattleSpellCastParameters & parameters, std::vector <const CStack*> & reflected) const;
|
void castNormal(const SpellCastEnvironment * env, const BattleSpellCastParameters & parameters, std::vector <const CStack*> & reflected) const;
|
||||||
void castMagicMirror(const SpellCastEnvironment * env, const BattleSpellCastParameters & parameters) const;
|
void castMagicMirror(const SpellCastEnvironment * env, const BattleSpellCastParameters & parameters) const;
|
||||||
|
void handleImmunities(const CBattleInfoCallback * cb, const SpellTargetingContext & ctx, std::vector<const CStack *> & stacks) const;
|
||||||
void handleResistance(const SpellCastEnvironment * env, std::vector<const CStack*> & attackedCres, BattleSpellCast & sc) const;
|
void handleResistance(const SpellCastEnvironment * env, std::vector<const CStack*> & attackedCres, BattleSpellCast & sc) const;
|
||||||
|
|
||||||
friend class SpellCastContext;
|
friend class SpellCastContext;
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ void AcidBreathDamageMechanics::applyBattleEffects(const SpellCastEnvironment *
|
|||||||
//calculating dmg to display
|
//calculating dmg to display
|
||||||
ctx.setDamageToDisplay(parameters.effectPower);
|
ctx.setDamageToDisplay(parameters.effectPower);
|
||||||
|
|
||||||
for(auto & attackedCre : ctx.attackedCres) //no immunities
|
for(auto & attackedCre : ctx.attackedCres)
|
||||||
{
|
{
|
||||||
BattleStackAttacked bsa;
|
BattleStackAttacked bsa;
|
||||||
bsa.flags |= BattleStackAttacked::SPELL_EFFECT;
|
bsa.flags |= BattleStackAttacked::SPELL_EFFECT;
|
||||||
@@ -35,9 +35,23 @@ void AcidBreathDamageMechanics::applyBattleEffects(const SpellCastEnvironment *
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AcidBreathDamageMechanics::handleImmunities(const CBattleInfoCallback * cb, const SpellTargetingContext & ctx, std::vector<const CStack*> & stacks) const
|
ESpellCastProblem::ESpellCastProblem AcidBreathDamageMechanics::isImmuneByStack(const ISpellCaster * caster, const CStack * obj) const
|
||||||
{
|
{
|
||||||
//no immunities
|
//just in case
|
||||||
|
if(!obj->alive())
|
||||||
|
return ESpellCastProblem::WRONG_SPELL_TARGET;
|
||||||
|
|
||||||
|
//there should be no immunities by design
|
||||||
|
//but make it a bit configurable
|
||||||
|
//ignore all immunities, except specific absolute immunity
|
||||||
|
{
|
||||||
|
//SPELL_IMMUNITY absolute case
|
||||||
|
std::stringstream cachingStr;
|
||||||
|
cachingStr << "type_" << Bonus::SPELL_IMMUNITY << "subtype_" << owner->id.toEnum() << "addInfo_1";
|
||||||
|
if(obj->hasBonus(Selector::typeSubtypeInfo(Bonus::SPELL_IMMUNITY, owner->id.toEnum(), 1), cachingStr.str()))
|
||||||
|
return ESpellCastProblem::STACK_IMMUNE_TO_SPELL;
|
||||||
|
}
|
||||||
|
return ESpellCastProblem::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
///DeathStareMechanics
|
///DeathStareMechanics
|
||||||
|
|||||||
@@ -17,9 +17,11 @@ class DLL_LINKAGE AcidBreathDamageMechanics : public DefaultSpellMechanics
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AcidBreathDamageMechanics(CSpell * s): DefaultSpellMechanics(s){};
|
AcidBreathDamageMechanics(CSpell * s): DefaultSpellMechanics(s){};
|
||||||
|
|
||||||
|
ESpellCastProblem::ESpellCastProblem isImmuneByStack(const ISpellCaster * caster, const CStack * obj) const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void applyBattleEffects(const SpellCastEnvironment * env, const BattleSpellCastParameters & parameters, SpellCastContext & ctx) const override;
|
void applyBattleEffects(const SpellCastEnvironment * env, const BattleSpellCastParameters & parameters, SpellCastContext & ctx) const override;
|
||||||
void handleImmunities(const CBattleInfoCallback * cb, const SpellTargetingContext & ctx, std::vector<const CStack *> & stacks) const override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class DLL_LINKAGE DeathStareMechanics : public DefaultSpellMechanics
|
class DLL_LINKAGE DeathStareMechanics : public DefaultSpellMechanics
|
||||||
|
|||||||
Reference in New Issue
Block a user