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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================
#include "cbase.h"
#ifdef CLIENT_DLL
#include "iinput.h"
#endif
#include "tf_weapon_pda.h"
#include "in_buttons.h"
#include "tf_gamerules.h"
#include "tf_weaponbase_gun.h"
// Server specific.
#if !defined( CLIENT_DLL )
#include "tf_player.h"
#include "vguiscreen.h"
// Client specific.
#else
#include "c_tf_player.h"
#include <igameevents.h>
#include "tf_hud_menu_engy_build.h"
#include "tf_hud_menu_engy_destroy.h"
#include "tf_hud_menu_spy_disguise.h"
#include "prediction.h"
#ifdef STAGING_ONLY
#include "tf_hud_menu_spy_build.h"
#endif // STAGING_ONLY
#endif
//=============================================================================
//
// TFWeaponBase Melee tables.
//
IMPLEMENT_NETWORKCLASS_ALIASED( TFWeaponPDA, DT_TFWeaponPDA )
BEGIN_NETWORK_TABLE( CTFWeaponPDA, DT_TFWeaponPDA )
END_NETWORK_TABLE()
BEGIN_PREDICTION_DATA( CTFWeaponPDA )
END_PREDICTION_DATA()
// Server specific.
#if !defined( CLIENT_DLL )
BEGIN_DATADESC( CTFWeaponPDA )
END_DATADESC()
#endif
LINK_ENTITY_TO_CLASS( tf_pda_expansion_dispenser, CTFWeaponPDAExpansion_Dispenser );
IMPLEMENT_NETWORKCLASS_ALIASED( TFWeaponPDAExpansion_Dispenser, DT_TFWeaponPDAExpansion_Dispenser )
// Network Table --
BEGIN_NETWORK_TABLE( CTFWeaponPDAExpansion_Dispenser, DT_TFWeaponPDAExpansion_Dispenser )
END_NETWORK_TABLE()
// -- Network Table
// Data Desc --
BEGIN_DATADESC( CTFWeaponPDAExpansion_Dispenser )
END_DATADESC()
//************************************************************************************************
LINK_ENTITY_TO_CLASS( tf_pda_expansion_teleporter, CTFWeaponPDAExpansion_Teleporter );
IMPLEMENT_NETWORKCLASS_ALIASED( TFWeaponPDAExpansion_Teleporter, DT_TFWeaponPDAExpansion_Teleporter )
// Network Table --
BEGIN_NETWORK_TABLE( CTFWeaponPDAExpansion_Teleporter, DT_TFWeaponPDAExpansion_Teleporter )
END_NETWORK_TABLE()
// -- Network Table
// Data Desc --
BEGIN_DATADESC( CTFWeaponPDAExpansion_Teleporter )
END_DATADESC()
CTFWeaponPDA::CTFWeaponPDA()
{
}
void CTFWeaponPDA::Spawn()
{
BaseClass::Spawn();
}
//-----------------------------------------------------------------------------
// Purpose: cancel menu
//-----------------------------------------------------------------------------
void CTFWeaponPDA::PrimaryAttack( void )
{
CTFPlayer *pOwner = ToTFPlayer( GetOwner() );
if ( !pOwner )
{
return;
}
pOwner->SelectLastItem();
}
//-----------------------------------------------------------------------------
// Purpose: toggle invis
//-----------------------------------------------------------------------------
void CTFWeaponPDA::SecondaryAttack( void )
{
// semi-auto behaviour
if ( m_bInAttack2 )
return;
// Get the player owning the weapon.
CTFPlayer *pPlayer = ToTFPlayer( GetPlayerOwner() );
if ( !pPlayer )
return;
pPlayer->DoClassSpecialSkill();
m_bInAttack2 = true;
m_flNextSecondaryAttack = gpGlobals->curtime + 0.5;
}
#if !defined( CLIENT_DLL )
void CTFWeaponPDA::Precache()
{
BaseClass::Precache();
PrecacheVGuiScreen( GetPanelName() );
}
//-----------------------------------------------------------------------------
// Purpose: Gets info about the control panels
//-----------------------------------------------------------------------------
void CTFWeaponPDA::GetControlPanelInfo( int nPanelIndex, const char *&pPanelName )
{
pPanelName = GetPanelName();
}
#else
float CTFWeaponPDA::CalcViewmodelBob( void )
{
// no bob
return BaseClass::CalcViewmodelBob();
}
#endif
//-----------------------------------------------------------------------------
// Purpose:
// Output : Returns true on success, false on failure.
//-----------------------------------------------------------------------------
bool CTFWeaponPDA::ShouldShowControlPanels( void )
{
return true;
}
#ifdef CLIENT_DLL
void CTFWeaponPDA::OnDataChanged( DataUpdateType_t type )
{
if ( m_iState != m_iOldState && GetOwner() == C_TFPlayer::GetLocalTFPlayer() )
{
// Was active, now not
if ( m_iOldState == WEAPON_IS_ACTIVE && m_iState != m_iOldState )
{
CHudBaseBuildMenu *pBuildMenu = GetBuildMenu();
Assert( pBuildMenu );
if ( pBuildMenu )
{
pBuildMenu->SetBuilderEquipped( false );
}
}
else if ( m_iState == WEAPON_IS_ACTIVE && m_iOldState == WEAPON_IS_CARRIED_BY_PLAYER ) // Was inactive, now is
{
CHudBaseBuildMenu *pBuildMenu = GetBuildMenu();
Assert( pBuildMenu );
if ( pBuildMenu )
{
pBuildMenu->SetBuilderEquipped( true );
}
}
}
BaseClass::OnDataChanged( type );
}
void CTFWeaponPDA::UpdateOnRemove()
{
CHudBaseBuildMenu *pBuildMenu = GetBuildMenu();
Assert( pBuildMenu );
if ( pBuildMenu )
{
pBuildMenu->SetBuilderEquipped( false );
}
return BaseClass::UpdateOnRemove();
}
#endif
//==============================
IMPLEMENT_NETWORKCLASS_ALIASED( TFWeaponPDA_Engineer_Build, DT_TFWeaponPDA_Engineer_Build )
BEGIN_NETWORK_TABLE( CTFWeaponPDA_Engineer_Build, DT_TFWeaponPDA_Engineer_Build )
END_NETWORK_TABLE()
BEGIN_PREDICTION_DATA( CTFWeaponPDA_Engineer_Build )
END_PREDICTION_DATA()
LINK_ENTITY_TO_CLASS( tf_weapon_pda_engineer_build, CTFWeaponPDA_Engineer_Build );
PRECACHE_WEAPON_REGISTER( tf_weapon_pda_engineer_build );
#ifdef CLIENT_DLL
CHudBaseBuildMenu *CTFWeaponPDA_Engineer_Build::GetBuildMenu() const
{
return GET_HUDELEMENT( CHudMenuEngyBuild );
}
#endif // CLIENT_DLL
//==============================
IMPLEMENT_NETWORKCLASS_ALIASED( TFWeaponPDA_Engineer_Destroy, DT_TFWeaponPDA_Engineer_Destroy )
BEGIN_NETWORK_TABLE( CTFWeaponPDA_Engineer_Destroy, DT_TFWeaponPDA_Engineer_Destroy )
END_NETWORK_TABLE()
BEGIN_PREDICTION_DATA( CTFWeaponPDA_Engineer_Destroy )
END_PREDICTION_DATA()
LINK_ENTITY_TO_CLASS( tf_weapon_pda_engineer_destroy, CTFWeaponPDA_Engineer_Destroy );
PRECACHE_WEAPON_REGISTER( tf_weapon_pda_engineer_destroy );
#ifdef CLIENT_DLL
CHudBaseBuildMenu *CTFWeaponPDA_Engineer_Destroy::GetBuildMenu() const
{
return GET_HUDELEMENT( CHudMenuEngyDestroy );
}
#endif // CLIENT_DLL
//==============================
IMPLEMENT_NETWORKCLASS_ALIASED( TFWeaponPDA_Spy, DT_TFWeaponPDA_Spy )
BEGIN_NETWORK_TABLE( CTFWeaponPDA_Spy, DT_TFWeaponPDA_Spy )
END_NETWORK_TABLE()
BEGIN_PREDICTION_DATA( CTFWeaponPDA_Spy )
END_PREDICTION_DATA()
LINK_ENTITY_TO_CLASS( tf_weapon_pda_spy, CTFWeaponPDA_Spy );
PRECACHE_WEAPON_REGISTER( tf_weapon_pda_spy );
#ifdef CLIENT_DLL
CHudBaseBuildMenu *CTFWeaponPDA_Spy::GetBuildMenu() const
{
return GET_HUDELEMENT( CHudMenuSpyDisguise );
}
#endif // CLIENT_DLL
#ifdef STAGING_ONLY
//==============================
IMPLEMENT_NETWORKCLASS_ALIASED( TFWeaponPDA_Spy_Build, DT_TFWeaponPDA_Spy_Build )
BEGIN_NETWORK_TABLE( CTFWeaponPDA_Spy_Build, DT_TFWeaponPDA_Spy_Build )
END_NETWORK_TABLE()
BEGIN_PREDICTION_DATA( CTFWeaponPDA_Spy_Build )
END_PREDICTION_DATA()
LINK_ENTITY_TO_CLASS( tf_weapon_pda_spy_build, CTFWeaponPDA_Spy_Build );
PRECACHE_WEAPON_REGISTER( tf_weapon_pda_spy_build );
#ifdef CLIENT_DLL
CHudBaseBuildMenu *CTFWeaponPDA_Spy_Build::GetBuildMenu() const
{
return GET_HUDELEMENT( CHudMenuSpyBuild );
}
#endif // CLIENT_DLL
#endif // STAGING_ONLY
//==============================
void CTFWeaponPDA_Spy::ItemPreFrame( void )
{
BaseClass::ItemPreFrame();
ProcessDisguiseImpulse();
CheckDisguiseTimer();
}
void CTFWeaponPDA_Spy::ItemBusyFrame( void )
{
BaseClass::ItemBusyFrame();
ProcessDisguiseImpulse();
CheckDisguiseTimer();
}
void CTFWeaponPDA_Spy::ItemHolsterFrame( void )
{
BaseClass::ItemHolsterFrame();
ProcessDisguiseImpulse();
CheckDisguiseTimer();
}
void CTFWeaponPDA_Spy::ProcessDisguiseImpulse( void )
{
CTFPlayer *pPlayer = ToTFPlayer( GetPlayerOwner() );
if ( !pPlayer )
return;
pPlayer->m_Shared.ProcessDisguiseImpulse( pPlayer );
}
void CTFWeaponPDA_Spy::CheckDisguiseTimer( void )
{
/*
// Get the player owning the weapon.
CTFPlayer *pPlayer = ToTFPlayer( GetPlayerOwner() );
if ( !pPlayer )
return;
if ( pPlayer->m_Shared.InCond( TF_COND_DISGUISING ) )
{
if ( gpGlobals->curtime > pPlayer->m_Shared.GetDisguiseCompleteTime() )
{
pPlayer->m_Shared.CompleteDisguise();
}
}
*/
}
#ifdef CLIENT_DLL
bool CTFWeaponPDA_Spy::Deploy( void )
{
bool bDeploy = BaseClass::Deploy();
if ( bDeploy )
{
// let the spy pda menu know to reset
IGameEvent *event = gameeventmanager->CreateEvent( "spy_pda_reset" );
if ( event )
{
gameeventmanager->FireEventClientSide( event );
}
}
return bDeploy;
}
#endif
bool CTFWeaponPDA_Spy::CanBeSelected( void )
{
CTFPlayer *pOwner = ToTFPlayer( GetOwner() );
if ( pOwner && !pOwner->CanDisguise() )
{
return false;
}
return BaseClass::CanBeSelected();
}
bool CTFWeaponPDA_Spy::VisibleInWeaponSelection( void )
{
if ( !CanBeSelected() )
return false;
return BaseClass::VisibleInWeaponSelection();
}
//-----------------------------------------------------------------------------
// PDA Expansion Slots
void CTFWeaponPDAExpansion_Dispenser::Equip( CBasePlayer *pOwner )
{
#ifdef GAME_DLL
CTFPlayer *pPlayer = ToTFPlayer( pOwner );
if ( pPlayer )
{
// Detonate
CBaseObject *pObject = pPlayer->GetObjectOfType( OBJ_DISPENSER );
if ( pObject )
{
pObject->DetonateObject();
}
}
#endif
BaseClass::Equip( pOwner );
}
//-----------------------------------------------------------------------------
void CTFWeaponPDAExpansion_Dispenser::UnEquip( CBasePlayer *pOwner )
{
#ifdef GAME_DLL
CTFPlayer *pPlayer = ToTFPlayer( pOwner );
if ( pPlayer )
{
// Detonate
CBaseObject *pObject = pPlayer->GetObjectOfType( OBJ_DISPENSER );
if ( pObject )
{
pObject->DetonateObject();
}
}
#endif
BaseClass::UnEquip( pOwner );
}
//-----------------------------------------------------------------------------
void CTFWeaponPDAExpansion_Teleporter::Equip( CBasePlayer *pOwner )
{
#ifdef GAME_DLL
CTFPlayer *pPlayer = ToTFPlayer( pOwner );
if ( pPlayer )
{
// Detonate entrance and exit
CBaseObject *pObject = pPlayer->GetObjectOfType( OBJ_TELEPORTER, 0 );
if ( pObject )
{
pObject->DetonateObject();
}
pObject = pPlayer->GetObjectOfType( OBJ_TELEPORTER, 1 );
if ( pObject )
{
pObject->DetonateObject();
}
pObject = pPlayer->GetObjectOfType( OBJ_TELEPORTER, 2 );
if ( pObject )
{
pObject->DetonateObject();
}
pObject = pPlayer->GetObjectOfType( OBJ_TELEPORTER, 3 );
if ( pObject )
{
pObject->DetonateObject();
}
}
#endif
BaseClass::Equip( pOwner );
}
//-----------------------------------------------------------------------------
void CTFWeaponPDAExpansion_Teleporter::UnEquip( CBasePlayer *pOwner )
{
#ifdef GAME_DLL
CTFPlayer *pPlayer = ToTFPlayer( pOwner );
if ( pPlayer )
{
// Detonate entrance and exit
CBaseObject *pObject = pPlayer->GetObjectOfType( OBJ_TELEPORTER, 0 );
if ( pObject )
{
pObject->DetonateObject();
}
pObject = pPlayer->GetObjectOfType( OBJ_TELEPORTER, 1 );
if ( pObject )
{
pObject->DetonateObject();
}
pObject = pPlayer->GetObjectOfType( OBJ_TELEPORTER, 2 );
if ( pObject )
{
pObject->DetonateObject();
}
pObject = pPlayer->GetObjectOfType( OBJ_TELEPORTER, 3 );
if ( pObject )
{
pObject->DetonateObject();
}
}
#endif
BaseClass::UnEquip( pOwner );
}
//-----------------------------------------------------------------------------
// Purpose: Check if we should show the "destroy" panel
//-----------------------------------------------------------------------------
bool CTFWeaponPDA_Engineer_Destroy::VisibleInWeaponSelection( void )
{
if ( IsConsole()
#ifdef CLIENT_DLL
|| ::input->IsSteamControllerActive()
|| tf_build_menu_controller_mode.GetBool()
#endif
)
{
return false;
}
return BaseClass::VisibleInWeaponSelection();
}
#ifdef STAGING_ONLY
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool CTFWeaponPDA_Spy_Build::CanDeploy( void )
{
if ( !TFGameRules() || !TFGameRules()->GameModeUsesUpgrades() )
return false;
CTFPlayer *pPlayer = GetTFPlayerOwner();
if ( !pPlayer || !pPlayer->m_Shared.CanBuildSpyTraps() )
return false;
return BaseClass::CanDeploy();
}
//-----------------------------------------------------------------------------
// Purpose: UI Progress
//-----------------------------------------------------------------------------
float CTFWeaponPDA_Spy_Build::GetProgress( void )
{
CTFPlayer *pPlayer = GetTFPlayerOwner();
if ( !pPlayer )
return 0.f;
return pPlayer->m_Shared.GetRageMeter() / 100.0f;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool CTFWeaponPDA_Spy_Build::VisibleInWeaponSelection( void )
{
if ( !BaseClass::VisibleInWeaponSelection() )
return false;
return TFGameRules() && TFGameRules()->GameModeUsesUpgrades();
}
#endif // STAGING_ONLY
|