summaryrefslogtreecommitdiff
path: root/game/shared/tf/tf_weaponbase_gun.h
blob: b35f3dc0922eb9ae70fbe6dbe62c0fea8401bb42 (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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: Weapon Base Gun 
//
//=============================================================================

#ifndef TF_WEAPONBASE_GUN_H
#define TF_WEAPONBASE_GUN_H
#ifdef _WIN32
#pragma once
#endif

#include "tf_shareddefs.h"
#include "tf_weaponbase.h"

#define CREATE_SIMPLE_WEAPON_TABLE( WpnName, entityname )			\
	\
	IMPLEMENT_NETWORKCLASS_ALIASED( WpnName, DT_##WpnName )	\
	\
	BEGIN_NETWORK_TABLE( C##WpnName, DT_##WpnName )			\
	END_NETWORK_TABLE()										\
	\
	BEGIN_PREDICTION_DATA( C##WpnName )						\
	END_PREDICTION_DATA()									\
	\
	LINK_ENTITY_TO_CLASS( entityname, C##WpnName );			\
	PRECACHE_WEAPON_REGISTER( entityname );

#if defined( CLIENT_DLL )
#define CTFWeaponBaseGun C_TFWeaponBaseGun
#endif

#define ZOOM_CONTEXT		"ZoomContext"
#define ZOOM_REZOOM_TIME	1.4f

//=============================================================================
//
// Weapon Base Melee Gun
//
class CTFWeaponBaseGun : public CTFWeaponBase
{
public:

	DECLARE_CLASS( CTFWeaponBaseGun, CTFWeaponBase );
	DECLARE_NETWORKCLASS(); 
	DECLARE_PREDICTABLE();
#if !defined( CLIENT_DLL ) 
	DECLARE_DATADESC();
#endif

	CTFWeaponBaseGun();

	virtual void PrimaryAttack();
	virtual void SecondaryAttack( void );
	virtual bool Holster( CBaseCombatWeapon *pSwitchingTo );

	// Derived classes call this to fire a bullet.
	//bool TFBaseGunFire( void );

	virtual void DoFireEffects();
	virtual bool ShouldDoMuzzleFlash( void ) { return true; }

	void ToggleZoom( void );

	virtual int GetWeaponProjectileType( void ) const { return m_pWeaponInfo->GetWeaponData( m_iWeaponMode ).m_iProjectile; }
	virtual CBaseEntity *FireProjectile( CTFPlayer *pPlayer );
	virtual void RemoveProjectileAmmo( CTFPlayer *pPlayer );
	virtual void ModifyProjectile( CBaseEntity* pProj ) {};

	virtual void FireBullet( CTFPlayer *pPlayer );
	CBaseEntity *FireRocket( CTFPlayer *pPlayer, int iRocketType=0 );
	CBaseEntity *FireNail( CTFPlayer *pPlayer, int iSpecificNail );
	virtual CBaseEntity *FirePipeBomb( CTFPlayer *pPlayer, int iPipeBombType );
	CBaseEntity *FireFlare( CTFPlayer *pPlayer );
	virtual CBaseEntity *FireArrow( CTFPlayer *pPlayer, ProjectileType_t projectileType );
	virtual CBaseEntity *FireJar( CTFPlayer *pPlayer );
	virtual CBaseEntity *FireFlameRocket( CTFPlayer *pPlayer );
	virtual CBaseEntity *FireEnergyBall( CTFPlayer *pPlayer, bool bRing=false );

	virtual bool HasLastShotCritical( void );

	virtual float GetWeaponSpread( void );
	virtual void  GetCustomProjectileModel( CAttribute_String *attrCustomProjModel );
	virtual float GetProjectileSpeed( void ) { return 0.0f; }
	virtual float GetProjectileGravity( void ) { return 0.f; }
	virtual float GetProjectileSpread( void ) { return 0.0f; }

	virtual int GetAmmoPerShot( void );

	void UpdatePunchAngles( CTFPlayer *pPlayer );
	virtual float GetProjectileDamage( void );

	virtual bool ShouldPlayFireAnim( void ) { return true; }

	virtual void ZoomIn( void );
	virtual void ZoomOut( void );
	void ZoomOutIn( void );

	virtual void PlayWeaponShootSound( void );
	virtual bool HasPrimaryAmmo( void );
	virtual bool CanDeploy( void );
	virtual bool CanBeSelected( void );

	virtual bool ShouldRemoveDisguiseOnPrimaryAttack() const;

private:

	CTFWeaponBaseGun( const CTFWeaponBaseGun & );
};

#endif // TF_WEAPONBASE_GUN_H