From 63562471083e6a73f348d399bf4c6458b0ac41ce Mon Sep 17 00:00:00 2001 From: AlexVinS Date: Fri, 3 Apr 2015 03:28:20 +0300 Subject: [PATCH] Add dispell effect to ANTI_MAGIC * fixes 0002156 --- lib/spells/BattleSpellMechanics.cpp | 25 +++++++++++++++++++++++++ lib/spells/BattleSpellMechanics.h | 8 ++++++++ lib/spells/ISpellMechanics.cpp | 2 ++ 3 files changed, 35 insertions(+) diff --git a/lib/spells/BattleSpellMechanics.cpp b/lib/spells/BattleSpellMechanics.cpp index 8812224d8..208985074 100644 --- a/lib/spells/BattleSpellMechanics.cpp +++ b/lib/spells/BattleSpellMechanics.cpp @@ -14,6 +14,31 @@ #include "../NetPacks.h" #include "../BattleState.h" +///AntimagicMechanics +void AntimagicMechanics::applyBattle(BattleInfo * battle, const BattleSpellCast * packet) const +{ + DefaultSpellMechanics::applyBattle(battle, packet); + + for(auto stackID : packet->affectedCres) + { + if(vstd::contains(packet->resisted, stackID)) + { + logGlobal->errorStream() << "Resistance to positive spell " << owner->name; + continue; + } + + CStack * s = battle->getStack(stackID); + s->popBonuses([&](const Bonus *b) -> bool + { + if(b->source == Bonus::SPELL_EFFECT) + { + return b->sid != owner->id; //effect from this spell + } + return false; //not a spell effect + }); + } +} + ///ChainLightningMechanics std::set ChainLightningMechanics::getAffectedStacks(SpellTargetingContext & ctx) const { diff --git a/lib/spells/BattleSpellMechanics.h b/lib/spells/BattleSpellMechanics.h index 045564ed2..72374bf78 100644 --- a/lib/spells/BattleSpellMechanics.h +++ b/lib/spells/BattleSpellMechanics.h @@ -12,6 +12,14 @@ #include "CDefaultSpellMechanics.h" +class DLL_LINKAGE AntimagicMechanics : public DefaultSpellMechanics +{ +public: + AntimagicMechanics(CSpell * s): DefaultSpellMechanics(s){}; + + void applyBattle(BattleInfo * battle, const BattleSpellCast * packet) const override final; +}; + class DLL_LINKAGE ChainLightningMechanics : public DefaultSpellMechanics { public: diff --git a/lib/spells/ISpellMechanics.cpp b/lib/spells/ISpellMechanics.cpp index 87a4de1af..2f24f077e 100644 --- a/lib/spells/ISpellMechanics.cpp +++ b/lib/spells/ISpellMechanics.cpp @@ -28,6 +28,8 @@ ISpellMechanics * ISpellMechanics::createMechanics(CSpell * s) { switch (s->id) { + case SpellID::ANTI_MAGIC: + return new AntimagicMechanics(s); case SpellID::ACID_BREATH_DAMAGE: return new AcidBreathDamageMechanics(s); case SpellID::CHAIN_LIGHTNING: