1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-23 22:37:55 +02:00

Cumulative spell effects

* Added experimental support for cumulative effects for ENCHANTED bonus
* Updated and fixed SPECIAL_PECULIAR_ENCHANT processing
* Initial implementation of cumulative spell effects.
* Scheme for new spell feature - cumulative bonus.
This commit is contained in:
AlexVinS
2016-11-02 20:11:01 +03:00
committed by Arseniy Shestakov
parent 0c7eeeaa5c
commit 0f5202689e
18 changed files with 292 additions and 212 deletions

View File

@@ -4489,30 +4489,32 @@ bool CGameHandler::makeCustomAction(BattleAction &ba)
}
void CGameHandler::stackAppearTrigger(const CStack *st)
void CGameHandler::stackEnchantedTrigger(const CStack * st)
{
auto bl = *(st->getBonuses(Selector::type(Bonus::ENCHANTED)));
for (auto b : bl)
for(auto b : bl)
{
SetStackEffect sse;
int val = bl.valOfBonuses(Selector::typeSubtype(b->type, b->subtype));
if (val > 3)
if(val > 3)
{
for (auto s : gs->curB->battleGetAllStacks())
for(auto s : gs->curB->battleGetAllStacks())
{
if (battleMatchOwner(st, s, true) && s->isValidTarget()) //all allied
if(battleMatchOwner(st, s, true) && s->isValidTarget()) //all allied
sse.stacks.push_back (s->ID);
}
}
else
sse.stacks.push_back (st->ID);
Bonus pseudoBonus;
pseudoBonus.sid = b->subtype;
pseudoBonus.val = ((val > 3) ? (val - 3) : val);
pseudoBonus.turnsRemain = 50;
st->stackEffectToFeature(sse.effect, pseudoBonus);
if (sse.effect.size())
const CSpell * sp = SpellID(b->subtype).toSpell();
const int level = ((val > 3) ? (val - 3) : val);
sp->getEffects(sse.effect, level, false, 50);
//this makes effect accumulate for at most 50 turns by default, but effect may be permanent and last till the end of battle
sp->getEffects(sse.cumulativeEffects, level, true, 50);
if(!sse.effect.empty() || !sse.cumulativeEffects.empty())
sendAndApply(&sse);
}
}
@@ -4526,7 +4528,6 @@ void CGameHandler::stackTurnTrigger(const CStack *st)
bte.additionalInfo = 0;
if (st->alive())
{
stackAppearTrigger(st);
//unbind
if (st->hasBonus(Selector::type(Bonus::BIND_EFFECT)))
{
@@ -5724,7 +5725,7 @@ void CGameHandler::runBattle()
}
}
stackAppearTrigger(stack);
stackEnchantedTrigger(stack);
}
//spells opening battle
@@ -5766,6 +5767,12 @@ void CGameHandler::runBattle()
const BattleInfo & curB = *gs->curB;
for(auto stack : curB.stacks)
{
if(stack->alive() && curB.round > 1)
stackEnchantedTrigger(stack);
}
//stack loop
const CStack *next;