1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//
//=============================================================================//
#ifndef TF_PLAYERCLASS_H
#define TF_PLAYERCLASS_H
#ifdef _WIN32
#pragma once
#endif
#include "tier0/fasttimer.h"
#include <crtdbg.h>
class CPlayerClassData;
class CPlayerClass;
class CBaseTFPlayer;
class COrder;
class CBaseObject;
class CBaseTechnology;
class CWeaponCombatShield;
enum ResupplyReason_t
{
RESUPPLY_RESPAWN = 0,
RESUPPLY_ALL_FROM_STATION,
RESUPPLY_AMMO_FROM_STATION,
RESUPPLY_GRENADES_FROM_STATION,
};
//==============================================================================
// PLAYER CLASSES
//==============================================================================
class CBaseTFPlayer;
class CTFTeam;
// Base PlayerClass
// The PlayerClass classes handle all class specific weaponry / abilities / etc
class CPlayerClass
{
public:
DECLARE_CLASS_NOBASE( CPlayerClass );
CPlayerClass( CBaseTFPlayer *pPlayer, TFClass iClass );
virtual ~CPlayerClass();
// Any objects created/owned by class should be allocated and destroyed here
virtual void ClassActivate( void );
virtual void ClassDeactivate( void );
// Class initialization
virtual void CreateClass( void ); // Create the class upon initial spawn
virtual void RespawnClass( void ); // Called upon all respawns
virtual bool ResupplyAmmo( float flPercentage, ResupplyReason_t reason ); // Reset the ammo counts
virtual bool ResupplyAmmoType( float flAmount, const char *pAmmoType ); // Purpose: Supply the player with Ammo. Return true if some ammo was given.
virtual void SetMaxHealth( float flMaxHealth ); // Set the player's max health
int GetMaxHealthCVarValue(); // Return the player class's max health cvar
virtual float GetMaxSpeed( void ); // Calculate and return the player's max speed
virtual float GetMaxWalkSpeed( void ); // Calculate and return the player's max walking speed
virtual void SetMaxSpeed( float flMaxSpeed ); // Set the player's max speed
virtual string_t GetClassModel( int nTeam ); // Return a string containing this class's model
virtual const char* GetClassModelString( int nTeam );
virtual void SetupMoveData( void ); // Setup the default player movement data.
virtual void SetupSizeData( void );
virtual bool CanSeePlayerOnRadar( CBaseTFPlayer *pl );
virtual void ItemPostFrame( void );
virtual bool ClientCommand( const CCommand &args );
// Class abilities
virtual void ClassThink( void );
virtual void GainedNewTechnology( CBaseTechnology *pTechnology ); // New technology has been gained
// Deployment
virtual float GetDeployTime( void ) { return 0.0; };
// Resources
virtual int ClassCostAdjustment( ResupplyBuyType_t nType ) { return 0; }
// Objects
int GetNumObjects( int iObjectType );
virtual int CanBuild( int iObjectType );
virtual int StartedBuildingObject( int iObjectType );
virtual void StoppedBuilding( int iObjectType );
virtual void FinishedObject( CBaseObject *pObject );
virtual void PickupObject( CBaseObject *pObject );
virtual void OwnedObjectDestroyed( CBaseObject *pObject );
virtual void OwnedObjectChangeToTeam( CBaseObject *pObject, CBaseTFPlayer *pNewOwner );
virtual void OwnedObjectChangeFromTeam( CBaseObject *pObject, CBaseTFPlayer *pOldOwner );
virtual void CheckDeterioratingObjects( void );
// Hooks
virtual float OnTakeDamage( const CTakeDamageInfo &info );
virtual bool ShouldApplyDamageForce( const CTakeDamageInfo &info );
// Vehicles
virtual void OnVehicleStart() {}
virtual void OnVehicleEnd() {}
virtual bool CanGetInVehicle( void ) { return true; }
virtual void PlayerDied( CBaseEntity *pAttacker );
virtual void PlayerKilledPlayer( CBaseTFPlayer *pVictim );
virtual void SetPlayerHull( void );
virtual void GetPlayerHull( bool bDucking, Vector &vecMin, Vector &vecMax );
// Player Physics Shadow
virtual void InitVCollision( void );
// Powerups
virtual void PowerupStart( int iPowerup, float flAmount, CBaseEntity *pAttacker, CDamageModifier *pDamageModifier );
virtual void PowerupEnd( int iPowerup );
// Camo
virtual void ClearCamouflage( void ) { return; };
// Disguise
virtual void FinishedDisguising( void ) { return; };
virtual void StopDisguising( void ) { return; };
// Orders
virtual void CreatePersonalOrder( void );
// Create a high-priority order. This should be called by all player classes before
// they try to create class-specific orders. This function returns true if an order is
// created.
bool CreateInitialOrder();
bool AnyResourceZoneOrders();
bool AnyNonResourceZoneOrders(); // Returns true if there are any non-resource-zone orders.
// If there are, then no class should make any overriding orders.
// Respawn ( allow classes to override spawn points )
virtual CBaseEntity *SelectSpawnPoint( void );
void *operator new( size_t stAllocateBlock )
{
Assert( stAllocateBlock != 0 );
void *pMem = malloc( stAllocateBlock );
memset( pMem, 0, stAllocateBlock );
return pMem;
}
void* operator new( size_t stAllocateBlock, int nBlockUse, const char *pFileName, int nLine )
{
Assert( stAllocateBlock != 0 );
void *pMem = _malloc_dbg( stAllocateBlock, nBlockUse, pFileName, nLine );
memset( pMem, 0, stAllocateBlock );
return pMem;
}
void operator delete( void *pMem )
{
free( pMem );
}
void SetClassModel( string_t sModelName, int nTeam ) { m_sClassModel[nTeam] = sModelName; }
// Weapon & Tech Associations
void AddWeaponTechAssoc( char *pWeaponTech );
// Accessors.
inline CBaseTFPlayer* GetPlayer() { return m_pPlayer; }
CTFTeam* GetTeam();
virtual void ResetViewOffset( void );
virtual TFClass GetTFClass( void );
void AddWeaponTechAssociations( void );
// For CNetworkVar support. Chain to the player entity.
void NetworkStateChanged();
TFClass m_TFClass;
protected:
double m_flNormalizedEngagementNextTime;
CBaseTFPlayer *m_pPlayer; // Reference to the player
float m_flMaxWalkingSpeed;
string_t m_sClassModel[ MAX_TF_TEAMS + 1 ];
// Weapon & Tech associations
// Used to give out all weapons the player currently has the technologies for.
struct WeaponTechAssociation_t
{
char *pWeaponTech;
};
WeaponTechAssociation_t m_WeaponTechAssociations[ MAX_WEAPONS ];
int m_iNumWeaponTechAssociations;
CHandle<CWeaponCombatShield> m_hWpnShield;
private:
void ClearAllWeaponTechAssoc( void );
private:
bool m_bTechAssociationsSet;
};
#endif // TF_PLAYERCLASS_H
|