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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================//
#include "cbase.h"
#include "weapon_csbase.h"
#include "fx_cs_shared.h"
#if defined( CLIENT_DLL )
#define CWeaponFiveSeven C_WeaponFiveSeven
#include "c_cs_player.h"
#else
#include "cs_player.h"
#endif
class CWeaponFiveSeven : public CWeaponCSBase
{
public:
DECLARE_CLASS( CWeaponFiveSeven, CWeaponCSBase );
DECLARE_NETWORKCLASS();
DECLARE_PREDICTABLE();
CWeaponFiveSeven();
virtual void Spawn();
virtual void PrimaryAttack();
virtual void SecondaryAttack();
virtual bool Deploy();
virtual bool Reload();
virtual void WeaponIdle();
virtual float GetInaccuracy() const;
virtual CSWeaponID GetWeaponID( void ) const { return WEAPON_FIVESEVEN; }
private:
CWeaponFiveSeven( const CWeaponFiveSeven & );
float m_flLastFire;
};
IMPLEMENT_NETWORKCLASS_ALIASED( WeaponFiveSeven, DT_WeaponFiveSeven )
BEGIN_NETWORK_TABLE( CWeaponFiveSeven, DT_WeaponFiveSeven )
END_NETWORK_TABLE()
#if defined CLIENT_DLL
BEGIN_PREDICTION_DATA( CWeaponFiveSeven )
DEFINE_FIELD( m_flLastFire, FIELD_FLOAT ),
END_PREDICTION_DATA()
#endif
LINK_ENTITY_TO_CLASS( weapon_fiveseven, CWeaponFiveSeven );
PRECACHE_WEAPON_REGISTER( weapon_fiveseven );
CWeaponFiveSeven::CWeaponFiveSeven()
{
m_flLastFire = gpGlobals->curtime;
}
void CWeaponFiveSeven::Spawn( )
{
BaseClass::Spawn();
m_flAccuracy = 0.92;
}
bool CWeaponFiveSeven::Deploy()
{
m_flAccuracy = 0.92;
return BaseClass::Deploy();
}
float CWeaponFiveSeven::GetInaccuracy() const
{
if ( weapon_accuracy_model.GetInt() == 1 )
{
CCSPlayer *pPlayer = GetPlayerOwner();
if ( !pPlayer )
return 0.0f;
if ( !FBitSet( pPlayer->GetFlags(), FL_ONGROUND ) )
return 1.5f * (1 - m_flAccuracy);
else if (pPlayer->GetAbsVelocity().Length2D() > 5)
return 0.255f * (1 - m_flAccuracy);
else if ( FBitSet( pPlayer->GetFlags(), FL_DUCKING ) )
return 0.075f * (1 - m_flAccuracy);
else
return 0.15f * (1 - m_flAccuracy);
}
else
return BaseClass::GetInaccuracy();
}
void CWeaponFiveSeven::PrimaryAttack()
{
CCSPlayer *pPlayer = GetPlayerOwner();
if ( !pPlayer )
return;
// Mark the time of this shot and determine the accuracy modifier based on the last shot fired...
m_flAccuracy -= (0.25)*(0.275 - (gpGlobals->curtime - m_flLastFire));
if (m_flAccuracy > 0.92)
m_flAccuracy = 0.92;
else if (m_flAccuracy < 0.725)
m_flAccuracy = 0.725;
m_flLastFire = gpGlobals->curtime;
if (m_iClip1 <= 0)
{
if ( m_bFireOnEmpty )
{
PlayEmptySound();
m_flNextPrimaryAttack = gpGlobals->curtime + 0.1f;
m_bFireOnEmpty = false;
}
return;
}
pPlayer->m_iShotsFired++;
m_iClip1--;
pPlayer->DoMuzzleFlash();
SendWeaponAnim( ACT_VM_PRIMARYATTACK );
// player "shoot" animation
pPlayer->SetAnimation( PLAYER_ATTACK1 );
FX_FireBullets(
pPlayer->entindex(),
pPlayer->Weapon_ShootPosition(),
pPlayer->EyeAngles() + 2.0f * pPlayer->GetPunchAngle(),
GetWeaponID(),
Primary_Mode,
CBaseEntity::GetPredictionRandomSeed() & 255,
GetInaccuracy(),
GetSpread());
m_flNextPrimaryAttack = m_flNextSecondaryAttack = gpGlobals->curtime + GetCSWpnData().m_flCycleTime;
if (!m_iClip1 && pPlayer->GetAmmoCount( GetPrimaryAmmoType() ) <= 0)
{
// HEV suit - indicate out of ammo condition
pPlayer->SetSuitUpdate("!HEV_AMO0", false, 0);
}
SetWeaponIdleTime( gpGlobals->curtime + 2 );
// update accuracy
m_fAccuracyPenalty += GetCSWpnData().m_fInaccuracyImpulseFire[Primary_Mode];
QAngle angle = pPlayer->GetPunchAngle();
angle.x -= 2;
pPlayer->SetPunchAngle( angle );
}
void CWeaponFiveSeven::SecondaryAttack()
{
}
bool CWeaponFiveSeven::Reload()
{
if ( !DefaultPistolReload() )
return false;
m_flAccuracy = 0.92;
return true;
}
void CWeaponFiveSeven::WeaponIdle()
{
if (m_flTimeWeaponIdle > gpGlobals->curtime)
return;
// only idle if the slid isn't back
if (m_iClip1 != 0)
{
SetWeaponIdleTime( gpGlobals->curtime + 4 );
SendWeaponAnim( ACT_VM_IDLE );
}
}
|