OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
MWMechanics::AiWander Class Reference

Causes the Actor to wander within a specified range. More...

#include <aiwander.hpp>

Inheritance diagram for MWMechanics::AiWander:
Collaboration diagram for MWMechanics::AiWander:

Public Member Functions

 AiWander (int distance, int duration, int timeOfDay, const std::vector< unsigned char > &idle, bool repeat)
 Constructor. More...
 
 AiWander (const ESM::AiSequence::AiWander *wander)
 
virtual AiPackageclone () const
 Clones the package. More...
 
virtual bool execute (const MWWorld::Ptr &actor, CharacterController &characterController, AiState &state, float duration)
 
virtual int getTypeId () const
 
virtual void writeState (ESM::AiSequence::AiSequence &sequence) const
 
virtual void fastForward (const MWWorld::Ptr &actor, AiState &state)
 Simulates the passing of time. More...
 
bool getRepeat () const
 Return true if this package should repeat. Currently only used for Wander packages. More...
 
osg::Vec3f getDestination (const MWWorld::Ptr &actor) const
 Get the destination point of the AI package (not applicable to all AI packages, default return (0, 0, 0)) More...
 
- Public Member Functions inherited from MWMechanics::AiPackage
 AiPackage ()
 Default constructor. More...
 
virtual ~AiPackage ()
 Default Deconstructor. More...
 
virtual unsigned int getPriority () const
 Higher number is higher priority (0 being the lowest) More...
 
virtual MWWorld::Ptr getTarget () const
 Get the target actor the AI is targeted at (not applicable to all AI packages, default return empty Ptr) More...
 
virtual bool sideWithTarget () const
 Return true if having this AiPackage makes the actor side with the target in fights (default false) More...
 
virtual bool followTargetThroughDoors () const
 Return true if the actor should follow the target through teleport doors (default false) More...
 
virtual bool canCancel () const
 Can this Ai package be canceled? (default true) More...
 
virtual bool shouldCancelPreviousAi () const
 Upon adding this Ai package, should the Ai Sequence attempt to cancel previous Ai packages (default true)? More...
 
void reset ()
 Reset pathfinding state. More...
 
bool isTargetMagicallyHidden (const MWWorld::Ptr &target)
 

Private Types

enum  GroupIndex { GroupIndex_MinIdle = 2, GroupIndex_MaxIdle = 9 }
 

Private Member Functions

void init ()
 
void stopWalking (const MWWorld::Ptr &actor, AiWanderStorage &storage, bool clearPath=true)
 
bool playIdle (const MWWorld::Ptr &actor, unsigned short idleSelect)
 
bool checkIdle (const MWWorld::Ptr &actor, unsigned short idleSelect)
 
short unsigned getRandomIdle ()
 
void setPathToAnAllowedNode (const MWWorld::Ptr &actor, AiWanderStorage &storage, const ESM::Position &actorPos)
 
void playGreetingIfPlayerGetsTooClose (const MWWorld::Ptr &actor, AiWanderStorage &storage)
 
void evadeObstacles (const MWWorld::Ptr &actor, AiWanderStorage &storage, float duration, ESM::Position &pos)
 
void playIdleDialogueRandomly (const MWWorld::Ptr &actor)
 
void turnActorToFacePlayer (const osg::Vec3f &actorPosition, const osg::Vec3f &playerPosition, AiWanderStorage &storage)
 
void doPerFrameActionsForState (const MWWorld::Ptr &actor, float duration, AiWanderStorage &storage, ESM::Position &pos)
 
void onIdleStatePerFrameActions (const MWWorld::Ptr &actor, float duration, AiWanderStorage &storage)
 
void onWalkingStatePerFrameActions (const MWWorld::Ptr &actor, float duration, AiWanderStorage &storage, ESM::Position &pos)
 
void onChooseActionStatePerFrameActions (const MWWorld::Ptr &actor, AiWanderStorage &storage)
 
bool reactionTimeActions (const MWWorld::Ptr &actor, AiWanderStorage &storage, const MWWorld::CellStore *&currentCell, bool cellChange, ESM::Position &pos, float duration)
 
bool isPackageCompleted (const MWWorld::Ptr &actor, AiWanderStorage &storage)
 
void wanderNearStart (const MWWorld::Ptr &actor, AiWanderStorage &storage, int wanderDistance)
 
