1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00
This commit is contained in:
AlexVinS 2017-07-16 00:01:33 +03:00
parent a4c0ad94b1
commit 7374689301
5 changed files with 12 additions and 12 deletions

View File

@ -1649,7 +1649,7 @@ void CBattleInterface::enterCreatureCastingMode()
{
const ISpellCaster *caster = activeStack;
const CSpell *spell = SpellID(creatureSpellToCast).toSpell();
const bool isCastingPossible = (spell->canBeCastAt(curInt->cb.get(), caster, ECastingMode::CREATURE_ACTIVE_CASTING, BattleHex::INVALID) == ESpellCastProblem::OK);
const bool isCastingPossible = (spell->canBeCastAt(curInt->cb.get(), ECastingMode::CREATURE_ACTIVE_CASTING, caster, BattleHex::INVALID) == ESpellCastProblem::OK);
if (isCastingPossible)
{
@ -2499,7 +2499,7 @@ bool CBattleInterface::isCastingPossibleHere(const CStack *sactive, const CStack
else
{
const ECastingMode::ECastingMode mode = creatureCasting ? ECastingMode::CREATURE_ACTIVE_CASTING : ECastingMode::HERO_CASTING;
isCastingPossible = (sp->canBeCastAt(curInt->cb.get(), caster, mode, myNumber) == ESpellCastProblem::OK);
isCastingPossible = (sp->canBeCastAt(curInt->cb.get(), mode, caster, myNumber) == ESpellCastProblem::OK);
}
}
else

View File

@ -855,11 +855,11 @@ AccessibilityInfo CBattleInfoCallback::getAccesibility() const
//special battlefields with logically unavailable tiles
std::vector<BattleHex> impassableHexes;
if(battleGetBattlefieldType().num == BFieldType::SHIP_TO_SHIP)
{
impassableHexes =
{
{
impassableHexes =
{
6, 7, 8, 9,
24, 25, 26,
24, 25, 26,
58, 59, 60,
75, 76, 77,
92, 93, 94,
@ -868,7 +868,7 @@ AccessibilityInfo CBattleInfoCallback::getAccesibility() const
159, 160, 161, 162, 163,
176, 177, 178, 179, 180
};
}
}
for(auto hex : impassableHexes)
ret[hex] = EAccessibility::UNAVAILABLE;
@ -1463,7 +1463,7 @@ SpellID CBattleInfoCallback::getRandomBeneficialSpell(CRandomGenerator & rand, c
if(subject->hasBonus(Selector::source(Bonus::SPELL_EFFECT, spellID), Selector::all, cachingStr.str())
//TODO: this ability has special limitations
|| spellID.toSpell()->canBeCastAt(this, subject, ECastingMode::CREATURE_ACTIVE_CASTING, subject->position) != ESpellCastProblem::OK)
|| spellID.toSpell()->canBeCast(this, ECastingMode::CREATURE_ACTIVE_CASTING, subject) != ESpellCastProblem::OK)
continue;
switch (spellID)

View File

@ -399,7 +399,7 @@ void CSpell::getEffects(std::vector<Bonus> & lst, const int level, const bool cu
}
}
ESpellCastProblem::ESpellCastProblem CSpell::canBeCastAt(const CBattleInfoCallback * cb, const ISpellCaster * caster, ECastingMode::ECastingMode mode, BattleHex destination) const
ESpellCastProblem::ESpellCastProblem CSpell::canBeCastAt(const CBattleInfoCallback * cb, ECastingMode::ECastingMode mode, const ISpellCaster * caster, BattleHex destination) const
{
ESpellCastProblem::ESpellCastProblem problem = canBeCast(cb, mode, caster);
if(problem != ESpellCastProblem::OK)

View File

@ -297,8 +297,8 @@ public:
///Checks general but spell-specific problems. Use only during battle.
ESpellCastProblem::ESpellCastProblem canBeCast(const CBattleInfoCallback * cb, ECastingMode::ECastingMode mode, const ISpellCaster * caster) const;
///checks for creature immunity / anything that prevent casting *at given hex* - doesn't take into account general problems such as not having spellbook or mana points etc.
ESpellCastProblem::ESpellCastProblem canBeCastAt(const CBattleInfoCallback * cb, const ISpellCaster * caster, ECastingMode::ECastingMode mode, BattleHex destination) const;
///checks for creature immunity / anything that prevent casting *at given hex*
ESpellCastProblem::ESpellCastProblem canBeCastAt(const CBattleInfoCallback * cb, ECastingMode::ECastingMode mode, const ISpellCaster * caster, BattleHex destination) const;
///checks for creature immunity / anything that prevent casting *at given target* - doesn't take into account general problems such as not having spellbook or mana points etc.
ESpellCastProblem::ESpellCastProblem isImmuneByStack(const ISpellCaster * caster, const CStack * obj) const;

View File

@ -5260,7 +5260,7 @@ void CGameHandler::attackCasting(const BattleAttack & bat, Bonus::BonusType atta
vstd::amin(chance, 100);
const CSpell * spell = SpellID(spellID).toSpell();
if(spell->canBeCastAt(gs->curB, attacker, ECastingMode::AFTER_ATTACK_CASTING, oneOfAttacked->position) != ESpellCastProblem::OK)
if(spell->canBeCastAt(gs->curB, ECastingMode::AFTER_ATTACK_CASTING, attacker, oneOfAttacked->position) != ESpellCastProblem::OK)
continue;
//check if spell should be cast (probability handling)