浏览代码

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

AlexVinS 9 年之前
父节点
当前提交
e91a6d45e8
共有 1 个文件被更改,包括 11 次插入2 次删除
  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;