bool destinationIsAtWater (const MWWorld::Ptr &actor, const osg::Vec3f &destination)
 
bool destinationThroughGround (const osg::Vec3f &startPoint, const osg::Vec3f &destination)
 
void completeManualWalking (const MWWorld::Ptr &actor, AiWanderStorage &storage)
 
void getNeighbouringNodes (ESM::Pathgrid::Point dest, const MWWorld::CellStore *currentCell, ESM::Pathgrid::PointList &points)
 
void getAllowedNodes (const MWWorld::Ptr &actor, const ESM::Cell *cell, AiWanderStorage &storage)
 
void trimAllowedNodes (std::vector< ESM::Pathgrid::Point > &nodes, const PathFinder &pathfinder)
 
void ToWorldCoordinates (ESM::Pathgrid::Point &point, const ESM::Cell *cell)
 convert point from local (i.e. cell) to world coordinates More...
 
void SetCurrentNodeToClosestAllowedNode (const osg::Vec3f &npcPos, AiWanderStorage &storage)
 
void AddNonPathGridAllowedPoints (osg::Vec3f npcPos, const ESM::Pathgrid *pathGrid, int pointIndex, AiWanderStorage &storage)
 
void AddPointBetweenPathGridPoints (const ESM::Pathgrid::Point &start, const ESM::Pathgrid::Point &end, AiWanderStorage &storage)
 

Static Private Member Functions

static int OffsetToPreventOvercrowding ()
 

Private Attributes

int mDistance
 
int mDuration
 
float mRemainingDuration
 
int mTimeOfDay
 
std::vector< unsigned char > mIdle
 
bool mRepeat
 
bool mStoredInitialActorPosition
 
osg::Vec3f mInitialActorPosition
 
bool mHasDestination
 
osg::Vec3f mDestination
 

Static Private Attributes

static const std::string sIdleSelectToGroupName [GroupIndex_MaxIdle-GroupIndex_MinIdle+1]
 lookup table for converting idleSelect value to groupName More...
 

Additional Inherited Members

- Public Types inherited from MWMechanics::AiPackage
enum  TypeId {
  TypeIdNone = -1, TypeIdWander = 0, TypeIdTravel = 1, TypeIdEscort = 2,
  TypeIdFollow = 3, TypeIdActivate = 4, TypeIdCombat = 5, TypeIdPursue = 6,
  TypeIdAvoidDoor = 7, TypeIdFace = 8, TypeIdBreathe = 9, TypeIdInternalTravel = 10,
  TypeIdCast = 11
}
 Enumerates the various AITypes available. More...
 
- Static Public Member Functions inherited from MWMechanics::AiPackage
static bool isReachableRotatingOnTheRun (const MWWorld::Ptr &actor, const ESM::Pathgrid::Point &dest)
 Return if actor's rotation speed is sufficient to rotate to the destination pathpoint on the run. Otherwise actor should rotate while standing. More...
 
- Protected Member Functions inherited from MWMechanics::AiPackage
bool pathTo (const MWWorld::Ptr &actor, const ESM::Pathgrid::Point &dest, float duration, float destTolerance=0.0f)
 Handles path building and shortcutting with obstacles avoiding. More...
 
bool shortcutPath (const ESM::Pathgrid::Point &startPoint, const ESM::Pathgrid::Point &endPoint, const MWWorld::Ptr &actor, bool *destInLOS, bool isPathClear)
 
bool checkWayIsClearForActor (const ESM::Pathgrid::Point &startPoint, const ESM::Pathgrid::Point &endPoint, const MWWorld::Ptr &actor)
 Check if the way to the destination is clear, taking into account actor speed. More...
 
virtual bool doesPathNeedRecalc (const ESM::Pathgrid::Point &newDest, const MWWorld::CellStore *currentCell)
 
void evadeObstacles (const MWWorld::Ptr &actor, float duration, const ESM::Position &pos)
 
void openDoors (const MWWorld::Ptr &actor)
 
const PathgridGraphgetPathGridGraph (const MWWorld::CellStore *cell)
 
- Protected Attributes inherited from MWMechanics::AiPackage
PathFinder mPathFinder
 
ObstacleCheck mObstacleCheck
 
float mTimer
 
std::string mTargetActorRefId
 
int mTargetActorId
 
