1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

ENCHANTER_CASTING trigger tweak

This commit is contained in:
AlexVinS 2017-06-05 21:41:27 +03:00
parent 66cfc2fef9
commit 1d1519db5c
3 changed files with 14 additions and 11 deletions

View File

@ -87,10 +87,14 @@ void BattleSpellCastParameters::cast(const SpellCastEnvironment * env)
spell->battleCast(env, *this); spell->battleCast(env, *this);
} }
void BattleSpellCastParameters::castIfPossible(const SpellCastEnvironment * env) bool BattleSpellCastParameters::castIfPossible(const SpellCastEnvironment * env)
{ {
if(ESpellCastProblem::OK == cb->battleCanCastThisSpell(caster, spell, mode)) if(ESpellCastProblem::OK == cb->battleCanCastThisSpell(caster, spell, mode))
{
cast(env); cast(env);
return true;
}
return false;
} }
BattleHex BattleSpellCastParameters::getFirstDestinationHex() const BattleHex BattleSpellCastParameters::getFirstDestinationHex() const

View File

@ -57,7 +57,8 @@ public:
void cast(const SpellCastEnvironment * env); void cast(const SpellCastEnvironment * env);
///cast with silent check for permitted cast ///cast with silent check for permitted cast
void castIfPossible(const SpellCastEnvironment * env); ///returns true if cast was permitted
bool castIfPossible(const SpellCastEnvironment * env);
BattleHex getFirstDestinationHex() const; BattleHex getFirstDestinationHex() const;

View File

@ -4631,14 +4631,14 @@ void CGameHandler::stackTurnTrigger(const CStack *st)
const CSpell * spell = SpellID(spellID).toSpell(); const CSpell * spell = SpellID(spellID).toSpell();
bl.remove_if([&bonus](const Bonus* b){return b==bonus.get();}); bl.remove_if([&bonus](const Bonus* b){return b==bonus.get();});
if (gs->curB->battleCanCastThisSpell(st, spell, ECastingMode::ENCHANTER_CASTING) == ESpellCastProblem::OK) BattleSpellCastParameters parameters(gs->curB, st, spell);
{ parameters.spellLvl = bonus->val;
BattleSpellCastParameters parameters(gs->curB, st, spell); parameters.effectLevel = bonus->val;//todo: recheck
parameters.spellLvl = bonus->val; parameters.mode = ECastingMode::ENCHANTER_CASTING;
parameters.effectLevel = bonus->val;//todo: recheck
parameters.mode = ECastingMode::ENCHANTER_CASTING;
parameters.cast(spellEnv);
cast = parameters.castIfPossible(spellEnv);
if(cast)
{
//todo: move to mechanics //todo: move to mechanics
BattleSetStackProperty ssp; BattleSetStackProperty ssp;
ssp.which = BattleSetStackProperty::ENCHANTER_COUNTER; ssp.which = BattleSetStackProperty::ENCHANTER_COUNTER;
@ -4646,8 +4646,6 @@ void CGameHandler::stackTurnTrigger(const CStack *st)
ssp.val = bonus->additionalInfo; //increase cooldown counter ssp.val = bonus->additionalInfo; //increase cooldown counter
ssp.stackID = st->ID; ssp.stackID = st->ID;
sendAndApply(&ssp); sendAndApply(&ssp);
cast = true;
} }
} }
} }