1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-04-10 15:45:37 +00:00

Restructure function isCommanded

This commit is contained in:
ζeh Matt 2022-03-28 16:07:20 +03:00
parent 1c70b9790c
commit f5b527e445
No known key found for this signature in database
GPG Key ID: 18CE582C71A225B0

View File

@ -56,14 +56,17 @@ bool isConscious(const MWWorld::Ptr& ptr)
bool isCommanded(const MWWorld::Ptr& actor) bool isCommanded(const MWWorld::Ptr& actor)
{ {
const auto& stats = actor.getClass().getCreatureStats(actor); const auto& actorClass = actor.getClass();
for(const auto& params : stats.getActiveSpells()) const auto& stats = actorClass.getCreatureStats(actor);
const bool isActorNpc = actorClass.isNpc();
const auto level = stats.getLevel();
for (const auto& params : stats.getActiveSpells())
{ {
for(const auto& effect : params.getEffects()) for (const auto& effect : params.getEffects())
{ {
if(((effect.mEffectId == ESM::MagicEffect::CommandHumanoid && actor.getClass().isNpc()) if (((effect.mEffectId == ESM::MagicEffect::CommandHumanoid && isActorNpc)
|| (effect.mEffectId == ESM::MagicEffect::CommandCreature && !actor.getClass().isNpc())) || (effect.mEffectId == ESM::MagicEffect::CommandCreature && !isActorNpc))
&& effect.mMagnitude >= stats.getLevel()) && effect.mMagnitude >= level)
return true; return true;
} }
} }