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

#include <actors.hpp>

Collaboration diagram for MWMechanics::Actors:

Public Types

typedef std::map< MWWorld::Ptr,
Actor * > 
PtrActorMap
 

Public Member Functions

 Actors ()
 
 ~Actors ()
 
PtrActorMap::const_iterator begin ()
 
PtrActorMap::const_iterator end ()
 
bool isActorDetected (const MWWorld::Ptr &actor, const MWWorld::Ptr &observer)
 
void updateMagicEffects (const MWWorld::Ptr &ptr)
 
void addActor (const MWWorld::Ptr &ptr, bool updateImmediately=false)
 
void removeActor (const MWWorld::Ptr &ptr)
 
void castSpell (const MWWorld::Ptr &ptr, const std::string spellId, bool manualSpell=false)
 
void updateActor (const MWWorld::Ptr &old, const MWWorld::Ptr &ptr)
 Updates an actor with a new Ptr. More...
 
void dropActors (const MWWorld::CellStore *cellStore, const MWWorld::Ptr &ignore)
 Deregister all actors (except for ignore) in the given cell. More...
 
void updateCombatMusic ()
 Update combat music state. More...
 
void update (float duration, bool paused)
 Update actor stats and store desired velocity vectors in movement. More...
 
void updateActor (const MWWorld::Ptr &ptr, float duration)
 
void engageCombat (const MWWorld::Ptr &actor1, const MWWorld::Ptr &actor2, std::map< const MWWorld::Ptr, const std::set< MWWorld::Ptr > > &cachedAllies, bool againstPlayer)
 
void updateHeadTracking (const MWWorld::Ptr &actor, const MWWorld::Ptr &targetActor, MWWorld::Ptr &headTrackTarget, float &sqrHeadTrackDistance)
 
void rest (bool sleep)
 Update actors while the player is waiting or sleeping. This should be called every hour. More...
 
void restoreDynamicStats (const MWWorld::Ptr &actor, bool sleep)
 
int getHoursToRest (const MWWorld::Ptr &ptr) const
 Calculate how many hours the given actor needs to rest in order to be fully healed. More...
 
void fastForwardAi ()
 Simulate the passing of time. More...
 
int countDeaths (const std::string &id) const
 Return the number of deaths for actors with the given ID. More...
 
bool isAttackPreparing (const MWWorld::Ptr &ptr)
 
bool isRunning (const MWWorld::Ptr &ptr)
 
bool isSneaking (const MWWorld::Ptr &ptr)
 
void forceStateUpdate (const MWWorld::Ptr &ptr)
 
bool playAnimationGroup (const MWWorld::Ptr &ptr, const std::string &groupName, int mode, int number, bool persist=false)
 
void skipAnimation (const MWWorld::Ptr &ptr)
 
bool checkAnimationPlaying (const MWWorld::Ptr &ptr, const std::string &groupName)
 
void persistAnimationStates ()
 
void getObjectsInRange (const osg::Vec3f &position, float radius, std::vector< MWWorld::Ptr > &out)
 
bool isAnyObjectInRange (const osg::Vec3f &position, float radius)
 
void cleanupSummonedCreature (CreatureStats &casterStats, int creatureActorId)
 
std::list< MWWorld::PtrgetActorsSidingWith (const MWWorld::Ptr &actor)
 Returns the list of actors which are siding with the given actor in fights. More...
 
std::list< MWWorld::PtrgetActorsFollowing (const MWWorld::Ptr &actor)
 
void getActorsFollowing (const MWWorld::Ptr &actor, std::set< MWWorld::Ptr > &out)
 Recursive version of getActorsFollowing. More...
 
void getActorsSidingWith (const MWWorld::Ptr &actor, std::set< MWWorld::Ptr > &out)
 Recursive version of getActorsSidingWith. More...
 
