From d51daf5875a003b4653460f6951d61d736198538 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 12 Oct 2014 17:17:52 +0200 Subject: [PATCH] Fix AI not using F_Always spells, for example "vampire touch" --- apps/openmw/mwmechanics/aicombataction.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwmechanics/aicombataction.cpp b/apps/openmw/mwmechanics/aicombataction.cpp index 152854af9..cc8279b1e 100644 --- a/apps/openmw/mwmechanics/aicombataction.cpp +++ b/apps/openmw/mwmechanics/aicombataction.cpp @@ -166,10 +166,18 @@ namespace MWMechanics { const CreatureStats& stats = actor.getClass().getCreatureStats(actor); - // Never casting racial spells (ST_Power and F_Always) - if (spell->mData.mType != ESM::Spell::ST_Spell || spell->mData.mFlags & ESM::Spell::F_Always) + if (spell->mData.mType != ESM::Spell::ST_Spell) return 0.f; + // Don't make use of racial bonus spells, like MW. Can be made optional later + if (actor.getClass().isNpc()) + { + std::string raceid = actor.get()->mBase->mRace; + const ESM::Race* race = MWBase::Environment::get().getWorld()->getStore().get().find(raceid); + if (race->mPowers.exists(spell->mId)) + return 0.f; + } + if (spell->mData.mCost > stats.getMagicka().getCurrent()) return 0.f;