فهرست منبع

expert DISPELL also removes spell-created obstacles

AlexVinS 10 سال پیش
والد
کامیت
9d0b29b973
2فایلهای تغییر یافته به همراه26 افزوده شده و 1 حذف شده
  1. 23 0
      lib/spells/BattleSpellMechanics.cpp
  2. 3 1
      lib/spells/BattleSpellMechanics.h

+ 23 - 0
lib/spells/BattleSpellMechanics.cpp

@@ -185,6 +185,29 @@ ESpellCastProblem::ESpellCastProblem DispellMechanics::isImmuneByStack(const CGH
 	return ESpellCastProblem::WRONG_SPELL_TARGET;
 }
 
+void DispellMechanics::applyBattleEffects(const SpellCastEnvironment * env, BattleSpellCastParameters & parameters, SpellCastContext & ctx) const
+{
+	DefaultSpellMechanics::applyBattleEffects(env, parameters, ctx);
+	
+	if(parameters.spellLvl > 2)
+	{
+		//expert DISPELL also removes spell-created obstacles
+		
+		ObstaclesRemoved packet;
+		
+		for(const auto obstacle : parameters.cb->obstacles)
+		{
+			if(obstacle->obstacleType == CObstacleInstance::FIRE_WALL 
+				|| obstacle->obstacleType == CObstacleInstance::FORCE_FIELD 
+				|| obstacle->obstacleType == CObstacleInstance::LAND_MINE)
+				packet.obstacles.insert(obstacle->uniqueID);
+		}
+		
+		if(!packet.obstacles.empty())
+			env->sendAndApply(&packet);
+	}
+}
+
 ///EarthquakeMechanics
 void EarthquakeMechanics::applyBattleEffects(const SpellCastEnvironment * env, BattleSpellCastParameters & parameters, SpellCastContext & ctx) const
 {

+ 3 - 1
lib/spells/BattleSpellMechanics.h

@@ -43,7 +43,9 @@ public:
 	ESpellCastProblem::ESpellCastProblem isImmuneByStack(const CGHeroInstance * caster, const CStack * obj) const override;
 	
 	void applyBattle(BattleInfo * battle, const BattleSpellCast * packet) const override final;
-	ESpellCastProblem::ESpellCastProblem canBeCasted(const CBattleInfoCallback * cb, PlayerColor player) const override;	
+	ESpellCastProblem::ESpellCastProblem canBeCasted(const CBattleInfoCallback * cb, PlayerColor player) const override;
+protected:
+	void applyBattleEffects(const SpellCastEnvironment * env, BattleSpellCastParameters & parameters, SpellCastContext & ctx) const override;	
 };
 
 class DLL_LINKAGE EarthquakeMechanics : public DefaultSpellMechanics