mirror of
https://github.com/vcmi/vcmi.git
synced 2025-09-16 09:26:28 +02:00
This commit is contained in:
@@ -1649,7 +1649,7 @@ void CBattleInterface::enterCreatureCastingMode()
|
|||||||
{
|
{
|
||||||
const ISpellCaster *caster = activeStack;
|
const ISpellCaster *caster = activeStack;
|
||||||
const CSpell *spell = SpellID(creatureSpellToCast).toSpell();
|
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)
|
if (isCastingPossible)
|
||||||
{
|
{
|
||||||
@@ -2499,7 +2499,7 @@ bool CBattleInterface::isCastingPossibleHere(const CStack *sactive, const CStack
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
const ECastingMode::ECastingMode mode = creatureCasting ? ECastingMode::CREATURE_ACTIVE_CASTING : ECastingMode::HERO_CASTING;
|
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
|
else
|
||||||
|
@@ -855,11 +855,11 @@ AccessibilityInfo CBattleInfoCallback::getAccesibility() const
|
|||||||
//special battlefields with logically unavailable tiles
|
//special battlefields with logically unavailable tiles
|
||||||
std::vector<BattleHex> impassableHexes;
|
std::vector<BattleHex> impassableHexes;
|
||||||
if(battleGetBattlefieldType().num == BFieldType::SHIP_TO_SHIP)
|
if(battleGetBattlefieldType().num == BFieldType::SHIP_TO_SHIP)
|
||||||
{
|
{
|
||||||
impassableHexes =
|
impassableHexes =
|
||||||
{
|
{
|
||||||
6, 7, 8, 9,
|
6, 7, 8, 9,
|
||||||
24, 25, 26,
|
24, 25, 26,
|
||||||
58, 59, 60,
|
58, 59, 60,
|
||||||
75, 76, 77,
|
75, 76, 77,
|
||||||
92, 93, 94,
|
92, 93, 94,
|
||||||
@@ -868,7 +868,7 @@ AccessibilityInfo CBattleInfoCallback::getAccesibility() const
|
|||||||
159, 160, 161, 162, 163,
|
159, 160, 161, 162, 163,
|
||||||
176, 177, 178, 179, 180
|
176, 177, 178, 179, 180
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
for(auto hex : impassableHexes)
|
for(auto hex : impassableHexes)
|
||||||
ret[hex] = EAccessibility::UNAVAILABLE;
|
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())
|
if(subject->hasBonus(Selector::source(Bonus::SPELL_EFFECT, spellID), Selector::all, cachingStr.str())
|
||||||
//TODO: this ability has special limitations
|
//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;
|
continue;
|
||||||
|
|
||||||
switch (spellID)
|
switch (spellID)
|
||||||
|
@@ -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);
|
ESpellCastProblem::ESpellCastProblem problem = canBeCast(cb, mode, caster);
|
||||||
if(problem != ESpellCastProblem::OK)
|
if(problem != ESpellCastProblem::OK)
|
||||||
|
@@ -297,8 +297,8 @@ public:
|
|||||||
///Checks general but spell-specific problems. Use only during battle.
|
///Checks general but spell-specific problems. Use only during battle.
|
||||||
ESpellCastProblem::ESpellCastProblem canBeCast(const CBattleInfoCallback * cb, ECastingMode::ECastingMode mode, const ISpellCaster * caster) const;
|
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.
|
///checks for creature immunity / anything that prevent casting *at given hex*
|
||||||
ESpellCastProblem::ESpellCastProblem canBeCastAt(const CBattleInfoCallback * cb, const ISpellCaster * caster, ECastingMode::ECastingMode mode, BattleHex destination) const;
|
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.
|
///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;
|
ESpellCastProblem::ESpellCastProblem isImmuneByStack(const ISpellCaster * caster, const CStack * obj) const;
|
||||||
|
@@ -5260,7 +5260,7 @@ void CGameHandler::attackCasting(const BattleAttack & bat, Bonus::BonusType atta
|
|||||||
vstd::amin(chance, 100);
|
vstd::amin(chance, 100);
|
||||||
|
|
||||||
const CSpell * spell = SpellID(spellID).toSpell();
|
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;
|
continue;
|
||||||
|
|
||||||
//check if spell should be cast (probability handling)
|
//check if spell should be cast (probability handling)
|
||||||
|
Reference in New Issue
Block a user