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

Allow cast avdmap spells without spellbook

* fixes http://bugs.vcmi.eu/view.php?id=1898
* partial fix for http://bugs.vcmi.eu/view.php?id=482
* fixes http://bugs.vcmi.eu/view.php?id=2155
This commit is contained in:
AlexVinS 2016-10-01 17:21:39 +03:00
parent f124db9f61
commit 799b8519e0
2 changed files with 3 additions and 6 deletions

View File

@ -377,8 +377,6 @@ ESpellCastProblem::ESpellCastProblem CBattleInfoCallback::battleCanCastSpell(con
if(!hero)
return ESpellCastProblem::NO_HERO_TO_CAST_SPELL;
if(!hero->getArt(ArtifactPosition::SPELLBOOK))
return ESpellCastProblem::NO_SPELLBOOK;
if(hero->hasBonusOfType(Bonus::BLOCK_ALL_MAGIC))
return ESpellCastProblem::MAGIC_IS_BLOCKED;
}
@ -1703,6 +1701,8 @@ ESpellCastProblem::ESpellCastProblem CBattleInfoCallback::battleCanCastThisSpell
{
const CGHeroInstance * castingHero = dynamic_cast<const CGHeroInstance *>(caster);//todo: unify hero|creature spell cost
assert(castingHero);
if(!castingHero->getArt(ArtifactPosition::SPELLBOOK))
return ESpellCastProblem::NO_SPELLBOOK;
if(!castingHero->canCastThisSpell(spell))
return ESpellCastProblem::HERO_DOESNT_KNOW_SPELL;
if(castingHero->mana < battleGetSpellCost(spell, castingHero)) //not enough mana

View File

@ -974,12 +974,9 @@ void CGHeroInstance::getCastDescription(const CSpell * spell, const std::vector<
bool CGHeroInstance::canCastThisSpell(const CSpell * spell) const
{
if(nullptr == getArt(ArtifactPosition::SPELLBOOK))
return false;
const bool isAllowed = IObjectInterface::cb->isAllowed(0, spell->id);
const bool inSpellBook = vstd::contains(spells, spell->id);
const bool inSpellBook = vstd::contains(spells, spell->id) && nullptr != getArt(ArtifactPosition::SPELLBOOK);
const bool specificBonus = hasBonusOfType(Bonus::SPELL, spell->id);
bool schoolBonus = false;