1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-29 23:07:48 +02:00

New pack - BattleEffectTrigger for various one-shot effects with animation

This commit is contained in:
DjWarmonger
2011-10-08 13:02:58 +00:00
parent f4fc77ccb8
commit 0903d6037c
14 changed files with 167 additions and 70 deletions

View File

@@ -858,34 +858,6 @@ DLL_EXPORT void BattleSetActiveStack::applyGs( CGameState *gs )
gs->curB->activeStack = stack;
CStack *st = gs->curB->getStack(stack);
if (st->alive())
{
//regeneration
if(st->hasBonusOfType(Bonus::HP_REGENERATION))
st->firstHPleft = std::min<ui32>( st->MaxHealth(), st->valOfBonuses(Bonus::HP_REGENERATION) );
if(st->hasBonusOfType(Bonus::FULL_HP_REGENERATION))
st->firstHPleft = st->MaxHealth();
if(st->hasBonusOfType(Bonus::POISON))
{
Bonus * b = st->getBonus(Selector::source(Bonus::SPELL_EFFECT, 71) && Selector::type(Bonus::STACK_HEALTH));
if (b) //TODO: what if not?...
{
b->val -= 10;
amax (b->val, -(st->valOfBonuses(Bonus::POISON)));
}
}
if(st->hasBonusOfType(Bonus::MANA_DRAIN))
{
const CGHeroInstance * enemy = gs->curB->getHero(gs->curB->theOtherPlayer(st->owner));
if (enemy)
{
ui32 manaDrained = st->valOfBonuses(Bonus::MANA_DRAIN);
amin (manaDrained, gs->curB->heroes[0]->mana);
gs->getHero(enemy->id)->mana -= manaDrained; //jeez, it's overcomplicate
}
}
}
//remove bonuses that last until when stack gets new turn
st->getBonusList().remove_if(Bonus::UntilGetsTurn);
@@ -893,6 +865,36 @@ DLL_EXPORT void BattleSetActiveStack::applyGs( CGameState *gs )
st->state.insert(HAD_MORALE);
}
DLL_EXPORT void BattleTriggerEffect::applyGs( CGameState *gs )
{
CStack *st = gs->curB->getStack(stackID);
switch (effect)
{
case Bonus::HP_REGENERATION:
st->firstHPleft += val;
amin (st->firstHPleft, (ui32)st->MaxHealth());
break;
case Bonus::MANA_DRAIN:
{
CGHeroInstance * h = gs->getHero(additionalInfo);
h->mana -= val;
amax(h->mana, 0);
break;
}
case Bonus::POISON:
{
Bonus * b = st->getBonus(Selector::source(Bonus::SPELL_EFFECT, 71) && Selector::type(Bonus::STACK_HEALTH));
if (b)
b->val = val;
break;
}
case Bonus::ENCHANTER:
case Bonus::FEAR:
default:
tlog2 << "Unrecognized trigger effect type "<< type <<"\n";
}
}
void BattleResult::applyGs( CGameState *gs )
{
//stack with SUMMONED flag but coming from garrison -> most likely resurrected, needs to be removed