void getActorsSidingWith (const MWWorld::Ptr &actor, std::set< MWWorld::Ptr > &out, std::map< const MWWorld::Ptr, const std::set< MWWorld::Ptr > > &cachedAllies)
 Recursive version of getActorsSidingWith that takes, adds to and returns a cache of actors mapped to their allies. More...
 
std::list< intgetActorsFollowingIndices (const MWWorld::Ptr &actor)
 Get the list of AiFollow::mFollowIndex for all actors following this target. More...
 
std::list< MWWorld::PtrgetActorsFighting (const MWWorld::Ptr &actor)
 Returns the list of actors which are fighting the given actor. More...
 
std::list< MWWorld::PtrgetEnemiesNearby (const MWWorld::Ptr &actor)
 Unlike getActorsFighting, also returns actors that would fight the given actor if they saw him. More...
 
void write (ESM::ESMWriter &writer, Loading::Listener &listener) const
 
void readRecord (ESM::ESMReader &reader, uint32_t type)
 
void clear ()
 
bool isCastingSpell (const MWWorld::Ptr &ptr) const
 
bool isReadyToBlock (const MWWorld::Ptr &ptr) const
 
bool isAttackingOrSpell (const MWWorld::Ptr &ptr) const
 

Private Member Functions

void addBoundItem (const std::string &itemId, const MWWorld::Ptr &actor)
 
void removeBoundItem (const std::string &itemId, const MWWorld::Ptr &actor)
 
void adjustMagicEffects (const MWWorld::Ptr &creature)
 
void calculateDynamicStats (const MWWorld::Ptr &ptr)
 
void calculateCreatureStatModifiers (const MWWorld::Ptr &ptr, float duration)
 
void calculateNpcStatModifiers (const MWWorld::Ptr &ptr, float duration)
 
void calculateRestoration (const MWWorld::Ptr &ptr, float duration)
 
void updateDrowning (const MWWorld::Ptr &ptr, float duration, bool isKnockedOut, bool isPlayer)
 
void updateEquippedLight (const MWWorld::Ptr &ptr, float duration, bool mayEquip)
 
void updateCrimePursuit (const MWWorld::Ptr &ptr, float duration)
 
void killDeadActors ()
 
void purgeSpellEffects (int casterActorId)
 

Private Attributes

std::map< std::string, intmDeathCount
 
PtrActorMap mActors
 
float mTimerDisposeSummonsCorpses
 

Member Typedef Documentation

Constructor & Destructor Documentation

MWMechanics::Actors::Actors ( )
MWMechanics::Actors::~Actors ( )

Here is the call graph for this function:

Member Function Documentation

void MWMechanics::Actors::addActor ( const MWWorld::Ptr ptr,
bool  updateImmediately = false 
)

Register an actor for stats management

Note
Dead actors are ignored.

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::Actors::addBoundItem ( const std::string &  itemId,
const MWWorld::Ptr actor 
)
private

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::Actors::adjustMagicEffects ( const MWWorld::Ptr creature)
private

Here is the call graph for this function:

Here is the caller graph for this function:

PtrActorMap::const_iterator MWMechanics::Actors::begin ( )
inline

Here is the caller graph for this function:

void MWMechanics::Actors::calculateCreatureStatModifiers ( const MWWorld::Ptr ptr,
float  duration 
)
private

Here is the caller graph for this function:

void MWMechanics::Actors::calculateDynamicStats ( const MWWorld::Ptr ptr)
private

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::Actors::calculateNpcStatModifiers ( const MWWorld::Ptr ptr,
float  duration 
)
private

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::Actors::calculateRestoration ( const MWWorld::Ptr ptr,
float  duration 
)
private

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::Actors::castSpell ( const MWWorld::Ptr ptr,
const std::string  spellId,
bool  manualSpell = false 
)

Here is the caller graph for this function:

bool MWMechanics::Actors::checkAnimationPlaying ( const MWWorld::Ptr ptr,
const std::string &  groupName 
)

Here is the caller graph for this function:

