summaryrefslogtreecommitdiff
path: root/game/shared/tf/tf_weapon_grenadelauncher.h
blob: e5166e6f4dfe03f142d410912543704743dc8d8a (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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
//
//=============================================================================
#ifndef TF_WEAPON_GRENADELAUNCHER_H
#define TF_WEAPON_GRENADELAUNCHER_H
#ifdef _WIN32
#pragma once
#endif

#include "tf_weaponbase_gun.h"
#include "tf_weaponbase_grenadeproj.h"

// Client specific.
#ifdef CLIENT_DLL
#define CTFGrenadeLauncher	C_TFGrenadeLauncher
#define CTFCannon			C_TFCannon
#endif

#define TF_GRENADE_LAUNCHER_XBOX_CLIP 4

//=============================================================================
//
// TF Weapon Grenade Launcher.
//
class CTFGrenadeLauncher : public CTFWeaponBaseGun, public ITFChargeUpWeapon
{
public:

	DECLARE_CLASS( CTFGrenadeLauncher, CTFWeaponBaseGun );
	DECLARE_NETWORKCLASS(); 
	DECLARE_PREDICTABLE();

	// Server specific.
#ifdef GAME_DLL
	DECLARE_DATADESC();
#endif

	CTFGrenadeLauncher();
	~CTFGrenadeLauncher();

	virtual void	Spawn( void );
	virtual int		GetWeaponID( void ) const			{ return TF_WEAPON_GRENADELAUNCHER; }
	virtual void	SecondaryAttack();

	virtual void FireFullClipAtOnce( void );
	//virtual CBaseEntity* FirePipeBomb( CTFPlayer *pPlayer, int iPipeBombType );

	virtual bool	Holster( CBaseCombatWeapon *pSwitchingTo );
	virtual bool	Deploy( void );
	virtual void	PrimaryAttack( void );
	virtual void	ItemPostFrame( void );
	virtual void	Misfire( void );
	virtual void	WeaponIdle( void );
	virtual bool	SendWeaponAnim( int iActivity );
	virtual void	WeaponReset( void );
	virtual float	GetProjectileSpeed( void );

	int			  GetDetonateMode( void ) const;

	virtual bool	Reload( void );

	virtual int		GetMaxClip1( void ) const;
	virtual int		GetDefaultClip1( void ) const;

	virtual bool	IsBlastImpactWeapon( void ) const { return true; }

	// ITFChargeUpWeapon
	virtual bool CanCharge( void );
	virtual float GetChargeBeginTime( void );
	virtual float GetChargeMaxTime( void );

	void LaunchGrenade( void );

	void AddDonkVictim( const CBaseEntity* pVictim );
	bool IsDoubleDonk( const CBaseEntity* pVictim ) const;

private:

	CTFGrenadeLauncher( const CTFGrenadeLauncher & ) {}
	int m_nLauncherSlot;

	void FireProjectileInternal( CTFPlayer* pTFPlayer );
	void PostFire();

	void ResetDetonateTime();
	float GetMortarDetonateTimeLength();

	CNetworkVar( float, m_flDetonateTime );

	// Barrel rotation needs to be in sync
	CNetworkVar( int, m_iCurrentTube );	// Which tube is the one we just fired out of
	CNetworkVar( int, m_iGoalTube );	// Which tube is the one we would like to fire out of next?

	int		m_iBarrelBone;
	float	m_flBarrelRotateBeginTime;	// What time did we begin the animation to rotate to the next barrel?
	float	m_flBarrelAngle;	// What is the current rotation of the barrel?
	bool	m_bCurrentAndGoalTubeEqual;


#ifdef CLIENT_DLL
	void StartChargeEffects();
	void StopChargeEffects();

	CNewParticleEffect			*m_pCannonFuseSparkEffect;
	CNewParticleEffect			*m_pCannonCharge;

	// Barrel spinning (cribbed from Minigun)
	virtual CStudioHdr *OnNewModel( void );
	virtual void		StandardBlendingRules( CStudioHdr *hdr, Vector pos[], Quaternion q[], float currentTime, int boneMask );

	virtual	void		OnDataChanged( DataUpdateType_t type );

	void				UpdateBarrelMovement( void );

	virtual void		ViewModelAttachmentBlending( CStudioHdr *hdr, Vector pos[], Quaternion q[], float currentTime, int boneMask );
#endif // CLIENT_DLL

	virtual void		ItemPreFrame( void );

	struct Donks_t
	{
		CHandle <CBaseEntity> m_hVictim;
		float m_flExpireTime;
	};

	CUtlVector< Donks_t > m_vecDonkVictims;

};


class CTFCannon : public CTFGrenadeLauncher
{
public:
	DECLARE_CLASS( CTFCannon, CTFGrenadeLauncher );
	DECLARE_NETWORKCLASS(); 
	DECLARE_PREDICTABLE();

	virtual int		GetWeaponID( void ) const			{ return TF_WEAPON_CANNON; }
};

#endif // TF_WEAPON_GRENADELAUNCHER_H