1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 13:49:55 +00:00
openmw-tes3mp/apps/openmw/mwmechanics/character.hpp

184 lines
3.8 KiB
C++
Raw Normal View History

#ifndef GAME_MWMECHANICS_CHARACTER_HPP
#define GAME_MWMECHANICS_CHARACTER_HPP
#include <OgreVector3.h>
#include "../mwworld/ptr.hpp"
namespace MWWorld
{
class ContainerStoreIterator;
class InventoryStore;
}
namespace MWRender
{
class Animation;
}
namespace MWMechanics
{
class Movement;
class NpcStats;
2013-05-13 07:54:44 +00:00
enum Priority {
Priority_Default,
Priority_Movement,
Priority_Weapon,
Priority_Torch,
2013-05-13 07:54:44 +00:00
Priority_Death,
Num_Priorities
};
enum CharacterState {
CharState_None,
CharState_SpecialIdle,
CharState_Idle,
2013-02-03 08:19:22 +00:00
CharState_Idle2,
CharState_Idle3,
CharState_Idle4,
CharState_Idle5,
CharState_Idle6,
CharState_Idle7,
CharState_Idle8,
CharState_Idle9,
2013-02-06 03:05:07 +00:00
CharState_IdleSwim,
2013-03-06 15:58:56 +00:00
CharState_IdleSneak,
CharState_WalkForward,
CharState_WalkBack,
CharState_WalkLeft,
CharState_WalkRight,
2013-02-06 03:05:07 +00:00
CharState_SwimWalkForward,
CharState_SwimWalkBack,
CharState_SwimWalkLeft,
CharState_SwimWalkRight,
2013-02-07 00:53:52 +00:00
CharState_RunForward,
CharState_RunBack,
CharState_RunLeft,
CharState_RunRight,
CharState_SwimRunForward,
CharState_SwimRunBack,
CharState_SwimRunLeft,
CharState_SwimRunRight,
2013-03-06 15:58:56 +00:00
CharState_SneakForward,
CharState_SneakBack,
CharState_SneakLeft,
CharState_SneakRight,
2013-03-31 10:50:20 +00:00
CharState_TurnLeft,
CharState_TurnRight,
2013-02-15 12:45:28 +00:00
CharState_Jump,
2013-02-03 08:19:22 +00:00
CharState_Death1,
CharState_Death2,
CharState_Death3,
CharState_Death4,
CharState_Death5,
CharState_SwimDeath
};
enum WeaponType {
WeapType_None,
WeapType_HandToHand,
WeapType_OneHand,
WeapType_TwoHand,
WeapType_TwoWide,
WeapType_BowAndArrow,
WeapType_Crossbow,
WeapType_ThowWeapon,
WeapType_PickProbe,
WeapType_Spell
};
2013-07-13 21:24:52 +00:00
enum UpperBodyCharacterState {
UpperCharState_Nothing,
UpperCharState_EquipingWeap,
UpperCharState_UnEquipingWeap,
UpperCharState_WeapEquiped,
2013-07-16 21:38:55 +00:00
UpperCharState_StartToMinAttack,
UpperCharState_MinAttackToMaxAttack,
UpperCharState_MaxAttackToMinHit,
UpperCharState_MinHitToHit,
UpperCharState_FollowStartToFollowStop,
UpperCharState_CastingSpell
2013-07-13 21:24:52 +00:00
};
class CharacterController
{
MWWorld::Ptr mPtr;
MWRender::Animation *mAnimation;
typedef std::deque<std::pair<std::string,size_t> > AnimationQueue;
AnimationQueue mAnimQueue;
CharacterState mIdleState;
std::string mCurrentIdle;
CharacterState mMovementState;
std::string mCurrentMovement;
float mMovementSpeed;
CharacterState mDeathState;
std::string mCurrentDeath;
2013-07-13 21:24:52 +00:00
UpperBodyCharacterState mUpperBodyState;
WeaponType mWeaponType;
2013-07-23 09:50:52 +00:00
std::string mCurrentWeapon;
bool mSkipAnim;
2013-04-28 05:53:04 +00:00
// counted for skill increase
float mSecondsOfSwimming;
float mSecondsOfRunning;
std::string mAttackType; // slash, chop or thrust
void refreshCurrentAnims(CharacterState idle, CharacterState movement, bool force=false);
static void getWeaponGroup(WeaponType weaptype, std::string &group);
static MWWorld::ContainerStoreIterator getActiveWeapon(NpcStats &stats,
MWWorld::InventoryStore &inv,
WeaponType *weaptype);
void clearAnimQueue();
bool updateNpcState();
public:
CharacterController(const MWWorld::Ptr &ptr, MWRender::Animation *anim);
virtual ~CharacterController();
void updatePtr(const MWWorld::Ptr &ptr);
void update(float duration, Movement &movement);
void playGroup(const std::string &groupname, int mode, int count);
void skipAnim();
bool isAnimPlaying(const std::string &groupName);
void kill();
void resurrect();
bool isDead() const
{ return mDeathState != CharState_None; }
void forceStateUpdate();
};
}
#endif /* GAME_MWMECHANICS_CHARACTER_HPP */