summaryrefslogtreecommitdiff
path: root/game/shared/tf2/weapon_combat_grenade.cpp
blob: 781b710d22649ecd410d6075c7c5c1d69094f197 (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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:	The Commando's anti-personnel grenades
//
// $NoKeywords: $
//=============================================================================//
#include "cbase.h"
#include "basetfplayer_shared.h"
#include "weapon_combat_usedwithshieldbase.h"
#include "weapon_combat_basegrenade.h"
#include "weapon_combatshield.h"
#include "in_buttons.h"

#if !defined( CLIENT_DLL )
#include "grenade_antipersonnel.h"
#else
#define CWeaponCombatGrenade C_WeaponCombatGrenade
#endif

// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"


class CBaseGrenade;

//-----------------------------------------------------------------------------
// Purpose: Combo shield & grenade weapon
//-----------------------------------------------------------------------------
class CWeaponCombatGrenade : public CWeaponCombatBaseGrenade
{
	DECLARE_CLASS( CWeaponCombatGrenade, CWeaponCombatBaseGrenade );
public:
	DECLARE_NETWORKCLASS();
	DECLARE_PREDICTABLE();

	CWeaponCombatGrenade();

	virtual void Precache( void );
	virtual CBaseGrenade *CreateGrenade( const Vector &vecOrigin, const Vector &vecAngles, CBasePlayer *pOwner );

	// All predicted weapons need to implement and return true
	virtual bool			IsPredicted( void ) const
	{ 
		return true;
	}

#if defined( CLIENT_DLL )
	virtual bool	ShouldPredict( void )
	{
		if ( GetOwner() == C_BasePlayer::GetLocalPlayer() )
			return true;

		return BaseClass::ShouldPredict();
	}
#endif
private:														
	CWeaponCombatGrenade( const CWeaponCombatGrenade & );						

};

CWeaponCombatGrenade::CWeaponCombatGrenade( void )
{
	SetPredictionEligible( true );
}

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CWeaponCombatGrenade::Precache( void )
{
	BaseClass::Precache();
#if !defined( CLIENT_DLL )
	UTIL_PrecacheOther( "grenade_antipersonnel" );
#endif
}

CBaseGrenade *CWeaponCombatGrenade::CreateGrenade( const Vector &vecOrigin, const Vector &vecAngles, CBasePlayer *pOwner )
{
#if !defined( CLIENT_DLL )
	return CGrenadeAntiPersonnel::Create(vecOrigin, vecAngles, pOwner );
#else
	return NULL;
#endif
}


LINK_ENTITY_TO_CLASS( weapon_combat_grenade, CWeaponCombatGrenade );

IMPLEMENT_NETWORKCLASS_ALIASED( WeaponCombatGrenade, DT_WeaponCombatGrenade )

BEGIN_NETWORK_TABLE( CWeaponCombatGrenade, DT_WeaponCombatGrenade )
END_NETWORK_TABLE()

BEGIN_PREDICTION_DATA( CWeaponCombatGrenade )
END_PREDICTION_DATA()

PRECACHE_WEAPON_REGISTER(weapon_combat_grenade);