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

Base class for AI packages. More...

#include <aipackage.hpp>

Inheritance diagram for MWMechanics::AiPackage:
Collaboration diagram for MWMechanics::AiPackage:

Public Types

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...
 

Public Member Functions

 AiPackage ()
 Default constructor. More...
 
virtual ~AiPackage ()
 Default Deconstructor. More...
 
virtual AiPackageclone () const =0
 Clones the package. More...
 
virtual bool execute (const MWWorld::Ptr &actor, CharacterController &characterController, AiState &state, float duration)=0
 
virtual int getTypeId () const =0
 
virtual unsigned int getPriority () const
 Higher number is higher priority (0 being the lowest) More...
 
virtual void writeState (ESM::AiSequence::AiSequence &sequence) const
 
virtual void fastForward (const MWWorld::Ptr &actor, AiState &state)
 Simulates the passing of time. 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 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...
 
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...
 
virtual bool getRepeat () const
 Return true if this package should repeat. Currently only used for Wander packages. More...
 
void reset ()
 Reset pathfinding state. More...
 
bool isTargetMagicallyHidden (const MWWorld::Ptr &target)
 

Static Public Member Functions

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

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

PathFinder mPathFinder
 
ObstacleCheck mObstacleCheck
 
float mTimer
 
std::string mTargetActorRefId
 
int mTargetActorId
 
osg::Vec3f mLastActorPos
 
short mRotateOnTheRunChecks
 
bool mIsShortcutting
 
bool mShortcutProhibited
 
ESM::Pathgrid::Point mShortcutFailPos
 

Private Member Functions

bool isNearInactiveCell (const ESM::Position &actorPos)
 

Detailed Description

Base class for AI packages.

Member Enumeration Documentation

Enumerates the various AITypes available.

Enumerator
TypeIdNone 
TypeIdWander 
TypeIdTravel 
TypeIdEscort 
TypeIdFollow 
TypeIdActivate 
TypeIdCombat 
TypeIdPursue 
TypeIdAvoidDoor 
TypeIdFace 
TypeIdBreathe 
TypeIdInternalTravel 
TypeIdCast 

Constructor & Destructor Documentation

MWMechanics::AiPackage::AiPackage ( )

Default constructor.

MWMechanics::AiPackage::~AiPackage ( )
virtual

Default Deconstructor.

Member Function Documentation

bool MWMechanics::AiPackage::canCancel ( ) const
virtual
bool MWMechanics::AiPackage::checkWayIsClearForActor ( const ESM::Pathgrid::Point startPoint,
const ESM::Pathgrid::Point endPoint,
const MWWorld::Ptr actor 
)
protected

Check if the way to the destination is clear, taking into account actor speed.

Here is the call graph for this function:

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

Clones the package.

Implemented in MWMechanics::AiWander, MWMechanics::AiCombat, MWMechanics::AiFollow, MWMechanics::AiEscort, MWMechanics::AiPursue, MWMechanics::AiActivate, MWMechanics::AiTravel, MWMechanics::AiAvoidDoor, MWMechanics::AiBreathe, MWMechanics::AiCast, and MWMechanics::AiFace.

Here is the caller graph for this function:

bool MWMechanics::AiPackage::doesPathNeedRecalc ( const ESM::Pathgrid::Point newDest,
const MWWorld::CellStore currentCell 
)
protectedvirtual

Here is the call graph for this function:

void MWMechanics::AiPackage::evadeObstacles ( const MWWorld::Ptr actor,
float  duration,
const ESM::Position pos 
)
protected

Here is the call graph for this function:

virtual bool MWMechanics::AiPackage::execute ( const MWWorld::Ptr actor,
CharacterController characterController,
AiState state,
float  duration 
)
pure virtual
virtual void MWMechanics::AiPackage::fastForward ( const MWWorld::Ptr actor,
AiState state 
)
inlinevirtual

Simulates the passing of time.

Reimplemented in MWMechanics::AiWander, MWMechanics::AiFollow, MWMechanics::AiEscort, and MWMechanics::AiTravel.

Here is the caller graph for this function:

bool MWMechanics::AiPackage::followTargetThroughDoors ( ) const
virtual

Return true if the actor should follow the target through teleport doors (default false)

Reimplemented in MWMechanics::AiFollow.

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

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

Reimplemented in MWMechanics::AiWander.

Here is the caller graph for this function:

const MWMechanics::PathgridGraph & MWMechanics::AiPackage::getPathGridGraph ( const MWWorld::CellStore cell)
protected

Here is the call graph for this function:

Here is the caller graph for this function:

