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

#include "cbase.h" 
#include "weapon_dodfullauto_punch.h"
#include "in_buttons.h"
#include "dod_shareddefs.h"

#ifndef CLIENT_DLL
#include "dod_player.h"
#endif

IMPLEMENT_NETWORKCLASS_ALIASED( DODFullAutoPunchWeapon, DT_FullAutoPunchWeapon )

BEGIN_NETWORK_TABLE( CDODFullAutoPunchWeapon, DT_FullAutoPunchWeapon )
END_NETWORK_TABLE()

#ifdef CLIENT_DLL
BEGIN_PREDICTION_DATA( CDODFullAutoPunchWeapon )
END_PREDICTION_DATA()
#endif

void CDODFullAutoPunchWeapon::Spawn( void )
{
	m_iAltFireHint = HINT_USE_MELEE;

	BaseClass::Spawn();
}

void CDODFullAutoPunchWeapon::SecondaryAttack( void )
{
	if ( m_bInReload )
	{
		m_bInReload = false;
		GetPlayerOwner()->m_flNextAttack = gpGlobals->curtime;
	}
	else if ( GetPlayerOwner()->m_flNextAttack > gpGlobals->curtime )
	{
		return;
	}

	Punch();

	// start calling ItemPostFrame
	GetPlayerOwner()->m_flNextAttack = gpGlobals->curtime;

	m_flNextPrimaryAttack = m_flNextSecondaryAttack;

#ifndef CLIENT_DLL
	CDODPlayer *pPlayer = GetDODPlayerOwner();
	if ( pPlayer )
	{
		pPlayer->RemoveHintTimer( m_iAltFireHint );
	}
#endif
}

bool CDODFullAutoPunchWeapon::Reload( void )
{
	bool bSuccess = BaseClass::Reload();

	if ( bSuccess )
	{
		m_flNextSecondaryAttack = gpGlobals->curtime;
	}

	return bSuccess;
}

void CDODFullAutoPunchWeapon::ItemBusyFrame( void )
{
	BaseClass::ItemBusyFrame();

	CBasePlayer *pPlayer = GetPlayerOwner();

	if ( pPlayer && (pPlayer->m_nButtons & IN_ATTACK2) && (m_flNextSecondaryAttack <= gpGlobals->curtime))
	{
		SecondaryAttack();
		pPlayer->m_nButtons &= ~IN_ATTACK2;
	}
}