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

handleSpellCasting: Handle immunity before RESISTANCE. Now immune creatures shouldnt show resisted animation

This commit is contained in:
AlexVinS 2014-05-18 12:23:56 +04:00
parent c5ba8b9b4b
commit 1431fcedf7
2 changed files with 8 additions and 9 deletions

View File

@ -730,12 +730,6 @@ std::vector<ui32> BattleInfo::calculateResistedStacks(const CSpell * sp, const C
std::vector<ui32> ret;
for(auto & affectedCreature : affectedCreatures)
{
if(battleIsImmune(caster, sp, mode, (affectedCreature)->position) != ESpellCastProblem::OK) //FIXME: immune stacks should not display resisted animation
{
ret.push_back((affectedCreature)->ID);
continue;
}
//non-negative spells should always succeed, unless immune
if(!sp->isNegative())// && (*it)->owner == casterSideOwner)
continue;

View File

@ -3944,7 +3944,7 @@ void CGameHandler::playerMessage( PlayerColor player, const std::string &message
void CGameHandler::handleSpellCasting( SpellID spellID, int spellLvl, BattleHex destination, ui8 casterSide, PlayerColor casterColor, const CGHeroInstance * caster, const CGHeroInstance * secHero,
int usedSpellPower, ECastingMode::ECastingMode mode, const CStack * stack, si32 selectedStack)
{
const CSpell *spell = SpellID(spellID).toSpell();
const CSpell * spell = SpellID(spellID).toSpell();
//Helper local function that creates obstacle on given position. Obstacle type is inferred from spell type.
@ -4008,7 +4008,7 @@ void CGameHandler::handleSpellCasting( SpellID spellID, int spellLvl, BattleHex
if (caster) //calculate spell cost
{
sc.spellCost = gs->curB->battleGetSpellCost(SpellID(spellID).toSpell(), caster);
sc.spellCost = gs->curB->battleGetSpellCost(spell, caster);
if (secHero && mode == ECastingMode::HERO_CASTING) //handle mana channel
{
@ -4026,7 +4026,8 @@ void CGameHandler::handleSpellCasting( SpellID spellID, int spellLvl, BattleHex
//calculating affected creatures for all spells
//must be vector, as in Chain Lightning order matters
std::vector<const CStack*> attackedCres; //what is that and what is sc.afectedCres?
std::vector<const CStack*> attackedCres; //CStack vector is somewhat more suitable than ID vector
if (mode != ECastingMode::ENCHANTER_CASTING)
{
auto creatures = gs->curB->getAffectedCreatures(spell, spellLvl, casterColor, destination);
@ -4048,6 +4049,10 @@ void CGameHandler::handleSpellCasting( SpellID spellID, int spellLvl, BattleHex
}
}
vstd::erase_if(attackedCres,[=](const CStack * s){
return gs->curB->battleIsImmune(caster,spell,mode,s->position);
});
for (auto cre : attackedCres)
{
sc.affectedCres.insert (cre->ID);