////////////////////////////////////////////////////////////////////// // // Game Source Code // // File: XEntityPlayer.h // Description: Entity player class. // // History: // - August 16, 2001: Created by Alberto Demichelis // - September 2001: Taken Over by Petar Kotevski // ////////////////////////////////////////////////////////////////////// #ifndef __GAME_PLAYER_H__ #define __GAME_PLAYER_H__ #if _MSC_VER > 1000 #pragma once #endif #include "GameObject.h" #include #include #include "ScriptObjectStream.h" #include "ScriptObjectVector.h" #include "FireType.h" #include "SynchedRandomSeed.h" // CSynchedRandomSeed ////////////////////////////////////////////////////////////////////////// #define BITMASK_PLAYER 1 #define BITMASK_WEAPON 2 // both 1st and 3rd person weapon #define BITMASK_OBJECT 4 // Foraward declarations. class CXPuppetProxy; class CWeaponClass; class CXEntityProcessingCmd; class CXGame; class CWeaponSystemEx; class CVehicle; struct WeaponParams; class CXArea; struct IAIObject; /*! * Base class for all game objects. * Implements IEntityContainer interface. * */ //! Current weapon description structure. struct WeaponInfo { bool owns; //!< have this weapon in possesion. int maxAmmo; //!< Max ammo allowed for this weapon. bool reloading; //!< Is weapon is reloading now. float fireFirstBulletTime; //!< first bullet in a burst float fireTime; //!< Last time we fired. float fireLastShot; //!< Last succeded shot int iFireMode; //!< firemode ICryCharInstance::ObjectBindingHandle hBindInfo, hAuxBindInfo; //!< auxillary bind info for two weapon shooting and binding WeaponInfo() { ZeroStruct(*this); hBindInfo = ICryCharInstance::nInvalidObjectBindingHandle; hAuxBindInfo = ICryCharInstance::nInvalidObjectBindingHandle; } void DetachBindingHandles(ICryCharInstance *pCharacter) { assert (IsHeapValid()); if (hBindInfo) { pCharacter->Detach(hBindInfo); hBindInfo = ICryCharInstance::nInvalidObjectBindingHandle; } if (hAuxBindInfo) { pCharacter->Detach(hAuxBindInfo); hAuxBindInfo = ICryCharInstance::nInvalidObjectBindingHandle; } assert (IsHeapValid()); } }; struct PlayerDynamics { PlayerDynamics() { gravity=swimming_gravity=inertia=swimming_inertia=air_control=jump_gravity=1E10f; } float gravity; //!< any number to override or 1E10f otherwise float swimming_gravity; //!< any number to override or 1E10f otherwise float inertia; //!< any number to override or 1E10f otherwise float swimming_inertia; //!< any number to override or 1E10f otherwise float air_control; //!< any number to override or 1E10f otherwise float jump_gravity; //!< we could have to use a different gravity when jumping (to feel better) ; any number to override or 1E10f otherwise }; // all stamina-related values are here (exept for current value - it's m_stats.stamina) struct StaminaTable { float StaminaHUD; // this is exposed to script to be indicated on HUD float BreathHUD; // this is exposed to script to be indicated on HUD float BreathDecoyUnderwater; float BreathDecoyAim; float BreathRestore; float RunSprintScale; float SwimSprintScale; float RestoreRun; float RestoreWalk; float RestoreIdle; float DecoyRun; float DecoyJump; float DecoyUnderWater; StaminaTable() { ZeroStruct(*this); StaminaHUD = 1.0f; BreathHUD = 1.0f; BreathDecoyUnderwater = 15.0f; BreathDecoyAim = 10.0f; BreathRestore = 9.0f; RunSprintScale = 1.4f; SwimSprintScale = 1.4f; RestoreRun = 1.5f; RestoreWalk = 8.0f; RestoreIdle = 10.0f; DecoyRun = 30.0f; DecoyJump = 10.0f; DecoyUnderWater = 35.0f; } }; ////////////////////////////////////////////////////////////////////////// struct SPlayerUpdateContext { pe_status_living status; bool bPlayerVisible; }; /*! Implement the entity container for the player entity */ class CPlayer : public CGameObject { public: enum eInVehiclestate { PVS_OUT=0, PVS_DRIVER, PVS_GUNNER, PVS_PASSENGER, }; friend class CScriptObjectPlayer; friend class CXPuppetProxy; //! Current state of player. struct PlayerStats { //{{NETWORK SYNCHRONIZED STATS int health; //!< Players current health. 0..255 because of network packet, int because of LUA, 0=dead int armor; //!< Players current armor. 0..255 because of network packet, int because of LUA int ammo_in_clip; int ammo; int numofgrenades; int grenadetype; int weapon; //!< Index of selected weapon. int firemode; int score; //!< Players score in the game. int deaths; //!< Players deaths count bool firing; bool firing_grenade; bool crosshairOnScreen; bool canfire; bool reloading; bool melee_attack; //<> sync this value bool aiming; bool has_flashlight; bool has_binoculars; bool fire_rate_busy; BYTE random_seed; BYTE last_accuracy; //}}END OF NETWORK SYNCHRONIZED STATS float accuracy; float melee_distance; //!< range of the melee attack (used in UpdateMelee) default 2.0 set in BasicPlayer.lua bool crouch; //!< Player is crouching. bool prone; //!< Player is proning. int maxHealth; //!< Players maximal allowed health. int legHealth; //!< Players LEG HIT ZONE current health. int maxLegHealth; //!< Players LEG HIT ZONE max health. int armHealth; //!< Players ARM HIT ZONE current health. int maxArmHealth; //!< Players ARM HIT ZONE max health. int maxArmor; //!< Players maximal allowed armor. float dmgFireAccuracy; // to decreace accuracy with arm damage initial value = 100 float dmgSpeedCoeff; // to solw down with leg damage initial value = 100 eFireType LastFiringType; // How we fired during the last update eFireType FiringType; bool cancelFireFlag; bool aim; //!< Player is aiming. float weapon_busy; // bool isDriver; //!< Player is in vehicle and drivin. eInVehiclestate inVehicleState; // bool inVehicleActive; // if player actually entered vehicle - gettingIn animations over bool moving; //!< Player is moving. bool running; //!< Player is running. bool jumping; //!< Player is jumping - (JUMP pressed). bool flying; //!< Player is flying - not touching ground right now. bool jumping_in_air; //!< Player is flying - not touching ground for some time. bool landing; // was jumping_in_air - now on ground bool concentration; //!< player is concentration (listening) int climbing; //!< Player is climbing (int to avoid overrides when this parameter is not specified through script-calls) bool injump; float fSpeedScale; // For internal use. bool moveLeft; bool moveRight; bool use_pressed; bool holding_breath; bool back_pressed; bool bForceWalk; bool drawfpweapon; bool lock_weapon; //if true the player cannot switch weapon float fInWater; // player is fInWater world units under water (measured from entity pos; not eyepos !) float fKWater; // [0,1] - gravity scale when swimming float underwater; // player is completly under water for this amount of time (seconds) float swimTime; // player is swiming for this amount of time (seconds) float fVel; float curBlindingValue; // how much is blinded by flashlights bool bIsBlinded; // bool bIsLimping; float stamina; // used for SPRINT RUN/jump/sprintSwimming /// float breath; // for underwater/aiming bool onLadder; bool bModelHidden; }; Vec3 m_vDEBUGAIFIREANGLES; float m_fRecoilXDelta; float m_fRecoilZDelta; float m_fRecoilXUp; float m_fRecoilZUp; float m_fRecoilX; float m_fRecoilZ; typedef std::map PlayerWeapons; typedef PlayerWeapons::iterator PlayerWeaponsItor; public: float m_fGrenadeTimer; CPlayer(CXGame *); virtual ~CPlayer(); virtual void UpdatePhysics(float fDeltaTime); void UpdateCamera(); bool IsAlive() const { return (m_stats.health>0); } //! Process player commands. virtual void ProcessCmd(unsigned int nPing,CXEntityProcessingCmd &ProcessingCmd); //! Local for players. virtual void ProcessAngles(CXEntityProcessingCmd &ProcessingCmd); virtual void ProcessMovements(CXEntityProcessingCmd &ProcessingCmd, bool bScheduled=false); virtual void ProcessWeapons(CXEntityProcessingCmd &ProcessingCmd); virtual void FireGrenade(const Vec3 &origin, const Vec3 &angles, IEntity *pIShooter); // virtual Vec3 TraceGrenade( const Vec3& firePos, const Vec3& dir, const float vel, // const float timeStep=.1f, const float timeLimit=30.0f ); void SetFiring(bool bIsFiring); //! Set new character model for this player. void SetPlayerModel( const string &model ); //! Get character model of this player. // string GetPlayerModel() const { return m_strModel; }; //! Set new character color for this player. void SetColor( const Vec3 &invColor ){ m_vColor=invColor; } //! Get character color of this player. Vec3 GetColor() const { return m_vColor; }; /*! Sets the swaying-amplitude @param fAmp amplitude */ void SetSwayAmp(float fAmp) { m_walkParams.swayAmp=fAmp; } /*! Sets the swaying-frequency @param fFreq frequency */ void SetSwayFreq(float fFreq) { m_walkParams.swayFreq=fFreq; } /*! sets base angle for players angels restriction uses current entity angle for restriction base */ void SetAngleLimitBase( ) { m_AngleLimitBase = GetEntity()->GetAngles(); // m_AngleLimitBase.ConvertToRadAngles(); } void SetAngleLimitBase( const Vec3& base ) { m_AngleLimitBase = base; // m_AngleLimitBase.ConvertToRadAngles(); } /*! sets base angle for players angels restriction uses current camera angle for restriction base */ void SetAngleLimitBaseOnCamera( ) { m_AngleLimitBase = m_pEntity->GetAngles(); } /*! Limits the vertical player angles - min value @param fLimit - min angle value */ void SetMinAngleLimitV( float const fLimit) { m_MinVAngle=fLimit; } /*! Limits the vertical player angles - max value @param fLimit - max angle value */ void SetMaxAngleLimitV( float const fLimit) { m_MaxVAngle=fLimit; } /*! Enables vertical player angles restriction @param enabled */ void EnableAngleLimitV( bool const enabled ) { m_AngleLimitVFlag=enabled; } /*! Limits the horizontal player angles - min value @param fLimit - min angle value */ void SetMinAngleLimitH( float const fLimit) { m_MinHAngle=fLimit; } /*! Limits the horizontal player angles - max value @param fLimit - max angle value */ void SetMaxAngleLimitH( float const fLimit) { m_MaxHAngle=fLimit; } /*! Enables horizontal player angles restriction @param enabled */ void EnableAngleLimitH( bool const enabled ) { m_AngleLimitHFlag=enabled; } bool IsAngleLimitVOn( ) const { return m_AngleLimitVFlag; } bool IsAngleLimitHOn( ) const { return m_AngleLimitHFlag; } Vec3 CalcTangentOnEnviroment( const Vec3 &forward ); // //deathType - head/body hit void StartDie( const Vec3& hitImpuls, const Vec3 hitPoint, int partid, const int deathType ); bool HasCollided(); // binoculars bool HasBinoculars() const { return m_stats.has_binoculars; } void GiveBinoculars( bool on ); // flashlight void SwitchFlashLight( bool on ); bool InitLight( const char* img=NULL, const char* shader=NULL ); bool HasFlashLight() const { return m_stats.has_flashlight; } void GiveFlashLight( bool on ); // interface IEntityContainer ------------------------------------------------------------------ virtual bool Init(); virtual void Update(); virtual void OnSetAngles( const Vec3 &ang ); virtual bool Write( CStream &stream,EntityCloneState *cs=NULL); virtual bool Read( CStream &stream ); virtual bool Read_PATCH_1( CStream &stream ); virtual bool QueryContainerInterface( ContainerInterfaceType desired_interface, void **ppInterface); virtual float GetLightRadius(); virtual void OnEntityNetworkUpdate( const EntityId &idViewerEntity, const Vec3d &v3dViewer, uint32 &inoutPriority, EntityCloneState &inoutCloneState ) const; // --------------------------------------------------------------------------------------------- /*! Sets camera shaking-parameters @param shakeAxis axis to shake around @param shakeDegree degree of shaking @param shakeFreq frequency if shaking @param shakeTime time in seconds of shaking */ void SetShake(const Vec3& shakeAxis, float shakeDegree, float shakeFreq, float shakeTime) { m_walkParams.shakeAxis=shakeAxis; m_walkParams.shakeDegree=shakeDegree; m_walkParams.shakeFreq=shakeFreq; m_walkParams.shakeTime=shakeTime; m_walkParams.shakeOffset=0.0f; m_walkParams.shakeElapsedTime=0.0f; } void SetShakeL(const Vec3& shakeAmpl, const Vec3& shakeFreq, const float shakeTime) { m_walkParams.shakeLAmpl=shakeAmpl; m_walkParams.shakeLFreq=shakeFreq; m_walkParams.shakeLTime=shakeTime; m_walkParams.shakeLElapsedTime=0.0f; } void SetShakeL2(const Vec3& shakeAmpl, const Vec3& shakeFreq, const float shakeTime) { m_walkParams.shakeLAmpl=shakeAmpl; m_walkParams.shakeLFreq=shakeFreq; if(m_walkParams.shakeLElapsedTimeIsBound()); } Vec3 m_vDEBUG_POS; // used for Load/Save and Network syncronization bool Save( CStream &stream); bool Load( CStream &stream); bool Load_PATCH_1( CStream &stream); bool SaveGame(CStream &stm); bool LoadGame(CStream &stm); bool LoadGame_PATCH_1(CStream &stm); void UpdateDrawAngles( ); void OnDraw(const SRendParams & RendParams); /*! Retrieves the game associated with this container @return pointer to the game */ CXGame *GetGame() const { return m_pGame; }; IScriptObject *GetScriptObject(); /*! Attaches a ScriptObject to this container @param pObject pointer to the ScriptObject */ void SetScriptObject(IScriptObject *pObject); /*! Overrides the calculated gravity-setting for the next frame @param fNewGravity new gravity to set */ void SetGravityOverride(float fNewGravity) { m_fGravityOverride=fNewGravity; } void GetEntityDesc( CEntityDesc &desc ) const { desc.sModel=m_strModel.c_str(); desc.vColor=GetColor(); } void EnterVehicle( CVehicle *pVehicle, eInVehiclestate state, const char *szHelperName); void LeaveVehicle(); CVehicle* GetVehicle() { return m_pVehicle; }; // void Die(); void SetDimNormal(const pe_player_dimensions* const pDim=NULL ); void SetDimStealth(const pe_player_dimensions* const pDim=NULL ); void SetDimCrouch(const pe_player_dimensions* const pDim=NULL ); void SetDimProne(const pe_player_dimensions* const pDim=NULL ); // void SetAnimationRefSpeed(const float run=-1.0f, const float walk=-1.0f, const float crouch=-1.0f, const float prone=-1.0f ); void SetAnimationRefSpeedRun(const float fwd=-1.0f, const float side=-1.0f, const float back=-1.0f ); void SetAnimationRefSpeedWalk(const float fwd=-1.0f, const float side=-1.0f, const float back=-1.0f ); void SetAnimationRefSpeedRunRelaxed(const float fwd=-1.0f, const float side=-1.0f, const float back=-1.0f ); void SetAnimationRefSpeedWalkRelaxed(const float fwd=-1.0f, const float side=-1.0f, const float back=-1.0f ); void SetAnimationRefSpeedXWalk(const float fwd=-1.0f, const float side=-1.0f, const float back=-1.0f ); void SetAnimationRefSpeedXRun(const float fwd=-1.0f, const float side=-1.0f, const float back=-1.0f ); void SetAnimationRefSpeedCrouch(const float fwd=-1.0f, const float side=-1.0f, const float back=-1.0f ); // void SetAnimationRefSpeedRun(const float fwd=-1.0f, const float side=-1.0f, const float back=-1.0f ); void SetRunSpeed(const float speed); void SetWalkSpeed(const float speed); void SetCrouchSpeed(const float speed); void SetProneSpeed(const float speed); void SetSwimSpeed(const float speed); void SetJumpForce(const float force); void SetLean(const float lean); void SetCameraBob(const float pitch, const float roll, const float length); void SetWeaponBob(const float ampl); void SetDynamics(const PlayerDynamics *pDyn); void Respawn(); int GetBoneHitZone( int boneIdx ) const; // set a set of properties for the heat vision void SetHeatVisionValues(int dwFlags,const char *szName,float fValue,float fFadingValue); // returns ACTUAL plaerys direction angle - the one it's shooting/looking at Vec3 GetActualAngles(); //! Check if this player is visible. bool IsVisible() const; protected: void UpdateLean(); Vec3 CalcLeanOffset(float leanAngle); bool IsLeaning(); void SetEyePos(); void SetEyePosDead(); void SetEyePosBone(); void SetEyePosOffset(); void UpdateDead( SPlayerUpdateContext &ctx ); void UpdateRotateHead(); void ResetRotateHead(); void UpdateWeapon(); void UpdateBoatCamera(); void UpdateFirstPersonView(); void UpdateThirdPersonView(); void UpdateBonesRotation( ); bool UpdateBonesPtrs( ); void UpdateMelee(); void UpdateCharacterAnimations( SPlayerUpdateContext &ctx ); void UpdateCharacterAnimationsMounted( SPlayerUpdateContext &ctx ); void UpdateFireAnimations(); void UpdateJumpAnimations(); void ScaleAnimationSpeed( const float speed2d ); void StartAnimation( const SPlayerUpdateContext &ctx ); bool GenerateAnimationName( char *sAnimName ); void UpdateAutoCenter(); void StartAutoCenter(bool forward); void ResetAutoCenter(); void ProcessVehicleMovements(CXEntityProcessingCmd &ProcessingCmd); void SetWeapon(int iClsID); /*! Retrieves the current time @return elapsed time in seconds */ float GetCurrTime() const { return m_pTimer->GetCurrTime(); }; Vec3 m_vPrevMntPos; // used when at mounted weapon // camera pos/angles used for vehicles FPV to mace smooth camera public: // player's camera mode enum e_PCM{ PCM_ENTERINGVEHICLE, PCM_LEAVINVEHICLE, PCM_INVEHICLE, PCM_OUTVEHICLE, PCM_CASUAL, // casual transition - on/out of water, ladders }; void InitCameraTransition( e_PCM mode, bool OnlyZtransition = false ); Vec3 m_vCurCamposVhcl; Vec3 m_vCurAngleVhcl; Vec3 m_vCurAngleParent; e_PCM m_CameraMode; //filippo //! this specify if we want the camera transition work only on the Z pos of the view: //! true - smooth only Z , false - smooth view angles and whole view pos. bool m_bCameraTransitionOnlyZ; Vec3 m_vDeltaEyeVehicle; //!< needed to shift camera view accordingly with vehicle position while changing sit position. bool m_bLastDeltaEyeVehicle; //!< this tell us if m_vDeltaEyeVehicle must be used. in case we are switching sit position inside the same vehicle. protected: float m_fCameraTime; float m_fCameraSpdV; float m_fCameraSpdA; float m_fLastCamUpdateTime; void UpdateCameraTransition( const Vec3& vEyePos ); public: struct SWalkParams { float runRoll; float runPitch; float swayAmp; float swayFreq; float swayOfs; float leanDegree; float leanCur; float leanAmount; float leanStart; float leanEnd; float leanFactor; float leanSpeed; float fLeanTarget; float fCurrLean; Vec3 shakeAxis; float shakeDegree; float shakeFreq; float shakeTime; float shakeOffset; float shakeElapsedTime; Vec3 shakeAOffset; Vec3 shakeLOffset; Vec3 shakeLAmpl; Vec3 shakeLFreq; float shakeLTime; float shakeLElapsedTime; float fWaterPitchPhase; float fWaterRollPhase; float weaponPos; float weaponCycle; float weaponCycleSpeed; Vec3 dir; float speed; float vertSpeed; float vertSpeedFalling; float curLength; float stepLength; float flyCoeff; float prevF; }; ////////////////////////////////////////////////////////////////////////// // Fields. ////////////////////////////////////////////////////////////////////////// //! Player parameters. public: Vec3 m_vShake; PlayerStats m_stats; // Walking params. SWalkParams m_walkParams; string m_strModel; //!< Name of player model. bool m_bFirstPerson; //!< True when in first person mode. bool m_bFirstPersonLoaded; //!< True when was saved in first person mode - set on loading. bool m_bAlwaysRun; bool m_bWeaponJustFired; bool m_aimLook; bool m_bEyesInWater; //-- A flag to indicate if the animation system is enabled or not //-- When a special animation sequence is needed, this flag should //-- be set to 0 so that the normal animation system does not override it. //-- Otherwise this flag should be set to 1 int m_AnimationSystemEnabled; // void RemoveAllWeapons(); Vec3 m_vEyePos; Vec3 m_vEyeAngles; protected: // Vec3 m_vLeanPos; // Vec3 m_vLeanAngles; // angular offset added of something player stands on (i.e. shaking boat) Vec3 m_vEyeAnglesBaseOffset; IAIObject *m_pLightTarget; bool m_bLightOn; ITimer *m_pTimer; CXGame *m_pGame; HSCRIPTFUNCTION m_pUpdateAnimation; pe_player_dimensions m_PlayerDimNormal; pe_player_dimensions m_PlayerDimStealth; pe_player_dimensions m_PlayerDimCrouch; pe_player_dimensions m_PlayerDimProne; pe_player_dimensions m_PlayerDimSwim; pe_player_dimensions m_PlayerDimDead; CScriptObjectVector m_ssoHitPosVec; CScriptObjectVector m_ssoHitDirVec; CScriptObjectVector m_ssoHitNormVec; Vec3 m_vColor; // m_HostedAreasIdx; CXAreaUser m_AreaUser; Vec3 m_vCharacterAngles; //void PlaySound(ISound * pSound,float fSoundScale, Vec3 &Offset); virtual Vec3 CalcSoundPos(); void SetViewMode(bool bThirdPerson); unsigned MemStats( void ); void CounterAdd( const string name, const float timeScale ); void CounterSetEvent( const string name, const float thrhld, const string eventName ); void CounterIncrement( const string name, const float value ); float CounterGetValue( const string name ); void CounterSetValue( const string name, const float value ); protected: void CounterUpdateAll( const float dt ); struct couterEntry { float value; float scale; float eventTrhld; string eventToCall; couterEntry() { scale = 1.0f; } }; typedef std::map< string, couterEntry > CountersMap; CountersMap m_UpdatedCounters; //!< typedef std::map< string, float > BlendTimesMap; BlendTimesMap m_AniBlendTimes; void UpdateCollisionDamage(); void ProceedFLight( ); Vec3 GetFLightPos( ); void UpdateLightBlinding( ); void OnDrawMountedWeapon(const SRendParams & RendParams); //! attached dynamic light source - flashlight CDLight *m_pDynLight; IPhysicalEntity *m_pPrevDmgCollider; float m_timeDmgCollision; float m_prevCollDamage; // // countdown to remove entity float m_fDeathTimer; bool m_bRotateHead; bool m_bInertiaOverride; bool m_bIsFish; char m_AutoCenter; //0 -off, 1 -going forward, 2 -goung backward float m_fNoChangeangleTime; float m_fProcessTime; bool m_bMouseMoved; // flag used to count time in autocentering public: void SetBlendTime(const char *sAniName, float fBlendTime); void GetBlendTime(const char *sAniName, float&fBlendTime); void PreloadInstanceResources(Vec3d vPrevPortalPos, float fPrevPortalDistance, float fTime); float m_fGravityOverride; int m_PrevWeaponID; // typedef std::vector VectorOfVectors; // VectorOfVectors m_vBlindingPosList; // std::vector m_vBlindingPosList; typedef std::map BlindingList; BlindingList m_vBlindingList; BlindingList::const_iterator m_LastUsed; // Vec3 m_vBlindingPos; float m_vBlindingValueFade; float m_RunSpeedScale; float m_CrouchSpeedScale; float m_ProneSpeedScale; float m_XRunSpeedScale; // stealth float m_XWalkSpeedScale; float m_RRunSpeedScale; // relaxed float m_RWalkSpeedScale; float m_fAccuracyMod; float m_fAccuracy; // sets speeds multiplyers for AI puppet proxyis void SetSpeedMult( float run, float crouch, float prone, float xrun, float xwalk, float rrun, float rwalk ); void SetStaminaTable( const StaminaTable& stTable ); void UpdateStamina(float fDeltaTime); // bool Get3DCrosshairPosition( Vec3& pos3D, Vec3& posScr ); bool GetWaitForFireRelease() const { return m_bWaitForFireRelease; } void SetWaitForFireRelease(bool bVal) { m_bWaitForFireRelease = bVal; } IEntity *m_pMountedWeapon; // here we store last angles of player at mounted weapon when no intersection // with any objects would happen Vec3d m_vSafeAngAtMountedWeapon; //! DampInputVector make change the input vector of the player in a smooth way, it is implemented for AIs but can be used also for players. void DampInputVector(vectorf &vec ,float speed ,float stopspeed ,bool only2d ,bool linear); float m_input_accel;//!