mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-03 03:19:40 +00:00
extracted function isTargetMagicallyHidden().
This commit is contained in:
parent
038851420d
commit
0884a3796f
4 changed files with 12 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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 **/
|
||||
|
|
|
@ -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())
|
||||
|
|
Loading…
Reference in a new issue