1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-15 00:05:02 +02:00

Fixes issues related to spell mechanics

This commit is contained in:
nordsoft
2023-04-10 17:08:24 +04:00
parent f550457d23
commit b9cabef179
7 changed files with 44 additions and 22 deletions

View File

@ -363,13 +363,14 @@ void CRewardableObject::grantRewardAfterLevelup(const CRewardVisitInfo & info, c
cb->giveCreatures(this, hero, creatures, false);
}
if(!info.reward.casts.empty())
if(info.reward.spellCast.first != SpellID::NONE)
{
caster = std::make_unique<spells::OuterCaster>(hero, SecSkillLevel::EXPERT);
for(const auto & c : info.reward.casts)
{
cb->castSpell(caster.get(), c, int3{-1, -1, -1});
}
caster.setActualCaster(hero);
caster.setSpellSchoolLevel(info.reward.spellCast.second);
cb->castSpell(&caster, info.reward.spellCast.first, int3{-1, -1, -1});
if(info.reward.removeObject)
logMod->warn("Removal of object with spell casts is not supported!");
}
else if(info.reward.removeObject) //FIXME: object can't track spell cancel or finish, so removeObject leads to crash
cb->removeObject(this);