Browse Source

Probably fixed http://bugs.vcmi.eu/view.php?id=2523

AlexVinS 9 năm trước cách đây
mục cha
commit
e91a6d45e8
1 tập tin đã thay đổi với 11 bổ sung2 xóa
  1. 11 2
      lib/spells/BattleSpellMechanics.cpp

+ 11 - 2
lib/spells/BattleSpellMechanics.cpp

@@ -788,14 +788,23 @@ bool SacrificeMechanics::requiresCreatureTarget() const
 ///SpecialRisingSpellMechanics
 ESpellCastProblem::ESpellCastProblem SpecialRisingSpellMechanics::canBeCast(const CBattleInfoCallback * cb, const SpellTargetingContext & ctx) const
 {
-	const CStack * stack = cb->getStackIf([ctx](const CStack * s)
+	//find our possible target here
+	const CStack * stackToHeal = cb->getStackIf([ctx](const CStack * s)
 	{
 		const bool ownerMatches = !ctx.ti.smart || s->getOwner() == ctx.caster->getOwner();
 
 		return ownerMatches && s->isValidTarget(!ctx.ti.onlyAlive) && s->coversPos(ctx.destination);
 	});
 
-	if(nullptr == stack)
+	//find if there is stack preventing cast
+	const CStack * enemyStack = cb->getStackIf([ctx](const CStack * s)
+	{
+		const bool ownerMatches = ctx.ti.smart && s->getOwner() != ctx.caster->getOwner();
+
+		return ownerMatches && s->isValidTarget(true) && s->coversPos(ctx.destination);
+	});
+
+	if(nullptr == stackToHeal || nullptr != enemyStack)
 		return ESpellCastProblem::NO_APPROPRIATE_TARGET;
 
 	return ESpellCastProblem::OK;