Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1256 lines
42 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef C_CS_PLAYER_H
  7. #define C_CS_PLAYER_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "cs_playeranimstate.h"
  12. #include "c_baseplayer.h"
  13. #include "cs_shareddefs.h"
  14. #include "weapon_csbase.h"
  15. #include "baseparticleentity.h"
  16. #include "beamdraw.h"
  17. #include "glow_outline_effect.h"
  18. #include "cs_player_rank_shared.h"
  19. #include "GameEventListener.h"
  20. #include "cstrike15_item_inventory.h"
  21. #include "cs_custom_weapon_visualsdata_processor.h"
  22. #include "cs_player_shared.h"
  23. #include "iinput.h"
  24. #include "cstrike15_item_inventory.h"
  25. #include "csgo_playeranimstate.h"
  26. #include "cs_gamerules.h"
  27. #include "basecsgrenade_projectile.h"
  28. #define SPEECH_VOIP_PARTICLE_EFFECT_NAME "speech_voice"
  29. #define RADIO_VOICE_PARTICLE_EFFECT_NAME "radio_voice"
  30. enum CStrikeScreenSpaceEffect
  31. {
  32. AR_LEADER_SCREEN_SPACE_EFFECT,
  33. CSTRIKE_SCREEN_SPACE_EFFECT_COUNT
  34. };
  35. //#define CHARACTER_SPAWN_CAM_ZOOM_IN
  36. extern const char *musicTypeStrings[];
  37. class C_PhysicsProp;
  38. extern ConVar cl_disablefreezecam;
  39. struct clientSmokeGrenadeRecord_t
  40. {
  41. Vector m_vecPosition;
  42. float m_flInceptionTime;
  43. int m_iEntityId;
  44. };
  45. struct clientHitVerify_t
  46. {
  47. clientHitVerify_t()
  48. {
  49. vecPosition = Vector(0, 0, 0);
  50. flTimestamp = 0;
  51. flExpireTime = -1;
  52. }
  53. clientHitVerify_t( Vector inPos, float flTimestamp, float flExpireTime )
  54. {
  55. vecPosition = inPos;
  56. flTimestamp = flTimestamp;
  57. flExpireTime = flExpireTime;
  58. }
  59. Vector vecPosition;
  60. float flTimestamp;
  61. float flExpireTime;
  62. };
  63. class C_BulletHitModel : public C_BaseAnimating
  64. {
  65. DECLARE_CLASS( C_BulletHitModel, C_BaseAnimating );
  66. public:
  67. //C_BulletHitModel() : m_pPlayerParent(NULL), m_iBoneIndex( 0 ), m_bIsHit( false ), m_flTimeCreated( 0 ){}
  68. void AttachToPlayer( C_CSPlayer *pTargetPlayer, int nBoneIndex, matrix3x4_t matLocalOffset, bool bIsHit, Vector vecStartPos );
  69. virtual int DrawModel( int flags, const RenderableInstance_t &instance );
  70. bool UpdatePosition( void );
  71. CCSPlayer *GetPlayerParent();
  72. private:
  73. matrix3x4_t m_matLocal;
  74. int m_iBoneIndex;
  75. EHANDLE m_hPlayerParent;
  76. bool m_bIsHit;
  77. float m_flTimeCreated;
  78. Vector m_vecStartPos;
  79. };
  80. #define BONESNAPSHOT_ENTIRE_BODY 0
  81. #define BONESNAPSHOT_UPPER_BODY 1
  82. #define BONESNAPSHOT_DECAYDURATION_MIN 0
  83. #define BONESNAPSHOT_DECAYDURATION_MAX 0.4f
  84. class CBoneSnapshot
  85. {
  86. public:
  87. void Update( CBaseAnimating* pEnt, bool bReadOnly = false );
  88. inline void UpdateReadOnly( void ) { Update( m_pEnt, true ); }
  89. void SetShouldCapture( void ) { m_bCapturePending = true; }
  90. void SetShouldCapture( float flNewDecayDuration )
  91. {
  92. m_bCapturePending = true;
  93. m_flDecayIdealDuration = clamp( flNewDecayDuration, BONESNAPSHOT_DECAYDURATION_MIN, BONESNAPSHOT_DECAYDURATION_MAX );
  94. m_flDecayStartTime = gpGlobals->curtime;
  95. m_flDecayEndTime = m_flDecayStartTime + m_flDecayIdealDuration;
  96. }
  97. bool IsCapturePending( void ) { return (m_bEnabled && m_bCapturePending); }
  98. void Enable( void ) { if ( !m_bEnabled ) { AbandonAnyPending(); } m_bEnabled = true; }
  99. void Disable( void ) { if ( m_bEnabled ) { AbandonAnyPending(); } m_bEnabled = false; }
  100. float GetCurrentWeight( void ) { return m_flWeight; }
  101. void SetLastBoneSetupTimeIndex( void ) { m_flLastBoneSetupTimeIndex = gpGlobals->curtime; }
  102. void Init( void )
  103. {
  104. m_pEnt = NULL;
  105. m_flWeight = 0;
  106. memset( m_Weightlist, 0, ARRAYSIZE(m_Weightlist) );
  107. m_bWeightlistInitialized = false;
  108. m_bEnabled = false;
  109. m_bCapturePending = false;
  110. m_vecSubordinateSnapshots.RemoveAll();
  111. m_flDecayIdealDuration = 0.25f;
  112. m_flDecayStartTime = 0;
  113. m_flDecayEndTime = 0;
  114. m_vecWorldCapturePos.Init();
  115. m_flLastBoneSetupTimeIndex = 0;
  116. m_nStudioRenderHdrId = -1;
  117. }
  118. void Init( CBaseAnimating* pEnt ) { Init(); m_pEnt = pEnt; }
  119. CBoneSnapshot() { Init(); }
  120. void AddSubordinate( CBoneSnapshot* pSnapshot )
  121. {
  122. if ( !m_vecSubordinateSnapshots.HasElement(pSnapshot) )
  123. {
  124. m_vecSubordinateSnapshots[ m_vecSubordinateSnapshots.AddToTail() ] = pSnapshot;
  125. }
  126. }
  127. void AbandonAnyPending( void )
  128. {
  129. m_flWeight = 0;
  130. m_bCapturePending = false;
  131. }
  132. void SetWeightListName( const char* szWeightListName ) { m_szWeightlistName = szWeightListName; }
  133. private:
  134. CBaseAnimating* m_pEnt;
  135. float m_flWeight;
  136. matrix3x4a_t m_Cache[ MAXSTUDIOBONES ];
  137. const char* m_szWeightlistName;
  138. float m_Weightlist[ MAXSTUDIOBONES ];
  139. bool m_bWeightlistInitialized;
  140. bool m_bEnabled;
  141. bool m_bCapturePending;
  142. float m_flDecayIdealDuration;
  143. float m_flDecayStartTime;
  144. float m_flDecayEndTime;
  145. Vector m_vecWorldCapturePos;
  146. float m_flLastBoneSetupTimeIndex;
  147. int m_nStudioRenderHdrId;
  148. CUtlVector<CBoneSnapshot*> m_vecSubordinateSnapshots;
  149. void CaptureSnapshot( void );
  150. void PlaybackSnapshot( void );
  151. void InitWeightList( void );
  152. bool IsBoneSetupTimeIndexRecent( void ) { return (gpGlobals->curtime - m_flLastBoneSetupTimeIndex) <= 0.25f; }
  153. };
  154. //-----------------------------------------------------------------------------
  155. class CAddonModel
  156. {
  157. public:
  158. CHandle<C_BaseAnimating> m_hEnt; // The model for the addon.
  159. int m_iAddon; // One of the ADDON_ bits telling which model this is.
  160. int m_iAttachmentPoint; // Which attachment point on the player model this guy is on.
  161. };
  162. // Class that handles the playback of a sound instance during round start
  163. class RoundStartSoundPlaybackData
  164. {
  165. public:
  166. RoundStartSoundPlaybackData() { m_pEntityPlayingSound = NULL; m_SoundName[0] = 0; m_fPlaybackTime = 0.0f; m_bHasBeenPlayed = false; }
  167. CBaseEntity* m_pEntityPlayingSound; // Entity playing the sound event
  168. char m_SoundName[64]; // Name of sound event to play
  169. float m_fPlaybackTime; // Length of time for sound event to play
  170. bool m_bHasBeenPlayed; // true = event has been played
  171. };
  172. class CStartOfRoundAudioPlayback
  173. {
  174. public:
  175. CStartOfRoundAudioPlayback() { m_NextAvailableTime = 1.0f; m_bPlaybackEnabled = false; }
  176. // Adds a sound event to be played at the next round restart
  177. void AddSound( CBaseEntity* pEntityPlayingSound, char* pName, float fDelayTime );
  178. // Play all the queued sounds
  179. void PlaySounds( void );
  180. // Clear all the queued sounds
  181. void ClearSounds( void );
  182. // Updates the playback when m_bPlaybackEnabled is valid
  183. void Update( void );
  184. void RemoveSoundByName( char* pName );
  185. protected:
  186. // List of sounds to play at start of round
  187. CUtlVector<RoundStartSoundPlaybackData> m_SoundEvents;
  188. // Time from start of round when the next added sound event can play
  189. float m_NextAvailableTime;
  190. // Allows Update() to be called so sounds can play
  191. bool m_bPlaybackEnabled;
  192. };
  193. //-----------------------------------------------------------------------------
  194. class C_CSPlayer : public C_BasePlayer, public CGameEventListener, public ICSPlayerAnimStateHelpers
  195. #if !defined( NO_STEAM ) && !defined( NO_STEAM_GAMECOORDINATOR )
  196. , public IHasAttributes
  197. #endif
  198. {
  199. public:
  200. DECLARE_CLASS( C_CSPlayer, C_BasePlayer );
  201. DECLARE_CLIENTCLASS();
  202. DECLARE_PREDICTABLE();
  203. DECLARE_INTERPOLATION();
  204. C_CSPlayer();
  205. ~C_CSPlayer();
  206. float * GetRenderClipPlane( void );
  207. float m_fRenderingClipPlane[4];
  208. int m_nLastClipPlaneSetupFrame;
  209. int m_nClipPlaneProximityLimitAttachmentIndex;
  210. Vector m_vecLastClipCameraPos;
  211. Vector m_vecLastClipCameraForward;
  212. bool m_bClipHitStaticWorld;
  213. bool m_bCachedPlaneIsValid;
  214. CBaseWeaponWorldModel *m_pClippingWeaponWorldModel;
  215. virtual void SetSequence(int nSequence) OVERRIDE;
  216. virtual bool Simulate();
  217. virtual void Spawn( void );
  218. virtual void UpdateOnRemove( void );
  219. virtual void OnSetDormant( bool bDormant );
  220. //EHANDLE GetCarriedHostage() const;
  221. void GiveCarriedHostage( EHANDLE hHostage );
  222. void RefreshCarriedHostage( bool bForceCreate );
  223. void RemoveCarriedHostage();
  224. bool HasDefuser() const;
  225. void GiveDefuser();
  226. void RemoveDefuser();
  227. bool HasNightVision() const;
  228. static C_CSPlayer* GetLocalCSPlayer();
  229. CSPlayerState State_Get() const;
  230. CSPlayerState m_previousPlayerState;
  231. virtual float GetMinFOV() const;
  232. // Get how much $$$ this guy has.
  233. int GetAccount() const;
  234. // Returns one of the CS_CLASS_ enums.
  235. int PlayerClass() const;
  236. bool IsInBuyZone();
  237. bool IsInBuyPeriod();
  238. bool CanBuyDuringImmunity();
  239. bool CanPlayerBuy( bool display );
  240. bool CanShowTeamMenu() const; // Returns true if we're allowed to show the team menu right now.
  241. // Get the amount of armor the player has.
  242. int ArmorValue() const;
  243. bool HasHelmet() const;
  244. bool HasHeavyArmor() const;
  245. // create tracers
  246. void CreateWeaponTracer( Vector vecStart, Vector vecEnd );
  247. virtual const QAngle& EyeAngles();
  248. virtual void CalcObserverView( Vector& eyeOrigin, QAngle& eyeAngles, float& fov );
  249. // observer mode
  250. void SetSpecWatchingGrenade( C_BaseEntity *pGrenade, bool bWatching );
  251. virtual int GetObserverMode() const;
  252. virtual CBaseEntity *GetObserverTarget() const;
  253. bool IsSpecFollowingGrenade( void ) {return m_bIsSpecFollowingGrenade; }
  254. bool IsHoldingSpecGrenadeKey( void );
  255. bool m_bIsSpecFollowingGrenade;
  256. EHANDLE m_hOldGrenadeObserverTarget;
  257. virtual void GetRenderBounds( Vector& theMins, Vector& theMaxs );
  258. virtual void GetShadowRenderBounds( Vector &mins, Vector &maxs, ShadowType_t shadowType );
  259. virtual bool GetShadowCastDirection( Vector *pDirection, ShadowType_t shadowType ) const;
  260. virtual void VPhysicsUpdate( IPhysicsObject *pPhysics );
  261. // Get the ID target entity index. The ID target is the player that is behind our crosshairs, used to
  262. // display the player's name.
  263. int GetIDTarget() const;
  264. int GetTargetedWeapon( void ) const;
  265. virtual void NotifyShouldTransmit( ShouldTransmitState_t state );
  266. virtual void ClientThink();
  267. virtual void OnTimeJump() OVERRIDE;
  268. virtual void OnDataChanged( DataUpdateType_t type );
  269. virtual void PostDataUpdate( DataUpdateType_t updateType );
  270. virtual bool Interpolate( float currentTime );
  271. virtual void UpdateStepSound( surfacedata_t *psurface, const Vector &vecOrigin, const Vector &vecVelocity );
  272. virtual surfacedata_t * GetFootstepSurface( const Vector &origin, const char *surfaceName );
  273. virtual void PlayClientJumpSound( void );
  274. virtual void ValidateModelIndex( void );
  275. static bool RenderLocalScreenSpaceEffect( CStrikeScreenSpaceEffect effect, IMatRenderContext *pRenderContext, int x, int y, int w, int h );
  276. bool AreScreenSpaceVomitParticlesActive( void ) const;
  277. bool DrawScreenSpaceVomitParticles( IMatRenderContext *pRenderContext );
  278. int GetHealth() const { return m_iHealth; }
  279. virtual int GetMaxHealth() const;
  280. bool Weapon_CanSwitchTo(C_BaseCombatWeapon *pWeapon);
  281. virtual void UpdateClientSideAnimation();
  282. virtual void ProcessMuzzleFlashEvent();
  283. void HandleTaserAnimation();
  284. virtual const Vector& GetRenderOrigin( void );
  285. bool CreateMove( float flInputSampleTime, CUserCmd *pCmd );
  286. CUtlVector< C_BaseParticleEntity* > m_SmokeGrenades;
  287. virtual bool ShouldDraw( void );
  288. virtual bool UpdateDispatchLayer( CAnimationLayer *pLayer, CStudioHdr *pWeaponStudioHdr, int iSequence ) OVERRIDE;
  289. virtual void AccumulateLayers( IBoneSetup &boneSetup, BoneVector pos[], BoneQuaternion q[], float currentTime );
  290. bool UpdateLayerWeaponDispatch( C_AnimationLayer *pLayer, int iSequence );
  291. virtual float GetLayerSequenceCycleRate( C_AnimationLayer *pLayer, int iSequence );
  292. virtual void BuildTransformations( CStudioHdr *pStudioHdr, BoneVector *pos, BoneQuaternion q[], const matrix3x4_t& cameraTransform, int boneMask, CBoneBitList &boneComputed );
  293. virtual void DoExtraBoneProcessing( CStudioHdr *pStudioHdr, BoneVector pos[], BoneQuaternion q[], matrix3x4a_t boneToWorld[], CBoneBitList &boneComputed, CIKContext *pIKContext ) OVERRIDE;
  294. virtual bool SetupBones( matrix3x4a_t *pBoneToWorldOut, int nMaxBones, int boneMask, float currentTime );
  295. void ReevauluateAnimLOD( int boneMask = 0 );
  296. virtual C_BaseAnimating * BecomeRagdollOnClient();
  297. virtual IRagdoll* GetRepresentativeRagdoll() const;
  298. virtual void TeamChange( int iNewTeam );
  299. void ImpactTrace( trace_t *pTrace, int iDamageType, char *pCustomImpactName );
  300. // Have this player play the sounds from his view model's reload animation.
  301. void PlayReloadEffect( int iActAnimID, const Vector *pOrigin = NULL );
  302. virtual void FireEvent( const Vector& origin, const QAngle& angles, int event, const char *options );
  303. virtual void DropPhysicsMag( const char *options ) OVERRIDE;
  304. bool HasC4( void );
  305. bool HasWeaponOfType( int nWeaponID ) const;
  306. virtual bool CreateLightEffects( void ) { return false; } //no dimlight effects
  307. // Sometimes the server wants to update the client's cycle to get the two to run in sync (for proper hit detection)
  308. virtual void SetServerIntendedCycle( float intended ) { m_serverIntendedCycle = intended; }
  309. virtual float GetServerIntendedCycle( void ) { return m_serverIntendedCycle; }
  310. virtual bool IsTaunting( void ) const { return m_bIsTaunting; }
  311. virtual bool IsThirdPersonTaunt( void ) const { return m_bIsThirdPersonTaunt; }
  312. virtual bool IsHoldingTaunt( void ) const { return m_bIsHoldingTaunt; }
  313. virtual bool IsLookingAtWeapon( void ) const { return m_bIsLookingAtWeapon; }
  314. virtual bool IsHoldingLookAtWeapon( void ) const { return m_bIsHoldingLookAtWeapon; }
  315. virtual float GetTauntYaw( void ) const { return m_flTauntYaw; }
  316. virtual const char *GetVOIPParticleEffectName() const { return SPEECH_VOIP_PARTICLE_EFFECT_NAME; }
  317. virtual const char *GetRadioHeadParticleEffectName() const { return RADIO_VOICE_PARTICLE_EFFECT_NAME; }
  318. virtual void UpdateRadioHeadIcon( bool bVoice );
  319. virtual bool ShouldShowRadioHeadIcon() const;
  320. virtual CNewParticleEffect *GetRadioHeadParticleEffect( void );
  321. virtual CNewParticleEffect *GetVOIPParticleEffect( void );
  322. virtual Vector GetParticleHeadLabelOffset( void );
  323. virtual bool HasSpeechVOIPParticleIconActive( void ) { return (m_speechVOIPParticleEffect && m_speechVOIPParticleEffect.IsValid()); }
  324. virtual void AddDecal( const Vector& rayStart, const Vector& rayEnd, const Vector& decalCenter, int hitbox, int decalIndex, bool doTrace, trace_t& tr, int maxLODToDecal );
  325. virtual void SetRenderAlpha( byte a );
  326. virtual void SetRenderMode( RenderMode_t nRenderMode, bool bForceUpdate = false );
  327. virtual int DrawModel( int flags, const RenderableInstance_t &instance );
  328. virtual bool ShouldReceiveProjectedTextures( int flags )
  329. {
  330. return ( this != C_BasePlayer::GetLocalPlayer() || IsTaunting() || ShouldDraw() );
  331. }
  332. void ClearSoundEvents()
  333. {
  334. m_SoundEvents.RemoveAll();
  335. }
  336. CsMusicType_t GetCurrentMusic() { return m_nCurrentMusic; } const
  337. void SetCurrentMusic( CsMusicType_t nMusicType )
  338. {
  339. m_nCurrentMusic = nMusicType;
  340. if( nMusicType == CSMUSIC_START )
  341. {
  342. m_flMusicRoundStartTime = gpGlobals->curtime;
  343. }
  344. m_flCurrentMusicStartTime = gpGlobals->curtime;
  345. }
  346. float GetCurrentMusicElapsed()
  347. {
  348. return gpGlobals->curtime - m_flCurrentMusicStartTime;
  349. }
  350. float GetMusicStartRoundElapsed()
  351. {
  352. return gpGlobals->curtime - m_flMusicRoundStartTime;
  353. }
  354. bool IsPlayerDominated( int iPlayerIndex );
  355. bool IsPlayerDominatingMe( int iPlayerIndex );
  356. virtual float GetFOV( void ) const;
  357. virtual void CalcFreezeCamView( Vector& eyeOrigin, QAngle& eyeAngles, float& fov );
  358. virtual void CalcDeathCamView( Vector& eyeOrigin, QAngle& eyeAngles, float& fov );
  359. void UpdateFreezeCamFlashlightEffect( C_BaseEntity *pTarget, float flAmount );
  360. void CancelFreezeCamFlashlightEffect();
  361. bool m_bFreezeCamFlashlightActive;
  362. CTextureReference m_freezeCamSpotLightTexture;
  363. virtual float GetDeathCamInterpolationTime();
  364. float GetFreezeFrameInterpolant( void );
  365. float GetFreezeFrameTilt( void ) { return m_flFreezeFrameTilt; }
  366. // check autoaim
  367. bool IsCursorOnAutoAimTarget();
  368. AcquireResult::Type CanAcquire( CSWeaponID weaponId, AcquireMethod::Type acquireMethod, CEconItemView *pItem = NULL );
  369. int GetCarryLimit( CSWeaponID weaponId );
  370. int GetWeaponPrice( CSWeaponID weaponId, const CEconItemView *pWepView = NULL ) const;
  371. CWeaponCSBase* CSWeapon_OwnsThisType( CEconItemView *pItem ) const;
  372. virtual bool ShouldRegenerateOriginFromCellBits() const;
  373. bool IsOtherSameTeam( int nTeam );
  374. bool IsOtherEnemy( CCSPlayer *pPlayer );
  375. bool IsOtherEnemy( int nEntIndex );
  376. bool IsOtherEnemyAndPlaying( int nEntIndex );
  377. virtual void SetModelPointer( const model_t *pModel );
  378. protected:
  379. CUtlReference< CNewParticleEffect > m_radioHeadIconParticleEffect;
  380. // Called by shared code.
  381. public:
  382. // ICSPlayerAnimState overrides.
  383. virtual CWeaponCSBase* CSAnim_GetActiveWeapon();
  384. virtual bool CSAnim_CanMove();
  385. void DoAnimationEvent( PlayerAnimEvent_t event, int nData = 0 );
  386. // Implemented in shared code.
  387. public:
  388. virtual float GetPlayerMaxSpeed();
  389. bool IsPrimaryOrSecondaryWeapon( CSWeaponType nType );
  390. bool GetUseConfigurationForHighPriorityUseEntity( CBaseEntity *pEntity, CConfigurationForHighPriorityUseEntity_t &cfg );
  391. CBaseEntity *GetUsableHighPriorityEntity( void );
  392. void GetBulletTypeParameters(
  393. int iBulletType,
  394. float &fPenetrationPower,
  395. float &flPenetrationDistance );
  396. void FireBullet(
  397. Vector vecSrc,
  398. const QAngle &shootAngles,
  399. float flDistance,
  400. float flPenetration,
  401. int nPenetrationCount,
  402. int iBulletType,
  403. int iDamage,
  404. float flRangeModifier,
  405. CBaseEntity *pevAttacker,
  406. bool bDoEffects,
  407. float xSpread, float ySpread );
  408. bool HandleBulletPenetration(
  409. float &flPenetration,
  410. int &iEnterMaterial,
  411. bool &hitGrate,
  412. trace_t &tr,
  413. Vector &vecDir,
  414. surfacedata_t *pSurfaceData,
  415. float flPenetrationModifier,
  416. float flDamageModifier,
  417. bool bDoEffects,
  418. int iDamageType,
  419. float flPenetrationPower,
  420. int &nPenetrationCount,
  421. Vector &vecSrc,
  422. float flDistance,
  423. float flCurrentDistance,
  424. float &fCurrentDamage );
  425. virtual QAngle GetAimPunchAngle( void );
  426. QAngle GetRawAimPunchAngle( void ) const;
  427. void KickBack(
  428. float fAngle,
  429. float fMagnitude );
  430. int GetDefaultCrouchedFOV( void ) const;
  431. void DisplayPenetrationDebug( Vector vecEnter, Vector vecExit, float flDistance, float flInitialDamage, float flDamageLostImpact, float flTotalLostDamage, short nEnterSurf, short nExitSurf );
  432. // Returns true if the player is allowed to move.
  433. bool CanMove() const;
  434. // Returns the player mask which includes the solid mask plus the team mask.
  435. virtual unsigned int PhysicsSolidMaskForEntity( void ) const;
  436. void OnJump( float fImpulse );
  437. void OnLand( float fVelocity );
  438. bool HasC4() const; // Is this player carrying a C4 bomb?
  439. bool IsVIP() const; // Is this player the VIP?
  440. virtual void SetAnimation( PLAYER_ANIM playerAnim );
  441. virtual bool ShouldInterpolate( void );
  442. public:
  443. void UpdateIDTarget( void );
  444. void UpdateTargetedWeapon( void );
  445. void RemoveAddonModels( void );
  446. void UpdateMinModels( void );
  447. void CreateC4Effect( CBaseEntity *pEnt, bool bIsWeaponModel );
  448. void RemoveC4Effect( bool bIsWeaponModel );
  449. void SetActivity( Activity eActivity );
  450. Activity GetActivity( void ) const;
  451. void DoAnimStateEvent( PlayerAnimEvent_t evt );
  452. // Global/static methods
  453. virtual void ThirdPersonSwitch( bool bThirdperson );
  454. virtual void CalcView( Vector &eyeOrigin, QAngle &eyeAngles, float &zNear, float &zFar, float &fov );
  455. public:
  456. IPlayerAnimState *m_PlayerAnimState;
  457. CCSGOPlayerAnimState *m_PlayerAnimStateCSGO;
  458. virtual Vector Weapon_ShootPosition();
  459. // Used to control animation state.
  460. Activity m_Activity;
  461. CNetworkVar( bool, m_bIsScoped );
  462. CNetworkVar( bool, m_bIsWalking );
  463. // Predicted variables.
  464. CNetworkVar( bool, m_bResumeZoom );
  465. CNetworkVar( CSPlayerState, m_iPlayerState ); // SupraFiend: this gives the current state in the joining process, the states are listed above
  466. CNetworkVar( bool, m_bIsDefusing ); // tracks whether this player is currently defusing a bomb
  467. CNetworkVar( bool, m_bIsGrabbingHostage ); // tracks whether this player is currently defusing a bomb
  468. CNetworkVar( bool, m_bIsRescuing ); // tracks whether this player is currently rescuing a hostage
  469. CNetworkVar( float, m_fImmuneToGunGameDamageTime ); // When gun game spawn damage immunity will expire
  470. float m_fImmuneToGunGameDamageTimeLast;
  471. CNetworkVar( bool, m_bGunGameImmunity ); // tracks whether this player is currently immune in gun game
  472. CNetworkVar( bool, m_bHasMovedSinceSpawn ); // Whether player has moved from spawn position
  473. CNetworkVar( bool, m_bMadeFinalGunGameProgressiveKill );
  474. CNetworkVar( int, m_iGunGameProgressiveWeaponIndex ); // index of current gun game weapon
  475. CNetworkVar( int, m_iNumGunGameTRKillPoints ); // number of kill points accumulated so far in TR Gun Game mode (resets to 0 when weapon is upgraded)
  476. CNetworkVar( int, m_iNumGunGameKillsWithCurrentWeapon );
  477. CNetworkVar( int, m_iNumRoundKills ); // number of kills a player has gotten in a round
  478. CNetworkVar( int, m_iNumRoundKillsHeadshots ); // number of headshot kills a player has gotten in a round
  479. CNetworkVar( float, m_fMolotovUseTime ); // Molotov can be used if current time is after this time
  480. CNetworkVar( float, m_fMolotovDamageTime ); // Last time when this player was burnt by Molotov damage
  481. CNetworkVar( bool, m_bInBombZone );
  482. CNetworkVar( bool, m_bInBuyZone );
  483. CNetworkVar( bool, m_bInNoDefuseArea );
  484. CNetworkVar( int, m_iThrowGrenadeCounter ); // used to trigger grenade throw animations.
  485. CNetworkVar( bool, m_bWaitForNoAttack ); // flag to indicate player cannot attack until the attack button is released
  486. CNetworkVar( bool, m_bIsRespawningForDMBonus ); // flag to indicate player wants to spawn with the deathmatch bonus weapons
  487. CNetworkVar( float, m_flGuardianTooFarDistFrac );
  488. CNetworkVar( float, m_flDetectedByEnemySensorTime );
  489. float m_flNextGuardianTooFarWarning;
  490. CNetworkVar( bool, m_bKilledByTaser );
  491. CNetworkVar( int, m_iMoveState ); // Is the player trying to run or walk or idle? Tells us what the player is "trying" to do.
  492. CNetworkVar( bool, m_bCanMoveDuringFreezePeriod );
  493. CNetworkVar( bool, m_isCurrentGunGameLeader );
  494. CNetworkVar( bool, m_isCurrentGunGameTeamLeader );
  495. CNetworkString( m_szArmsModel, MAX_MODEL_STRING_SIZE ); // Which arms we're using for the view model.
  496. const PlayerViewmodelArmConfig *m_pViewmodelArmConfig;
  497. CNetworkVar( float, m_flLowerBodyYawTarget );
  498. CNetworkVar( bool, m_bStrafing );
  499. bool m_bUseNewAnimstate;
  500. CBoneSnapshot m_boneSnapshots[2];
  501. bool IsAnyBoneSnapshotPending( void );
  502. float m_flLastSpawnTimeIndex;
  503. virtual void NotifyOnLayerChangeSequence( const CAnimationLayer* pLayer, const int nNewSequence ) OVERRIDE;
  504. virtual void NotifyOnLayerChangeWeight( const CAnimationLayer* pLayer, const float flNewWeight ) OVERRIDE;
  505. virtual void NotifyOnLayerChangeCycle( const CAnimationLayer* pLayer, const float flNewCycle ) OVERRIDE;
  506. bool IsInHostageRescueZone( void );
  507. // This is a combination of the ADDON_ flags in cs_shareddefs.h.
  508. CNetworkVar( int, m_iAddonBits );
  509. // Clients don't know about holstered weapons, so we need to be told about them here
  510. CNetworkVar( int, m_iPrimaryAddon );
  511. CNetworkVar( int, m_iSecondaryAddon );
  512. // How long the progress bar takes to get to the end. If this is 0, then the progress bar
  513. // should not be drawn.
  514. CNetworkVar( int, m_iProgressBarDuration );
  515. // When the progress bar should start.
  516. CNetworkVar( float, m_flProgressBarStartTime );
  517. CNetworkVar( float, m_flStamina );
  518. CNetworkVar( int, m_iDirection ); // The current lateral kicking direction; 1 = right, 0 = left
  519. CNetworkVar( int, m_iShotsFired ); // number of shots fired recently
  520. CNetworkVar( int, m_nNumFastDucks ); // UNUSED. Kept for backwards demo compatibility. $$$REI TODO: Investigate safely removing variables
  521. CNetworkVar( bool, m_bDuckOverride ); // force the player to duck regardless of if they're holding crouch
  522. CNetworkVar( bool, m_bNightVisionOn );
  523. CNetworkVar( bool, m_bHasNightVision );
  524. CNetworkVar( float, m_flVelocityModifier );
  525. CNetworkVar( float, m_flGroundAccelLinearFracLastTime );
  526. CNetworkVar( int, m_iStartAccount ); // how much cash the player started the round with
  527. CNetworkVar( int, m_totalHitsOnServer );
  528. CNetworkVar( bool, m_bIsBuyMenuOpen );
  529. bool IsBuyMenuOpen( void ) { return m_bIsBuyMenuOpen; }
  530. void SetBuyMenuOpen( bool bOpen );
  531. EHANDLE m_hRagdoll;
  532. EHANDLE m_hCarriedHostage;
  533. EHANDLE m_hCarriedHostageProp;
  534. bool m_bPlayingHostageCarrySound;
  535. CWeaponCSBase* GetActiveCSWeapon() const;
  536. CWeaponCSBase* GetCSWeapon( CSWeaponID id ) const;
  537. virtual ShadowType_t ShadowCastType();
  538. #ifdef CS_SHIELD_ENABLED
  539. bool HasShield( void ) { return m_bHasShield; }
  540. bool IsShieldDrawn( void ) { return m_bShieldDrawn; }
  541. void SetShieldDrawnState( bool bState ) { m_bShieldDrawn = bState; }
  542. #else
  543. bool HasShield( void ) { return false; }
  544. bool IsShieldDrawn( void ) { return false; }
  545. void SetShieldDrawnState( bool bState ) {}
  546. #endif
  547. bool IsMiniScoreHidden( void ) { return m_bHud_MiniScoreHidden; }
  548. bool IsRadarHidden( void ) { return m_bHud_RadarHidden; }
  549. virtual int GetLastKillerIndex( void ) { return m_nLastKillerIndex; }
  550. int GetLastConcurrentKilled( void ) { return m_nLastConcurrentKilled; }
  551. int GetDeathCamMusicIndex( void ) { return m_nDeathCamMusic; }
  552. float m_flNightVisionAlpha;
  553. float m_flFlashBangTime; // end time
  554. float m_flFlashScreenshotAlpha;
  555. float m_flFlashOverlayAlpha;
  556. bool m_bFlashBuildUp;
  557. bool m_bFlashDspHasBeenCleared;
  558. bool m_bFlashScreenshotHasBeenGrabbed;
  559. bool IsFlashBangActive( void ) { return ( m_flFlashDuration > 0.0f ) && ( gpGlobals->curtime < m_flFlashBangTime ); }
  560. bool IsFlashBangBuildUpActive( void ) { return m_bFlashBuildUp && IsFlashBangActive(); }
  561. float GetFlashStartTime( void ) { return (m_flFlashBangTime - m_flFlashDuration); }
  562. float GetFlashTimeElapsed( void ) { return MAX( gpGlobals->curtime - GetFlashStartTime(), 0.0f ); }
  563. bool IsBlinded( void ) { return (m_flFlashBangTime - 1.0f) > gpGlobals->curtime; }
  564. CNetworkVar( float, m_flFlashMaxAlpha );
  565. CNetworkVar( float, m_flFlashDuration );
  566. float GetLastFiredWeaponTime( void ) { return m_flLastFiredWeaponTime; }
  567. float m_flLastFiredWeaponTime;
  568. // Having the RecvProxy in the player allows us to keep the var private
  569. static void RecvProxy_CycleLatch( const CRecvProxyData *pData, void *pStruct, void *pOut );
  570. // Bots and hostages auto-duck during jumps
  571. bool m_duckUntilOnGround;
  572. Vector m_lastStandingPos; // used by the gamemovement code for finding ladders
  573. void SurpressLadderChecks( const Vector& pos, const Vector& normal );
  574. bool CanGrabLadder( const Vector& pos, const Vector& normal );
  575. // [tj] checks if this player has another given player on their Steam friends list.
  576. bool HasPlayerAsFriend( C_CSPlayer* player );
  577. bool MadeFinalGunGameProgressiveKill( void ) { return m_bMadeFinalGunGameProgressiveKill; }
  578. int GetPlayerGunGameWeaponIndex( void ) { return m_iGunGameProgressiveWeaponIndex; }
  579. int GetNumGunGameTRKillPoints( void ) { return m_iNumGunGameTRKillPoints; }
  580. int GetNumGunGameKillsWithCurrentWeapon( void ) { return m_iNumGunGameKillsWithCurrentWeapon; }
  581. int GetNumRoundKills( void ) { return m_iNumRoundKills; }
  582. int GetNumRoundKillsHeadshots( void ) { return m_iNumRoundKillsHeadshots; }
  583. void DisplayInventory(bool showPistol);
  584. bool CanUseGrenade( CSWeaponID );
  585. MedalRank_t GetRank( MedalCategory_t category );
  586. uint32 GetMusicID( void );
  587. void ToggleRandomWeapons( void );
  588. bool ShouldShowTeamPlayerColors( int nOtherTeamNum );
  589. bool ShouldShowTeamPlayerColorLetters( void );
  590. static void UpdateGlowsForAllPlayers( void );
  591. CGlowObject m_GlowObject;
  592. uint16 GetCurrentEquipmentValue ( void ) const { return m_unCurrentEquipmentValue; }
  593. uint16 GetRoundStartEquipmentValue ( void ) const { return m_unRoundStartEquipmentValue; }
  594. uint16 GetFreezetimeEndEquipmentValue ( void ) const { return m_unFreezetimeEndEquipmentValue; }
  595. bool IsAbleToInstantRespawn( void );
  596. char const * IsAbleToApplySpray( trace_t *ptr, Vector *pvecForward, Vector *pvecRight );
  597. float GetLastSmokeOverlayAlpha( void ) const { return m_flLastSmokeOverlayAlpha; }
  598. char *GetHalloweenMaskModelAddon( C_CSPlayer *pPlayer );
  599. uint32 GetActiveQuestID( void ) const;
  600. QuestProgress::Reason GetQuestProgressReason( void ) const;
  601. Vector m_vecLastMuzzleFlashPos;
  602. QAngle m_angLastMuzzleFlashAngle;
  603. EHANDLE m_hMuzzleFlashShape;
  604. int m_iHealthBarRenderMaskIndex;
  605. float m_flHealthFadeValue;
  606. float m_flHealthFadeAlpha;
  607. // Match Stats data
  608. int m_iMatchStats_Kills[ MAX_MATCH_STATS_ROUNDS ]; //kills, per round
  609. int m_iMatchStats_Damage[ MAX_MATCH_STATS_ROUNDS ]; //damage, per round
  610. int m_iMatchStats_EquipmentValue[ MAX_MATCH_STATS_ROUNDS ]; //Equipment value, per round
  611. int m_iMatchStats_MoneySaved[ MAX_MATCH_STATS_ROUNDS ]; //Saved money, per round
  612. int m_iMatchStats_KillReward[ MAX_MATCH_STATS_ROUNDS ];
  613. int m_iMatchStats_LiveTime[ MAX_MATCH_STATS_ROUNDS ];
  614. int m_iMatchStats_Deaths[ MAX_MATCH_STATS_ROUNDS ];
  615. int m_iMatchStats_Assists[ MAX_MATCH_STATS_ROUNDS ];
  616. int m_iMatchStats_HeadShotKills[ MAX_MATCH_STATS_ROUNDS ];
  617. int m_iMatchStats_Objective[ MAX_MATCH_STATS_ROUNDS ];
  618. int m_iMatchStats_CashEarned[ MAX_MATCH_STATS_ROUNDS ];
  619. int m_iMatchStats_UtilityDamage[ MAX_MATCH_STATS_ROUNDS ];
  620. int m_iMatchStats_EnemiesFlashed[ MAX_MATCH_STATS_ROUNDS ];
  621. CUtlReference<CNewParticleEffect> m_ARScreenGlowEffect;
  622. private:
  623. void AnimateGlows( void );
  624. void UpdateGlows( void );
  625. void UpdateFlashBangEffect( void );
  626. CountdownTimer m_ladderSurpressionTimer;
  627. Vector m_lastLadderNormal;
  628. Vector m_lastLadderPos;
  629. ClientCCHandle_t m_CCDeathHandle; // handle to death cc effect
  630. float m_flDeathCCWeight; // for fading in cc effect
  631. bool m_bFreezeFrameCloseOnKiller;
  632. int m_nFreezeFrameShiftSideDist;
  633. Vector m_vecFreezeFrameEnd;
  634. QAngle m_vecFreezeFrameAnglesStart;
  635. float m_flFreezeFrameTilt;
  636. bool m_bOldIsScoped;
  637. CNetworkVar( QuestProgress::Reason, m_nQuestProgressReason );
  638. CNetworkVar( uint16, m_unCurrentEquipmentValue );
  639. CNetworkVar( uint16, m_unRoundStartEquipmentValue );
  640. CNetworkVar( uint16, m_unFreezetimeEndEquipmentValue );
  641. CNetworkArray( MedalRank_t, m_rank, MEDAL_CATEGORY_COUNT );
  642. CNetworkVar( uint16, m_unMusicID );
  643. void ProcessSpottedEntityUpdate( void );
  644. void UpdateSoundEvents( void );
  645. // void HandleTauntSound( void );
  646. void CreateNewCustomClothingModels( void );
  647. void UpdateCustomClothingModels( void );
  648. private:
  649. bool ApplyCompositeMaterialsToCustomClothingModel( C_BaseAnimating* pTargetEntity, CEconItemView *pItem, int nSlotId, bool bForceRegenerate /*= false */ ) const;
  650. void CreateAddonModel( int i );
  651. void UpdateAddonModels( bool bForce = false );
  652. bool m_bAddonModelsAreOutOfDate;
  653. void UpdateHostageCarryModels();
  654. void PushawayThink();
  655. Vector m_vecThirdPersonViewPositionOverride;
  656. virtual Vector GetThirdPersonViewPosition( void );
  657. //=============================================================================
  658. // HPE_BEGIN:
  659. // [dwenger] Added for auto-buy functionality
  660. //=============================================================================
  661. void FireGameEvent( IGameEvent *event );
  662. //=============================================================================
  663. // HPE_END
  664. //=============================================================================
  665. int m_iAccount;
  666. bool m_bHasHelmet;
  667. bool m_bHasHeavyArmor;
  668. int m_iClass;
  669. int m_ArmorValue;
  670. QAngle m_angEyeAngles;
  671. bool m_bHasDefuser;
  672. bool m_bInHostageRescueZone;
  673. float m_fNextThinkPushAway;
  674. // Glow stuff
  675. float m_fNextGlowCheckUpdate;
  676. float m_fNextGlowCheckInterval;
  677. float m_fGlowAlpha;
  678. float m_fGlowAlphaTarget;
  679. float m_fGlowAlphaUpdateTime;
  680. float m_fGlowAlphaTargetTime;
  681. static bool s_bPlayingFreezeCamSound;
  682. bool m_bShouldAutobuyDMWeapons;
  683. //=============================================================================
  684. // HPE_BEGIN:
  685. // [dwenger] Added for auto-buy functionality
  686. //=============================================================================
  687. bool m_bShouldAutobuyNow;
  688. //=============================================================================
  689. // HPE_END
  690. //=============================================================================
  691. #ifdef CS_SHIELD_ENABLED
  692. bool m_bHasShield;
  693. bool m_bShieldDrawn;
  694. #endif
  695. bool m_bHud_MiniScoreHidden;
  696. bool m_bHud_RadarHidden;
  697. int m_nLastKillerIndex;
  698. int m_nLastConcurrentKilled;
  699. int m_nDeathCamMusic;
  700. CInterpolatedVar< QAngle > m_iv_angEyeAngles;
  701. // ID Target
  702. int m_iIDEntIndex;
  703. CountdownTimer m_delayTargetIDTimer;
  704. int m_iTargetedWeaponEntIndex;
  705. // Show the ID target after the cursor leaves the entity
  706. int m_iOldIDEntIndex;
  707. CountdownTimer m_holdTargetIDTimer;
  708. void ReleaseFlashlight( void );
  709. Beam_t *m_pFlashlightBeam;
  710. class CCSSoundEvent
  711. {
  712. public:
  713. CCSSoundEvent() : m_bHasSoundOrigin(false) {}
  714. string_t m_SoundName;
  715. float m_flEventTime; // Play the event when gpGlobals->curtime goes past this.
  716. Vector m_SoundOrigin;
  717. bool m_bHasSoundOrigin;
  718. };
  719. CUtlLinkedList<CCSSoundEvent,int> m_SoundEvents;
  720. // List of sounds to play at start of round
  721. CStartOfRoundAudioPlayback m_StartOfRoundSoundEvents;
  722. // manage per play music
  723. CsMusicType_t m_nCurrentMusic;
  724. float m_flCurrentMusicStartTime;
  725. float m_flMusicRoundStartTime;
  726. // This is the list of addons hanging off the guy (grenades, C4, nightvision, etc).
  727. CUtlLinkedList<CAddonModel, int> m_AddonModels;
  728. int m_iLastAddonBits;
  729. int m_iLastPrimaryAddon;
  730. int m_iLastSecondaryAddon;
  731. CUtlReference<CNewParticleEffect> m_hC4AddonLED;
  732. CUtlReference<CNewParticleEffect> m_hC4WeaponLED;
  733. int m_cycleLatch; // server periodically updates this to fix up our anims, here it is a 4 bit fixed point
  734. float m_serverIntendedCycle; // server periodically updates this to fix up our anims, here it is the float we want, or -1 for no override
  735. // [tj] Network variables that track who are dominating and being dominated by
  736. CNetworkArray( bool, m_bPlayerDominated, MAX_PLAYERS+1 ); // array of state per other player whether player is dominating other players
  737. CNetworkArray( bool, m_bPlayerDominatingMe, MAX_PLAYERS+1 ); // array of state per other player whether other players are dominating this player
  738. CNetworkArray( int, m_iWeaponPurchasesThisRound, MAX_WEAPONS ); // number of times each weapon purchased this round; used to limit repurchases
  739. CNetworkVar( bool, m_bIsTaunting );
  740. CNetworkVar( bool, m_bIsThirdPersonTaunt );
  741. CNetworkVar( bool, m_bIsHoldingTaunt );
  742. CNetworkVar( float, m_flTauntYaw );
  743. CNetworkVar( bool, m_bIsLookingAtWeapon );
  744. CNetworkVar( bool, m_bIsHoldingLookAtWeapon );
  745. bool m_bWasTaunting;
  746. bool m_bTauntInterpolating;
  747. CameraThirdData_t m_TauntCameraData;
  748. float m_flTauntCamCurrentDist;
  749. float m_flTauntCamTargetDist;
  750. QAngle m_angTauntPredViewAngles;
  751. QAngle m_angTauntEngViewAngles;
  752. public:
  753. float m_flThirdpersonRecoil;
  754. // taser items
  755. float m_nextTaserShakeTime;
  756. float m_firstTaserShakeTime;
  757. float m_flLastSmokeOverlayAlpha;
  758. C_CSPlayer( const C_CSPlayer & );
  759. // For interpolating between observer targets
  760. protected:
  761. void UpdateObserverTargetVisibility( void ) const;
  762. Vector m_vecObserverInterpolateOffset; // Offset vec applied to the view which decays over time
  763. Vector m_vecObserverInterpStartPos;
  764. float m_flObsInterp_PathLength; // Full path lenght being interpolated
  765. Quaternion m_qObsInterp_OrientationStart;
  766. Quaternion m_qObsInterp_OrientationTravelDir;
  767. eObserverInterpState m_obsInterpState;
  768. bool m_bObserverInterpolationNeedsDeferredSetup;
  769. public:
  770. bool ShouldInterpolateObserverChanges() const;
  771. void StartObserverInterpolation( const QAngle &startAngles );
  772. virtual eObserverInterpState GetObserverInterpState( void ) const OVERRIDE;
  773. virtual bool IsInObserverInterpolation( void ) const OVERRIDE { return ShouldInterpolateObserverChanges() && m_obsInterpState != OBSERVER_INTERP_NONE; }
  774. virtual void SetObserverTarget( EHANDLE hObserverTarget ) OVERRIDE;
  775. void InterpolateObserverView( Vector& vOrigin, QAngle& vAngles );
  776. Vector GetObserverInterpolatedOffsetVector( void ) { return m_vecObserverInterpolateOffset; }
  777. bool IsAssassinationTarget( void ) const;
  778. private:
  779. CNetworkVar( bool, m_bIsAssassinationTarget ); // This player is an assassination target for an active mission
  780. #if CS_CONTROLLABLE_BOTS_ENABLED
  781. public:
  782. bool IsControllingBot() const { return m_bIsControllingBot; }
  783. bool CanControlObservedBot() const { return m_bCanControlObservedBot; }
  784. int GetControlledBotIndex() const { return m_iControlledBotEntIndex; }
  785. virtual bool GetAttachment( int number, matrix3x4_t &matrix );
  786. virtual bool GetAttachment( int number, Vector &origin );
  787. virtual bool GetAttachment( int number, Vector &origin, QAngle &angles );
  788. private:
  789. bool m_bIsControllingBot; // Are we controlling a bot?
  790. // Note that this can be TRUE even if GetControlledPlayer() returns NULL, IFF we started controlling a bot and then the bot was deleted for some reason.
  791. bool m_bCanControlObservedBot; // True if the player can control the bot s/he is observing
  792. int m_iControlledBotEntIndex;
  793. void UpdateFirstPersonShadowCasters( void );
  794. float m_flNextMagDropTime;
  795. int m_nLastMagDropAttachmentIndex;
  796. CNetworkVar( bool, m_bHasControlledBotThisRound );
  797. #endif
  798. public:
  799. int GetEloBracket( void ) const;
  800. void SetEloBracket ( int bracket );
  801. #if !defined( NO_STEAM ) && !defined( NO_STEAM_GAMECOORDINATOR )
  802. public:
  803. // IHasAttributes
  804. CAttributeManager *GetAttributeManager( void ) {
  805. #if defined( USE_PLAYER_ATTRIBUTE_MANAGER )
  806. return &m_AttributeManager;
  807. #else
  808. return NULL;
  809. #endif
  810. }
  811. CAttributeContainer *GetAttributeContainer( void ) { return NULL; }
  812. CBaseEntity *GetAttributeOwner( void ) { return NULL; }
  813. CAttributeList *GetAttributeList( void ) {
  814. #if defined( USE_PLAYER_ATTRIBUTE_MANAGER )
  815. return &m_AttributeList;
  816. #else
  817. return NULL;
  818. #endif
  819. }
  820. virtual void ReapplyProvision( void ) { return; }
  821. #if defined( USE_PLAYER_ATTRIBUTE_MANAGER )
  822. protected:
  823. CNetworkVarEmbedded( CAttributeContainerPlayer, m_AttributeManager );
  824. #endif
  825. //----------------------------
  826. // INVENTORY MANAGEMENT
  827. public:
  828. // Inventory access
  829. #if defined ENABLE_CLIENT_INVENTORIES_FOR_OTHER_PLAYERS
  830. CCSPlayerInventory *Inventory( void );
  831. CEconItemView *GetEquippedItemInLoadoutSlot( int iLoadoutSlot ) { return Inventory()->GetInventoryItemByItemID( m_EquippedLoadoutItemIndices[iLoadoutSlot] ); }
  832. CEconItemView *GetEquippedItemInLoadoutSlotOrBaseItem( int iLoadoutSlot );
  833. #endif
  834. private:
  835. // Items that have been equipped on this player instance (the inventory loadout may have changed)
  836. itemid_t m_EquippedLoadoutItemIndices[LOADOUT_POSITION_COUNT];
  837. #endif //!defined( NO_STEAM ) && !defined( NO_STEAM_GAMECOORDINATOR )
  838. public:
  839. void ClearAllBulletHitModels( void );
  840. void UpdateAllBulletHitModels( void );
  841. CUtlVector< C_BulletHitModel* > m_vecBulletHitModels;
  842. // This code allowed us to measure discrepency between client and server bullet hits.
  843. // It became obsolete when we started using a separate seed for client and server
  844. // to eliminate 'rage' hacks.
  845. //
  846. CUtlVector< clientHitVerify_t > m_vecBulletVerifyListClient;
  847. CUtlVector< clientHitVerify_t > m_vecBulletVerifyListServer;
  848. void CompareClientServerBulletHits( void );
  849. CUserMessageBinder m_UMCMsgReportHit;
  850. uint8 m_ui8ClientServerHitDifference;
  851. // Ammo count at death OGS data
  852. struct roundEndAmmoCount_t
  853. {
  854. roundEndAmmoCount_t()
  855. {
  856. V_memset( this, 0, sizeof( *this ) );
  857. }
  858. int nPrimaryWeaponDefIndex;
  859. int nPrimaryWeaponAmmoCount;
  860. int nSecondaryWeaponDefIndex;
  861. int nSecondaryWeaponAmmoCount;
  862. };
  863. roundEndAmmoCount_t m_roundEndAmmoCount;
  864. Vector m_vecLastAliveLocalVelocity;
  865. private:
  866. void RecordAmmoForRound( void );
  867. Vector m_vecLastContactShadowTraceOriginLeft;
  868. Vector m_vecLastContactShadowTraceOriginRight;
  869. float m_flLastContactShadowGroundHeightLeft;
  870. float m_flLastContactShadowGroundHeightRight;
  871. public:
  872. EHANDLE m_hContactShadowLeft;
  873. EHANDLE m_hContactShadowRight;
  874. void CreateClientEffectModels( void );
  875. void RemoveClientEffectModels( void );
  876. };
  877. C_CSPlayer* GetLocalOrInEyeCSPlayer( void );
  878. C_CSPlayer* GetHudPlayer( void ); // get the player we should show the HUD for (local or observed)
  879. inline C_CSPlayer *ToCSPlayer( CBaseEntity *pEntity )
  880. {
  881. if ( !pEntity || !pEntity->IsPlayer() )
  882. return NULL;
  883. return assert_cast<C_CSPlayer*>( pEntity );
  884. }
  885. namespace vgui
  886. {
  887. class IImage;
  888. }
  889. vgui::IImage* GetDefaultAvatarImage( C_BasePlayer *pPlayer );
  890. void AddSmokeGrenade( Vector location, int iEntityId );
  891. void AddSmokeGrenadeHandle( EHANDLE hGrenade );
  892. void RemoveSmokeGrenade( Vector location, int iEntityId );
  893. void RemoveSmokeGrenadeHandle( EHANDLE hGrenade );
  894. void RemoveAllSmokeGrenades( void );
  895. void RemoveSmokeGrenadeHandle( EHANDLE hGrenade );
  896. bool LineGoesThroughSmoke( Vector from, Vector to, bool grenadeBloat );
  897. void TruncatePlayerName( wchar_t *pCleanedHTMLName, int destLen, int nTruncateAt, bool bSkipHTML = false );
  898. class C_CSRagdoll : public C_BaseAnimatingOverlay
  899. {
  900. public:
  901. DECLARE_CLASS( C_CSRagdoll, C_BaseAnimatingOverlay );
  902. DECLARE_CLIENTCLASS();
  903. C_CSRagdoll();
  904. ~C_CSRagdoll();
  905. virtual void OnDataChanged( DataUpdateType_t type );
  906. int GetPlayerEntIndex() const;
  907. IRagdoll* GetIRagdoll() const;
  908. void GetRagdollInitBoneArrays( matrix3x4a_t *pDeltaBones0, matrix3x4a_t *pDeltaBones1, matrix3x4a_t *pCurrentBones, float boneDt );
  909. void GetRagdollInitBoneArraysYawMode( matrix3x4a_t *pDeltaBones0, matrix3x4a_t *pDeltaBones1, matrix3x4a_t *pCurrentBones, float boneDt );
  910. void ApplyRandomTaserForce( void );
  911. void ImpactTrace( trace_t *pTrace, int iDamageType, char *pCustomImpactName );
  912. bool IsInitialized() { return m_bInitialized; }
  913. virtual void ValidateModelIndex( void );
  914. void SetRagdollClientSideAddon( uint32 uiAddonMask );
  915. int BloodColor(){ return BLOOD_COLOR_RED; }
  916. void ApplySemiRandomDirectionalForce( Vector vecDir, float flStrength );
  917. void AttachWearableGibsFromPlayer( C_CSPlayer *pParentPlayer );
  918. void DestroyAttachedWearableGibs( void );
  919. int GetDeathPose( void ) { return m_iDeathPose; }
  920. private:
  921. C_CSRagdoll( const C_CSRagdoll & ) :m_nGlowObjectHandle( -1) { }
  922. void DestroyGlowObject();
  923. void Interp_Copy( C_BaseAnimatingOverlay *pSourceEntity );
  924. void CreateLowViolenceRagdoll( void );
  925. void CreateCSRagdoll( void );
  926. private:
  927. EHANDLE m_hPlayer;
  928. CHandle<C_BaseAnimating> m_hHolidayHatAddon;
  929. CHandle<C_BaseAnimating> m_hHolidayGhostAddon;
  930. CHandle<C_BaseAnimating> m_hAssassinationTargetAddon;
  931. CNetworkVector( m_vecRagdollVelocity );
  932. CNetworkVector( m_vecRagdollOrigin );
  933. CNetworkVar(int, m_iDeathPose );
  934. CNetworkVar(int, m_iDeathFrame );
  935. CNetworkVar(float, m_flDeathYaw );
  936. CNetworkVar(float, m_flAbsYaw );
  937. bool m_bInitialized;
  938. int m_nGlowObjectHandle;
  939. };
  940. #endif // C_CS_PLAYER_H