osg::Vec3f mLastActorPos
 
short mRotateOnTheRunChecks
 
bool mIsShortcutting
 
bool mShortcutProhibited
 
ESM::Pathgrid::Point mShortcutFailPos
 

Detailed Description

Causes the Actor to wander within a specified range.

Member Enumeration Documentation

Enumerator
GroupIndex_MinIdle 
GroupIndex_MaxIdle 

Constructor & Destructor Documentation

MWMechanics::AiWander::AiWander ( int  distance,
int  duration,
int  timeOfDay,
const std::vector< unsigned char > &  idle,
bool  repeat 
)

Constructor.

Parameters
distanceMax distance the ACtor will wander
durationTime, in hours, that this package will be preformed
timeOfDayCurrently unimplemented. Not functional in the original engine.
idleChances of each idle to play (9 in total)
repeatRepeat wander or not

Here is the call graph for this function:

MWMechanics::AiWander::AiWander ( const ESM::AiSequence::AiWander wander)

Here is the call graph for this function:

Member Function Documentation

void MWMechanics::AiWander::AddNonPathGridAllowedPoints ( osg::Vec3f  npcPos,
const ESM::Pathgrid pathGrid,
int  pointIndex,
AiWanderStorage storage 
)
private

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::AiWander::AddPointBetweenPathGridPoints ( const ESM::Pathgrid::Point start,
const ESM::Pathgrid::Point end,
AiWanderStorage storage 
)
private

Here is the call graph for this function:

Here is the caller graph for this function:

bool MWMechanics::AiWander::checkIdle ( const MWWorld::Ptr actor,
unsigned short  idleSelect 
)
private

Here is the call graph for this function:

Here is the caller graph for this function:

AiPackage * MWMechanics::AiWander::clone ( ) const
virtual

Clones the package.

Implements MWMechanics::AiPackage.

void MWMechanics::AiWander::completeManualWalking ( const MWWorld::Ptr actor,
AiWanderStorage storage 
)
private

Here is the call graph for this function:

Here is the caller graph for this function:

bool MWMechanics::AiWander::destinationIsAtWater ( const MWWorld::Ptr actor,
const osg::Vec3f &  destination 
)
private

Here is the call graph for this function:

Here is the caller graph for this function:

bool MWMechanics::AiWander::destinationThroughGround ( const osg::Vec3f &  startPoint,
const osg::Vec3f &  destination 
)
private

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::AiWander::doPerFrameActionsForState ( const MWWorld::Ptr actor,
float  duration,
AiWanderStorage storage,
ESM::Position pos 
)
private

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::AiWander::evadeObstacles ( const MWWorld::Ptr actor,
AiWanderStorage storage,
float  duration,
ESM::Position pos 
)
private

Here is the call graph for this function:

Here is the caller graph for this function:

bool MWMechanics::AiWander::execute ( const MWWorld::Ptr actor,
CharacterController characterController,
AiState state,
float  duration 
)
virtual

Updates and runs the package (Should run every frame)

Returns
Package completed?

Implements MWMechanics::AiPackage.

Here is the call graph for this function:

void MWMechanics::AiWander::fastForward ( const MWWorld::Ptr actor,
AiState state 
)
virtual

Simulates the passing of time.

Reimplemented from MWMechanics::AiPackage.

Here is the call graph for this function:

void MWMechanics::AiWander::getAllowedNodes ( const MWWorld::Ptr actor,
const ESM::Cell cell,
AiWanderStorage storage 
)
private

Here is the call graph for this function:

Here is the caller graph for this function:

osg::Vec3f MWMechanics::AiWander::getDestination ( const MWWorld::Ptr actor) const
virtual

Get the destination point of the AI package (not applicable to all AI packages, default return (0, 0, 0))

Reimplemented from MWMechanics::AiPackage.

Here is the call graph for this function:

void MWMechanics::AiWander::getNeighbouringNodes ( ESM::Pathgrid::Point  dest,
const MWWorld::CellStore currentCell,
ESM::Pathgrid::PointList points 
)
private

Here is the call graph for this function:

Here is the caller graph for this function:

short unsigned MWMechanics::AiWander::getRandomIdle ( )
private

Here is the call graph for this function:

Here is the caller graph for this function:

bool MWMechanics::AiWander::getRepeat ( ) const
virtual

