OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
mechanicsmanagerimp.hpp
Go to the documentation of this file.
1 #ifndef GAME_MWMECHANICS_MECHANICSMANAGERIMP_H
2 #define GAME_MWMECHANICS_MECHANICSMANAGERIMP_H
3 
4 #include "../mwbase/mechanicsmanager.hpp"
5 
6 #include "../mwworld/ptr.hpp"
7 
8 #include "creaturestats.hpp"
9 #include "npcstats.hpp"
10 #include "objects.hpp"
11 #include "actors.hpp"
12 
13 namespace MWWorld
14 {
15  class CellStore;
16 }
17 
18 namespace MWMechanics
19 {
21  {
23 
26 
30 
32 
37  bool mAI;
38 
41 
42  typedef std::pair<std::string, bool> Owner; // < Owner id, bool isFaction >
43  typedef std::map<Owner, int> OwnerMap; // < Owner, number of stolen items with this id from this owner >
44  typedef std::map<std::string, OwnerMap> StolenItemsMap;
46 
47  public:
48 
49  void buildPlayer();
52 
54 
55  virtual void add (const MWWorld::Ptr& ptr);
57 
58  virtual void remove (const MWWorld::Ptr& ptr);
60 
61  virtual void updateCell(const MWWorld::Ptr &old, const MWWorld::Ptr &ptr);
63 
64  virtual void drop(const MWWorld::CellStore *cellStore);
66 
67  virtual void watchActor(const MWWorld::Ptr& ptr);
70 
71  virtual void update (float duration, bool paused);
76 
77  virtual void advanceTime (float duration);
78 
79  virtual void setPlayerName (const std::string& name);
81 
82  virtual void setPlayerRace (const std::string& id, bool male, const std::string &head, const std::string &hair);
84 
85  virtual void setPlayerBirthsign (const std::string& id);
87 
88  virtual void setPlayerClass (const std::string& id);
90 
91  virtual void setPlayerClass (const ESM::Class& class_);
93 
94  virtual void rest(bool sleep);
97 
98  virtual int getHoursToRest() const;
100 
101  virtual int getBarterOffer(const MWWorld::Ptr& ptr,int basePrice, bool buying);
103 
104  virtual int getDerivedDisposition(const MWWorld::Ptr& ptr, bool addTemporaryDispositionChange = true);
106 
107  virtual int countDeaths (const std::string& id) const;
109 
110  virtual void getPersuasionDispositionChange (const MWWorld::Ptr& npc, PersuasionType type, bool& success, float& tempChange, float& permChange);
112 
114  virtual bool awarenessCheck (const MWWorld::Ptr& ptr, const MWWorld::Ptr& observer);
115 
117  virtual void startCombat (const MWWorld::Ptr& ptr, const MWWorld::Ptr& target);
118 
126  virtual bool commitCrime (const MWWorld::Ptr& ptr, const MWWorld::Ptr& victim,
127  OffenseType type, int arg=0, bool victimAware=false);
129  virtual bool actorAttacked (const MWWorld::Ptr& victim, const MWWorld::Ptr& attacker);
130 
133  virtual void actorKilled (const MWWorld::Ptr& victim, const MWWorld::Ptr& attacker);
134 
137  virtual void itemTaken (const MWWorld::Ptr& ptr, const MWWorld::Ptr& item, const MWWorld::Ptr& container,
138  int count);
140  virtual void objectOpened (const MWWorld::Ptr& ptr, const MWWorld::Ptr& item);
143  virtual bool sleepInBed (const MWWorld::Ptr& ptr, const MWWorld::Ptr& bed);
144 
145  virtual void forceStateUpdate(const MWWorld::Ptr &ptr);
146 
149  virtual bool playAnimationGroup(const MWWorld::Ptr& ptr, const std::string& groupName, int mode, int number, bool persist=false);
150  virtual void skipAnimation(const MWWorld::Ptr& ptr);
151  virtual bool checkAnimationPlaying(const MWWorld::Ptr& ptr, const std::string &groupName);
152  virtual void persistAnimationStates();
153 
156  virtual void updateMagicEffects (const MWWorld::Ptr& ptr);
157 
158  virtual void getObjectsInRange (const osg::Vec3f& position, float radius, std::vector<MWWorld::Ptr>& objects);
159  virtual void getActorsInRange(const osg::Vec3f &position, float radius, std::vector<MWWorld::Ptr> &objects);
160 
161  virtual std::list<MWWorld::Ptr> getActorsSidingWith(const MWWorld::Ptr& actor);
162  virtual std::list<MWWorld::Ptr> getActorsFollowing(const MWWorld::Ptr& actor);
163  virtual std::list<int> getActorsFollowingIndices(const MWWorld::Ptr& actor);
164 
165  virtual std::list<MWWorld::Ptr> getActorsFighting(const MWWorld::Ptr& actor);
166  virtual std::list<MWWorld::Ptr> getEnemiesNearby(const MWWorld::Ptr& actor);
167 
169  virtual void getActorsFollowing(const MWWorld::Ptr& actor, std::set<MWWorld::Ptr>& out);
171  virtual void getActorsSidingWith(const MWWorld::Ptr& actor, std::set<MWWorld::Ptr>& out);
172 
173  virtual bool toggleAI();
174  virtual bool isAIActive();
175 
176  virtual void playerLoaded();
177 
178  virtual int countSavedGameRecords() const;
179 
180  virtual void write (ESM::ESMWriter& writer, Loading::Listener& listener) const;
181 
182  virtual void readRecord (ESM::ESMReader& reader, uint32_t type);
183 
184  virtual void clear();
185 
186  virtual bool isAggressive (const MWWorld::Ptr& ptr, const MWWorld::Ptr& target);
187 
188  virtual void keepPlayerAlive();
189 
190  virtual bool isReadyToBlock (const MWWorld::Ptr& ptr) const;
191 
192  virtual void confiscateStolenItems (const MWWorld::Ptr& player, const MWWorld::Ptr& targetContainer);
193 
196  virtual std::vector<std::pair<std::string, int> > getStolenItemOwners(const std::string& itemid);
197 
199  virtual bool isItemStolenFrom(const std::string& itemid, const std::string& ownerid);
200 
202  virtual bool isAllowedToUse (const MWWorld::Ptr& ptr, const MWWorld::CellRef& cellref, MWWorld::Ptr& victim);
203 
204  virtual void setWerewolf(const MWWorld::Ptr& actor, bool werewolf);
205  virtual void applyWerewolfAcrobatics(const MWWorld::Ptr& actor);
206 
207  virtual void cleanupSummonedCreature(const MWWorld::Ptr& caster, int creatureActorId);
208 
209  private:
210  void reportCrime (const MWWorld::Ptr& ptr, const MWWorld::Ptr& victim,
211  OffenseType type, int arg=0);
212 
213 
214  };
215 }
216 
217 #endif
DynamicStat< float > mWatchedHealth
Definition: mechanicsmanagerimp.hpp:27
virtual bool isReadyToBlock(const MWWorld::Ptr &ptr) const
Definition: mechanicsmanagerimp.cpp:1504
virtual int getDerivedDisposition(const MWWorld::Ptr &ptr, bool addTemporaryDispositionChange=true)
Calculate the diposition of an NPC toward the player.
Definition: mechanicsmanagerimp.cpp:504
DynamicStat< float > mWatchedMagicka
Definition: mechanicsmanagerimp.hpp:28
Encapsulated variant of ESM::CellRef with change tracking.
Definition: cellref.hpp:15
Definition: stat.hpp:108
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 playe...
Definition: mechanicsmanagerimp.cpp:583
virtual void setPlayerName(const std::string &name)
Set player name.
Definition: mechanicsmanagerimp.cpp:433
virtual std::list< MWWorld::Ptr > getEnemiesNearby(const MWWorld::Ptr &actor)
Definition: mechanicsmanagerimp.cpp:1424
virtual bool toggleAI()
Definition: mechanicsmanagerimp.cpp:801
bool mUpdatePlayer
Definition: mechanicsmanagerimp.hpp:34
Definition: esmreader.hpp:21
Definition: actors.hpp:25
PersuasionType
Definition: mechanicsmanager.hpp:148
virtual bool isAllowedToUse(const MWWorld::Ptr &ptr, const MWWorld::CellRef &cellref, MWWorld::Ptr &victim)
Definition: mechanicsmanagerimp.cpp:820
virtual bool playAnimationGroup(const MWWorld::Ptr &ptr, const std::string &groupName, int mode, int number, bool persist=false)
Definition: mechanicsmanagerimp.cpp:768
StolenItemsMap mStolenItems
Definition: mechanicsmanagerimp.hpp:45
virtual void add(const MWWorld::Ptr &ptr)
Register an object for management.
Definition: mechanicsmanagerimp.cpp:242
virtual void drop(const MWWorld::CellStore *cellStore)
Deregister all objects in the given cell.
Definition: mechanicsmanagerimp.cpp:270
virtual void skipAnimation(const MWWorld::Ptr &ptr)
Definition: mechanicsmanagerimp.cpp:775
virtual void advanceTime(float duration)
Definition: mechanicsmanagerimp.cpp:282
virtual void actorKilled(const MWWorld::Ptr &victim, const MWWorld::Ptr &attacker)
Definition: mechanicsmanagerimp.cpp:1270
virtual void setPlayerBirthsign(const std::string &id)
Set player birthsign.
Definition: mechanicsmanagerimp.cpp:465
virtual bool sleepInBed(const MWWorld::Ptr &ptr, const MWWorld::Ptr &bed)
Definition: mechanicsmanagerimp.cpp:849
Definition: loadinglistener.hpp:8
virtual void readRecord(ESM::ESMReader &reader, uint32_t type)
Definition: mechanicsmanagerimp.cpp:1453
virtual std::vector< std::pair< std::string, int > > getStolenItemOwners(const std::string &itemid)
Definition: mechanicsmanagerimp.cpp:883
Definition: objects.hpp:17
virtual int getHoursToRest() const
Calculate how many hours the player needs to rest in order to be fully healed.
Definition: mechanicsmanagerimp.cpp:428
virtual bool isAggressive(const MWWorld::Ptr &ptr, const MWWorld::Ptr &target)
Definition: mechanicsmanagerimp.cpp:1473
virtual void clear()
Definition: mechanicsmanagerimp.cpp:1465
virtual void confiscateStolenItems(const MWWorld::Ptr &player, const MWWorld::Ptr &targetContainer)
Definition: mechanicsmanagerimp.cpp:908
Definition: esmwriter.hpp:17
virtual void itemTaken(const MWWorld::Ptr &ptr, const MWWorld::Ptr &item, const MWWorld::Ptr &container, int count)
Definition: mechanicsmanagerimp.cpp:938
virtual void getPersuasionDispositionChange(const MWWorld::Ptr &npc, PersuasionType type, bool &success, float &tempChange, float &permChange)
Perform a persuasion action on NPC.
Definition: mechanicsmanagerimp.cpp:625
bool mClassSelected
Definition: mechanicsmanagerimp.hpp:35
void reportCrime(const MWWorld::Ptr &ptr, const MWWorld::Ptr &victim, OffenseType type, int arg=0)
Definition: mechanicsmanagerimp.cpp:1047
virtual std::list< MWWorld::Ptr > getActorsSidingWith(const MWWorld::Ptr &actor)
Returns the list of actors which are siding with the given actor in fights.
Definition: mechanicsmanagerimp.cpp:1405
virtual void rest(bool sleep)
Definition: mechanicsmanagerimp.cpp:423
virtual int countDeaths(const std::string &id) const
Return the number of deaths for actors with the given ID.
Definition: mechanicsmanagerimp.cpp:620
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! ...
Definition: mechanicsmanagerimp.cpp:1291
virtual void startCombat(const MWWorld::Ptr &ptr, const MWWorld::Ptr &target)
Makes ptr fight target. Also shouts a combat taunt.
Definition: mechanicsmanagerimp.cpp:1364
std::map< Owner, int > OwnerMap
Definition: mechanicsmanagerimp.hpp:43
bool mRaceSelected
Definition: mechanicsmanagerimp.hpp:36
bool mAI
is AI active?
Definition: mechanicsmanagerimp.hpp:37
virtual void updateMagicEffects(const MWWorld::Ptr &ptr)
Definition: mechanicsmanagerimp.cpp:796
DynamicStat< float > mWatchedFatigue
Definition: mechanicsmanagerimp.hpp:29
virtual bool isItemStolenFrom(const std::string &itemid, const std::string &ownerid)
Has the player stolen this item from the given owner?
Definition: mechanicsmanagerimp.cpp:898
virtual void updateCell(const MWWorld::Ptr &old, const MWWorld::Ptr &ptr)
Moves an object to a new cell.
Definition: mechanicsmanagerimp.cpp:258
virtual bool checkAnimationPlaying(const MWWorld::Ptr &ptr, const std::string &groupName)
Definition: mechanicsmanagerimp.cpp:782
Mutable state of a cell.
Definition: cellstore.hpp:53
virtual void watchActor(const MWWorld::Ptr &ptr)
Definition: mechanicsmanagerimp.cpp:277
bool mWatchedStatsEmpty
Definition: mechanicsmanagerimp.hpp:33
virtual int countSavedGameRecords() const
Definition: mechanicsmanagerimp.cpp:1436
virtual void playerLoaded()
Definition: mechanicsmanagerimp.cpp:812
virtual bool actorAttacked(const MWWorld::Ptr &victim, const MWWorld::Ptr &attacker)
Definition: mechanicsmanagerimp.cpp:1223
MechanicsManager()
Definition: mechanicsmanagerimp.cpp:235
virtual void write(ESM::ESMWriter &writer, Loading::Listener &listener) const
Definition: mechanicsmanagerimp.cpp:1442
Actors mActors
Definition: mechanicsmanagerimp.hpp:40
virtual std::list< MWWorld::Ptr > getActorsFollowing(const MWWorld::Ptr &actor)
Definition: mechanicsmanagerimp.cpp:1410
virtual void update(float duration, bool paused)
Definition: mechanicsmanagerimp.cpp:290
virtual void setPlayerRace(const std::string &id, bool male, const std::string &head, const std::string &hair)
Set player race.
Definition: mechanicsmanagerimp.cpp:446
Definition: mechanicsmanagerimp.hpp:20
virtual bool commitCrime(const MWWorld::Ptr &ptr, const MWWorld::Ptr &victim, OffenseType type, int arg=0, bool victimAware=false)
Definition: mechanicsmanagerimp.cpp:981
virtual void keepPlayerAlive()
Resurrects the player if necessary.
Definition: mechanicsmanagerimp.cpp:1496
virtual void persistAnimationStates()
Save the current animation state of managed references to their RefData.
Definition: mechanicsmanagerimp.cpp:790
virtual void setWerewolf(const MWWorld::Ptr &actor, bool werewolf)
Turn actor into werewolf or normal form.
Definition: mechanicsmanagerimp.cpp:1509
Objects mObjects
Definition: mechanicsmanagerimp.hpp:39
Definition: loadclas.hpp:18
Definition: stat.hpp:137
virtual std::list< int > getActorsFollowingIndices(const MWWorld::Ptr &actor)
Definition: mechanicsmanagerimp.cpp:1415
Interface for game mechanics manager (implemented in MWMechanics)
Definition: mechanicsmanager.hpp:38
virtual void applyWerewolfAcrobatics(const MWWorld::Ptr &actor)
Definition: mechanicsmanagerimp.cpp:1604
void buildPlayer()
Definition: mechanicsmanagerimp.cpp:69
virtual bool isAIActive()
Definition: mechanicsmanagerimp.cpp:807
Pointer to a LiveCellRef.
Definition: ptr.hpp:19
virtual void forceStateUpdate(const MWWorld::Ptr &ptr)
Forces an object to refresh its animation state.
Definition: mechanicsmanagerimp.cpp:762
virtual void getActorsInRange(const osg::Vec3f &position, float radius, std::vector< MWWorld::Ptr > &objects)
Definition: mechanicsmanagerimp.cpp:1400
std::map< std::string, OwnerMap > StolenItemsMap
Definition: mechanicsmanagerimp.hpp:44
virtual void cleanupSummonedCreature(const MWWorld::Ptr &caster, int creatureActorId)
Definition: mechanicsmanagerimp.cpp:1612
virtual void setPlayerClass(const std::string &id)
Set player class to stock class.
Definition: mechanicsmanagerimp.cpp:472
MWWorld::Ptr mWatched
Definition: mechanicsmanagerimp.hpp:22
SkillValue mWatchedSkills[27]
Definition: mechanicsmanagerimp.hpp:25
virtual std::list< MWWorld::Ptr > getActorsFighting(const MWWorld::Ptr &actor)
Returns a list of actors who are fighting the given actor within the fAlarmDistance.
Definition: mechanicsmanagerimp.cpp:1420
virtual void getObjectsInRange(const osg::Vec3f &position, float radius, std::vector< MWWorld::Ptr > &objects)
Definition: mechanicsmanagerimp.cpp:1394
OffenseType
Definition: mechanicsmanager.hpp:113
std::pair< std::string, bool > Owner
Definition: mechanicsmanagerimp.hpp:42
float mWatchedTimeToStartDrowning
Definition: mechanicsmanagerimp.hpp:31
AttributeValue mWatchedAttributes[8]
Definition: mechanicsmanagerimp.hpp:24
const char * name
Definition: crashcatcher.cpp:59
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...
Definition: mechanicsmanagerimp.cpp:875