void MWMechanics::Actors::cleanupSummonedCreature ( MWMechanics::CreatureStats casterStats,
int  creatureActorId 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::Actors::clear ( )

Here is the caller graph for this function:

int MWMechanics::Actors::countDeaths ( const std::string &  id) const

Return the number of deaths for actors with the given ID.

Here is the caller graph for this function:

void MWMechanics::Actors::dropActors ( const MWWorld::CellStore cellStore,
const MWWorld::Ptr ignore 
)

Deregister all actors (except for ignore) in the given cell.

Here is the caller graph for this function:

PtrActorMap::const_iterator MWMechanics::Actors::end ( )
inline

Here is the caller graph for this function:

void MWMechanics::Actors::engageCombat ( const MWWorld::Ptr actor1,
const MWWorld::Ptr actor2,
std::map< const MWWorld::Ptr, const std::set< MWWorld::Ptr > > &  cachedAllies,
bool  againstPlayer 
)

Start combat between two actors : If againstPlayer = true then actor2 should be the Player. If one of the combatants is creature it should be actor1.

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::Actors::fastForwardAi ( )

Simulate the passing of time.

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::Actors::forceStateUpdate ( const MWWorld::Ptr ptr)

Here is the caller graph for this function:

std::list< MWWorld::Ptr > MWMechanics::Actors::getActorsFighting ( const MWWorld::Ptr actor)

Returns the list of actors which are fighting the given actor.

ie AiCombat is active and the target is the actor

Here is the call graph for this function:

Here is the caller graph for this function:

std::list< MWWorld::Ptr > MWMechanics::Actors::getActorsFollowing ( const MWWorld::Ptr actor)

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::Actors::getActorsFollowing ( const MWWorld::Ptr actor,
std::set< MWWorld::Ptr > &  out 
)

Recursive version of getActorsFollowing.

Here is the call graph for this function:

std::list< int > MWMechanics::Actors::getActorsFollowingIndices ( const MWWorld::Ptr actor)

Get the list of AiFollow::mFollowIndex for all actors following this target.

Here is the call graph for this function:

Here is the caller graph for this function:

std::list< MWWorld::Ptr > MWMechanics::Actors::getActorsSidingWith ( const MWWorld::Ptr actor)

Returns the list of actors which are siding with the given actor in fights.

ie AiFollow or AiEscort is active and the target is the actor

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::Actors::getActorsSidingWith ( const MWWorld::Ptr actor,
std::set< MWWorld::Ptr > &  out 
)

Recursive version of getActorsSidingWith.

Here is the call graph for this function:

void MWMechanics::Actors::getActorsSidingWith ( const MWWorld::Ptr actor,
std::set< MWWorld::Ptr > &  out,
std::map< const MWWorld::Ptr, const std::set< MWWorld::Ptr > > &  cachedAllies 
)

Recursive version of getActorsSidingWith that takes, adds to and returns a cache of actors mapped to their allies.

Here is the call graph for this function:

std::list< MWWorld::Ptr > MWMechanics::Actors::getEnemiesNearby ( const MWWorld::Ptr actor)

Unlike getActorsFighting, also returns actors that would fight the given actor if they saw him.

Here is the call graph for this function:

Here is the caller graph for this function:

int MWMechanics::Actors::getHoursToRest ( const MWWorld::Ptr ptr) const

Calculate how many hours the given actor needs to rest in order to be fully healed.

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::Actors::getObjectsInRange ( const osg::Vec3f &  position,
float  radius,
std::vector< MWWorld::Ptr > &  out 
)

Here is the caller graph for this function:

bool MWMechanics::Actors::isActorDetected ( const MWWorld::Ptr actor,
const MWWorld::Ptr observer 
)

Check if the target actor was detected by an observer If the observer is a non-NPC, check all actors in AI processing distance as observers

Here is the call graph for this function:

Here is the caller graph for this function:

bool MWMechanics::Actors::isAnyObjectInRange ( const osg::Vec3f &  position,
float  radius 
)

Here is the caller graph for this function:

bool MWMechanics::Actors::isAttackingOrSpell ( const MWWorld::Ptr ptr) const

Here is the call graph for this function:

Here is the caller graph for this function:

bool MWMechanics::Actors::isAttackPreparing ( const MWWorld::Ptr ptr)

Here is the call graph for this function:

Here is the caller graph for this function:

bool MWMechanics::Actors::isCastingSpell ( const MWWorld::Ptr ptr) const

Here is the caller graph for this function:

bool MWMechanics::Actors::isReadyToBlock ( const MWWorld::Ptr ptr) const

Here is the caller graph for this function:

bool MWMechanics::Actors::isRunning ( const MWWorld::Ptr ptr)

Here is the call graph for this function:

Here is the caller graph for this function:

bool MWMechanics::Actors::isSneaking ( const MWWorld::Ptr ptr)

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::Actors::killDeadActors ( )
private

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::Actors::persistAnimationStates ( )

Here is the caller graph for this function:

bool MWMechanics::Actors::playAnimationGroup ( const MWWorld::Ptr ptr,
const std::string &  groupName,
int  mode,
int  number,
bool  persist = false 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::Actors::purgeSpellEffects ( int  casterActorId)
private

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::Actors::readRecord ( ESM::ESMReader reader,
uint32_t  type 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::Actors::removeActor ( const MWWorld::Ptr ptr)

Deregister an actor for stats management

Note
Ignored, if ptr is not a registered actor.

Here is the caller graph for this function:

void MWMechanics::Actors::removeBoundItem ( const std::string &  itemId,
const MWWorld::Ptr actor 
)
private

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::Actors::rest ( bool  sleep)

Update actors while the player is waiting or sleeping. This should be called every hour.

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::Actors::restoreDynamicStats ( const MWWorld::Ptr actor,
bool  sleep 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::Actors::skipAnimation ( const MWWorld::Ptr ptr)

Here is the caller graph for this function:

void MWMechanics::Actors::update ( float  duration,
bool  paused 
)

Update actor stats and store desired velocity vectors in movement.

Todo:
move update logic to Actor class where appropriate

Here is the caller graph for this function:

void MWMechanics::Actors::updateActor ( const MWWorld::Ptr old,
const MWWorld::Ptr ptr 
)

Updates an actor with a new Ptr.

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::Actors::updateActor ( const MWWorld::Ptr ptr,
float  duration 
)

This function is normally called automatically during the update process, but it can also be called explicitly at any time to force an update.

Here is the call graph for this function:

void MWMechanics::Actors::updateCombatMusic ( )

Update combat music state.

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::Actors::updateCrimePursuit ( const MWWorld::Ptr ptr,
float  duration 
)
private

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::Actors::updateDrowning ( const MWWorld::Ptr ptr,
float  duration,
bool  isKnockedOut,
bool  isPlayer 
)
private

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::Actors::updateEquippedLight ( const MWWorld::Ptr ptr,
float  duration,
bool  mayEquip 
)
private

Automatically equip NPCs torches at night and unequip them at day

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::Actors::updateHeadTracking ( const MWWorld::Ptr actor,
const MWWorld::Ptr targetActor,
MWWorld::Ptr headTrackTarget,
float &  sqrHeadTrackDistance 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::Actors::updateMagicEffects ( const MWWorld::Ptr ptr)

Update magic effects for an actor. Usually done automatically once per frame, but if we're currently paused we may want to do it manually (after equipping permanent enchantment)

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::Actors::write ( ESM::ESMWriter writer,
Loading::Listener listener 
) const

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

PtrActorMap MWMechanics::Actors::mActors
private
std::map<std::string, int> MWMechanics::Actors::mDeathCount
private
float MWMechanics::Actors::mTimerDisposeSummonsCorpses
private

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