1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-03-03 13:49:40 +00:00

extracted function isTargetMagicallyHidden().

This commit is contained in:
dteviot 2015-08-09 14:20:55 +12:00
parent 038851420d
commit 0884a3796f
4 changed files with 12 additions and 4 deletions

View file

@ -222,8 +222,7 @@ namespace MWMechanics
MWMechanics::Movement& movement = storage.mMovement;
// Stop attacking if target is not seen
if (target.getClass().getCreatureStats(target).getMagicEffects().get(ESM::MagicEffect::Invisibility).getMagnitude() > 0
|| target.getClass().getCreatureStats(target).getMagicEffects().get(ESM::MagicEffect::Chameleon).getMagnitude() > 75)
if (isTargetMagicallyHidden(target))
{
movement.mPosition[1] = movement.mPosition[0] = 0;
return false; // TODO: run away instead of doing nothing

View file

@ -4,6 +4,7 @@
#include <components/esm/loadcell.hpp>
#include <components/esm/loadland.hpp>
#include <components/esm/loadmgef.hpp>
#include "../mwbase/world.hpp"
#include "../mwbase/environment.hpp"
@ -129,3 +130,10 @@ bool MWMechanics::AiPackage::doesPathNeedRecalc(ESM::Pathgrid::Point dest, const
{
return distance(mPrevDest, dest) > 10;
}
bool MWMechanics::AiPackage::isTargetMagicallyHidden(const MWWorld::Ptr& target)
{
MagicEffects& magicEffects(target.getClass().getCreatureStats(target).getMagicEffects());
return (magicEffects.get(ESM::MagicEffect::Invisibility).getMagnitude() > 0)
|| (magicEffects.get(ESM::MagicEffect::Chameleon).getMagnitude() > 75);
}

View file

@ -69,6 +69,8 @@ namespace MWMechanics
/// Simulates the passing of time
virtual void fastForward(const MWWorld::Ptr& actor, AiState& state) {}
bool isTargetMagicallyHidden(const MWWorld::Ptr& target);
protected:
/// Causes the actor to attempt to walk to the specified location
/** \return If the actor has arrived at his destination **/

View file

@ -43,8 +43,7 @@ bool AiPursue::execute (const MWWorld::Ptr& actor, CharacterController& characte
)
return true; //Target doesn't exist
if (target.getClass().getCreatureStats(target).getMagicEffects().get(ESM::MagicEffect::Invisibility).getMagnitude() > 0
|| target.getClass().getCreatureStats(target).getMagicEffects().get(ESM::MagicEffect::Chameleon).getMagnitude() > 75)
if (isTargetMagicallyHidden(target))
return true;
if(target.getClass().getCreatureStats(target).isDead())