summaryrefslogtreecommitdiff
path: root/game/shared/tf/tf_weapon_flag.cpp
blob: af2e985d7794294b02b9b438d08bc03de65d6193 (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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
//=============================================================================

#include "cbase.h"
#include "tf_weapon_flag.h"
#include "decals.h"

// Client specific.
#ifdef CLIENT_DLL
#include "c_tf_player.h"
// Server specific.
#else
#include "tf_player.h"
#include "tf_team.h"
#endif

//=============================================================================
//
// Weapon Flag tables.
//
IMPLEMENT_NETWORKCLASS_ALIASED( TFFlag, DT_TFWeaponFlag )

BEGIN_NETWORK_TABLE( CTFFlag, DT_TFWeaponFlag )
END_NETWORK_TABLE()

BEGIN_PREDICTION_DATA( CTFFlag )
END_PREDICTION_DATA()

LINK_ENTITY_TO_CLASS( tf_weapon_flag, CTFFlag );
PRECACHE_WEAPON_REGISTER( tf_weapon_flag );

//=============================================================================
//
// Weapon Flag functions.
//

//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
CTFFlag::CTFFlag()
{

}

//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool CTFFlag::Deploy( void )
{
	if ( BaseClass::Deploy() )
	{
#ifdef GAME_DLL
        TFTeamMgr()->PlayerCenterPrint( ToTFPlayer( GetOwner() ), "#TF_Flag_AltFireToDrop" );
#endif
		return true;
	}

	return false;
}

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CTFFlag::SecondaryAttack( void )
{
	CTFPlayer *pPlayer = ToTFPlayer( GetOwner() );

	if ( !pPlayer )
		return;

	if ( !CanAttack() )
		return;

#ifdef GAME_DLL
	pPlayer->DropCurrentWeapon();
#endif
	pPlayer->SwitchToNextBestWeapon( this );
}