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
170
171
172
173
174
175
176
177
178
179
180
181
182
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================//
#include "cbase.h"
#include "basehlcombatweapon.h"
#include "NPCevent.h"
#include "basecombatcharacter.h"
#include "ai_basenpc.h"
#include "player.h"
#include "in_buttons.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
#define DAMAGE_PER_SECOND 10
#define MAX_SETTINGS 5
float RateOfFire[ MAX_SETTINGS ] =
{
0.1,
0.2,
0.5,
0.7,
1.0,
};
float Damage[ MAX_SETTINGS ] =
{
2,
4,
10,
14,
20,
};
//=========================================================
//=========================================================
class CWeaponAR1 : public CHLMachineGun
{
DECLARE_DATADESC();
public:
DECLARE_CLASS( CWeaponAR1, CHLMachineGun );
DECLARE_SERVERCLASS();
CWeaponAR1();
int m_ROF;
void Precache( void );
bool Deploy( void );
float GetFireRate( void ) {return RateOfFire[ m_ROF ];}
int CapabilitiesGet( void ) { return bits_CAP_WEAPON_RANGE_ATTACK1; }
void SecondaryAttack( void );
virtual void FireBullets( const FireBulletsInfo_t &info );
virtual const Vector& GetBulletSpread( void )
{
static const Vector cone = VECTOR_CONE_10DEGREES;
return cone;
}
void Operator_HandleAnimEvent( animevent_t *pEvent, CBaseCombatCharacter *pOperator )
{
switch( pEvent->event )
{
case EVENT_WEAPON_AR1:
{
Vector vecShootOrigin, vecShootDir;
vecShootOrigin = pOperator->Weapon_ShootPosition( );
CAI_BaseNPC *npc = pOperator->MyNPCPointer();
ASSERT( npc != NULL );
vecShootDir = npc->GetActualShootTrajectory( vecShootOrigin );
WeaponSound(SINGLE_NPC);
pOperator->FireBullets( 1, vecShootOrigin, vecShootDir, VECTOR_CONE_PRECALCULATED, MAX_TRACE_LENGTH, m_iPrimaryAmmoType, 2 );
pOperator->DoMuzzleFlash();
}
break;
default:
CBaseCombatWeapon::Operator_HandleAnimEvent( pEvent, pOperator );
break;
}
}
DECLARE_ACTTABLE();
};
IMPLEMENT_SERVERCLASS_ST(CWeaponAR1, DT_WeaponAR1)
END_SEND_TABLE()
LINK_ENTITY_TO_CLASS( weapon_ar1, CWeaponAR1 );
PRECACHE_WEAPON_REGISTER(weapon_ar1);
acttable_t CWeaponAR1::m_acttable[] =
{
{ ACT_RANGE_ATTACK1, ACT_RANGE_ATTACK_AR1, true },
};
IMPLEMENT_ACTTABLE(CWeaponAR1);
//---------------------------------------------------------
// Save/Restore
//---------------------------------------------------------
BEGIN_DATADESC( CWeaponAR1 )
DEFINE_FIELD( m_ROF, FIELD_INTEGER ),
END_DATADESC()
CWeaponAR1::CWeaponAR1( )
{
m_ROF = 0;
}
void CWeaponAR1::Precache( void )
{
BaseClass::Precache();
}
bool CWeaponAR1::Deploy( void )
{
//CBaseCombatCharacter *pOwner = m_hOwner;
return BaseClass::Deploy();
}
//=========================================================
//=========================================================
void CWeaponAR1::FireBullets( const FireBulletsInfo_t &info )
{
if(CBasePlayer *pPlayer = ToBasePlayer( GetOwner() ))
{
pPlayer->FireBullets( info );
}
}
void CWeaponAR1::SecondaryAttack( void )
{
CBasePlayer *pPlayer = ToBasePlayer( GetOwner() );
if ( pPlayer )
{
pPlayer->m_nButtons &= ~IN_ATTACK2;
}
m_flNextSecondaryAttack = gpGlobals->curtime + 0.1;
m_ROF += 1;
if( m_ROF == MAX_SETTINGS )
{
m_ROF = 0;
}
int i;
Msg( "\n" );
for( i = 0 ; i < MAX_SETTINGS ; i++ )
{
if( i == m_ROF )
{
Msg( "|" );
}
else
{
Msg( "-" );
}
}
Msg( "\n" );
}
|