From 8265ebc4846059f4fa4a85234ff4e73d73584797 Mon Sep 17 00:00:00 2001 From: Capostrophic Date: Fri, 15 May 2020 22:24:48 +0300 Subject: [PATCH] Fix spell school calculation --- apps/openmw/mwmechanics/spellutil.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwmechanics/spellutil.cpp b/apps/openmw/mwmechanics/spellutil.cpp index cce07f9e3f..def3bbbc84 100644 --- a/apps/openmw/mwmechanics/spellutil.cpp +++ b/apps/openmw/mwmechanics/spellutil.cpp @@ -101,6 +101,9 @@ namespace MWMechanics float getSpellSuccessChance (const ESM::Spell* spell, const MWWorld::Ptr& actor, int* effectiveSchool, bool cap, bool checkMagicka) { + // NB: Base chance is calculated here because the effective school pointer must be filled + float baseChance = calcSpellBaseSuccessChance(spell, actor, effectiveSchool); + bool godmode = actor == getPlayer() && MWBase::Environment::get().getWorld()->getGodModeState(); CreatureStats& stats = actor.getClass().getCreatureStats(actor); @@ -124,7 +127,7 @@ namespace MWMechanics return 100; float castBonus = -stats.getMagicEffects().get(ESM::MagicEffect::Sound).getMagnitude(); - float castChance = calcSpellBaseSuccessChance(spell, actor, effectiveSchool) + castBonus; + float castChance = baseChance + castBonus; castChance *= stats.getFatigueTerm(); return std::max(0.f, cap ? std::min(100.f, castChance) : castChance);