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

Support for Mana Channeling ability.

This commit is contained in:
DjWarmonger
2011-10-09 11:23:24 +00:00
parent 5e40d3da72
commit b4d0ebf9ab
4 changed files with 43 additions and 20 deletions

View File

@ -3496,6 +3496,26 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, THex destinati
sc.dmgToDisplay = 0;
sc.castedByHero = (bool)caster;
sc.attackerType = (stack ? stack->type->idNumber : -1);
sc.manaGained = 0;
sc.spellCost = 0;
if (caster) //calculate spell cost
{
sc.spellCost = gs->curB->getSpellCost(VLC->spellh->spells[spellID], caster);
if (secHero && mode == SpellCasting::HERO_CASTING) //handle mana channel
{
int manaChannel = 0;
BOOST_FOREACH(CStack * stack, gs->curB->stacks) //TODO: shouldn't bonus system handle it somehow?
{
if (stack->owner == secHero->tempOwner)
{
amax(manaChannel, stack->valOfBonuses(Bonus::MANA_CHANNELING));
}
}
sc.manaGained = (manaChannel * sc.spellCost) / 100;
}
}
//calculating affected creatures for all spells
std::set<CStack*> attackedCres;