OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
actors.hpp
Go to the documentation of this file.
1 #ifndef GAME_MWMECHANICS_ACTORS_H
2 #define GAME_MWMECHANICS_ACTORS_H
3 
4 #include <set>
5 #include <vector>
6 #include <string>
7 #include <map>
8 #include <list>
9 
10 #include "../mwbase/world.hpp"
11 
12 #include "movement.hpp"
13 
14 namespace MWWorld
15 {
16  class Ptr;
17  class CellStore;
18 }
19 
20 namespace MWMechanics
21 {
22  class Actor;
23  class CreatureStats;
24 
25  class Actors
26  {
27  std::map<std::string, int> mDeathCount;
28 
29  void updateNpc(const MWWorld::Ptr &ptr, float duration);
30 
31  void adjustMagicEffects (const MWWorld::Ptr& creature);
32 
33  void calculateDynamicStats (const MWWorld::Ptr& ptr);
34 
35  void calculateCreatureStatModifiers (const MWWorld::Ptr& ptr, float duration);
36  void calculateNpcStatModifiers (const MWWorld::Ptr& ptr, float duration);
37 
38  void calculateRestoration (const MWWorld::Ptr& ptr, float duration);
39 
40  void updateDrowning (const MWWorld::Ptr& ptr, float duration);
41 
42  void updateEquippedLight (const MWWorld::Ptr& ptr, float duration);
43 
44  void updateCrimePersuit (const MWWorld::Ptr& ptr, float duration);
45 
46  void killDeadActors ();
47 
48  void purgeSpellEffects (int casterActorId);
49 
50  public:
51 
52  Actors();
53  ~Actors();
54 
55  typedef std::map<MWWorld::Ptr,Actor*> PtrActorMap;
56 
57  PtrActorMap::const_iterator begin() { return mActors.begin(); }
58  PtrActorMap::const_iterator end() { return mActors.end(); }
59 
62  void updateMagicEffects (const MWWorld::Ptr& ptr);
63 
64  void addActor (const MWWorld::Ptr& ptr, bool updateImmediately=false);
68 
69  void removeActor (const MWWorld::Ptr& ptr);
73 
74  void updateActor(const MWWorld::Ptr &old, const MWWorld::Ptr& ptr);
76 
77  void dropActors (const MWWorld::CellStore *cellStore, const MWWorld::Ptr& ignore);
79 
80  void update (float duration, bool paused);
82 
83  void updateActor (const MWWorld::Ptr& ptr, float duration);
86 
91  void engageCombat(const MWWorld::Ptr& actor1, const MWWorld::Ptr& actor2, bool againstPlayer);
92 
93  void updateHeadTracking(const MWWorld::Ptr& actor, const MWWorld::Ptr& targetActor,
94  MWWorld::Ptr& headTrackTarget, float& sqrHeadTrackDistance);
95 
96  void rest(bool sleep);
98 
99  void restoreDynamicStats(const MWWorld::Ptr& actor, bool sleep);
100 
101  int getHoursToRest(const MWWorld::Ptr& ptr) const;
103 
104  void fastForwardAi();
106 
107  int countDeaths (const std::string& id) const;
109 
110  void forceStateUpdate(const MWWorld::Ptr &ptr);
111 
112  bool playAnimationGroup(const MWWorld::Ptr& ptr, const std::string& groupName, int mode, int number, bool persist=false);
113  void skipAnimation(const MWWorld::Ptr& ptr);
114  bool checkAnimationPlaying(const MWWorld::Ptr& ptr, const std::string& groupName);
115  void persistAnimationStates();
116 
117  void getObjectsInRange(const osg::Vec3f& position, float radius, std::vector<MWWorld::Ptr>& out);
118 
119  void cleanupSummonedCreature (CreatureStats& casterStats, int creatureActorId);
120 
122 
123  std::list<MWWorld::Ptr> getActorsSidingWith(const MWWorld::Ptr& actor);
124  std::list<MWWorld::Ptr> getActorsFollowing(const MWWorld::Ptr& actor);
125 
127  void getActorsFollowing(const MWWorld::Ptr &actor, std::set<MWWorld::Ptr>& out);
129  void getActorsSidingWith(const MWWorld::Ptr &actor, std::set<MWWorld::Ptr>& out);
130 
132  std::list<int> getActorsFollowingIndices(const MWWorld::Ptr& actor);
133 
135 
136  std::list<MWWorld::Ptr> getActorsFighting(const MWWorld::Ptr& actor);
137 
139  std::list<MWWorld::Ptr> getEnemiesNearby(const MWWorld::Ptr& actor);
140 
141  void write (ESM::ESMWriter& writer, Loading::Listener& listener) const;
142 
143  void readRecord (ESM::ESMReader& reader, uint32_t type);
144 
145  void clear(); // Clear death counter
146 
147  bool isReadyToBlock(const MWWorld::Ptr& ptr) const;
148 
149  private:
151 
152  };
153 }
154 
155 #endif
void calculateCreatureStatModifiers(const MWWorld::Ptr &ptr, float duration)
Definition: actors.cpp:531
std::list< MWWorld::Ptr > getActorsFighting(const MWWorld::Ptr &actor)
Returns the list of actors which are fighting the given actor.
Definition: actors.cpp:1540
void restoreDynamicStats(const MWWorld::Ptr &actor, bool sleep)
Definition: actors.cpp:444
void getObjectsInRange(const osg::Vec3f &position, float radius, std::vector< MWWorld::Ptr > &out)
Definition: actors.cpp:1442
std::list< MWWorld::Ptr > getActorsFollowing(const MWWorld::Ptr &actor)
Definition: actors.cpp:1473
Definition: esmreader.hpp:21
void readRecord(ESM::ESMReader &reader, uint32_t type)
Definition: actors.cpp:1589
void skipAnimation(const MWWorld::Ptr &ptr)
Definition: actors.cpp:1421
void forceStateUpdate(const MWWorld::Ptr &ptr)
Definition: actors.cpp:1401
Definition: actors.hpp:25
Common creature stats.
Definition: creaturestats.hpp:25
void updateCrimePersuit(const MWWorld::Ptr &ptr, float duration)
Definition: actors.cpp:902
std::map< MWWorld::Ptr, Actor * > PtrActorMap
Definition: actors.hpp:55
PtrActorMap::const_iterator end()
Definition: actors.hpp:58
void fastForwardAi()
Simulate the passing of time.
Definition: actors.cpp:1632
void adjustMagicEffects(const MWWorld::Ptr &creature)
Definition: actors.cpp:402
Definition: loadinglistener.hpp:8
void updateHeadTracking(const MWWorld::Ptr &actor, const MWWorld::Ptr &targetActor, MWWorld::Ptr &headTrackTarget, float &sqrHeadTrackDistance)
Definition: actors.cpp:239
Definition: esmwriter.hpp:17
bool playAnimationGroup(const MWWorld::Ptr &ptr, const std::string &groupName, int mode, int number, bool persist=false)
Definition: actors.cpp:1408
bool isReadyToBlock(const MWWorld::Ptr &ptr) const
Definition: actors.cpp:1623
void removeActor(const MWWorld::Ptr &ptr)
Definition: actors.cpp:977
void clear()
Definition: actors.cpp:1603
PtrActorMap::const_iterator begin()
Definition: actors.hpp:57
int countDeaths(const std::string &id) const
Return the number of deaths for actors with the given ID.
Definition: actors.cpp:1393
void addActor(const MWWorld::Ptr &ptr, bool updateImmediately=false)
Definition: actors.cpp:965
~Actors()
Definition: actors.cpp:960
void persistAnimationStates()
Definition: actors.cpp:1436
Mutable state of a cell.
Definition: cellstore.hpp:53
PtrActorMap mActors
Definition: actors.hpp:150
void rest(bool sleep)
Update actors while the player is waiting or sleeping. This should be called every hour...
Definition: actors.cpp:1347
void calculateRestoration(const MWWorld::Ptr &ptr, float duration)
Definition: actors.cpp:485
int getHoursToRest(const MWWorld::Ptr &ptr) const
Calculate how many hours the given actor needs to rest in order to be fully healed.
Definition: actors.cpp:1375
void updateActor(const MWWorld::Ptr &old, const MWWorld::Ptr &ptr)
Updates an actor with a new Ptr.
Definition: actors.cpp:987
void calculateDynamicStats(const MWWorld::Ptr &ptr)
Definition: actors.cpp:421
void write(ESM::ESMWriter &writer, Loading::Listener &listener) const
Definition: actors.cpp:1578
void updateNpc(const MWWorld::Ptr &ptr, float duration)
Definition: actors.cpp:395
void update(float duration, bool paused)
Update actor stats and store desired velocity vectors in movement.
Definition: actors.cpp:1015
void calculateNpcStatModifiers(const MWWorld::Ptr &ptr, float duration)
Definition: actors.cpp:743
std::list< MWWorld::Ptr > getActorsSidingWith(const MWWorld::Ptr &actor)
Returns the list of actors which are siding with the given actor in fights.
Definition: actors.cpp:1451
std::list< MWWorld::Ptr > getEnemiesNearby(const MWWorld::Ptr &actor)
Unlike getActorsFighting, also returns actors that would fight the given actor if they saw him...
Definition: actors.cpp:1557
Pointer to a LiveCellRef.
Definition: ptr.hpp:19
void updateMagicEffects(const MWWorld::Ptr &ptr)
Definition: actors.cpp:1615
void engageCombat(const MWWorld::Ptr &actor1, const MWWorld::Ptr &actor2, bool againstPlayer)
Definition: actors.cpp:281
void updateEquippedLight(const MWWorld::Ptr &ptr, float duration)
Definition: actors.cpp:805
Actors()
Definition: actors.cpp:958
void dropActors(const MWWorld::CellStore *cellStore, const MWWorld::Ptr &ignore)
Deregister all actors (except for ignore) in the given cell.
Definition: actors.cpp:1000
std::list< int > getActorsFollowingIndices(const MWWorld::Ptr &actor)
Get the list of AiFollow::mFollowIndex for all actors following this target.
Definition: actors.cpp:1509
bool checkAnimationPlaying(const MWWorld::Ptr &ptr, const std::string &groupName)
Definition: actors.cpp:1428
void killDeadActors()
Definition: actors.cpp:1243
std::map< std::string, int > mDeathCount
Definition: actors.hpp:27
void purgeSpellEffects(int casterActorId)
Definition: actors.cpp:1338
void updateDrowning(const MWWorld::Ptr &ptr, float duration)
Definition: actors.cpp:758
void cleanupSummonedCreature(CreatureStats &casterStats, int creatureActorId)
Definition: actors.cpp:1314