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

@ -1044,27 +1044,20 @@ DLL_EXPORT void StartAction::applyGs( CGameState *gs )
DLL_EXPORT void BattleSpellCast::applyGs( CGameState *gs )
{
assert(gs->curB);
CGHeroInstance *h = (side) ? gs->curB->heroes[1] : gs->curB->heroes[0];
if(h && castedByHero)
if (castedByHero)
{
int spellCost = 0;
if(gs->curB)
{
spellCost = gs->curB->getSpellCost(VLC->spellh->spells[id], h);
}
else
{
spellCost = VLC->spellh->spells[id]->costs[skill];
}
h->mana -= spellCost;
if (h->mana < 0)
h->mana = 0;
}
if(side >= 0 && side < 2 && castedByHero)
{
gs->curB->castSpells[side]++;
}
CGHeroInstance * h = gs->curB->heroes[side];
CGHeroInstance * enemy = gs->curB->heroes[1-side];
h->mana -= spellCost;
amax(h->mana, 0);
if (enemy && manaGained)
enemy->mana += manaGained;
if (side >= 0 && side < 2)
{
gs->curB->castSpells[side]++;
}
}
if(id == 35 || id == 78) //dispel and dispel helpful spells
{