AlexVinS 9 lat temu
rodzic
commit
f39e619304

+ 1 - 7
lib/spells/CDefaultSpellMechanics.cpp

@@ -285,14 +285,8 @@ void DefaultSpellMechanics::battleCast(const SpellCastEnvironment * env, const B
 		{
 			int targetHex = (*RandomGeneratorUtil::nextItem(mirrorTargets, env->getRandomGenerator()))->position;
 
-			BattleSpellCastParameters mirrorParameters(parameters.cb, attackedCre, owner);
+			BattleSpellCastParameters mirrorParameters(parameters, attackedCre);
 			mirrorParameters.aimToHex(targetHex);
-			mirrorParameters.mode = ECastingMode::MAGIC_MIRROR;
-			mirrorParameters.spellLvl = parameters.spellLvl;
-			mirrorParameters.effectLevel = parameters.effectLevel;
-			mirrorParameters.effectPower = parameters.effectPower;
-			mirrorParameters.effectValue = parameters.effectValue;
-			mirrorParameters.enchantPower = parameters.enchantPower;
 			mirrorParameters.cast(env);
 		}
 	}

+ 9 - 0
lib/spells/ISpellMechanics.cpp

@@ -56,6 +56,15 @@ BattleSpellCastParameters::BattleSpellCastParameters(const BattleInfo * cb, cons
 	vstd::amax(effectValue, 0);
 }
 
+BattleSpellCastParameters::BattleSpellCastParameters(const BattleSpellCastParameters & orig, const ISpellCaster * caster)
+	:spell(orig.spell), cb(orig.cb), caster(caster), casterColor(caster->getOwner()), casterSide(cb->whatSide(casterColor)),
+	casterHero(nullptr), mode(ECastingMode::MAGIC_MIRROR), casterStack(nullptr),
+	spellLvl(orig.spellLvl),  effectLevel(orig.effectLevel), effectPower(orig.effectPower), enchantPower(orig.enchantPower), effectValue(orig.effectValue)
+{
+	casterStack = dynamic_cast<const CStack *>(caster);
+	casterHero = dynamic_cast<const CGHeroInstance *>(caster);
+}
+
 void BattleSpellCastParameters::aimToHex(const BattleHex& destination)
 {
 	destinations.push_back(Destination(destination));

+ 5 - 0
lib/spells/ISpellMechanics.h

@@ -45,7 +45,12 @@ public:
 		const BattleHex hexValue;
 	};
 
+	//normal constructor
 	BattleSpellCastParameters(const BattleInfo * cb, const ISpellCaster * caster, const CSpell * spell_);
+
+	//magic mirror constructor
+	BattleSpellCastParameters(const BattleSpellCastParameters & orig, const ISpellCaster * caster);
+
 	void aimToHex(const BattleHex & destination);
 	void aimToStack(const CStack * destination);