1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-26 22:57:00 +02:00

Fixed creatures casting aimed spells at dead stacks.

This commit is contained in:
DjWarmonger 2012-02-29 13:47:57 +00:00
parent f2642cb62c
commit 18b1b83c8a
2 changed files with 12 additions and 6 deletions

View File

@ -1754,7 +1754,7 @@ void CBattleInterface::hexLclicked(int whichOne)
{
if(!myTurn)
return; //we are not permit to do anything
if(spellDestSelectMode) //TODO: choose target for area creature spell
if(spellDestSelectMode) //select spell target //TODO: choose target for area creature spell
{
//checking destination
bool allowCasting = true;
@ -1788,7 +1788,7 @@ void CBattleInterface::hexLclicked(int whichOne)
endCastingSpell();
}
}
else //we don't aim for spell target area
else //creature casting
{
bool walkableTile = false;
bool spellCast = false;
@ -1805,7 +1805,7 @@ void CBattleInterface::hexLclicked(int whichOne)
{
const CSpell * spell = CGI->spellh->spells[creatureSpellToCast];
if (curInt->cb->battleCanCastThisSpell(spell, BattleHex(whichOne)) == ESpellCastProblem::OK)
if (curInt->cb->battleCanCreatureCastThisSpell(spell, BattleHex(whichOne)) == ESpellCastProblem::OK)
{
if ((!spell->isNegative() && ourStack) || (!spell->isPositive() && !ourStack))
{

View File

@ -2100,7 +2100,13 @@ bool BattleInfo::battleTestElementalImmunity(const CStack * subject, const CSpel
ESpellCastProblem::ESpellCastProblem BattleInfo::battleIsImmune(const CGHeroInstance * caster, const CSpell * spell, ECastingMode::ECastingMode mode, BattleHex dest) const
{
const CStack * subject = getStackT(dest, false);
const CStack * subject;
bool risingSpell = vstd::contains(VLC->spellh->risingSpells, spell->id);
if (risingSpell)
subject = getStackT(dest, false); //including dead stacks
else
subject = getStackT(dest, true); //only alive
if(subject)
{
if (spell->isPositive() && subject->hasBonusOfType(Bonus::RECEPTIVE)) //accept all positive spells
@ -2191,7 +2197,7 @@ ESpellCastProblem::ESpellCastProblem BattleInfo::battleIsImmune(const CGHeroInst
return ESpellCastProblem::STACK_IMMUNE_TO_SPELL;
}
if (vstd::contains(VLC->spellh->risingSpells, spell->id))
if (risingSpell)
{
if (subject->count >= subject->baseAmount) //TODO: calculate potential hp raised
return ESpellCastProblem::STACK_IMMUNE_TO_SPELL;
@ -2210,7 +2216,7 @@ ESpellCastProblem::ESpellCastProblem BattleInfo::battleIsImmune(const CGHeroInst
return ESpellCastProblem::STACK_IMMUNE_TO_SPELL;
}
}
else
else //no target stack on this tile
{
if(spell->getTargetType() == CSpell::CREATURE ||
(spell->getTargetType() == CSpell::CREATURE_EXPERT_MASSIVE && mode == ECastingMode::HERO_CASTING && caster && caster->getSpellSchoolLevel(spell) < 3))