2013-01-10 08:35:24 -08:00
|
|
|
#ifndef GAME_MWMECHANICS_CHARACTER_HPP
|
|
|
|
#define GAME_MWMECHANICS_CHARACTER_HPP
|
|
|
|
|
2015-06-03 23:04:35 +02:00
|
|
|
#include <deque>
|
2013-01-18 16:00:51 -08:00
|
|
|
|
2013-10-02 22:54:36 +02:00
|
|
|
#include <components/esm/loadmgef.hpp>
|
|
|
|
|
2013-01-12 08:49:08 -08:00
|
|
|
#include "../mwworld/ptr.hpp"
|
2017-02-14 19:34:54 +00:00
|
|
|
#include "../mwworld/containerstore.hpp"
|
2013-01-12 08:49:08 -08:00
|
|
|
|
2015-05-22 00:55:43 +02:00
|
|
|
#include "../mwrender/animation.hpp"
|
|
|
|
|
2018-12-26 13:45:28 +04:00
|
|
|
#include "weapontype.hpp"
|
|
|
|
|
2013-07-24 21:08:16 -07:00
|
|
|
namespace MWWorld
|
|
|
|
{
|
|
|
|
class InventoryStore;
|
|
|
|
}
|
|
|
|
|
2013-01-16 10:16:37 -08:00
|
|
|
namespace MWRender
|
|
|
|
{
|
|
|
|
class Animation;
|
|
|
|
}
|
|
|
|
|
2013-01-10 08:35:24 -08:00
|
|
|
namespace MWMechanics
|
|
|
|
{
|
|
|
|
|
2015-03-06 21:36:42 +13:00
|
|
|
struct Movement;
|
2014-01-19 13:31:17 +01:00
|
|
|
class CreatureStats;
|
2013-03-31 00:13:56 -07:00
|
|
|
|
2013-05-13 00:54:44 -07:00
|
|
|
enum Priority {
|
|
|
|
Priority_Default,
|
2015-07-26 01:35:36 +02:00
|
|
|
Priority_WeaponLowerBody,
|
2015-09-16 16:14:17 +02:00
|
|
|
Priority_SneakIdleLowerBody,
|
2015-07-31 00:52:34 +02:00
|
|
|
Priority_SwimIdle,
|
2018-08-08 16:52:09 +04:00
|
|
|
Priority_Jump,
|
2019-01-09 18:05:51 +03:00
|
|
|
Priority_Movement,
|
2013-12-31 13:24:20 +02:00
|
|
|
Priority_Hit,
|
2013-05-13 03:32:00 -07:00
|
|
|
Priority_Weapon,
|
2015-07-15 14:54:37 +02:00
|
|
|
Priority_Block,
|
2014-01-08 16:05:14 +02:00
|
|
|
Priority_Knockdown,
|
2013-05-17 06:21:59 -07:00
|
|
|
Priority_Torch,
|
2014-09-16 03:01:48 +02:00
|
|
|
Priority_Storm,
|
2013-05-13 00:54:44 -07:00
|
|
|
Priority_Death,
|
2018-06-12 12:55:28 +04:00
|
|
|
Priority_Persistent,
|
2013-05-13 00:54:44 -07:00
|
|
|
|
|
|
|
Num_Priorities
|
|
|
|
};
|
|
|
|
|
2013-01-12 10:10:27 -08:00
|
|
|
enum CharacterState {
|
2013-07-15 22:56:23 -07:00
|
|
|
CharState_None,
|
|
|
|
|
2013-02-23 01:54:46 -08:00
|
|
|
CharState_SpecialIdle,
|
2013-01-18 13:43:45 -08:00
|
|
|
CharState_Idle,
|
2013-02-03 00:19:22 -08:00
|
|
|
CharState_Idle2,
|
|
|
|
CharState_Idle3,
|
|
|
|
CharState_Idle4,
|
|
|
|
CharState_Idle5,
|
|
|
|
CharState_Idle6,
|
|
|
|
CharState_Idle7,
|
|
|
|
CharState_Idle8,
|
|
|
|
CharState_Idle9,
|
2013-02-05 19:05:07 -08:00
|
|
|
CharState_IdleSwim,
|
2013-03-06 16:58:56 +01:00
|
|
|
CharState_IdleSneak,
|
2013-01-18 18:04:00 -08:00
|
|
|
|
|
|
|
CharState_WalkForward,
|
|
|
|
CharState_WalkBack,
|
2013-01-19 16:19:47 -08:00
|
|
|
CharState_WalkLeft,
|
|
|
|
CharState_WalkRight,
|
2013-01-18 18:04:00 -08:00
|
|
|
|
2013-02-05 19:05:07 -08:00
|
|
|
CharState_SwimWalkForward,
|
|
|
|
CharState_SwimWalkBack,
|
|
|
|
CharState_SwimWalkLeft,
|
|
|
|
CharState_SwimWalkRight,
|
|
|
|
|
2013-02-06 16:53:52 -08:00
|
|
|
CharState_RunForward,
|
|
|
|
CharState_RunBack,
|
|
|
|
CharState_RunLeft,
|
|
|
|
CharState_RunRight,
|
|
|
|
|
|
|
|
CharState_SwimRunForward,
|
|
|
|
CharState_SwimRunBack,
|
|
|
|
CharState_SwimRunLeft,
|
|
|
|
CharState_SwimRunRight,
|
|
|
|
|
2013-03-06 16:58:56 +01:00
|
|
|
CharState_SneakForward,
|
|
|
|
CharState_SneakBack,
|
|
|
|
CharState_SneakLeft,
|
|
|
|
CharState_SneakRight,
|
|
|
|
|
2013-03-31 03:50:20 -07:00
|
|
|
CharState_TurnLeft,
|
|
|
|
CharState_TurnRight,
|
2017-09-22 16:07:00 +04:00
|
|
|
CharState_SwimTurnLeft,
|
|
|
|
CharState_SwimTurnRight,
|
2013-03-31 03:50:20 -07:00
|
|
|
|
2013-02-15 04:45:28 -08:00
|
|
|
CharState_Jump,
|
|
|
|
|
2013-02-03 00:19:22 -08:00
|
|
|
CharState_Death1,
|
|
|
|
CharState_Death2,
|
|
|
|
CharState_Death3,
|
|
|
|
CharState_Death4,
|
2013-07-18 01:13:53 -07:00
|
|
|
CharState_Death5,
|
2013-12-31 13:24:20 +02:00
|
|
|
CharState_SwimDeath,
|
2017-09-22 14:51:06 +04:00
|
|
|
CharState_SwimDeathKnockDown,
|
|
|
|
CharState_SwimDeathKnockOut,
|
2014-03-26 18:55:16 +01:00
|
|
|
CharState_DeathKnockDown,
|
|
|
|
CharState_DeathKnockOut,
|
2013-12-31 13:24:20 +02:00
|
|
|
|
2014-01-02 21:54:41 +02:00
|
|
|
CharState_Hit,
|
2017-09-22 15:49:42 +04:00
|
|
|
CharState_SwimHit,
|
2014-01-21 01:01:21 +01:00
|
|
|
CharState_KnockDown,
|
2014-02-02 03:24:40 +01:00
|
|
|
CharState_KnockOut,
|
2017-09-22 15:26:35 +04:00
|
|
|
CharState_SwimKnockDown,
|
|
|
|
CharState_SwimKnockOut,
|
2014-01-21 01:01:21 +01:00
|
|
|
CharState_Block
|
2013-01-12 10:10:27 -08:00
|
|
|
};
|
|
|
|
|
2013-07-13 22:24:52 +01:00
|
|
|
enum UpperBodyCharacterState {
|
|
|
|
UpperCharState_Nothing,
|
|
|
|
UpperCharState_EquipingWeap,
|
|
|
|
UpperCharState_UnEquipingWeap,
|
|
|
|
UpperCharState_WeapEquiped,
|
2013-07-16 23:38:55 +02:00
|
|
|
UpperCharState_StartToMinAttack,
|
|
|
|
UpperCharState_MinAttackToMaxAttack,
|
|
|
|
UpperCharState_MaxAttackToMinHit,
|
|
|
|
UpperCharState_MinHitToHit,
|
2013-07-23 07:30:54 -07:00
|
|
|
UpperCharState_FollowStartToFollowStop,
|
|
|
|
UpperCharState_CastingSpell
|
2013-07-13 22:24:52 +01:00
|
|
|
};
|
|
|
|
|
2013-08-18 23:42:56 -07:00
|
|
|
enum JumpingState {
|
|
|
|
JumpState_None,
|
2014-09-17 02:20:46 +02:00
|
|
|
JumpState_InAir,
|
2013-08-18 23:42:56 -07:00
|
|
|
JumpState_Landing
|
|
|
|
};
|
|
|
|
|
2016-06-15 03:14:44 +02:00
|
|
|
struct WeaponInfo;
|
|
|
|
|
2015-05-22 00:55:43 +02:00
|
|
|
class CharacterController : public MWRender::Animation::TextKeyListener
|
2013-01-12 07:12:12 -08:00
|
|
|
{
|
2013-01-12 08:49:08 -08:00
|
|
|
MWWorld::Ptr mPtr;
|
2018-05-02 14:13:49 +04:00
|
|
|
MWWorld::Ptr mWeapon;
|
2013-01-16 10:16:37 -08:00
|
|
|
MWRender::Animation *mAnimation;
|
2014-10-08 10:58:52 +02:00
|
|
|
|
2016-07-30 19:24:03 +02:00
|
|
|
struct AnimationQueueEntry
|
|
|
|
{
|
|
|
|
std::string mGroup;
|
|
|
|
size_t mLoopCount;
|
|
|
|
bool mPersist;
|
|
|
|
};
|
|
|
|
typedef std::deque<AnimationQueueEntry> AnimationQueue;
|
2013-01-17 13:18:40 -08:00
|
|
|
AnimationQueue mAnimQueue;
|
|
|
|
|
2013-07-15 22:56:23 -07:00
|
|
|
CharacterState mIdleState;
|
|
|
|
std::string mCurrentIdle;
|
2013-07-16 01:30:03 -07:00
|
|
|
|
2013-07-15 22:56:23 -07:00
|
|
|
CharacterState mMovementState;
|
|
|
|
std::string mCurrentMovement;
|
2015-07-25 18:22:48 +02:00
|
|
|
float mMovementAnimSpeed;
|
|
|
|
bool mAdjustMovementAnimSpeed;
|
2014-09-06 05:52:47 +02:00
|
|
|
bool mHasMovedInXY;
|
2014-07-03 17:40:44 +02:00
|
|
|
bool mMovementAnimationControlled;
|
2013-07-15 22:56:23 -07:00
|
|
|
|
2013-07-15 23:43:33 -07:00
|
|
|
CharacterState mDeathState;
|
|
|
|
std::string mCurrentDeath;
|
2016-02-01 23:13:43 +01:00
|
|
|
bool mFloatToSurface;
|
2013-07-15 23:43:33 -07:00
|
|
|
|
2013-12-31 13:24:20 +02:00
|
|
|
CharacterState mHitState;
|
|
|
|
std::string mCurrentHit;
|
|
|
|
|
2013-07-13 22:24:52 +01:00
|
|
|
UpperBodyCharacterState mUpperBodyState;
|
2013-07-16 11:40:19 +01:00
|
|
|
|
2013-08-18 23:42:56 -07:00
|
|
|
JumpingState mJumpState;
|
2013-08-19 08:10:18 -07:00
|
|
|
std::string mCurrentJump;
|
2013-08-18 23:42:56 -07:00
|
|
|
|
2018-12-26 13:45:28 +04:00
|
|
|
int mWeaponType;
|
2013-07-23 02:50:52 -07:00
|
|
|
std::string mCurrentWeapon;
|
|
|
|
|
2015-06-26 05:15:07 +02:00
|
|
|
float mAttackStrength;
|
|
|
|
|
2013-01-16 21:25:50 -08:00
|
|
|
bool mSkipAnim;
|
2013-01-12 10:10:27 -08:00
|
|
|
|
2013-04-28 07:53:04 +02:00
|
|
|
// counted for skill increase
|
|
|
|
float mSecondsOfSwimming;
|
|
|
|
float mSecondsOfRunning;
|
|
|
|
|
2015-12-19 16:02:47 +01:00
|
|
|
MWWorld::ConstPtr mHeadTrackTarget;
|
2014-12-16 20:47:45 +01:00
|
|
|
|
2014-09-17 05:20:10 +02:00
|
|
|
float mTurnAnimationThreshold; // how long to continue playing turning animation after actor stopped turning
|
|
|
|
|
2013-07-16 23:32:41 +02:00
|
|
|
std::string mAttackType; // slash, chop or thrust
|
2015-07-02 19:14:28 +02:00
|
|
|
|
|
|
|
bool mAttackingOrSpell;
|
2018-06-28 16:58:51 +04:00
|
|
|
bool mCastingManualSpell;
|
2015-07-02 19:14:28 +02:00
|
|
|
|
2017-11-15 16:43:36 +01:00
|
|
|
float mTimeUntilWake;
|
|
|
|
|
2016-03-19 18:03:59 +01:00
|
|
|
void setAttackTypeBasedOnMovement();
|
2013-07-16 23:32:41 +02:00
|
|
|
|
2015-07-16 20:03:16 +02:00
|
|
|
void refreshCurrentAnims(CharacterState idle, CharacterState movement, JumpingState jump, bool force=false);
|
2018-08-20 22:04:02 +04:00
|
|
|
void refreshHitRecoilAnims(CharacterState& idle);
|
2018-12-26 13:45:28 +04:00
|
|
|
void refreshJumpAnims(const std::string& weapShortGroup, JumpingState jump, CharacterState& idle, bool force=false);
|
|
|
|
void refreshMovementAnims(const std::string& weapShortGroup, CharacterState movement, CharacterState& idle, bool force=false);
|
|
|
|
void refreshIdleAnims(const std::string& weapShortGroup, CharacterState idle, bool force=false);
|
2013-04-30 19:26:41 -07:00
|
|
|
|
2018-06-12 14:04:03 +04:00
|
|
|
void clearAnimQueue(bool clearPersistAnims = false);
|
2013-05-16 06:59:41 -07:00
|
|
|
|
2018-08-20 22:04:02 +04:00
|
|
|
bool updateWeaponState(CharacterState& idle);
|
2014-01-17 16:31:27 +01:00
|
|
|
bool updateCreatureState();
|
2015-11-03 17:48:35 +01:00
|
|
|
void updateIdleStormState(bool inwater);
|
2013-07-23 03:26:24 -07:00
|
|
|
|
2018-07-19 16:38:32 +04:00
|
|
|
std::string chooseRandomAttackAnimation() const;
|
|
|
|
bool isRandomAttackAnimation(const std::string& group) const;
|
|
|
|
|
2018-06-12 11:51:54 +04:00
|
|
|
bool isPersistentAnimPlaying();
|
|
|
|
|
2016-08-22 23:02:57 +02:00
|
|
|
void updateAnimQueue();
|
|
|
|
|
2014-12-16 20:47:45 +01:00
|
|
|
void updateHeadTracking(float duration);
|
|
|
|
|
2014-12-12 02:39:59 +01:00
|
|
|
void updateMagicEffects();
|
2013-12-08 23:05:21 +01:00
|
|
|
|
2014-05-26 19:56:32 +02:00
|
|
|
void playDeath(float startpoint, CharacterState death);
|
2016-05-19 22:30:14 +02:00
|
|
|
CharacterState chooseRandomDeathState() const;
|
2014-01-02 21:54:41 +02:00
|
|
|
void playRandomDeath(float startpoint = 0.0f);
|
2013-12-31 13:24:20 +02:00
|
|
|
|
2014-01-19 21:11:48 +01:00
|
|
|
/// choose a random animation group with \a prefix and numeric suffix
|
2018-10-09 10:21:12 +04:00
|
|
|
/// @param num if non-nullptr, the chosen animation number will be written here
|
|
|
|
std::string chooseRandomGroup (const std::string& prefix, int* num = nullptr) const;
|
2014-01-19 21:11:48 +01:00
|
|
|
|
2018-12-26 13:45:28 +04:00
|
|
|
bool updateCarriedLeftVisible(int weaptype) const;
|
2014-12-12 16:49:22 +01:00
|
|
|
|
2019-08-09 12:10:28 +04:00
|
|
|
std::string fallbackShortWeaponGroup(const std::string& baseGroupName, MWRender::Animation::BlendMask* blendMask = nullptr);
|
|
|
|
|
2019-08-09 12:58:20 +04:00
|
|
|
std::string getWeaponAnimation(int weaponType) const;
|
|
|
|
|
2013-01-12 08:49:08 -08:00
|
|
|
public:
|
2013-07-15 23:43:33 -07:00
|
|
|
CharacterController(const MWWorld::Ptr &ptr, MWRender::Animation *anim);
|
2013-02-04 07:10:14 -08:00
|
|
|
virtual ~CharacterController();
|
2013-01-12 10:10:27 -08:00
|
|
|
|
2015-05-22 00:55:43 +02:00
|
|
|
virtual void handleTextKey(const std::string &groupname, const std::multimap<float, std::string>::const_iterator &key,
|
|
|
|
const std::multimap<float, std::string>& map);
|
|
|
|
|
2013-11-14 13:30:48 +01:00
|
|
|
// Be careful when to call this, see comment in Actors
|
|
|
|
void updateContinuousVfx();
|
|
|
|
|
2013-02-25 09:57:34 -08:00
|
|
|
void updatePtr(const MWWorld::Ptr &ptr);
|
|
|
|
|
2018-09-21 16:34:23 +04:00
|
|
|
void update(float duration, bool animationOnly=false);
|
2013-01-16 16:31:09 -08:00
|
|
|
|
2018-09-22 12:57:50 +04:00
|
|
|
bool onOpen();
|
|
|
|
void onClose();
|
|
|
|
|
2016-07-30 19:24:03 +02:00
|
|
|
void persistAnimationState();
|
|
|
|
void unpersistAnimationState();
|
|
|
|
|
|
|
|
bool playGroup(const std::string &groupname, int mode, int count, bool persist=false);
|
2013-01-16 17:53:18 -08:00
|
|
|
void skipAnim();
|
2013-05-24 20:10:07 -07:00
|
|
|
bool isAnimPlaying(const std::string &groupName);
|
2013-01-16 17:53:18 -08:00
|
|
|
|
2016-06-12 00:04:50 +02:00
|
|
|
enum KillResult
|
|
|
|
{
|
|
|
|
Result_DeathAnimStarted,
|
|
|
|
Result_DeathAnimPlaying,
|
|
|
|
Result_DeathAnimJustFinished,
|
|
|
|
Result_DeathAnimFinished
|
|
|
|
};
|
|
|
|
KillResult kill();
|
2014-05-14 07:14:08 +02:00
|
|
|
|
2013-07-15 23:43:33 -07:00
|
|
|
void resurrect();
|
|
|
|
bool isDead() const
|
|
|
|
{ return mDeathState != CharState_None; }
|
2013-04-25 07:08:11 -07:00
|
|
|
|
|
|
|
void forceStateUpdate();
|
2014-10-08 10:58:52 +02:00
|
|
|
|
2018-08-16 17:47:06 +04:00
|
|
|
bool isAttackPreparing() const;
|
2018-06-28 16:58:51 +04:00
|
|
|
bool isCastingSpell() const;
|
2014-12-12 16:49:22 +01:00
|
|
|
bool isReadyToBlock() const;
|
2017-09-22 15:26:35 +04:00
|
|
|
bool isKnockedDown() const;
|
2014-12-12 17:39:00 +01:00
|
|
|
bool isKnockedOut() const;
|
2017-09-22 15:49:42 +04:00
|
|
|
bool isRecovery() const;
|
2015-09-16 15:37:36 +02:00
|
|
|
bool isSneaking() const;
|
2017-08-16 20:30:47 +04:00
|
|
|
bool isRunning() const;
|
2017-09-22 16:07:00 +04:00
|
|
|
bool isTurning() const;
|
2017-08-18 19:24:34 +04:00
|
|
|
bool isAttackingOrSpell() const;
|
2014-12-16 20:47:45 +01:00
|
|
|
|
2018-09-21 16:34:23 +04:00
|
|
|
void setVisibility(float visibility);
|
2015-07-02 19:14:28 +02:00
|
|
|
void setAttackingOrSpell(bool attackingOrSpell);
|
2018-06-28 16:58:51 +04:00
|
|
|
void castSpell(const std::string spellId, bool manualSpell=false);
|
2017-04-20 20:36:14 +09:00
|
|
|
void setAIAttackType(const std::string& attackType);
|
2016-09-20 02:13:10 +09:00
|
|
|
static void setAttackTypeRandomly(std::string& attackType);
|
2015-07-02 19:14:28 +02:00
|
|
|
|
2015-07-02 22:25:19 +02:00
|
|
|
bool readyToPrepareAttack() const;
|
2015-07-03 05:58:12 +02:00
|
|
|
bool readyToStartAttack() const;
|
|
|
|
|
|
|
|
float getAttackStrength() const;
|
2015-07-02 22:25:19 +02:00
|
|
|
|
2015-04-29 23:48:08 +02:00
|
|
|
/// @see Animation::setActive
|
2018-01-11 01:49:35 +00:00
|
|
|
void setActive(int active);
|
2015-04-29 23:48:08 +02:00
|
|
|
|
2014-12-16 20:47:45 +01:00
|
|
|
/// Make this character turn its head towards \a target. To turn off head tracking, pass an empty Ptr.
|
2015-12-19 16:02:47 +01:00
|
|
|
void setHeadTrackTarget(const MWWorld::ConstPtr& target);
|
2016-12-11 19:35:53 +01:00
|
|
|
|
|
|
|
void playSwishSound(float attackStrength);
|
2013-01-12 07:12:12 -08:00
|
|
|
};
|
2013-01-10 08:35:24 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* GAME_MWMECHANICS_CHARACTER_HPP */
|