1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00

Few spell-related tweaks

This commit is contained in:
AlexVinS 2017-03-18 14:08:02 +03:00
parent 5da109ad30
commit 3c893a6bec
4 changed files with 17 additions and 13 deletions

View File

@ -133,11 +133,6 @@ bool CSpell::adventureCast(const SpellCastEnvironment * env, AdventureSpellCastP
void CSpell::battleCast(const SpellCastEnvironment * env, const BattleSpellCastParameters & parameters) const
{
assert(env);
if(parameters.destinations.size()<1)
{
env->complain("Spell must have at least one destination");
return;
}
mechanics->battleCast(env, parameters);
}

View File

@ -82,11 +82,24 @@ void BattleSpellCastParameters::aimToStack(const CStack * destination)
void BattleSpellCastParameters::cast(const SpellCastEnvironment * env)
{
if(destinations.empty())
aimToHex(BattleHex::INVALID);
spell->battleCast(env, *this);
}
void BattleSpellCastParameters::castIfPossible(const SpellCastEnvironment * env)
{
if(ESpellCastProblem::OK == cb->battleCanCastThisSpell(caster, spell, mode))
cast(env);
}
BattleHex BattleSpellCastParameters::getFirstDestinationHex() const
{
if(destinations.empty())
{
logGlobal->error("Spell have no destinations.");
return BattleHex::INVALID;
}
return destinations.at(0).hexValue;
}

View File

@ -56,6 +56,9 @@ public:
void cast(const SpellCastEnvironment * env);
///cast with silent check for permitted cast
void castIfPossible(const SpellCastEnvironment * env);
BattleHex getFirstDestinationHex() const;
int getEffectValue() const;

View File

@ -4581,9 +4581,7 @@ void CGameHandler::stackTurnTrigger(const CStack *st)
BattleSpellCastParameters parameters(gs->curB, st, spell);
parameters.spellLvl = bonus->val;
parameters.effectLevel = bonus->val;//todo: recheck
parameters.aimToHex(BattleHex::INVALID);
parameters.mode = ECastingMode::ENCHANTER_CASTING;
parameters.cast(spellEnv);
//todo: move to mechanics
@ -5302,7 +5300,6 @@ void CGameHandler::handleAfterAttackCasting(const BattleAttack & bat)
parameters.aimToStack(gs->curB->battleGetStackByID(bat.bsa.at(0).stackAttacked));
parameters.effectPower = power;
parameters.mode = ECastingMode::AFTER_ATTACK_CASTING;
parameters.cast(spellEnv);
};
@ -5691,16 +5688,12 @@ void CGameHandler::runBattle()
{
const CSpell * spell = SpellID(b->subtype).toSpell();
if (ESpellCastProblem::OK != gs->curB->battleCanCastThisSpell(h, spell, ECastingMode::PASSIVE_CASTING))
continue;
BattleSpellCastParameters parameters(gs->curB, h, spell);
parameters.spellLvl = 3;
parameters.effectLevel = 3;
parameters.aimToHex(BattleHex::INVALID);
parameters.mode = ECastingMode::PASSIVE_CASTING;
parameters.enchantPower = b->val;
parameters.cast(spellEnv);
parameters.castIfPossible(spellEnv);
}
}
}