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:
		| @@ -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 | ||||
| { | ||||
|   | ||||
| @@ -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: | ||||
|   | ||||
| @@ -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: | ||||
|   | ||||
		Reference in New Issue
	
	Block a user