mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-06 09:09:40 +02:00
CSpell::canBeCast tweaks
This commit is contained in:
@@ -337,7 +337,7 @@ void CSpellWindow::computeSpellsPerArea()
|
|||||||
spellsCurSite.reserve(mySpells.size());
|
spellsCurSite.reserve(mySpells.size());
|
||||||
for(const CSpell * spell : mySpells)
|
for(const CSpell * spell : mySpells)
|
||||||
{
|
{
|
||||||
if(spell->combatSpell ^ !battleSpellsOnly
|
if(spell->isCombatSpell() ^ !battleSpellsOnly
|
||||||
&& ((selectedTab == 4) || spell->school.at((ESpellSchool)selectedTab))
|
&& ((selectedTab == 4) || spell->school.at((ESpellSchool)selectedTab))
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1716,14 +1716,6 @@ ESpellCastProblem::ESpellCastProblem CBattleInfoCallback::battleCanCastThisSpell
|
|||||||
logGlobal->errorStream() << "CBattleInfoCallback::battleCanCastThisSpell: no spellcaster.";
|
logGlobal->errorStream() << "CBattleInfoCallback::battleCanCastThisSpell: no spellcaster.";
|
||||||
return ESpellCastProblem::INVALID;
|
return ESpellCastProblem::INVALID;
|
||||||
}
|
}
|
||||||
const PlayerColor player = caster->getOwner();
|
|
||||||
const si8 side = playerToSide(player);
|
|
||||||
|
|
||||||
if(side < 0)
|
|
||||||
return ESpellCastProblem::INVALID;
|
|
||||||
|
|
||||||
if(!battleDoWeKnowAbout(side))
|
|
||||||
return ESpellCastProblem::INVALID;
|
|
||||||
|
|
||||||
ESpellCastProblem::ESpellCastProblem genProblem = battleCanCastSpell(caster, mode);
|
ESpellCastProblem::ESpellCastProblem genProblem = battleCanCastSpell(caster, mode);
|
||||||
if(genProblem != ESpellCastProblem::OK)
|
if(genProblem != ESpellCastProblem::OK)
|
||||||
@@ -1750,14 +1742,6 @@ ESpellCastProblem::ESpellCastProblem CBattleInfoCallback::battleCanCastThisSpell
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!spell->combatSpell)
|
|
||||||
return ESpellCastProblem::ADVMAP_SPELL_INSTEAD_OF_BATTLE_SPELL;
|
|
||||||
|
|
||||||
//effect like Recanter's Cloak. Blocks also passive casting.
|
|
||||||
//TODO: check creature abilities to block
|
|
||||||
if(battleMaxSpellLevel(side) < spell->level)
|
|
||||||
return ESpellCastProblem::SPELL_LEVEL_LIMIT_EXCEEDED;
|
|
||||||
|
|
||||||
return spell->canBeCast(this, mode, caster);
|
return spell->canBeCast(this, mode, caster);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -157,10 +157,25 @@ ui32 CSpell::calculateDamage(const ISpellCaster * caster, const CStack * affecte
|
|||||||
|
|
||||||
ESpellCastProblem::ESpellCastProblem CSpell::canBeCast(const CBattleInfoCallback * cb, ECastingMode::ECastingMode mode, const ISpellCaster * caster) const
|
ESpellCastProblem::ESpellCastProblem CSpell::canBeCast(const CBattleInfoCallback * cb, ECastingMode::ECastingMode mode, const ISpellCaster * caster) const
|
||||||
{
|
{
|
||||||
const ESpellCastProblem::ESpellCastProblem generalProblem = mechanics->canBeCast(cb, mode, caster);
|
if(!isCombatSpell())
|
||||||
|
return ESpellCastProblem::ADVMAP_SPELL_INSTEAD_OF_BATTLE_SPELL;
|
||||||
|
|
||||||
if(generalProblem != ESpellCastProblem::OK)
|
const PlayerColor player = caster->getOwner();
|
||||||
return generalProblem;
|
const si8 side = cb->playerToSide(player);
|
||||||
|
|
||||||
|
if(side < 0)
|
||||||
|
return ESpellCastProblem::INVALID;
|
||||||
|
|
||||||
|
//effect like Recanter's Cloak. Blocks also passive casting.
|
||||||
|
//TODO: check creature abilities to block
|
||||||
|
//TODO: check any possible caster
|
||||||
|
if(cb->battleMaxSpellLevel(side) < level)
|
||||||
|
return ESpellCastProblem::SPELL_LEVEL_LIMIT_EXCEEDED;
|
||||||
|
|
||||||
|
const ESpellCastProblem::ESpellCastProblem specificProblem = mechanics->canBeCast(cb, mode, caster);
|
||||||
|
|
||||||
|
if(specificProblem != ESpellCastProblem::OK)
|
||||||
|
return specificProblem;
|
||||||
|
|
||||||
//check for creature target existence
|
//check for creature target existence
|
||||||
//allow to cast spell if there is at least one smart target
|
//allow to cast spell if there is at least one smart target
|
||||||
|
|||||||
Reference in New Issue
Block a user