OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
character.hpp
Go to the documentation of this file.
1 #ifndef GAME_MWMECHANICS_CHARACTER_HPP
2 #define GAME_MWMECHANICS_CHARACTER_HPP
3 
4 #include <deque>
5 
7 
8 #include "../mwworld/ptr.hpp"
9 
10 #include "../mwrender/animation.hpp"
11 
12 namespace MWWorld
13 {
14  class ContainerStoreIterator;
15  class InventoryStore;
16 }
17 
18 namespace MWRender
19 {
20  class Animation;
21 }
22 
23 namespace MWMechanics
24 {
25 
26 struct Movement;
27 class CreatureStats;
28 
29 enum Priority {
42 
44 
46 };
47 
50 
63 
68 
73 
78 
83 
88 
91 
93 
102 
107 };
108 
111 
120 
122 };
123 
135 };
136 
141 };
142 
143 struct WeaponInfo;
144 
146 {
149 
151  {
152  std::string mGroup;
153  size_t mLoopCount;
154  bool mPersist;
155  };
156  typedef std::deque<AnimationQueueEntry> AnimationQueue;
158 
160  std::string mCurrentIdle;
161 
163  std::string mCurrentMovement;
168 
170  std::string mCurrentDeath;
172 
174  std::string mCurrentHit;
175 
177 
179  std::string mCurrentJump;
180 
182  std::string mCurrentWeapon;
183 
185 
186  bool mSkipAnim;
187 
188  // counted for skill increase
191 
193 
194  float mTurnAnimationThreshold; // how long to continue playing turning animation after actor stopped turning
195 
196  std::string mAttackType; // slash, chop or thrust
197 
199 
201 
202  void refreshCurrentAnims(CharacterState idle, CharacterState movement, JumpingState jump, bool force=false);
203  void refreshHitRecoilAnims();
204  void refreshJumpAnims(const WeaponInfo* weap, JumpingState jump, bool force=false);
205  void refreshMovementAnims(const WeaponInfo* weap, CharacterState movement, bool force=false);
206  void refreshIdleAnims(const WeaponInfo* weap, CharacterState idle, bool force=false);
207 
208  void clearAnimQueue();
209 
210  bool updateWeaponState();
211  bool updateCreatureState();
212  void updateIdleStormState(bool inwater);
213 
214  void updateAnimQueue();
215 
216  void updateHeadTracking(float duration);
217 
218  void updateMagicEffects();
219 
220  void playDeath(float startpoint, CharacterState death);
222  void playRandomDeath(float startpoint = 0.0f);
223 
226  std::string chooseRandomGroup (const std::string& prefix, int* num = NULL) const;
227 
228  bool updateCarriedLeftVisible(WeaponType weaptype) const;
229 
230 public:
232  virtual ~CharacterController();
233 
234  virtual void handleTextKey(const std::string &groupname, const std::multimap<float, std::string>::const_iterator &key,
235  const std::multimap<float, std::string>& map);
236 
237  // Be careful when to call this, see comment in Actors
238  void updateContinuousVfx();
239 
240  void updatePtr(const MWWorld::Ptr &ptr);
241 
242  void update(float duration);
243 
244  void persistAnimationState();
246 
247  bool playGroup(const std::string &groupname, int mode, int count, bool persist=false);
248  void skipAnim();
249  bool isAnimPlaying(const std::string &groupName);
250 
252  {
257  };
258  KillResult kill();
259 
260  void resurrect();
261  bool isDead() const
262  { return mDeathState != CharState_None; }
263 
264  void forceStateUpdate();
265 
266  bool isReadyToBlock() const;
267  bool isKnockedOut() const;
268  bool isSneaking() const;
269 
270  void setAttackingOrSpell(bool attackingOrSpell);
271  void setAIAttackType(std::string attackType); // set and used by AiCombat
272  static void setAttackTypeRandomly(std::string& attackType);
273 
274  bool readyToPrepareAttack() const;
275  bool readyToStartAttack() const;
276 
277  float getAttackStrength() const;
278 
280  void setActive(bool active);
281 
283  void setHeadTrackTarget(const MWWorld::ConstPtr& target);
284 
285  void playSwishSound(float attackStrength);
286 };
287 
289 }
290 
291 #endif /* GAME_MWMECHANICS_CHARACTER_HPP */
bool readyToPrepareAttack() const
Definition: character.cpp:2241
CharacterState
Definition: character.hpp:48
Iteration over a subset of objects in a ContainerStore.
Definition: containerstore.hpp:196
Definition: character.hpp:104
Definition: character.hpp:52
Definition: character.hpp:134
JumpingState mJumpState
Definition: character.hpp:178
Definition: character.hpp:127
Definition: character.hpp:69
virtual void handleTextKey(const std::string &groupname, const std::multimap< float, std::string >::const_iterator &key, const std::multimap< float, std::string > &map)
Definition: character.cpp:800
Definition: character.hpp:71
void updatePtr(const MWWorld::Ptr &ptr)
Definition: character.cpp:933
Definition: character.hpp:41
Definition: character.hpp:89
Definition: character.hpp:97
Definition: character.hpp:113
Definition: character.hpp:87
Definition: character.hpp:59
void refreshIdleAnims(const WeaponInfo *weap, CharacterState idle, bool force=false)
Definition: character.cpp:475
Definition: character.hpp:40
Definition: character.hpp:121
size_t mLoopCount
Definition: character.hpp:153
Definition: character.cpp:204
Definition: animation.hpp:77
Definition: character.hpp:30
void refreshCurrentAnims(CharacterState idle, CharacterState movement, JumpingState jump, bool force=false)
Definition: character.cpp:520
Definition: character.hpp:57
Definition: character.hpp:128
bool mAdjustMovementAnimSpeed
Definition: character.hpp:165
void num(char i, bool last)
Definition: gen_iconv.cpp:12
Definition: character.hpp:101
UpperBodyCharacterState mUpperBodyState
Definition: character.hpp:176
Definition: character.hpp:106
float mTurnAnimationThreshold
Definition: character.hpp:194
Definition: character.hpp:38
Definition: character.hpp:126
bool mSkipAnim
Definition: character.hpp:186
Definition: character.hpp:34
Definition: character.hpp:37
Definition: character.hpp:33
Definition: character.hpp:79
bool isReadyToBlock() const
Definition: character.cpp:2201
Definition: character.hpp:55
Definition: inventorystore.hpp:40
bool isAnimPlaying(const std::string &groupName)
Definition: character.cpp:2081
CharacterState mHitState
Definition: character.hpp:173
KillResult
Definition: character.hpp:251
void resurrect()
Definition: character.cpp:2135
Definition: character.hpp:60
void clearAnimQueue()
Definition: character.cpp:2089
Definition: character.hpp:75
AnimationQueue mAnimQueue
Definition: character.hpp:157
Definition: character.hpp:114
float getAttackStrength() const
Definition: character.cpp:2258
Definition: character.hpp:80
Definition: character.hpp:56
Definition: character.hpp:119
void playSwishSound(float attackStrength)
Definition: character.cpp:2273
Definition: character.hpp:43
void refreshHitRecoilAnims()
Definition: character.cpp:243
Definition: character.hpp:118
std::string mCurrentMovement
Definition: character.hpp:163
Definition: character.hpp:67
Definition: character.hpp:86
void setAttackTypeBasedOnMovement()
Definition: character.cpp:2189
Definition: character.hpp:64
bool isSneaking() const
Definition: character.cpp:2211
Definition: character.hpp:96
Definition: character.hpp:81
CharacterState mDeathState
Definition: character.hpp:169
float mMovementAnimSpeed
Definition: character.hpp:164
Definition: character.hpp:145
void updateContinuousVfx()
Definition: character.cpp:2146
Definition: character.hpp:36
bool updateWeaponState()
Definition: character.cpp:1088
float mSecondsOfRunning
Definition: character.hpp:190
Definition: character.hpp:132
MWWorld::ConstPtr mHeadTrackTarget
Definition: character.hpp:192
std::string mCurrentDeath
Definition: character.hpp:170
bool mHasMovedInXY
Definition: character.hpp:166
std::string mCurrentJump
Definition: character.hpp:179
Definition: character.hpp:74
bool mFloatToSurface
Definition: character.hpp:171
void updateAnimQueue()
Definition: character.cpp:1546
Definition: character.hpp:54
Definition: character.hpp:65
CharacterController(const MWWorld::Ptr &ptr, MWRender::Animation *anim)
Definition: character.cpp:694
void playRandomDeath(float startpoint=0.0f)
Definition: character.cpp:666
void refreshMovementAnims(const WeaponInfo *weap, CharacterState movement, bool force=false)
Definition: character.cpp:363
std::deque< AnimationQueueEntry > AnimationQueue
Definition: character.hpp:156
void jump(CodeContainer &code, int offset)
Definition: generator.cpp:586
Definition: character.hpp:116
Definition: character.hpp:117
Definition: character.hpp:110
Definition: character.hpp:140
bool updateCreatureState()
Definition: character.cpp:978
Definition: character.hpp:58
void unpersistAnimationState()
Definition: character.cpp:1978
void refreshJumpAnims(const WeaponInfo *weap, JumpingState jump, bool force=false)
Definition: character.cpp:320
bool isDead() const
Definition: character.hpp:261
MWWorld::Ptr mPtr
Definition: character.hpp:147
bool playGroup(const std::string &groupname, int mode, int count, bool persist=false)
Definition: character.cpp:2016
Definition: character.hpp:51
bool readyToStartAttack() const
Definition: character.cpp:2247
KillResult kill()
Definition: character.cpp:2111
std::string mCurrentIdle
Definition: character.hpp:160
Pointer to a const LiveCellRef.
Definition: ptr.hpp:90
Definition: character.hpp:62
bool mAttackingOrSpell
Definition: character.hpp:198
UpperBodyCharacterState
Definition: character.hpp:124
MWRender::Animation * mAnimation
Definition: character.hpp:148
Definition: character.hpp:31
JumpingState
Definition: character.hpp:137
Definition: character.hpp:125
float mAttackStrength
Definition: character.hpp:184
Definition: character.hpp:82
Definition: character.hpp:61
WeaponType mWeaponType
Definition: character.hpp:181
Definition: character.hpp:39
MWWorld::ContainerStoreIterator getActiveWeapon(CreatureStats &stats, MWWorld::InventoryStore &inv, WeaponType *weaptype)
Definition: character.cpp:555
Definition: character.hpp:84
Definition: character.hpp:35
static void setAttackTypeRandomly(std::string &attackType)
Definition: character.cpp:2230
void setAIAttackType(std::string attackType)
Definition: character.cpp:2225
bool mMovementAnimationControlled
Definition: character.hpp:167
Definition: character.hpp:112
Definition: character.hpp:115
Definition: character.hpp:32
bool mPersist
Definition: character.hpp:154
float mSecondsOfSwimming
Definition: character.hpp:189
bool isKnockedOut() const
Definition: character.cpp:2206
void updateMagicEffects()
Definition: character.cpp:2163
Definition: character.hpp:53
Definition: character.hpp:72
Definition: animation.hpp:139
Definition: character.hpp:45
Definition: character.hpp:100
virtual ~CharacterController()
Definition: character.cpp:783
std::string mAttackType
Definition: character.hpp:196
std::string mGroup
Definition: character.hpp:152
Definition: character.hpp:138
Definition: character.hpp:105
Definition: character.hpp:103
Definition: character.hpp:66
void setHeadTrackTarget(const MWWorld::ConstPtr &target)
Make this character turn its head towards target. To turn off head tracking, pass an empty Ptr...
Definition: character.cpp:2268
void updateHeadTracking(float duration)
Definition: character.cpp:2286
void setActive(bool active)
Definition: character.cpp:2263
Pointer to a LiveCellRef.
Definition: ptr.hpp:19
void updateIdleStormState(bool inwater)
Definition: character.cpp:938
void update(float duration)
Definition: character.cpp:1566
Definition: character.hpp:92
void forceStateUpdate()
Definition: character.cpp:2096
Definition: character.hpp:90
Definition: character.hpp:94
Priority
Definition: character.hpp:29
CharacterState chooseRandomDeathState() const
Definition: character.cpp:659
Definition: character.hpp:99
Definition: character.hpp:139
void playDeath(float startpoint, CharacterState death)
Definition: character.cpp:615
Definition: character.hpp:77
void persistAnimationState()
Definition: character.cpp:1948
void skipAnim()
Definition: character.cpp:2076
std::string mCurrentHit
Definition: character.hpp:174
void setAttackingOrSpell(bool attackingOrSpell)
Definition: character.cpp:2220
Definition: character.hpp:70
bool updateCarriedLeftVisible(WeaponType weaptype) const
Definition: character.cpp:1069
WeaponType
Definition: character.hpp:109
Definition: character.hpp:49
std::string mCurrentWeapon
Definition: character.hpp:182
CharacterState mMovementState
Definition: character.hpp:162
std::string chooseRandomGroup(const std::string &prefix, int *num=NULL) const
Definition: character.cpp:231
Definition: character.hpp:85
Definition: character.hpp:95
Definition: character.hpp:76
CharacterState mIdleState
Definition: character.hpp:159
Definition: character.hpp:98