1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

Merge and simplify resistance calculation

This commit is contained in:
AlexVinS
2014-05-18 14:21:05 +04:00
parent 7cf64a0628
commit b6b12ad8f6
3 changed files with 14 additions and 37 deletions

View File

@@ -4057,9 +4057,21 @@ void CGameHandler::handleSpellCasting( SpellID spellID, int spellLvl, BattleHex
{
sc.affectedCres.insert (cre->ID);
}
//checking if creatures resist
sc.resisted = gs->curB->calculateResistedStacks(spell, caster, secHero, attackedCres, casterColor, mode, usedSpellPower, spellLvl, gs->getRandomGenerator());
//resistance is applied only to negative spells
if(spell->isNegative())
{
for(auto s : attackedCres)
{
const int prob = std::min((s)->magicResistance(), 100); //probability of resistance in %
if(gs->getRandomGenerator().nextInt(99) < prob)
{
sc.resisted.push_back(s->ID);
}
}
}
//calculating dmg to display
if (spellID == SpellID::DEATH_STARE || spellID == SpellID::ACID_BREATH_DAMAGE)