Team Fortress 2 Source Code as on 22/4/2020
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.

996 lines
31 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef C_TF_PLAYER_H
  7. #define C_TF_PLAYER_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "tf_playeranimstate.h"
  12. #include "c_baseplayer.h"
  13. #include "tf_shareddefs.h"
  14. #include "baseparticleentity.h"
  15. #include "tf_player_shared.h"
  16. #include "c_tf_playerclass.h"
  17. #include "tf_item.h"
  18. #include "props_shared.h"
  19. #include "hintsystem.h"
  20. #include "c_playerattachedmodel.h"
  21. #include "c_playerrelativemodel.h"
  22. #include "iinput.h"
  23. #include "ihasattributes.h"
  24. #include "GameEventListener.h"
  25. #include "tf_item_inventory.h"
  26. #include "c_tf_mvm_boss_progress_user.h"
  27. #include "c_te_legacytempents.h"
  28. class C_MuzzleFlashModel;
  29. class C_BaseObject;
  30. class C_TFRagdoll;
  31. class C_TFWearable;
  32. class C_CaptureZone;
  33. class C_MerasmusBombEffect;
  34. class CTFReviveDialog;
  35. class C_TFDroppedWeapon;
  36. class C_PasstimePlayerReticle;
  37. class C_PasstimeAskForBallReticle;
  38. extern ConVar tf_medigun_autoheal;
  39. extern ConVar cl_autorezoom;
  40. extern ConVar cl_autoreload;
  41. enum EBonusEffectFilter_t
  42. {
  43. kEffectFilter_AttackerOnly,
  44. kEffectFilter_AttackerTeam,
  45. kEffectFilter_VictimOnly,
  46. kEffectFilter_VictimTeam,
  47. kEffectFilter_AttackerAndVictimOnly,
  48. kEffectFilter_BothTeams,
  49. };
  50. struct BonusEffect_t
  51. {
  52. BonusEffect_t( const char* pszSoundName, const char* pszParticleName, EBonusEffectFilter_t eParticleFilter, EBonusEffectFilter_t eSoundFilter, bool bPlaySoundInAttackersEars )
  53. : m_pszSoundName( pszSoundName )
  54. , m_pszParticleName( pszParticleName )
  55. , m_eParticleFilter( eParticleFilter )
  56. , m_eSoundFilter( eSoundFilter )
  57. , m_bPlaySoundInAttackersEars( bPlaySoundInAttackersEars )
  58. {}
  59. const char* m_pszSoundName;
  60. const char* m_pszParticleName;
  61. EBonusEffectFilter_t m_eParticleFilter;
  62. EBonusEffectFilter_t m_eSoundFilter;
  63. bool m_bPlaySoundInAttackersEars;
  64. };
  65. //-----------------------------------------------------------------------------
  66. // Purpose:
  67. //-----------------------------------------------------------------------------
  68. class C_TFPlayer : public C_BasePlayer, public IHasAttributes, public IInventoryUpdateListener, public C_TFMvMBossProgressUser
  69. {
  70. public:
  71. DECLARE_CLASS( C_TFPlayer, C_BasePlayer );
  72. DECLARE_CLIENTCLASS();
  73. DECLARE_PREDICTABLE();
  74. DECLARE_INTERPOLATION();
  75. C_TFPlayer();
  76. ~C_TFPlayer();
  77. virtual void Spawn();
  78. static C_TFPlayer* GetLocalTFPlayer();
  79. virtual void UpdateOnRemove( void );
  80. virtual const QAngle& GetRenderAngles();
  81. virtual void UpdateClientSideAnimation();
  82. virtual void SetDormant( bool bDormant );
  83. virtual void OnPreDataChanged( DataUpdateType_t updateType );
  84. virtual void OnDataChanged( DataUpdateType_t updateType );
  85. virtual void ProcessMuzzleFlashEvent();
  86. virtual void ValidateModelIndex( void );
  87. void Touch( CBaseEntity *pOther );
  88. virtual Vector GetObserverCamOrigin( void );
  89. virtual int DrawModel( int flags );
  90. virtual void ApplyBoneMatrixTransform( matrix3x4_t& transform );
  91. virtual void BuildTransformations( CStudioHdr *hdr, Vector *pos, Quaternion q[], const matrix3x4_t& cameraTransform, int boneMask, CBoneBitList &boneComputed );
  92. virtual bool CreateMove( float flInputSampleTime, CUserCmd *pCmd ) OVERRIDE;
  93. void CreateVehicleMove( float flInputSampleTime, CUserCmd *pCmd );
  94. virtual bool IsAllowedToSwitchWeapons( void );
  95. void StopViewModelParticles( C_BaseEntity *pParticleEnt );
  96. virtual void ClientThink();
  97. // Deal with recording
  98. virtual void GetToolRecordingState( KeyValues *msg );
  99. CTFWeaponBase *GetActiveTFWeapon( void ) const;
  100. bool IsActiveTFWeapon( CEconItemDefinition *weaponHandle ) const;
  101. bool IsActiveTFWeapon( const CSchemaItemDefHandle &weaponHandle ) const;
  102. virtual void Simulate( void );
  103. virtual void FireEvent( const Vector& origin, const QAngle& angles, int event, const char *options ) OVERRIDE;
  104. virtual void UpdateStepSound( surfacedata_t *psurface, const Vector &vecOrigin, const Vector &vecVelocity ) OVERRIDE;
  105. CNewParticleEffect *SpawnHalloweenSpellFootsteps( ParticleAttachment_t eParticleAttachment, int iHalloweenFootstepType );
  106. void FireBullet( CTFWeaponBase *pWpn, const FireBulletsInfo_t &info, bool bDoEffects, int nDamageType, int nCustomDamageType = TF_DMG_CUSTOM_NONE );
  107. void ImpactWaterTrace( trace_t &trace, const Vector &vecStart );
  108. bool CanAttack( int iCanAttackFlags = 0 );
  109. const C_TFPlayerClass *GetPlayerClass( void ) const { return &m_PlayerClass; }
  110. C_TFPlayerClass *GetPlayerClass( void ) { return &m_PlayerClass; }
  111. bool IsPlayerClass( int iClass ) const;
  112. virtual int GetMaxHealth( void ) const;
  113. int GetMaxHealthForBuffing() const;
  114. virtual int GetRenderTeamNumber( void );
  115. bool IsWeaponLowered( void );
  116. void AvoidPlayers( CUserCmd *pCmd );
  117. bool IsABot( void );
  118. // Get the ID target entity index. The ID target is the player that is behind our crosshairs, used to
  119. // display the player's name.
  120. void UpdateIDTarget();
  121. int GetIDTarget() const;
  122. void SetForcedIDTarget( int iTarget );
  123. void SetAnimation( PLAYER_ANIM playerAnim );
  124. virtual float GetMinFOV() const;
  125. virtual const QAngle& EyeAngles();
  126. bool ShouldDrawSpyAsDisguised();
  127. virtual int GetBody( void );
  128. int GetBuildResources( void );
  129. // MATTTODO: object selection if necessary
  130. void SetSelectedObject( C_BaseObject *pObject ) {}
  131. void GetTeamColor( Color &color );
  132. bool InSameDisguisedTeam( CBaseEntity *pEnt );
  133. virtual void ComputeFxBlend( void );
  134. // Taunts/VCDs
  135. virtual bool StartSceneEvent( CSceneEventInfo *info, CChoreoScene *scene, CChoreoEvent *event, CChoreoActor *actor, C_BaseEntity *pTarget );
  136. virtual bool ClearSceneEvent( CSceneEventInfo *info, bool fastKill, bool canceled );
  137. virtual void CalcView( Vector &eyeOrigin, QAngle &eyeAngles, float &zNear, float &zFar, float &fov );
  138. bool StartGestureSceneEvent( CSceneEventInfo *info, CChoreoScene *scene, CChoreoEvent *event, CChoreoActor *actor, CBaseEntity *pTarget );
  139. bool StopGestureSceneEvent( CSceneEventInfo *info, bool fastKill, bool canceled );
  140. void TurnOnTauntCam( void );
  141. void TurnOnTauntCam_Finish( void );
  142. void TurnOffTauntCam( void );
  143. void TurnOffTauntCam_Finish( void );
  144. bool IsTaunting( void ) const { return m_Shared.InCond( TF_COND_TAUNTING ); }
  145. virtual void InitPhonemeMappings();
  146. // Gibs.
  147. void InitPlayerGibs( void );
  148. void CheckAndUpdateGibType( void );
  149. void CreatePlayerGibs( const Vector &vecOrigin, const Vector &vecVelocity, float flImpactScale, bool bBurning, bool bWearableGibs=false, bool bOnlyHead=false, bool bDisguiseGibs=false );
  150. void DropPartyHat( breakablepropparams_t &breakParams, Vector &vecBreakVelocity );
  151. void DropWearable( C_TFWearable *pItem, const breakablepropparams_t &params );
  152. int GetObjectCount( void );
  153. C_BaseObject *GetObject( int index );
  154. C_BaseObject *GetObjectOfType( int iObjectType, int iObjectMode=0 ) const;
  155. int GetNumObjects( int iObjectType, int iObjectMode=0 );
  156. virtual bool ShouldCollide( int collisionGroup, int contentsMask ) const;
  157. float GetPercentInvisible( void );
  158. float GetEffectiveInvisibilityLevel( void ); // takes viewer into account
  159. virtual bool IsTransparent( void ) OVERRIDE { return GetPercentInvisible() > 0.f; }
  160. virtual void AddDecal( const Vector& rayStart, const Vector& rayEnd,
  161. const Vector& decalCenter, int hitbox, int decalIndex, bool doTrace, trace_t& tr, int maxLODToDecal = ADDDECAL_TO_ALL_LODS );
  162. virtual void CalcDeathCamView(Vector& eyeOrigin, QAngle& eyeAngles, float& fov);
  163. virtual Vector GetChaseCamViewOffset( CBaseEntity *target );
  164. virtual Vector GetDeathViewPosition();
  165. void ClientPlayerRespawn( void );
  166. virtual bool ShouldDraw();
  167. virtual int GetVisionFilterFlags( bool bWeaponsCheck = false );
  168. virtual void CalculateVisionUsingCurrentFlags( void );
  169. void CreateSaveMeEffect( MedicCallerType nType = CALLER_TYPE_NORMAL );
  170. void StopSaveMeEffect( bool bForceRemoveInstantly = false );
  171. void CreateTauntWithMeEffect();
  172. void StopTauntWithMeEffect();
  173. void CreateKart();
  174. void RemoveKart();
  175. C_BaseAnimating *GetKart() const { return m_pKart; }
  176. void CreateKartEffect( const char *pszEffectName );
  177. void StopKartEffect();
  178. void UpdateKartSounds();
  179. void StartKartBrakeEffect();
  180. void StopKartBrakeEffect();
  181. CNetworkVar( int, m_iKartState );
  182. bool IsAllowedToTaunt( void );
  183. virtual bool IsOverridingViewmodel( void );
  184. virtual int DrawOverriddenViewmodel( C_BaseViewModel *pViewmodel, int flags );
  185. void SetHealer( C_TFPlayer *pHealer, float flChargeLevel );
  186. void SetWasHealedByLocalPlayer( bool bState ) { m_bWasHealedByLocalPlayer = bState; }
  187. void GetHealer( C_TFPlayer **pHealer, float *flChargeLevel ) { *pHealer = m_hHealer; *flChargeLevel = m_flHealerChargeLevel; }
  188. bool GetWasHealedByLocalPlayer() { return m_bWasHealedByLocalPlayer; }
  189. float MedicGetChargeLevel( CTFWeaponBase **pRetMedigun = NULL );
  190. bool MedicIsReleasingCharge( void );
  191. CBaseEntity *MedicGetHealTarget( void );
  192. void StartBurningSound( void );
  193. void StopBurningSound( void );
  194. void StopBlastJumpLoopSound( int iUserID );
  195. void UpdateSpyStateChange( void );
  196. void UpdateRecentlyTeleportedEffect( void );
  197. void UpdateOverhealEffect( void );
  198. void UpdatedMarkedForDeathEffect( bool bFroceStop = false );
  199. void CreateOverhealEffect( int iTeam );
  200. void UpdateRuneIcon( bool bForceStop = false );
  201. bool CanShowClassMenu( void );
  202. bool CanShowTeamMenu( void );
  203. void InitializePoseParams( void );
  204. void UpdateLookAt( void );
  205. bool IsEnemyPlayer( void );
  206. void ShowNemesisIcon( bool bShow );
  207. void ShowDuelingIcon( bool bShow );
  208. void ShowIconForIT( bool bShow );
  209. #ifdef STAGING_ONLY
  210. void UpdateTranqMark( bool bShow, bool bForceStop = false );
  211. void UpdateSpyClassStealParticle( bool bShow );
  212. #endif // STAGING_ONLY
  213. void ShowBirthdayEffect( bool bShow );
  214. CUtlVector<EHANDLE> *GetSpawnedGibs( void ) { return &m_hSpawnedGibs; }
  215. bool HasBombinomiconEffectOnDeath( void );
  216. Vector GetClassEyeHeight( void );
  217. void ForceUpdateObjectHudState( void );
  218. bool GetMedigunAutoHeal( void ){ return tf_medigun_autoheal.GetBool(); }
  219. bool ShouldAutoRezoom( void ){ return cl_autorezoom.GetBool(); }
  220. bool ShouldAutoReload( void ){ return cl_autoreload.GetBool(); }
  221. void GetTargetIDDataString( bool bIsDisguised, OUT_Z_BYTECAP(iMaxLenInBytes) wchar_t *sDataString, int iMaxLenInBytes, bool &bIsAmmoData, bool &bIsKillStreakData );
  222. void RemoveDisguise( void );
  223. bool CanDisguise( void );
  224. bool CanDisguise_OnKill( void );
  225. virtual void OnAchievementAchieved( int iAchievement );
  226. virtual void OverrideView( CViewSetup *pSetup );
  227. bool CanAirDash( void ) const;
  228. bool CanGetWet() const;
  229. void CreateBoneAttachmentsFromWearables( C_TFRagdoll *pRagdoll, bool bDisguised );
  230. bool CanUseFirstPersonCommand( void );
  231. bool IsEffectRateLimited( EBonusEffectFilter_t effect, const C_TFPlayer* pAttacker ) const;
  232. bool ShouldPlayEffect( EBonusEffectFilter_t filter, const C_TFPlayer* pAttacker, const C_TFPlayer* pVictim ) const;
  233. virtual void FireGameEvent( IGameEvent *event );
  234. virtual const char* ModifyEventParticles( const char* token );
  235. // Set the distances the camera should use.
  236. void SetTauntCameraTargets( float back, float up );
  237. // TF-specific color values for GlowEffect
  238. virtual void GetGlowEffectColor( float *r, float *g, float *b );
  239. void UpdateGlowColor( void );
  240. virtual const Vector& GetRenderOrigin( void );
  241. RTime32 GetSpottedInPVSTime() const { return m_rtSpottedInPVSTime; }
  242. RTime32 GetJoinedSpectatorTeamTime() const { return m_rtJoinedSpectatorTeam; }
  243. RTime32 GetJoinedNormalTeamTime() const { return m_rtJoinedNormalTeam; }
  244. // IHasAttributes
  245. CAttributeManager *GetAttributeManager( void ) { return &m_AttributeManager; }
  246. CAttributeContainer *GetAttributeContainer( void ) { return NULL; }
  247. CBaseEntity *GetAttributeOwner( void ) { return NULL; }
  248. CAttributeList *GetAttributeList( void ) { return &m_AttributeList; }
  249. virtual void ReapplyProvision( void ) { return; }
  250. // ITFMvMBossProgressUser
  251. virtual const char* GetBossProgressImageName() const OVERRIDE;
  252. virtual float GetBossStatusProgress() const OVERRIDE;
  253. protected:
  254. CNetworkVarEmbedded( CAttributeContainerPlayer, m_AttributeManager );
  255. // IClientNetworkable implementation.
  256. public:
  257. virtual void NotifyShouldTransmit( ShouldTransmitState_t state );
  258. public:
  259. // Shared functions
  260. float GetMovementForwardPull( void ) const;
  261. bool CanPlayerMove() const;
  262. float TeamFortress_CalculateMaxSpeed( bool bIgnoreSpecialAbility = false ) const;
  263. void TeamFortress_SetSpeed();
  264. bool HasItem( void ) const; // Currently can have only one item at a time.
  265. void SetItem( C_TFItem *pItem );
  266. C_TFItem *GetItem( void ) const;
  267. bool HasTheFlag( ETFFlagType exceptionTypes[] = NULL, int nNumExceptions = 0 ) const;
  268. virtual bool IsAllowedToPickUpFlag( void ) const;
  269. float GetCritMult( void ) { return m_Shared.GetCritMult(); }
  270. virtual void ItemPostFrame( void );
  271. void SetOffHandWeapon( CTFWeaponBase *pWeapon );
  272. void HolsterOffHandWeapon( void );
  273. CTFWeaponBase* GetOffHandWeapon( void ) { return m_hOffHandWeapon; }
  274. void GetActiveSets( CUtlVector<const CEconItemSetDefinition *> *pItemSets );
  275. virtual int GetSkin();
  276. float GetLastDamageTime( void ) const { return m_flLastDamageTime; }
  277. virtual bool Weapon_CanSwitchTo( CBaseCombatWeapon *pWeapon );
  278. virtual bool Weapon_ShouldSetLast( CBaseCombatWeapon *pOldWeapon, CBaseCombatWeapon *pNewWeapon ) OVERRIDE;
  279. virtual bool Weapon_Switch( C_BaseCombatWeapon *pWeapon, int viewmodelindex = 0 ) OVERRIDE;
  280. virtual void SelectItem( const char *pstr, int iSubType = 0 ) OVERRIDE;
  281. virtual void UpdateWearables() OVERRIDE;
  282. CTFWearable *GetEquippedWearableForLoadoutSlot( int iLoadoutSlot );
  283. CBaseEntity *GetEntityForLoadoutSlot( int iLoadoutSlot ); //Gets whatever entity is associated with the loadout slot (wearable or weapon)
  284. CTFWeaponBase *Weapon_OwnsThisID( int iWeaponID ) const;
  285. CTFWeaponBase *Weapon_GetWeaponByType( int iType );
  286. virtual void GetStepSoundVelocities( float *velwalk, float *velrun );
  287. virtual void SetStepSoundTime( stepsoundtimes_t iStepSoundTime, bool bWalking );
  288. virtual const char *GetOverrideStepSound( const char *pszBaseStepSoundName );
  289. virtual void OnEmitFootstepSound( const CSoundParameters& params, const Vector& vecOrigin, float fVolume );
  290. virtual void ModifyEmitSoundParams( EmitSound_t &params );
  291. virtual void ThirdPersonSwitch( bool bThirdperson );
  292. bool DoClassSpecialSkill( void );
  293. bool EndClassSpecialSkill( void );
  294. bool CanGoInvisible( bool bAllowWhileCarryingFlag = false );
  295. int GetMaxAmmo( int iAmmoIndex, int iClassIndex = -1 );
  296. //-----------------------------------------------------------------------------------------------------
  297. // Return true if we are a "mini boss" in Mann Vs Machine mode
  298. bool IsMiniBoss( void ) const;
  299. bool ShouldTauntHintIconBeVisible() const;
  300. virtual bool IsHealthBarVisible( void ) const OVERRIDE;
  301. bool CanStartPhase( void );
  302. bool CanPickupBuilding( CBaseObject *pPickupObject );
  303. bool TryToPickupBuilding( void );
  304. void StartBuildingObjectOfType( int iType, int iObjectMode=0 );
  305. void FeignDeath( CTakeDamageInfo& info );
  306. C_CaptureZone *GetCaptureZoneStandingOn( void );
  307. C_CaptureZone *GetClosestCaptureZone( void );
  308. float GetMetersRan( void ) { return m_fMetersRan; }
  309. void SetMetersRan( float fMeters, int iFrame );
  310. CEconItemView *GetInspectItem( int *iLastItem );
  311. void SetBodygroupsDirty( void );
  312. void RecalcBodygroupsIfDirty( void );
  313. bool CanMoveDuringTaunt();
  314. bool ShouldStopTaunting();
  315. bool IsTauntForceMovingForward() const { return m_bTauntForceMoveForward; }
  316. float GetTauntMoveAcceleration() const { return m_flTauntMoveAccelerationTime; }
  317. float GetTauntMoveSpeed() const { return m_flTauntForceMoveForwardSpeed; }
  318. float GetTauntTurnAccelerationTime() const { return m_flTauntTurnAccelerationTime; }
  319. bool IsReadyToTauntWithPartner( void ) const { return m_bIsReadyToHighFive; }
  320. CTFPlayer * GetTauntPartner( void ) { return m_hHighFivePartner; }
  321. float GetTauntYaw( void ) { return m_flTauntYaw; }
  322. float GetPrevTauntYaw( void ) { return m_flPrevTauntYaw; }
  323. void SetTauntYaw( float flTauntYaw );
  324. int GetActiveTauntSlot() const { return m_nActiveTauntSlot; }
  325. void PlayTauntSoundLoop( const char *pszSoundLoopName );
  326. void StopTauntSoundLoop();
  327. float GetCurrentTauntMoveSpeed() const { return m_flCurrentTauntMoveSpeed; }
  328. void SetCurrentTauntMoveSpeed( float flSpeed ) { m_flCurrentTauntMoveSpeed = flSpeed; }
  329. float GetVehicleReverseTime() const { return m_flVehicleReverseTime; }
  330. void SetVehicleReverseTime( float flTime ) { m_flVehicleReverseTime = flTime; }
  331. CEconItemView *GetTauntEconItemView() { return m_TauntEconItemView.IsValid() ? &m_TauntEconItemView : NULL; }
  332. float GetHeadScale() const { return m_flHeadScale; }
  333. float GetTorsoScale() const { return m_flTorsoScale; }
  334. float GetHandScale() const { return m_flHandScale; }
  335. float GetLastResistTime() const { return m_flLastResistTime; }
  336. bool BRenderAsZombie( bool bWeaponsCheck = false );
  337. static void AdjustSkinIndexForZombie( int iClassIndex, int &iSkinIndex );
  338. // Ragdolls.
  339. virtual C_BaseAnimating *BecomeRagdollOnClient();
  340. virtual IRagdoll *GetRepresentativeRagdoll() const;
  341. EHANDLE m_hRagdoll;
  342. Vector m_vecRagdollVelocity;
  343. // Objects
  344. int CanBuild( int iObjectType, int iObjectMode=0 );
  345. CUtlVector< CHandle<C_BaseObject> > m_aObjects;
  346. virtual CStudioHdr *OnNewModel( void );
  347. void DisplaysHintsForTarget( C_BaseEntity *pTarget );
  348. // Shadows
  349. virtual ShadowType_t ShadowCastType( void ) ;
  350. virtual void GetShadowRenderBounds( Vector &mins, Vector &maxs, ShadowType_t shadowType );
  351. virtual void GetRenderBounds( Vector& theMins, Vector& theMaxs );
  352. virtual bool GetShadowCastDirection( Vector *pDirection, ShadowType_t shadowType ) const;
  353. CMaterialReference *GetInvulnMaterialRef( void ) { return &m_InvulnerableMaterial; }
  354. bool IsNemesisOfLocalPlayer();
  355. bool ShouldShowDuelingIcon();
  356. bool ShouldShowNemesisIcon();
  357. virtual IMaterial *GetHeadLabelMaterial( void );
  358. // Spy Cigarette
  359. bool CanLightCigarette( void );
  360. void UpdateDemomanEyeEffect( int iDecapitations );
  361. const char* GetDemomanEyeEffectName( int iDecapitations );
  362. int GetCurrency( void ){ return m_nCurrency; }
  363. virtual void UpdateMVMEyeGlowEffect( bool bVisible );
  364. void UpdateKillStreakEffects( int iCount, bool bKillScored = false );
  365. const char *GetEyeGlowEffect() { return m_pszEyeGlowEffectName; }
  366. Vector GetEyeGlowColor( bool bAlternate ) { return bAlternate? m_vEyeGlowColor1 : m_vEyeGlowColor2 ; }
  367. // Bounty Mode
  368. int GetExperienceLevel( void ) { return m_nExperienceLevel; }
  369. // Matchmaking
  370. bool GetMatchSafeToLeave() { return m_bMatchSafeToLeave; }
  371. // Halloween silliness.
  372. void HalloweenBombHeadUpdate( void );
  373. bool IsUsingVRHeadset( void ){ return m_bUsingVRHeadset; }
  374. bool ShouldPlayerDrawParticles( void );
  375. bool IsPlayerOnSteamFriendsList( C_BasePlayer *pPlayer );
  376. protected:
  377. void ResetFlexWeights( CStudioHdr *pStudioHdr );
  378. virtual void CalcInEyeCamView( Vector& eyeOrigin, QAngle& eyeAngles, float& fov );
  379. virtual void UpdateGlowEffect( void );
  380. virtual void DestroyGlowEffect( void );
  381. private:
  382. bool ShouldShowPowerupGlowEffect();
  383. void GetPowerupGlowEffectColor( float *r, float *g, float *b );
  384. void HandleTaunting( void );
  385. void TauntCamInterpolation( void );
  386. void OnPlayerClassChange( void );
  387. void UpdatePartyHat( void );
  388. void InitInvulnerableMaterial( void );
  389. void GetHorriblyHackedRailgunPosition( const Vector& vStart, Vector *out_pvStartPos );
  390. void MaybeDrawRailgunBeam( IRecipientFilter *pFilter, CTFWeaponBase *pWeapon, const Vector& vStartPos, const Vector& vEndPos );
  391. bool m_bWasTaunting;
  392. bool m_bTauntInterpolating;
  393. CameraThirdData_t m_TauntCameraData;
  394. float m_flTauntCamCurrentDist;
  395. float m_flTauntCamTargetDist;
  396. float m_flTauntCamCurrentDistUp;
  397. float m_flTauntCamTargetDistUp;
  398. QAngle m_angTauntPredViewAngles;
  399. QAngle m_angTauntEngViewAngles;
  400. CSoundPatch *m_pTauntSoundLoop;
  401. C_TFPlayerClass m_PlayerClass;
  402. // ID Target
  403. int m_iIDEntIndex;
  404. int m_iForcedIDTarget;
  405. CNewParticleEffect *m_pTeleporterEffect;
  406. bool m_bToolRecordingVisibility;
  407. int m_iOldSpawnCounter;
  408. // Healer
  409. CHandle<C_TFPlayer> m_hHealer;
  410. bool m_bWasHealedByLocalPlayer;
  411. float m_flHealerChargeLevel;
  412. int m_iOldHealth;
  413. int m_nOldMaxHealth;
  414. float m_fMetersRan;
  415. int m_iLastRanFrame;
  416. HPARTICLEFFECT m_pEyeEffect;
  417. bool m_bOldCustomModelVisible;
  418. CHandle< C_BaseCombatWeapon > m_hOldActiveWeapon;
  419. // Look At
  420. /*
  421. int m_headYawPoseParam;
  422. int m_headPitchPoseParam;
  423. float m_headYawMin;
  424. float m_headYawMax;
  425. float m_headPitchMin;
  426. float m_headPitchMax;
  427. float m_flLastBodyYaw;
  428. float m_flCurrentHeadYaw;
  429. float m_flCurrentHeadPitch;
  430. */
  431. // Spy cigarette smoke
  432. bool m_bCigaretteSmokeActive;
  433. // Medic callout particle effect
  434. CNewParticleEffect *m_pSaveMeEffect;
  435. CNewParticleEffect *m_pTauntWithMeEffect;
  436. bool m_bUpdateObjectHudState;
  437. bool m_bBodygroupsDirty;
  438. HPARTICLEFFECT m_hKartDamageEffect;
  439. CNetworkVar( float, m_flKartNextAvailableBoost );
  440. CNetworkVar( int, m_iKartHealth );
  441. int m_iOldKartHealth;
  442. void UpdateKartEffects();
  443. void UpdateKartState();
  444. int m_iOldKartState;
  445. C_BaseAnimating *m_pKart;
  446. public:
  447. float GetKartSpeedBoost( void );
  448. float GetKartHealth( void ) { return m_iKartHealth; }
  449. CTFPlayerShared m_Shared;
  450. friend class CTFPlayerShared;
  451. // Called by shared code.
  452. public:
  453. float GetClassChangeTime() const { return m_flChangeClassTime; }
  454. void SetFootStamps( int nFootStamps ) { m_nFootStamps = nFootStamps; }
  455. void DoAnimationEvent( PlayerAnimEvent_t event, int nData = 0 );
  456. bool PlayAnimEventInPrediction( PlayerAnimEvent_t event );
  457. bool GetPredictable( void ) const;
  458. // Halloween
  459. void CreateBombonomiconHint();
  460. void DestroyBombonomiconHint();
  461. void CleanUpAnimationOnSpawn();
  462. CTFPlayerAnimState *m_PlayerAnimState;
  463. QAngle m_angEyeAngles;
  464. CInterpolatedVar< QAngle > m_iv_angEyeAngles;
  465. CNetworkHandle( C_TFItem, m_hItem );
  466. CNetworkHandle( C_TFWeaponBase, m_hOffHandWeapon );
  467. CNetworkHandle( C_TFPlayer, m_hCoach );
  468. CNetworkHandle( C_TFPlayer, m_hStudent );
  469. CGlowObject *m_pStudentGlowEffect;
  470. CGlowObject *m_pPowerupGlowEffect;
  471. int m_iOldPlayerClass; // Used to detect player class changes
  472. bool m_bIsDisplayingNemesisIcon;
  473. bool m_bIsDisplayingDuelingIcon;
  474. bool m_bIsDisplayingIconForIT;
  475. bool m_bIsDisplayingTranqMark;
  476. bool m_bShouldShowBirthdayEffect;
  477. RuneTypes_t m_eDisplayingRuneIcon;
  478. float m_flLastDamageTime;
  479. bool m_bInPowerPlay;
  480. int m_iSpawnCounter;
  481. bool m_bArenaSpectator;
  482. bool m_bIsMiniBoss;
  483. bool m_bIsABot;
  484. int m_nBotSkill;
  485. int m_nOldBotSkill;
  486. bool m_bSaveMeParity;
  487. bool m_bOldSaveMeParity;
  488. bool m_bIsCoaching;
  489. private:
  490. void UpdateTauntItem();
  491. void ParseSharedTauntDataFromEconItemView( CEconItemView *pEconItemView );
  492. bool m_bAllowMoveDuringTaunt;
  493. bool m_bTauntForceMoveForward;
  494. float m_flTauntForceMoveForwardSpeed;
  495. float m_flTauntMoveAccelerationTime;
  496. float m_flTauntTurnSpeed;
  497. float m_flTauntTurnAccelerationTime;
  498. bool m_bIsReadyToHighFive;
  499. CNetworkHandle( C_TFPlayer, m_hHighFivePartner );
  500. int m_nForceTauntCam;
  501. float m_flTauntYaw;
  502. float m_flPrevTauntYaw;
  503. int m_nActiveTauntSlot;
  504. int m_nPrevTauntSlot;
  505. item_definition_index_t m_iTauntItemDefIndex;
  506. item_definition_index_t m_iPrevTauntItemDefIndex;
  507. float m_flCurrentTauntMoveSpeed;
  508. float m_flVehicleReverseTime;
  509. int m_nTauntSequence;
  510. float m_flTauntStartTime;
  511. float m_flTauntDuration;
  512. CEconItemView m_TauntEconItemView;
  513. public:
  514. int m_nOldWaterLevel;
  515. float m_flWaterEntryTime;
  516. bool m_bWaterExitEffectActive;
  517. bool m_bDuckJumpInterp;
  518. float m_flFirstDuckJumpInterp;
  519. float m_flLastDuckJumpInterp;
  520. float m_flDuckJumpInterp;
  521. CMaterialReference m_InvulnerableMaterial;
  522. // Burning
  523. CSoundPatch *m_pBurningSound;
  524. HPARTICLEFFECT m_pBurningEffect;
  525. float m_flBurnEffectStartTime;
  526. // Urine
  527. HPARTICLEFFECT m_pUrineEffect;
  528. // Milk
  529. HPARTICLEFFECT m_pMilkEffect;
  530. // Soldier Buff
  531. HPARTICLEFFECT m_pSoldierOffensiveBuffEffect;
  532. HPARTICLEFFECT m_pSoldierDefensiveBuffEffect;
  533. HPARTICLEFFECT m_pSoldierOffensiveHealthRegenBuffEffect;
  534. HPARTICLEFFECT m_pSoldierNoHealingDamageBuffEffect;
  535. // Speed boost
  536. HPARTICLEFFECT m_pSpeedBoostEffect;
  537. // Taunt effects
  538. HPARTICLEFFECT m_pTauntEffect;
  539. // Temp HACK for crit boost
  540. HPARTICLEFFECT m_pCritBoostEffect;
  541. HPARTICLEFFECT m_pOverHealedEffect;
  542. HPARTICLEFFECT m_pPhaseStandingEffect;
  543. HPARTICLEFFECT m_pStunnedEffect;
  544. HPARTICLEFFECT m_pMegaHealEffect;
  545. HPARTICLEFFECT m_pRadiusHealEffect;
  546. HPARTICLEFFECT m_pKingRuneRadiusEffect;
  547. HPARTICLEFFECT m_pKingBuffRadiusEffect;
  548. HPARTICLEFFECT m_pRunePlagueEffect;
  549. C_LocalTempEntity* m_pTempShield;
  550. float m_flLastResistTime;
  551. HPARTICLEFFECT m_pSappedPlayerEffect;
  552. HPARTICLEFFECT m_pMVMEyeGlowEffect[ 2 ];
  553. // KillStreak Weapons
  554. char m_pszEyeGlowEffectName[MAX_PATH];
  555. Vector m_vEyeGlowColor1;
  556. Vector m_vEyeGlowColor2;
  557. HPARTICLEFFECT m_pEyeGlowEffect[ 2 ];
  558. float m_flNextSheenStartTime;
  559. HPARTICLEFFECT m_pMVMBotRadiowave;
  560. HPARTICLEFFECT m_pRuneChargeReadyEffect;
  561. #ifdef STAGING_ONLY
  562. HPARTICLEFFECT m_pRocketPackEffect;
  563. #endif // STAGING_ONLY
  564. enum EKartParticles
  565. {
  566. KART_PARTICLE_LEFT_LIGHT = 0,
  567. KART_PARTICLE_RIGHT_LIGHT,
  568. KART_PARTICLE_LEFT_WHEEL,
  569. KART_PARTICLE_RIGHT_WHEEL,
  570. NUM_KART_PARTICLES
  571. };
  572. HPARTICLEFFECT m_pKartParticles[ NUM_KART_PARTICLES ];
  573. enum EKartSounds
  574. {
  575. KART_SOUND_ENGINE_LOOP = 0,
  576. KART_SOUND_BURNOUT_LOOP,
  577. NUM_KART_SOUNDS,
  578. };
  579. CSoundPatch *m_pKartSounds[ NUM_KART_SOUNDS ];
  580. CNewParticleEffect *m_pDisguisingEffect;
  581. float m_flDisguiseEffectStartTime;
  582. float m_flDisguiseEndEffectStartTime;
  583. EHANDLE m_hFirstGib;
  584. EHANDLE m_hHeadGib;
  585. CUtlVector<EHANDLE> m_hSpawnedGibs;
  586. int m_iOldTeam;
  587. int m_iOldClass;
  588. int m_iOldDisguiseTeam;
  589. int m_iOldDisguiseClass;
  590. int m_iOldObserverMode;
  591. EHANDLE m_hOldObserverTarget;
  592. bool m_bDisguised;
  593. int m_iPreviousMetal;
  594. int GetNumActivePipebombs( void );
  595. int m_iSpyMaskBodygroup;
  596. Vector m_vecCustomModelOrigin;
  597. // Halloween
  598. CHandle<C_PlayerAttachedModel> m_hHalloweenBombHat;
  599. CHandle<C_MerasmusBombEffect> m_hBombonomiconHint;
  600. CHandle<C_PlayerAttachedModel> m_hHalloweenKartCage;
  601. float m_flBombDelay;
  602. // Achievements
  603. float m_flSaveMeExpireTime;
  604. //CountdownTimer m_LeaveServerTimer;
  605. //----------------------------
  606. // INVENTORY MANAGEMENT
  607. public:
  608. // IInventoryUpdateListener
  609. virtual void InventoryUpdated( CPlayerInventory *pInventory );
  610. virtual void SOCacheUnsubscribed( const CSteamID & steamIDOwner ) { m_Shared.SetLoadoutUnavailable( true ); }
  611. void UpdateInventory( bool bInit );
  612. // Inventory access
  613. CTFPlayerInventory *Inventory( void ) { return &m_Inventory; }
  614. bool CanDisplayAllSeeEffect( EAttackBonusEffects_t effect ) const;
  615. void SetNextAllSeeEffectTime( EAttackBonusEffects_t effect, float flTime );
  616. private:
  617. CTFPlayerInventory m_Inventory;
  618. bool m_bInventoryReceived;
  619. private:
  620. float m_flChangeClassTime;
  621. float m_flWaterImpactTime;
  622. RTime32 m_rtSpottedInPVSTime;
  623. RTime32 m_rtJoinedSpectatorTeam;
  624. RTime32 m_rtJoinedNormalTeam;
  625. // Gibs.
  626. CUtlVector< int > m_aSillyGibs;
  627. CUtlVector< char* > m_aNormalGibs;
  628. CUtlVector<breakmodel_t> m_aGibs;
  629. C_TFPlayer( const C_TFPlayer & );
  630. mutable char m_bIsCalculatingMaximumSpeed;
  631. // In-game currency
  632. int m_nCurrency;
  633. int m_nOldCurrency;
  634. // Bounty Mode
  635. int m_nExperienceLevel;
  636. int m_nExperienceLevelProgress;
  637. int m_nPrevExperienceLevel;
  638. // Matchmaking
  639. // is this player bound to the match on penalty of abandon. Sync'd via local-player-only DT
  640. bool m_bMatchSafeToLeave;
  641. // Medic healtarget active weapon ammo/clip count
  642. uint16 m_nActiveWpnClip;
  643. // Blast jump whistle
  644. CSoundPatch *m_pBlastJumpLoop;
  645. float m_flBlastJumpLaunchTime;
  646. CNetworkVar( float, m_flHeadScale );
  647. CNetworkVar( float, m_flTorsoScale );
  648. CNetworkVar( float, m_flHandScale );
  649. // Allseecrit throttle - other clients ask us if we can be the source of another particle+sound
  650. float m_flNextMiniCritEffectTime[ kBonusEffect_Count ];
  651. CNetworkVar( bool, m_bUseBossHealthBar );
  652. CNetworkVar( bool, m_bUsingVRHeadset );
  653. CNetworkVar( bool, m_bForcedSkin );
  654. CNetworkVar( int, m_nForcedSkin );
  655. int m_nFootStamps;
  656. vgui::DHANDLE< CTFReviveDialog > m_hRevivePrompt;
  657. public:
  658. void SetShowHudMenuTauntSelection( bool bShow ) { m_bShowHudMenuTauntSelection = bShow; }
  659. bool ShouldShowHudMenuTauntSelection() const { return m_bShowHudMenuTauntSelection; }
  660. private:
  661. bool m_bShowHudMenuTauntSelection;
  662. public:
  663. CBaseEntity *GetGrapplingHookTarget() const { return m_hGrapplingHookTarget; }
  664. bool IsUsingActionSlot() const { return m_bUsingActionSlot; }
  665. void SetUsingActionSlot( bool bUsingActionSlot ) { m_bUsingActionSlot = bUsingActionSlot; }
  666. void SetSecondaryLastWeapon( CBaseCombatWeapon *pSecondaryLastWeapon ) { m_hSecondaryLastWeapon = pSecondaryLastWeapon; }
  667. CBaseCombatWeapon* GetSecondaryLastWeapon() const { return m_hSecondaryLastWeapon; }
  668. bool CanPickupDroppedWeapon( const C_TFDroppedWeapon *pWeapon );
  669. C_TFDroppedWeapon* GetDroppedWeaponInRange();
  670. bool HasCampaignMedal( int iMedal );
  671. CampaignMedalDisplayType_t GetCampaignMedalType( void );
  672. const char *GetCampaignMedalImage( void );
  673. void SetInspectTime( float flInspectTime ) { m_flInspectTime = flInspectTime; }
  674. bool IsInspecting() const;
  675. void HandleInspectHint();
  676. bool AddOverheadEffect( const char *pszEffectName );
  677. void RemoveOverheadEffect( const char *pszEffectName, bool bRemoveInstantly );
  678. void UpdateOverheadEffects();
  679. Vector GetOverheadEffectPosition();
  680. int GetSkinOverride() const { return m_iPlayerSkinOverride; }
  681. private:
  682. CNetworkHandle( CBaseEntity, m_hGrapplingHookTarget );
  683. CNetworkHandle( CBaseCombatWeapon, m_hSecondaryLastWeapon );
  684. CNetworkVar( bool, m_bUsingActionSlot );
  685. CNetworkVar( int, m_iCampaignMedals );
  686. CNetworkVar( float, m_flInspectTime );
  687. bool m_bNotifiedWeaponInspectThisLife;
  688. C_PasstimePlayerReticle *m_pPasstimePlayerReticle;
  689. C_PasstimeAskForBallReticle *m_pPasstimeAskForBallReticle;
  690. CUtlMap< const char *, HPARTICLEFFECT > m_mapOverheadEffects;
  691. float m_flOverheadEffectStartTime;
  692. CNetworkVar( int, m_iPlayerSkinOverride );
  693. };
  694. inline C_TFPlayer* ToTFPlayer( C_BaseEntity *pEntity )
  695. {
  696. if ( !pEntity || !pEntity->IsPlayer() )
  697. return NULL;
  698. Assert( dynamic_cast<C_TFPlayer*>( pEntity ) != 0 );
  699. return static_cast< C_TFPlayer* >( pEntity );
  700. }
  701. void SetAppropriateCamera( C_TFPlayer *pPlayer );
  702. class C_TFPlayerPreviewEffect
  703. {
  704. public:
  705. // If you re-order this list, please update TF_ImportPreview_Effect* in tf_english.txt
  706. enum PREVIEW_EFFECT
  707. {
  708. PREVIEW_EFFECT_NONE,
  709. PREVIEW_EFFECT_UBER,
  710. //PREVIEW_EFFECT_CRIT, // Punting on particle effects for now
  711. PREVIEW_EFFECT_URINE,
  712. //PREVIEW_EFFECT_MILK, // Punting on particle effects for now
  713. //PREVIEW_EFFECT_INVIS, // The CMDLPanel draw path doesn't handle transparency at the moment
  714. PREVIEW_EFFECT_BURN,
  715. NUM_PREVIEW_EFFECTS
  716. };
  717. public:
  718. C_TFPlayerPreviewEffect();
  719. void SetEffect(PREVIEW_EFFECT nEffect) { m_nPreviewEffect = nEffect; }
  720. PREVIEW_EFFECT GetEffect() const { return m_nPreviewEffect; }
  721. void SetTeam(int nTeam);
  722. int GetTeam() const { return m_nTeam; }
  723. CMaterialReference *GetInvulnMaterialRef( void ) { return &m_InvulnerableMaterial; }
  724. void Reset();
  725. protected:
  726. PREVIEW_EFFECT m_nPreviewEffect;
  727. int m_nTeam;
  728. CMaterialReference m_InvulnerableMaterial;
  729. };
  730. extern C_TFPlayerPreviewEffect g_PlayerPreviewEffect;
  731. #endif // C_TF_PLAYER_H