1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-10-31 00:07:39 +02:00

Add dispell effect to ANTI_MAGIC

* fixes 0002156
This commit is contained in:
AlexVinS
2015-04-03 03:28:20 +03:00
parent e4220fef82
commit 6356247108
3 changed files with 35 additions and 0 deletions

View File

@@ -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<const CStack *> ChainLightningMechanics::getAffectedStacks(SpellTargetingContext & ctx) const
{

View File

@@ -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:

View File

@@ -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: