From f2240dde9cbbadce39fc5078562692dc4d227e07 Mon Sep 17 00:00:00 2001 From: Allofich Date: Thu, 12 Jan 2017 03:11:45 +0900 Subject: [PATCH] Allow command spells to work when cast by AI on AI (Fixes #3723) --- apps/openmw/mwmechanics/actors.cpp | 6 ++---- apps/openmw/mwmechanics/spellcasting.cpp | 6 +++--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index c25eafcaf..db8598a75 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -84,10 +84,8 @@ public: const std::string& sourceName, const std::string& sourceId, int casterActorId, float magnitude, float remainingTime = -1, float totalTime = -1) { - MWWorld::Ptr player = MWMechanics::getPlayer(); - if ( ((key.mId == ESM::MagicEffect::CommandHumanoid && mActor.getClass().isNpc()) - || (key.mId == ESM::MagicEffect::CommandCreature && mActor.getTypeName() == typeid(ESM::Creature).name())) - && casterActorId == player.getClass().getCreatureStats(player).getActorId() + if (((key.mId == ESM::MagicEffect::CommandHumanoid && mActor.getClass().isNpc()) + || (key.mId == ESM::MagicEffect::CommandCreature && mActor.getTypeName() == typeid(ESM::Creature).name())) && magnitude >= mActor.getClass().getCreatureStats(mActor).getLevel()) mCommanded = true; } diff --git a/apps/openmw/mwmechanics/spellcasting.cpp b/apps/openmw/mwmechanics/spellcasting.cpp index 242c5e659..a364f90a9 100644 --- a/apps/openmw/mwmechanics/spellcasting.cpp +++ b/apps/openmw/mwmechanics/spellcasting.cpp @@ -492,9 +492,9 @@ namespace MWMechanics appliedLastingEffects.push_back(effect); // Command spells should have their effect, including taking the target out of combat, each time the spell successfully affects the target - if (effectIt->mEffectID == ESM::MagicEffect::CommandHumanoid && target.getClass().isNpc() - || (effectIt->mEffectID == ESM::MagicEffect::CommandCreature && target.getTypeName() == typeid(ESM::Creature).name()) - && caster == getPlayer() && magnitude >= target.getClass().getCreatureStats(target).getLevel()) + if (((effectIt->mEffectID == ESM::MagicEffect::CommandHumanoid && target.getClass().isNpc()) + || (effectIt->mEffectID == ESM::MagicEffect::CommandCreature && target.getTypeName() == typeid(ESM::Creature).name())) + && !caster.isEmpty() && caster.getClass().isActor() && target != getPlayer() && magnitude >= target.getClass().getCreatureStats(target).getLevel()) { MWMechanics::AiFollow package(caster.getCellRef().getRefId(), true); target.getClass().getCreatureStats(target).getAiSequence().stack(package, target);