1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-23 00:28:08 +02:00

Use SetMana packet in battle

This commit is contained in:
AlexVinS
2014-11-26 13:30:55 +03:00
parent fe1233310f
commit b31ed0e4ea
4 changed files with 45 additions and 18 deletions

View File

@ -184,9 +184,16 @@ DLL_LINKAGE void ChangeSpells::applyGs( CGameState *gs )
DLL_LINKAGE void SetMana::applyGs( CGameState *gs )
{
CGHeroInstance *hero = gs->getHero(hid);
vstd::amax(val, 0); //not less than 0
hero->mana = val;
CGHeroInstance * hero = gs->getHero(hid);
assert(hero);
if(absolute)
hero->mana = val;
else
hero->mana += val;
vstd::amax(hero->mana, 0); //not less than 0
}
DLL_LINKAGE void SetMovePoints::applyGs( CGameState *gs )
@ -1330,13 +1337,6 @@ DLL_LINKAGE void BattleSpellCast::applyGs( CGameState *gs )
assert(gs->curB);
if (castedByHero)
{
CGHeroInstance * h = gs->curB->battleGetFightingHero(side);
CGHeroInstance * enemy = gs->curB->battleGetFightingHero(!side);
h->mana -= spellCost;
vstd::amax(h->mana, 0);
if (enemy && manaGained)
enemy->mana += manaGained;
if (side < 2)
{
gs->curB->sides[side].castSpellsCount++;