summaryrefslogtreecommitdiff
path: root/game/server/tf/tf_weapon_builder.h
blob: 681103194d8361e3b91f992b9a41eb57570965bf (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
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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
// $NoKeywords: $
//=============================================================================//

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

#include "tf_weaponbase.h"

class CBaseObject;

//=========================================================
// Builder Weapon
//=========================================================
class CTFWeaponBuilder : public CTFWeaponBase
{
	DECLARE_CLASS( CTFWeaponBuilder, CTFWeaponBase );
public:
	CTFWeaponBuilder();
	~CTFWeaponBuilder();

	DECLARE_SERVERCLASS();

	virtual void	SetSubType( int iSubType );
	virtual void	SetObjectMode( int iMode ) { m_iObjectMode = iMode; }
	virtual void	Precache( void );
	virtual bool	CanDeploy( void );
	virtual bool	Holster( CBaseCombatWeapon *pSwitchingTo = NULL );
	virtual void	ItemPostFrame( void );
	virtual void	PrimaryAttack( void );
	virtual void	SecondaryAttack( void );
	virtual void	WeaponIdle( void );
	virtual bool	Deploy( void );	
	virtual Activity GetDrawActivity( void );
	virtual const char *GetViewModel( int iViewModel ) const;
	virtual const char *GetWorldModel( void ) const;

	virtual bool	AllowsAutoSwitchTo( void ) const;

	virtual int		GetType( void ) { return m_iObjectType; }

	virtual Activity TranslateViewmodelHandActivity( Activity actBase );

	void	SetCurrentState( int iState );
	void	SwitchOwnersWeaponToLast();

	// Placement
	void	StartPlacement( void );
	void	StopPlacement( void );
	void	UpdatePlacementState( void );		// do a check for valid placement
	bool	IsValidPlacement( void );			// is this a valid placement pos?


	// Building
	void	StartBuilding( void );

	// Special P Sapper (Wheatley) Item
	void	WheatleySapperIdle( CTFPlayer *pOwner );
	bool	IsWheatleySapper( void );
	void	WheatleyReset( bool bResetIntro = false );
	void	SetWheatleyState( int iNewState );
	float	WheatleyEmitSound( const char *snd , bool bEmitToAll = false, bool bNoRepeats = false );
	bool	IsWheatleyTalking( void );
	void	WheatleyDamage( void );
	int		GetWheatleyIdleWait();

	// Selection
	bool	HasAmmo( void );
	int		GetSlot( void ) const;
	int		GetPosition( void ) const;
	const char *GetPrintName( void ) const;
	bool	CanBuildObjectType( int iObjectType );
	void	SetObjectTypeAsBuildable( int iObjectType );

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

	virtual void	WeaponReset( void );

	virtual float	InternalGetEffectBarRechargeTime( void ) { return 15.0; }
	virtual int		GetEffectBarAmmo( void ) { return TF_AMMO_GRENADES2; }

public:
	CNetworkVar( int, m_iBuildState );
	CNetworkVar( unsigned int, m_iObjectType );
	CNetworkVar( unsigned int, m_iObjectMode );
	CNetworkVar( bool, m_bRoboSapper );
	CNetworkVar( float, m_flWheatleyTalkingUntil );
	CNetworkArray( bool, m_aBuildableObjectTypes, OBJ_LAST );

	CNetworkHandle( CBaseObject, m_hObjectBeingBuilt );

	int m_iValidBuildPoseParam;

	float m_flNextDenySound;

	// P Sapper (Wheatley) 
	float		m_flNextVoicePakIdleStartTime;
	KeyValues	*m_pkvWavList;
	int			m_iSapState;
	
	float		m_flWheatleyLastDamage;
	float		m_flWheatleyLastDeploy;
	float		m_flWheatleyLastHolster;
	int			m_iWheatleyVOSequenceOffset;
	bool		m_bWheatleyIntroPlayed;
	EHANDLE     m_hLastSappedBuilding;
	Vector		m_vLastKnownSapPos;

private:
	bool		m_bAttack3Down;
};

// P Sapper (Wheatley) States
enum
{
	TF_PSAPSTATE_IDLE = 0,	
	TF_PSAPSTATE_WAITINGHACK,
	TF_PSAPSTATE_WAITINGHACKPW,
	TF_PSAPSTATE_WAITINGHACKED,
	TF_PSAPSTATE_WAITINGFOLLOWUP,
	TF_PSAPSTATE_SPECIALIDLE_KNIFE,
	TF_PSAPSTATE_SPECIALIDLE_HARMLESS,
	TF_PSAPSTATE_SPECIALIDLE_HACK,
	TF_PSAPSTATE_INTRO,
};


//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
class CTFWeaponSapper : public CTFWeaponBuilder, public ITFChargeUpWeapon
{
public:
	DECLARE_CLASS( CTFWeaponSapper, CTFWeaponBuilder );
	DECLARE_SERVERCLASS();
	//DECLARE_PREDICTABLE();

	CTFWeaponSapper();

	virtual void		ItemPostFrame( void );

	// ITFChargeUpWeapon
	virtual bool CanCharge( void )				{ return GetChargeMaxTime() > 0; }
	virtual float GetChargeBeginTime( void )	{ return m_flChargeBeginTime; }
	virtual float GetChargeMaxTime( void )		{ float flChargeTime = 0; CALL_ATTRIB_HOOK_FLOAT( flChargeTime, sapper_deploy_time ); return flChargeTime; };

	virtual const char *GetViewModel( int iViewModel ) const;
	virtual const char *GetWorldModel( void ) const;

	virtual Activity TranslateViewmodelHandActivity( Activity actBase );

private:
	//float	m_flChargeBeginTime;
	bool	m_bAttackDown;

	CNetworkVar( float, m_flChargeBeginTime );
};

#define WHEATLEY_IDLE_WAIT_SECS_MIN 10.0
#define WHEATLEY_IDLE_WAIT_SECS_MAX 20.0


#endif // TF_WEAPON_BUILDER_H