virtual unsigned int MWMechanics::AiPackage::getPriority ( ) const
inlinevirtual

Higher number is higher priority (0 being the lowest)

Reimplemented in MWMechanics::AiCombat, MWMechanics::AiAvoidDoor, MWMechanics::AiCast, MWMechanics::AiBreathe, and MWMechanics::AiFace.

Here is the caller graph for this function:

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

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

Reimplemented in MWMechanics::AiWander.

MWWorld::Ptr MWMechanics::AiPackage::getTarget ( ) const
virtual

Get the target actor the AI is targeted at (not applicable to all AI packages, default return empty Ptr)

Reimplemented in MWMechanics::AiCombat, MWMechanics::AiPursue, and MWMechanics::AiCast.

Here is the call graph for this function:

Here is the caller graph for this function:

virtual int MWMechanics::AiPackage::getTypeId ( ) const
pure virtual

Returns the TypeID of the AiPackage

See Also
enum TypeId

Implemented in MWMechanics::AiWander, MWMechanics::AiCombat, MWMechanics::AiFollow, MWMechanics::AiEscort, MWMechanics::AiPursue, MWMechanics::AiTravel, MWMechanics::AiActivate, MWMechanics::AiAvoidDoor, MWMechanics::AiBreathe, MWMechanics::AiCast, and MWMechanics::AiFace.

Here is the caller graph for this function:

bool MWMechanics::AiPackage::isNearInactiveCell ( const ESM::Position actorPos)
private

Here is the call graph for this function:

bool MWMechanics::AiPackage::isReachableRotatingOnTheRun ( const MWWorld::Ptr actor,
const ESM::Pathgrid::Point dest 
)
static

Return if actor's rotation speed is sufficient to rotate to the destination pathpoint on the run. Otherwise actor should rotate while standing.

Here is the call graph for this function:

bool MWMechanics::AiPackage::isTargetMagicallyHidden ( const MWWorld::Ptr target)

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::AiPackage::openDoors ( const MWWorld::Ptr actor)
protected

Here is the call graph for this function:

bool MWMechanics::AiPackage::pathTo ( const MWWorld::Ptr actor,
const ESM::Pathgrid::Point dest,
float  duration,
float  destTolerance = 0.0f 
)
protected

Handles path building and shortcutting with obstacles avoiding.

Returns
If the actor has arrived at his destination

Stops the actor when it gets too close to a unloaded cell

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::AiPackage::reset ( )

Reset pathfinding state.

bool MWMechanics::AiPackage::shortcutPath ( const ESM::Pathgrid::Point startPoint,
const ESM::Pathgrid::Point endPoint,
const MWWorld::Ptr actor,
bool destInLOS,
bool  isPathClear 
)
protected

Check if there aren't any obstacles along the path to make shortcut possible If a shortcut is possible then path will be cleared and filled with the destination point.

Parameters
destInLOSIf not NULL function will return ray cast check result
Returns
If can shortcut the path

Here is the call graph for this function:

bool MWMechanics::AiPackage::shouldCancelPreviousAi ( ) const
virtual

Upon adding this Ai package, should the Ai Sequence attempt to cancel previous Ai packages (default true)?

Reimplemented in MWMechanics::AiCombat, MWMechanics::AiFollow, MWMechanics::AiPursue, MWMechanics::AiAvoidDoor, MWMechanics::AiCast, MWMechanics::AiBreathe, and MWMechanics::AiFace.

Here is the caller graph for this function:

bool MWMechanics::AiPackage::sideWithTarget ( ) const
virtual

Return true if having this AiPackage makes the actor side with the target in fights (default false)

Reimplemented in MWMechanics::AiFollow, and MWMechanics::AiEscort.

virtual void MWMechanics::AiPackage::writeState ( ESM::AiSequence::AiSequence sequence) const
inlinevirtual

Member Data Documentation

bool MWMechanics::AiPackage::mIsShortcutting
protected
osg::Vec3f MWMechanics::AiPackage::mLastActorPos
protected
ObstacleCheck MWMechanics::AiPackage::mObstacleCheck
protected
PathFinder MWMechanics::AiPackage::mPathFinder
protected
short MWMechanics::AiPackage::mRotateOnTheRunChecks
protected
ESM::Pathgrid::Point MWMechanics::AiPackage::mShortcutFailPos
protected
bool MWMechanics::AiPackage::mShortcutProhibited
protected
int MWMechanics::AiPackage::mTargetActorId
mutableprotected
std::string MWMechanics::AiPackage::mTargetActorRefId
protected
float MWMechanics::AiPackage::mTimer
protected

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