Return true if this package should repeat. Currently only used for Wander packages.

Reimplemented from MWMechanics::AiPackage.

int MWMechanics::AiWander::getTypeId ( ) const
virtual

Returns the TypeID of the AiPackage

See Also
enum TypeId

Implements MWMechanics::AiPackage.

void MWMechanics::AiWander::init ( )
private

Here is the caller graph for this function:

bool MWMechanics::AiWander::isPackageCompleted ( const MWWorld::Ptr actor,
AiWanderStorage storage 
)
private

Here is the call graph for this function:

Here is the caller graph for this function:

static int MWMechanics::AiWander::OffsetToPreventOvercrowding ( )
staticprivate
void MWMechanics::AiWander::onChooseActionStatePerFrameActions ( const MWWorld::Ptr actor,
AiWanderStorage storage 
)
private

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::AiWander::onIdleStatePerFrameActions ( const MWWorld::Ptr actor,
float  duration,
AiWanderStorage storage 
)
private

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::AiWander::onWalkingStatePerFrameActions ( const MWWorld::Ptr actor,
float  duration,
AiWanderStorage storage,
ESM::Position pos 
)
private

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::AiWander::playGreetingIfPlayerGetsTooClose ( const MWWorld::Ptr actor,
AiWanderStorage storage 
)
private

Here is the call graph for this function:

Here is the caller graph for this function:

bool MWMechanics::AiWander::playIdle ( const MWWorld::Ptr actor,
unsigned short  idleSelect 
)
private

Have the given actor play an idle animation

Returns
Success or error

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::AiWander::playIdleDialogueRandomly ( const MWWorld::Ptr actor)
private

Here is the call graph for this function:

Here is the caller graph for this function:

bool MWMechanics::AiWander::reactionTimeActions ( const MWWorld::Ptr actor,
AiWanderStorage storage,
const MWWorld::CellStore *&  currentCell,
bool  cellChange,
ESM::Position pos,
float  duration 
)
private

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::AiWander::SetCurrentNodeToClosestAllowedNode ( const osg::Vec3f &  npcPos,
AiWanderStorage storage 
)
private

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::AiWander::setPathToAnAllowedNode ( const MWWorld::Ptr actor,
AiWanderStorage storage,
const ESM::Position actorPos 
)
private

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::AiWander::stopWalking ( const MWWorld::Ptr actor,
AiWanderStorage storage,
bool  clearPath = true 
)
private

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::AiWander::ToWorldCoordinates ( ESM::Pathgrid::Point point,
const ESM::Cell cell 
)
private

convert point from local (i.e. cell) to world coordinates

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::AiWander::trimAllowedNodes ( std::vector< ESM::Pathgrid::Point > &  nodes,
const PathFinder pathfinder 
)
private

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::AiWander::turnActorToFacePlayer ( const osg::Vec3f &  actorPosition,
const osg::Vec3f &  playerPosition,
AiWanderStorage storage 
)
private

Here is the caller graph for this function:

void MWMechanics::AiWander::wanderNearStart ( const MWWorld::Ptr actor,
AiWanderStorage storage,
int  wanderDistance 
)
private

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::AiWander::writeState ( ESM::AiSequence::AiSequence sequence) const
virtual

Reimplemented from MWMechanics::AiPackage.

Member Data Documentation

osg::Vec3f MWMechanics::AiWander::mDestination
private
int MWMechanics::AiWander::mDistance
private
int MWMechanics::AiWander::mDuration
private
bool MWMechanics::AiWander::mHasDestination
private
std::vector<unsigned char> MWMechanics::AiWander::mIdle
private
osg::Vec3f MWMechanics::AiWander::mInitialActorPosition
private
float MWMechanics::AiWander::mRemainingDuration
private
bool MWMechanics::AiWander::mRepeat
private
bool MWMechanics::AiWander::mStoredInitialActorPosition
private
int MWMechanics::AiWander::mTimeOfDay
private
const std::string MWMechanics::AiWander::sIdleSelectToGroupName
staticprivate
Initial value:
=
{
std::string("idle2"),
std::string("idle3"),
std::string("idle4"),
std::string("idle5"),
std::string("idle6"),
std::string("idle7"),
std::string("idle8"),
std::string("idle9"),
}

lookup table for converting idleSelect value to groupName


The documentation for this class was generated from the following files: