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

#include <mechanicsmanagerimp.hpp>

Inheritance diagram for MWMechanics::MechanicsManager:
Collaboration diagram for MWMechanics::MechanicsManager:

Public Member Functions

void buildPlayer ()
 
 MechanicsManager ()
 
virtual void add (const MWWorld::Ptr &ptr)
 Register an object for management. More...
 
virtual void remove (const MWWorld::Ptr &ptr)
 Deregister an object for management. More...
 
virtual void updateCell (const MWWorld::Ptr &old, const MWWorld::Ptr &ptr)
 Moves an object to a new cell. More...
 
virtual void drop (const MWWorld::CellStore *cellStore)
 Deregister all objects in the given cell. More...
 
virtual void watchActor (const MWWorld::Ptr &ptr)
 
virtual void update (float duration, bool paused)
 
virtual void advanceTime (float duration)
 
virtual void setPlayerName (const std::string &name)
 Set player name. More...
 
virtual void setPlayerRace (const std::string &id, bool male, const std::string &head, const std::string &hair)
 Set player race. More...
 
virtual void setPlayerBirthsign (const std::string &id)
 Set player birthsign. More...
 
virtual void setPlayerClass (const std::string &id)
 Set player class to stock class. More...
 
virtual void setPlayerClass (const ESM::Class &class_)
 Set player class to custom class. More...
 
virtual void rest (bool sleep)
 
virtual int getHoursToRest () const
 Calculate how many hours the player needs to rest in order to be fully healed. More...
 
virtual int getBarterOffer (const MWWorld::Ptr &ptr, int basePrice, bool buying)
 This is used by every service to determine the price of objects given the trading skills of the player and NPC. More...
 
virtual int getDerivedDisposition (const MWWorld::Ptr &ptr, bool addTemporaryDispositionChange=true)
 Calculate the diposition of an NPC toward the player. More...
 
virtual int countDeaths (const std::string &id) const
 Return the number of deaths for actors with the given ID. More...
 
virtual void getPersuasionDispositionChange (const MWWorld::Ptr &npc, PersuasionType type, bool &success, float &tempChange, float &permChange)
 Perform a persuasion action on NPC. More...
 
virtual bool awarenessCheck (const MWWorld::Ptr &ptr, const MWWorld::Ptr &observer)
 Check if observer is potentially aware of ptr. Does not do a line of sight check! More...
 
virtual void startCombat (const MWWorld::Ptr &ptr, const MWWorld::Ptr &target)
 Makes ptr fight target. Also shouts a combat taunt. More...
 
virtual bool commitCrime (const MWWorld::Ptr &ptr, const MWWorld::Ptr &victim, OffenseType type, int arg=0, bool victimAware=false)
 
virtual bool actorAttacked (const MWWorld::Ptr &victim, const MWWorld::Ptr &attacker)
 
virtual void actorKilled (const MWWorld::Ptr &victim, const MWWorld::Ptr &attacker)
 
virtual void itemTaken (const MWWorld::Ptr &ptr, const MWWorld::Ptr &item, const MWWorld::Ptr &container, int count)
 
virtual void objectOpened (const MWWorld::Ptr &ptr, const MWWorld::Ptr &item)
 Utility to check if opening (i.e. unlocking) this object is illegal and calling commitCrime if so. More...
 
virtual bool sleepInBed (const MWWorld::Ptr &ptr, const MWWorld::Ptr &bed)
 
virtual void forceStateUpdate (const MWWorld::Ptr &ptr)
 Forces an object to refresh its animation state. More...
 
virtual bool playAnimationGroup (const MWWorld::Ptr &ptr, const std::string &groupName, int mode, int number, bool persist=false)
 
virtual void skipAnimation (const MWWorld::Ptr &ptr)
 
virtual bool checkAnimationPlaying (const MWWorld::Ptr &ptr, const std::string &groupName)
 
virtual void persistAnimationStates ()
 Save the current animation state of managed references to their RefData. More...
 
virtual void updateMagicEffects (const MWWorld::Ptr &ptr)
 
virtual void getObjectsInRange (const osg::Vec3f &position, float radius, std::vector< MWWorld::Ptr > &objects)
 
virtual void getActorsInRange (const osg::Vec3f &position, float radius, std::vector< MWWorld::Ptr > &objects)
 
virtual std::list< MWWorld::PtrgetActorsSidingWith (const MWWorld::Ptr &actor)
 Returns the list of actors which are siding with the given actor in fights. More...
 
virtual std::list< MWWorld::PtrgetActorsFollowing (const MWWorld::Ptr &actor)
 
virtual std::list< intgetActorsFollowingIndices (const MWWorld::Ptr &actor)
 
virtual std::list< MWWorld::PtrgetActorsFighting (const MWWorld::Ptr &actor)
 Returns a list of actors who are fighting the given actor within the fAlarmDistance. More...
 
virtual std::list< MWWorld::PtrgetEnemiesNearby (const MWWorld::Ptr &actor)
 
virtual void getActorsFollowing (const MWWorld::Ptr &actor, std::set< MWWorld::Ptr > &out)
 Recursive version of getActorsFollowing. More...
 
virtual void getActorsSidingWith (const MWWorld::Ptr &actor, std::set< MWWorld::Ptr > &out)
 Recursive version of getActorsSidingWith. More...
 
virtual bool toggleAI ()
 
virtual bool isAIActive ()
 
virtual void playerLoaded ()
 
virtual int countSavedGameRecords () const
 
virtual void write (ESM::ESMWriter &writer, Loading::Listener &listener) const
 
virtual void readRecord (ESM::ESMReader &reader, uint32_t type)
 
virtual void clear ()
 
virtual bool isAggressive (const MWWorld::Ptr &ptr, const MWWorld::Ptr &target)
 
virtual void keepPlayerAlive ()
 Resurrects the player if necessary. More...
 
virtual bool isReadyToBlock (const MWWorld::Ptr &ptr) const
 
virtual void confiscateStolenItems (const MWWorld::Ptr &player, const MWWorld::Ptr &targetContainer)
 
virtual std::vector< std::pair
< std::string, int > > 
getStolenItemOwners (const std::string &itemid)
 
virtual bool isItemStolenFrom (const std::string &itemid, const std::string &ownerid)
 Has the player stolen this item from the given owner? More...
 
virtual bool isAllowedToUse (const MWWorld::Ptr &ptr, const MWWorld::CellRef &cellref, MWWorld::Ptr &victim)
 
virtual void setWerewolf (const MWWorld::Ptr &actor, bool werewolf)
 Turn actor into werewolf or normal form. More...
 
virtual void applyWerewolfAcrobatics (const MWWorld::Ptr &actor)
 
virtual void cleanupSummonedCreature (const MWWorld::Ptr &caster, int creatureActorId)
 
- Public Member Functions inherited from MWBase::MechanicsManager
 MechanicsManager ()
 
virtual ~MechanicsManager ()
 

Private Types

typedef std::pair< std::string,
bool
Owner
 
typedef std::map< Owner, intOwnerMap
 
typedef std::map< std::string,
OwnerMap
StolenItemsMap
 

Private Member Functions

void reportCrime (const MWWorld::Ptr &ptr, const MWWorld::Ptr &victim, OffenseType type, int arg=0)
 

Private Attributes

MWWorld::Ptr mWatched
 
AttributeValue mWatchedAttributes [8]
 
SkillValue mWatchedSkills [27]
 
DynamicStat< float > mWatchedHealth
 
DynamicStat< float > mWatchedMagicka
 
DynamicStat< float > mWatchedFatigue
 
float mWatchedTimeToStartDrowning
 
bool mWatchedStatsEmpty
 
bool mUpdatePlayer
 
bool mClassSelected
 
bool mRaceSelected
 
bool mAI
 is AI active? More...
 
Objects mObjects
 
Actors mActors
 
StolenItemsMap mStolenItems
 

Additional Inherited Members

- Public Types inherited from MWBase::MechanicsManager
enum  OffenseType {
  OT_Theft, OT_Assault, OT_Murder, OT_Trespassing,
  OT_SleepingInOwnedBed, OT_Pickpocket
}
 
enum  PersuasionType {
  PT_Admire, PT_Intimidate, PT_Taunt, PT_Bribe10,
  PT_Bribe100, PT_Bribe1000
}
 

Member Typedef Documentation

typedef std::pair<std::string, bool> MWMechanics::MechanicsManager::Owner
private
typedef std::map<std::string, OwnerMap> MWMechanics::MechanicsManager::StolenItemsMap
private

Constructor & Destructor Documentation

MWMechanics::MechanicsManager::MechanicsManager ( )

Member Function Documentation

bool MWMechanics::MechanicsManager::actorAttacked ( const MWWorld::Ptr victim,
const MWWorld::Ptr attacker 
)
virtual
Returns
false if the attack was considered a "friendly hit" and forgiven

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

void MWMechanics::MechanicsManager::actorKilled ( const MWWorld::Ptr victim,
const MWWorld::Ptr attacker 
)
virtual

Notify that actor was killed, add a murder bounty if applicable

Note
No-op for non-player attackers

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

void MWMechanics::MechanicsManager::add ( const MWWorld::Ptr ptr)
virtual

Register an object for management.

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

void MWMechanics::MechanicsManager::advanceTime ( float  duration)
virtual

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

void MWMechanics::MechanicsManager::applyWerewolfAcrobatics ( const MWWorld::Ptr actor)
virtual

Sets the NPC's Acrobatics skill to match the fWerewolfAcrobatics GMST. It only applies to the current form the NPC is in.

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

bool MWMechanics::MechanicsManager::awarenessCheck ( const MWWorld::Ptr ptr,
const MWWorld::Ptr observer 
)
virtual

Check if observer is potentially aware of ptr. Does not do a line of sight check!

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::MechanicsManager::buildPlayer ( )

build player according to stored class/race/birthsign information. Will default to the values of the ESM::NPC object, if no explicit information is given.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

void MWMechanics::MechanicsManager::cleanupSummonedCreature ( const MWWorld::Ptr caster,
int  creatureActorId 
)
virtual

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

void MWMechanics::MechanicsManager::clear ( )
virtual

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

bool MWMechanics::MechanicsManager::commitCrime ( const MWWorld::Ptr ptr,
const MWWorld::Ptr victim,
OffenseType  type,
int  arg = 0,
bool  victimAware = false 
)
virtual
Note
victim may be empty
Parameters
argDepends on type, e.g. for Theft, the value of the item that was stolen.
victimAwareIs the victim already aware of the crime? If this parameter is false, it will be determined by a line-of-sight and awareness check.
Returns
was the crime seen?

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::MechanicsManager::confiscateStolenItems ( const MWWorld::Ptr player,
const MWWorld::Ptr targetContainer 
)
virtual

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

int MWMechanics::MechanicsManager::countDeaths ( const std::string &  id) const
virtual

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

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

int MWMechanics::MechanicsManager::countSavedGameRecords ( ) const
virtual
void MWMechanics::MechanicsManager::drop ( const MWWorld::CellStore cellStore)
virtual

Deregister all objects in the given cell.

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

void MWMechanics::MechanicsManager::forceStateUpdate ( const MWWorld::Ptr ptr)
virtual

Forces an object to refresh its animation state.

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

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

Returns a list of actors who are fighting the given actor within the fAlarmDistance.

ie AiCombat is active and the target is the actor

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

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

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

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

Recursive version of getActorsFollowing.

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

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

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

void MWMechanics::MechanicsManager::getActorsInRange ( const osg::Vec3f &  position,
float  radius,
std::vector< MWWorld::Ptr > &  objects 
)
virtual

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

Here is the caller graph for this function:

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

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

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Recursive version of getActorsSidingWith.

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

int MWMechanics::MechanicsManager::getBarterOffer ( const MWWorld::Ptr ptr,
int  basePrice,
bool  buying 
)
virtual

This is used by every service to determine the price of objects given the trading skills of the player and NPC.

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

int MWMechanics::MechanicsManager::getDerivedDisposition ( const MWWorld::Ptr ptr,
bool  addTemporaryDispositionChange = true 
)
virtual

Calculate the diposition of an NPC toward the player.

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

int MWMechanics::MechanicsManager::getHoursToRest ( ) const
virtual

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

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

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

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

void MWMechanics::MechanicsManager::getPersuasionDispositionChange ( const MWWorld::Ptr npc,
PersuasionType  type,
bool success,
float &  tempChange,
float &  permChange 
)
virtual

Perform a persuasion action on NPC.

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

std::vector< std::pair< std::string, int > > MWMechanics::MechanicsManager::getStolenItemOwners ( const std::string &  itemid)
virtual

List the owners that the player has stolen this item from (the owner can be an NPC or a faction). <Owner, item count>

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

bool MWMechanics::MechanicsManager::isAggressive ( const MWWorld::Ptr ptr,
const MWWorld::Ptr target 
)
virtual

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

Here is the caller graph for this function:

bool MWMechanics::MechanicsManager::isAIActive ( )
virtual
bool MWMechanics::MechanicsManager::isAllowedToUse ( const MWWorld::Ptr ptr,
const MWWorld::CellRef cellref,
MWWorld::Ptr victim 
)
virtual
Returns
is ptr allowed to take/use cellref or is it a crime?

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

Here is the caller graph for this function:

bool MWMechanics::MechanicsManager::isItemStolenFrom ( const std::string &  itemid,
const std::string &  ownerid 
)
virtual

Has the player stolen this item from the given owner?

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

bool MWMechanics::MechanicsManager::isReadyToBlock ( const MWWorld::Ptr ptr) const
virtual

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::MechanicsManager::itemTaken ( const MWWorld::Ptr ptr,
const MWWorld::Ptr item,
const MWWorld::Ptr container,
int  count 
)
virtual

Utility to check if taking this item is illegal and calling commitCrime if so

Parameters
containerThe container the item is in; may be empty for an item in the world

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

void MWMechanics::MechanicsManager::keepPlayerAlive ( )
virtual

Resurrects the player if necessary.

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

void MWMechanics::MechanicsManager::objectOpened ( const MWWorld::Ptr ptr,
const MWWorld::Ptr item 
)
virtual

Utility to check if opening (i.e. unlocking) this object is illegal and calling commitCrime if so.

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

void MWMechanics::MechanicsManager::persistAnimationStates ( )
virtual

Save the current animation state of managed references to their RefData.

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

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

Attempt to play an animation group

Returns
Success or error

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

void MWMechanics::MechanicsManager::playerLoaded ( )
virtual
void MWMechanics::MechanicsManager::readRecord ( ESM::ESMReader reader,
uint32_t  type 
)
virtual

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

void MWMechanics::MechanicsManager::remove ( const MWWorld::Ptr ptr)
virtual

Deregister an object for management.

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

void MWMechanics::MechanicsManager::reportCrime ( const MWWorld::Ptr ptr,
const MWWorld::Ptr victim,
OffenseType  type,
int  arg = 0 
)
private

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::MechanicsManager::rest ( bool  sleep)
virtual

If the player is sleeping or waiting, this should be called every hour.

Parameters
sleepis the player sleeping or waiting?

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

void MWMechanics::MechanicsManager::setPlayerBirthsign ( const std::string &  id)
virtual

Set player birthsign.

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

void MWMechanics::MechanicsManager::setPlayerClass ( const std::string &  id)
virtual

Set player class to stock class.

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

void MWMechanics::MechanicsManager::setPlayerClass ( const ESM::Class class_)
virtual

Set player class to custom class.

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

void MWMechanics::MechanicsManager::setPlayerName ( const std::string &  name)
virtual

Set player name.

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

void MWMechanics::MechanicsManager::setPlayerRace ( const std::string &  id,
bool  male,
const std::string &  head,
const std::string &  hair 
)
virtual

Set player race.

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

void MWMechanics::MechanicsManager::setWerewolf ( const MWWorld::Ptr actor,
bool  werewolf 
)
virtual

Turn actor into werewolf or normal form.

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

void MWMechanics::MechanicsManager::skipAnimation ( const MWWorld::Ptr ptr)
virtual

Skip the animation for the given MW-reference for one frame. Calls to this function for references that are currently not in the scene should be ignored.

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

bool MWMechanics::MechanicsManager::sleepInBed ( const MWWorld::Ptr ptr,
const MWWorld::Ptr bed 
)
virtual

Attempt sleeping in a bed. If this is illegal, call commitCrime.

Returns
was it illegal, and someone saw you doing it? Also returns fail when enemies are nearby

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

void MWMechanics::MechanicsManager::startCombat ( const MWWorld::Ptr ptr,
const MWWorld::Ptr target 
)
virtual

Makes ptr fight target. Also shouts a combat taunt.

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

Here is the caller graph for this function:

bool MWMechanics::MechanicsManager::toggleAI ( )
virtual
void MWMechanics::MechanicsManager::update ( float  duration,
bool  paused 
)
virtual

Update objects

Parameters
pausedIn game type does not currently advance (this usually means some GUI component is up).

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

void MWMechanics::MechanicsManager::updateCell ( const MWWorld::Ptr old,
const MWWorld::Ptr ptr 
)
virtual

Moves an object to a new cell.

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

void MWMechanics::MechanicsManager::updateMagicEffects ( const MWWorld::Ptr ptr)
virtual

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)

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

void MWMechanics::MechanicsManager::watchActor ( const MWWorld::Ptr ptr)
virtual

On each update look for changes in a previously registered actor and update the GUI accordingly.

Implements MWBase::MechanicsManager.

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

Implements MWBase::MechanicsManager.

Here is the call graph for this function:

Member Data Documentation

Actors MWMechanics::MechanicsManager::mActors
private
bool MWMechanics::MechanicsManager::mAI
private

is AI active?

bool MWMechanics::MechanicsManager::mClassSelected
private
Objects MWMechanics::MechanicsManager::mObjects
private
bool MWMechanics::MechanicsManager::mRaceSelected
private
StolenItemsMap MWMechanics::MechanicsManager::mStolenItems
private
bool MWMechanics::MechanicsManager::mUpdatePlayer
private
MWWorld::Ptr MWMechanics::MechanicsManager::mWatched
private
AttributeValue MWMechanics::MechanicsManager::mWatchedAttributes[8]
private
DynamicStat<float> MWMechanics::MechanicsManager::mWatchedFatigue
private
DynamicStat<float> MWMechanics::MechanicsManager::mWatchedHealth
private
DynamicStat<float> MWMechanics::MechanicsManager::mWatchedMagicka
private
SkillValue MWMechanics::MechanicsManager::mWatchedSkills[27]
private
bool MWMechanics::MechanicsManager::mWatchedStatsEmpty
private
float MWMechanics::MechanicsManager::mWatchedTimeToStartDrowning
private

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