summaryrefslogtreecommitdiff
path: root/game/server/tfc/tfc_player.h
blob: 484aaa35d2660cb22e3500058e46f835a7001873 (plain) (blame)
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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:		Player for HL1.
//
// $NoKeywords: $
//=============================================================================//

#ifndef TFC_PLAYER_H
#define TFC_PLAYER_H
#pragma once


#include "player.h"
#include "server_class.h"
#include "tfc_playeranimstate.h"
#include "tfc_shareddefs.h"
#include "tfc_player_shared.h"


class CTFCPlayer;
class CTFGoal;
class CTFGoalItem;


// Function table for each player state.
class CPlayerStateInfo
{
public:
	TFCPlayerState m_iPlayerState;
	const char *m_pStateName;
	
	void (CTFCPlayer::*pfnEnterState)();	// Init and deinit the state.
	void (CTFCPlayer::*pfnLeaveState)();

	void (CTFCPlayer::*pfnThink)();			// Called every frame.
};


//=============================================================================
// >> CounterStrike player
//=============================================================================
class CTFCPlayer : public CBasePlayer
{
public:
	DECLARE_CLASS( CTFCPlayer, CBasePlayer );
	DECLARE_SERVERCLASS();


	CTFCPlayer();
	~CTFCPlayer();

	static CTFCPlayer *CreatePlayer( const char *className, edict_t *ed );
	static CTFCPlayer* Instance( int iEnt );

	// This passes the event to the client's and server's CPlayerAnimState.
	void DoAnimationEvent( PlayerAnimEvent_t event );

	virtual void PostThink();
	virtual void InitialSpawn();
	virtual void Spawn();
	virtual void Precache();
	virtual bool ClientCommand( const CCommand &args );
	virtual void ChangeTeam( int iTeamNum ) OVERRIDE;
	virtual int	TakeHealth( float flHealth, int bitsDamageType );
	virtual void Event_Killed( const CTakeDamageInfo &info );

	void ClientHearVox( const char *pSentence );
	void DisplayLocalItemStatus( CTFGoal *pGoal );
	

public:

	// Is this entity an ally (on our team)?
	bool IsAlly( CBaseEntity *pEnt ) const;

	TFCPlayerState State_Get() const;				// Get the current state.

	void TF_AddFrags( int nFrags );

	void ResetMenu();

	// On fire..
	int GetNumFlames() const;
	void SetNumFlames( int nFlames );

	void ForceRespawn();

	void TeamFortress_SetSpeed();
	void TeamFortress_CheckClassStats();
	void TeamFortress_SetSkin();
	void TeamFortress_RemoveLiveGrenades();
	void TeamFortress_RemoveRockets();
	void TeamFortress_DetpackStop( void );
	
	BOOL TeamFortress_RemoveDetpacks( void );
	void RemovePipebombs( void );
	void RemoveOwnedEnt( char *pEntName );

// SPY STUFF
public:

	void Spy_RemoveDisguise();
	void TeamFortress_SpyCalcName();
	void Spy_ResetExternalWeaponModel( void );


// ENGINEER STUFF
public:

	void Engineer_RemoveBuildings();

	// Building 
	BOOL	is_building;	 	// TRUE for an ENGINEER if they're building something
	EHANDLE building;			// The building the ENGINEER is using
	float	building_wait;		// Used to prevent using a building again immediately
	EHANDLE real_owner;
	float	has_dispenser;		// TRUE if engineer has a dispenser
	float	has_sentry;			// TRUE if engineer has a sentry
	float	has_entry_teleporter;	// TRUE if engineer has an entry teleporter
	float	has_exit_teleporter;	// TRUE if engineer has an exit teleporter


// DEMO STUFF
public:

	int		m_iPipebombCount;


public:

	// Get the class info associated with us.
	const CTFCPlayerClassInfo* GetClassInfo() const;

	// Helpers to ease porting...
	int tp_grenades_1() const { return GetClassInfo()->m_iGrenadeType1; }
	int tp_grenades_2() const { return GetClassInfo()->m_iGrenadeType2; }
	int no_grenades_1() const { return GetAmmoCount( TFC_AMMO_GRENADES1 ); }
	int no_grenades_2() const { return GetAmmoCount( TFC_AMMO_GRENADES2 ); }

	
public:
	
	CTFCPlayerShared m_Shared;

	int	    item_list;			// Used to keep track of which goalitems are 
								// affecting the player at any time.
								// GoalItems use it to keep track of their own 
								// mask to apply to a player's item_list

	float		armortype;
	//float		armorvalue; // Use CBasePlayer::m_ArmorValue.
	int			armorclass;			// Type of armor being worn
	float		armor_allowed;

	float invincible_finished;
	float invisible_finished;
	float super_damage_finished;
	float radsuit_finished;

	int	lives;				// The number of lives you have left
	int is_unableto_spy_or_teleport;

	BOOL	bRemoveGrenade; // removes the primed grenade if set

	// Replacement_Model Stuff 
	string_t	replacement_model;
	int			replacement_model_body;
	int			replacement_model_skin;
	int			replacement_model_flags;
	
	// Spy
	int		undercover_team;		// The team the Spy is pretending to be in
	int		undercover_skin;		// The skin the Spy is pretending to have
	EHANDLE	undercover_target;		// The player the Spy is pretending to be
	BOOL		is_feigning;		// TRUE for a SPY if they're feigning death
	float	immune_to_check;
	BOOL	is_undercover;		// TRUE for a SPY if they're undercover

	// TEAMFORTRESS VARIABLES
	int		no_sentry_message;
	int		no_dispenser_message;

	// teleporter variables
	int		no_entry_teleporter_message;
	int		no_exit_teleporter_message;

	BOOL	is_detpacking;	 	// TRUE for a DEMOMAN if they're setting a detpack

	float	current_menu;		// is set to the number of the current menu, is 0 if they are not in a menu

// State management.
private:

	void State_Transition( TFCPlayerState newState );
	void State_Enter( TFCPlayerState newState );
	void State_Leave();
	CPlayerStateInfo* State_LookupInfo( TFCPlayerState state );

	CPlayerStateInfo *m_pCurStateInfo;

	void State_Enter_WELCOME();
	void State_Enter_PICKINGTEAM();
	void State_Enter_PICKINGCLASS();
	void State_Enter_ACTIVE();
	void State_Enter_OBSERVER_MODE();
	void State_Enter_DYING();


private:

	friend void Bot_Think( CTFCPlayer *pBot );
	void HandleCommand_JoinTeam( const char *pTeamName );
	void HandleCommand_JoinClass( const char *pClassName );

	void GiveDefaultItems();

	void TFCPlayerThink();

	void PhysObjectSleep();
	void PhysObjectWake();

	void GetIntoGame();


private:

	// Copyed from EyeAngles() so we can send it to the client.
	CNetworkQAngle( m_angEyeAngles );

	ITFCPlayerAnimState *m_PlayerAnimState;

	int m_iLegDamage;
};


inline CTFCPlayer *ToTFCPlayer( CBaseEntity *pEntity )
{
	if ( !pEntity || !pEntity->IsPlayer() )
		return NULL;

#ifdef _DEBUG
	Assert( dynamic_cast<CTFCPlayer*>( pEntity ) != 0 );
#endif
	return static_cast< CTFCPlayer* >( pEntity );
}


inline const CTFCPlayerClassInfo* CTFCPlayer::GetClassInfo() const
{
	return GetTFCClassInfo( m_Shared.GetPlayerClass() );
}


#endif	// TFC_PLAYER_H