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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: The Infiltrator Player Class
//
// $Workfile: $
// $Date: $
// $NoKeywords: $
//=============================================================================//
#include "cbase.h"
#include "orders.h"
#include "tf_player.h"
#include "tf_class_infiltrator.h"
#include "EntityList.h"
#include "basecombatweapon.h"
#include "menu_base.h"
#include "tf_obj.h"
#include "tf_team.h"
#include "weapon_builder.h"
ConVar class_infiltrator_speed( "class_infiltrator_speed","200", FCVAR_NONE, "Infiltrator movement speed" );
//=============================================================================
//
// Infiltrator Data Table
//
BEGIN_SEND_TABLE_NOBASE( CPlayerClassInfiltrator, DT_PlayerClassInfiltratorData )
END_SEND_TABLE()
//-----------------------------------------------------------------------------
// Purpose:
// Output : const char
//-----------------------------------------------------------------------------
const char *CPlayerClassInfiltrator::GetClassModelString( int nTeam )
{
static const char *string = "models/player/spy.mdl";
return string;
}
// Infiltrator
CPlayerClassInfiltrator::CPlayerClassInfiltrator( CBaseTFPlayer *pPlayer, TFClass iClass ) : CPlayerClass( pPlayer, iClass )
{
for (int i = 0; i < MAX_TF_TEAMS; ++i)
{
SetClassModel( MAKE_STRING(GetClassModelString(i)), i );
}
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
CPlayerClassInfiltrator::~CPlayerClassInfiltrator()
{
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CPlayerClassInfiltrator::ClassActivate( void )
{
BaseClass::ClassActivate();
// Setup movement data.
SetupMoveData();
//m_hAssassinationWeapon = NULL;
m_hSwappedWeapon = NULL;
m_bCanConsumeCorpses = false;
m_flStartCamoAt = 0.0f;
memset( &m_ClassData, 0, sizeof( m_ClassData ) );
}
//-----------------------------------------------------------------------------
// Purpose: Register for precaching.
//-----------------------------------------------------------------------------
void PrecacheInfiltrator(void *pUser)
{
}
PRECACHE_REGISTER_FN(PrecacheInfiltrator);
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CPlayerClassInfiltrator::RespawnClass( void )
{
BaseClass::RespawnClass();
m_flStartCamoAt = gpGlobals->curtime + INFILTRATOR_CAMOTIME_AFTER_SPAWN;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool CPlayerClassInfiltrator::ResupplyAmmo( float flFraction, ResupplyReason_t reason )
{
bool bGiven = false;
if ((reason == RESUPPLY_ALL_FROM_STATION) || (reason == RESUPPLY_AMMO_FROM_STATION))
{
if (ResupplyAmmoType( 200 * flFraction, "Bullets" ))
bGiven = true;
if (ResupplyAmmoType( 20 * flFraction, "Limpets" ))
bGiven = true;
}
if ( BaseClass::ResupplyAmmo(flFraction, reason) )
bGiven = true;
return bGiven;
}
//-----------------------------------------------------------------------------
// Purpose: Set infiltrator class specific movement data here.
//-----------------------------------------------------------------------------
void CPlayerClassInfiltrator::SetupMoveData( void )
{
// Setup Class statistics
m_flMaxWalkingSpeed = class_infiltrator_speed.GetFloat();
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CPlayerClassInfiltrator::SetupSizeData( void )
{
// Initially set the player to the base player class standing hull size.
m_pPlayer->SetCollisionBounds( INFILTRATORCLASS_HULL_STAND_MIN, INFILTRATORCLASS_HULL_STAND_MAX );
m_pPlayer->SetViewOffset( INFILTRATORCLASS_VIEWOFFSET_STAND );
m_pPlayer->m_Local.m_flStepSize = INFILTRATORCLASS_STEPSIZE;
}
//-----------------------------------------------------------------------------
// Purpose: New technology has been gained. Recalculate any class specific technology dependencies.
//-----------------------------------------------------------------------------
void CPlayerClassInfiltrator::GainedNewTechnology( CBaseTechnology *pTechnology )
{
// Consume corpse technology?
m_bCanConsumeCorpses = m_pPlayer->HasNamedTechnology( "inf_consume_corpse" );
BaseClass::GainedNewTechnology( pTechnology );
}
//-----------------------------------------------------------------------------
// Purpose: Return true if this player's allowed to build another one of the specified objects
//-----------------------------------------------------------------------------
int CPlayerClassInfiltrator::CanBuild( int iObjectType )
{
return BaseClass::CanBuild( iObjectType );
}
//-----------------------------------------------------------------------------
// Purpose: Called every frame by postthink
//-----------------------------------------------------------------------------
void CPlayerClassInfiltrator::ClassThink( void )
{
BaseClass::ClassThink();
CheckForAssassination();
}
//-----------------------------------------------------------------------------
// Purpose: The player's just had his camo cleared
//-----------------------------------------------------------------------------
void CPlayerClassInfiltrator::ClearCamouflage( void )
{
float flNewTime = gpGlobals->curtime + INFILTRATOR_RECAMO_TIME;
if ( flNewTime > m_flStartCamoAt )
{
m_flStartCamoAt = flNewTime;
}
}
//-----------------------------------------------------------------------------
// Purpose: Player's finished disguising.
//-----------------------------------------------------------------------------
void CPlayerClassInfiltrator::FinishedDisguising( void )
{
// Remove my camo
m_pPlayer->ClearCamouflage();
}
//-----------------------------------------------------------------------------
// Purpose: Player's lost his disguise.
//-----------------------------------------------------------------------------
void CPlayerClassInfiltrator::StopDisguising( void )
{
// Remove & restart my camo
m_pPlayer->ClearCamouflage();
}
//-----------------------------------------------------------------------------
// Purpose: Handle custom commands for this playerclass
//-----------------------------------------------------------------------------
bool CPlayerClassInfiltrator::ClientCommand( const char *pcmd )
{
// Toggle thermal vision
if ( FStrEq( pcmd, "special" ) )
{
Assert( m_pPlayer );
// Toggle
m_pPlayer->SetUsingThermalVision( !m_pPlayer->IsUsingThermalVision() );
return true;
}
return BaseClass::ClientCommand( pcmd );
}
//-----------------------------------------------------------------------------
// Purpose: Check to see if I can assassinate anyone
//-----------------------------------------------------------------------------
void CPlayerClassInfiltrator::CheckForAssassination( void )
{
/*
// Find my assassination weapon if I haven't already
if ( m_hAssassinationWeapon == NULL )
{
m_hAssassinationWeapon = (CWeaponInfiltrator*)m_pPlayer->Weapon_OwnsThisType( "weapon_infiltrator" );
}
// No Assasination weapon?
if ( m_hAssassinationWeapon == NULL )
return;
// If we have a target, bring the assassination weapon up.
if ( m_hAssassinationWeapon->GetAssassinationTarget() )
{
if ( m_pPlayer->GetActiveWeapon() != m_hAssassinationWeapon.Get() )
{
m_hSwappedWeapon = m_pPlayer->GetActiveWeapon();
m_pPlayer->Weapon_Switch( m_hAssassinationWeapon );
}
}
else
{
// We have no target. If the assassination weapon's up, put it away.
if ( m_pPlayer->GetActiveWeapon() == m_hAssassinationWeapon.Get() )
{
// Don't switch until the weapon's finished killing people
if ( m_pPlayer->GetActiveWeapon()->m_flNextPrimaryAttack <= gpGlobals->curtime )
{
m_pPlayer->Weapon_Switch( m_hSwappedWeapon );
m_hSwappedWeapon = NULL;
}
}
}
*/
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CPlayerClassInfiltrator::SetPlayerHull( void )
{
if ( m_pPlayer->GetFlags() & FL_DUCKING )
{
m_pPlayer->SetCollisionBounds( INFILTRATORCLASS_HULL_DUCK_MIN, INFILTRATORCLASS_HULL_DUCK_MAX );
}
else
{
m_pPlayer->SetCollisionBounds( INFILTRATORCLASS_HULL_STAND_MIN, INFILTRATORCLASS_HULL_STAND_MAX );
}
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CPlayerClassInfiltrator::ResetViewOffset( void )
{
if ( m_pPlayer )
{
m_pPlayer->SetViewOffset( INFILTRATORCLASS_VIEWOFFSET_STAND );
}
}
|