Allow command spells to work when cast by AI on AI

(Fixes #3723)
coverity_scan^2
Allofich 8 years ago
parent e825010107
commit f2240dde9c

@ -84,10 +84,8 @@ public:
const std::string& sourceName, const std::string& sourceId, int casterActorId, const std::string& sourceName, const std::string& sourceId, int casterActorId,
float magnitude, float remainingTime = -1, float totalTime = -1) float magnitude, float remainingTime = -1, float totalTime = -1)
{ {
MWWorld::Ptr player = MWMechanics::getPlayer(); if (((key.mId == ESM::MagicEffect::CommandHumanoid && mActor.getClass().isNpc())
if ( ((key.mId == ESM::MagicEffect::CommandHumanoid && mActor.getClass().isNpc()) || (key.mId == ESM::MagicEffect::CommandCreature && mActor.getTypeName() == typeid(ESM::Creature).name()))
|| (key.mId == ESM::MagicEffect::CommandCreature && mActor.getTypeName() == typeid(ESM::Creature).name()))
&& casterActorId == player.getClass().getCreatureStats(player).getActorId()
&& magnitude >= mActor.getClass().getCreatureStats(mActor).getLevel()) && magnitude >= mActor.getClass().getCreatureStats(mActor).getLevel())
mCommanded = true; mCommanded = true;
} }

@ -492,9 +492,9 @@ namespace MWMechanics
appliedLastingEffects.push_back(effect); 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 // 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() if (((effectIt->mEffectID == ESM::MagicEffect::CommandHumanoid && target.getClass().isNpc())
|| (effectIt->mEffectID == ESM::MagicEffect::CommandCreature && target.getTypeName() == typeid(ESM::Creature).name()) || (effectIt->mEffectID == ESM::MagicEffect::CommandCreature && target.getTypeName() == typeid(ESM::Creature).name()))
&& caster == getPlayer() && magnitude >= target.getClass().getCreatureStats(target).getLevel()) && !caster.isEmpty() && caster.getClass().isActor() && target != getPlayer() && magnitude >= target.getClass().getCreatureStats(target).getLevel())
{ {
MWMechanics::AiFollow package(caster.getCellRef().getRefId(), true); MWMechanics::AiFollow package(caster.getCellRef().getRefId(), true);
target.getClass().getCreatureStats(target).getAiSequence().stack(package, target); target.getClass().getCreatureStats(target).getAiSequence().stack(package, target);

Loading…
Cancel
Save