1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-15 00:05:02 +02:00

Support for Chain Lightning.

Fixed getClosestTile function.
This commit is contained in:
DjWarmonger
2012-05-20 11:40:23 +00:00
parent 59255a4cad
commit d34cf90bf7
4 changed files with 41 additions and 9 deletions

View File

@ -3953,6 +3953,7 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, BattleHex dest
case Spells::ICE_BOLT:
case Spells::LIGHTNING_BOLT:
case Spells::IMPLOSION:
case Spells::CHAIN_LIGHTNING:
case Spells::FROST_RING:
case Spells::FIREBALL:
case Spells::INFERNO:
@ -3975,6 +3976,7 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, BattleHex dest
sc.dmgToDisplay = 0;
}
}
int chainLightningModifier = 0;
for(std::set<CStack*>::iterator it = attackedCres.begin(); it != attackedCres.end(); ++it)
{
if(vstd::contains(sc.resisted, (*it)->ID)) //this creature resisted the spell
@ -3988,10 +3990,10 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, BattleHex dest
bsa.effect = spell->mainEffectAnim;
}
if (spellDamage)
bsa.damageAmount = spellDamage;
bsa.damageAmount = spellDamage >> chainLightningModifier;
else
{
bsa.damageAmount = gs->curB->calculateSpellDmg(spell, caster, *it, spellLvl, usedSpellPower);
bsa.damageAmount = gs->curB->calculateSpellDmg(spell, caster, *it, spellLvl, usedSpellPower) >> chainLightningModifier;
sc.dmgToDisplay += bsa.damageAmount;
}
bsa.stackAttacked = (*it)->ID;
@ -4001,6 +4003,9 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, BattleHex dest
bsa.attackerID = -1;
(*it)->prepareAttacked(bsa);
si.stacks.push_back(bsa);
if (spellID == Spells::CHAIN_LIGHTNING)
++chainLightningModifier;
}
break;
}