blob: 41f1caa072e41c24ec85a4bfec329a6ebb8200b2 (
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
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================//
#include "cbase.h"
#include "util.h"
#include "weapon_tfc_shotgun.h"
#include "decals.h"
#include "in_buttons.h"
#if defined( CLIENT_DLL )
#include "c_tfc_player.h"
#else
#include "tfc_player.h"
#endif
#define RE_SHOTGUN_TIME 2
// ----------------------------------------------------------------------------- //
// CTFCShotgun tables.
// ----------------------------------------------------------------------------- //
IMPLEMENT_NETWORKCLASS_ALIASED( TFCShotgun, DT_WeaponShotgun )
BEGIN_NETWORK_TABLE( CTFCShotgun, DT_WeaponShotgun )
END_NETWORK_TABLE()
BEGIN_PREDICTION_DATA( CTFCShotgun )
END_PREDICTION_DATA()
LINK_ENTITY_TO_CLASS( weapon_shotgun, CTFCShotgun );
PRECACHE_WEAPON_REGISTER( weapon_shotgun );
#ifndef CLIENT_DLL
BEGIN_DATADESC( CTFCShotgun )
END_DATADESC()
#endif
// ----------------------------------------------------------------------------- //
// CTFCShotgun implementation.
// ----------------------------------------------------------------------------- //
CTFCShotgun::CTFCShotgun()
{
m_fReloadTime = 0.25; // Time to insert an individual shell
m_iShellsReloaded = 1; // Number of shells inserted each reload
m_flPumpTime = -1;
m_fInSpecialReload = 0;
m_flNextReload = -1;
}
TFCWeaponID CTFCShotgun::GetWeaponID() const
{
return WEAPON_SHOTGUN;
}
void CTFCShotgun::PrimaryAttack()
{
CTFCPlayer *pOwner = GetPlayerOwner();
if ( !pOwner )
return;
Assert( Clip1() != 0 );
WeaponSound( SINGLE );
SendWeaponAnim( ACT_VM_PRIMARYATTACK );
pOwner->DoAnimationEvent( PLAYERANIMEVENT_FIRE_GUN );
// Shoot!
FireBulletsInfo_t info;
info.m_vecSrc = pOwner->Weapon_ShootPosition();
info.m_vecDirShooting = pOwner->GetAutoaimVector( AUTOAIM_5DEGREES );
info.m_iShots = 6;
info.m_flDistance = 2048;
info.m_iAmmoType = GetPrimaryAmmoType();
info.m_vecSpread = VECTOR_CONE_TF_SHOTGUN;
info.m_iTracerFreq = 0;
info.m_flDamage = 4;
pOwner->FireBullets( info );
m_flTimeWeaponIdle = gpGlobals->curtime + 5.0;
m_fInSpecialReload = 0;
pOwner->m_Shared.RemoveStateFlags( TFSTATE_RELOADING );
// Setup fire delays
m_iClip1 -= 1;
if ( Clip1() != 0 )
m_flPumpTime = gpGlobals->curtime + 0.5;
m_flNextPrimaryAttack = gpGlobals->curtime + 0.5;
}
void CTFCShotgun::SecondaryAttack()
{
return;
}
bool CTFCShotgun::Reload()
{
CTFCPlayer *pOwner = GetPlayerOwner();
if ( !pOwner )
return false;
if ( pOwner->GetAmmoCount( GetPrimaryAmmoType() ) < m_iShellsReloaded || Clip1() == GetMaxClip1() )
{
return false;
}
if (gpGlobals->curtime < m_flNextReload)
{
return false;
}
// don't reload until recoil is done
if (gpGlobals->curtime < m_flNextPrimaryAttack)
{
return false;
}
// check to see if we're ready to reload
if (m_fInSpecialReload == 0)
{
SendWeaponAnim( ACT_VM_PULLBACK ); // (ie: start reload)
pOwner->m_Shared.AddStateFlags( TFSTATE_RELOADING );
m_fInSpecialReload = 1;
m_flTimeWeaponIdle = gpGlobals->curtime + 0.1; // 0.6;
m_flNextPrimaryAttack = gpGlobals->curtime + 0.1; // 1.0;
}
else if (m_fInSpecialReload == 1)
{
if ( m_flTimeWeaponIdle > gpGlobals->curtime )
{
return false;
}
// was waiting for gun to move to side
m_fInSpecialReload = 2;
SendWeaponAnim( ACT_VM_RELOAD );
WeaponSound( RELOAD );
m_flNextReload = gpGlobals->curtime + m_fReloadTime; //0.5;
m_flTimeWeaponIdle = gpGlobals->curtime + m_fReloadTime; //0.5;
}
else
{
// Add them to the clip
m_iClip1 += m_iShellsReloaded;
pOwner->RemoveAmmo( m_iShellsReloaded, GetPrimaryAmmoType() );
m_fInSpecialReload = 1;
pOwner->m_Shared.RemoveStateFlags( TFSTATE_RELOADING );
}
return true;
}
void CTFCShotgun::WeaponIdle()
{
CTFCPlayer *pOwner = GetPlayerOwner();
if ( !pOwner )
return;
// After firing, pump the shotgun.
if ( m_flPumpTime != -1 && gpGlobals->curtime >= m_flPumpTime )
{
SendWeaponAnim( ACT_VM_PULLBACK_HIGH );
WeaponSound( SPECIAL1 ); // Pump sound.
m_flPumpTime = -1;
}
if ( gpGlobals->curtime > m_flTimeWeaponIdle)
{
if (Clip1() == 0 && m_fInSpecialReload == 0 && pOwner->GetAmmoCount( GetPrimaryAmmoType() ) >= m_iShellsReloaded)
{
Reload( );
}
else if (m_fInSpecialReload != 0)
{
if (Clip1() != GetMaxClip1() && pOwner->GetAmmoCount( GetPrimaryAmmoType() ) >= m_iShellsReloaded)
{
Reload( );
}
else
{
// play pumping sound
SendWeaponAnim( ACT_VM_PULLBACK_HIGH );
WeaponSound( SPECIAL1 ); // Pump sound.
m_fInSpecialReload = 0;
m_flTimeWeaponIdle = gpGlobals->curtime + 1.5;
}
}
else
{
SendWeaponAnim( ACT_VM_IDLE );
m_flTimeWeaponIdle = gpGlobals->curtime + GetViewModelSequenceDuration();
}
}
}
#ifdef CLIENT_DLL
// ------------------------------------------------------------------------------------------------ //
// ------------------------------------------------------------------------------------------------ //
// CLIENT DLL SPECIFIC CODE
// ------------------------------------------------------------------------------------------------ //
// ------------------------------------------------------------------------------------------------ //
#else
// ------------------------------------------------------------------------------------------------ //
// ------------------------------------------------------------------------------------------------ //
// GAME DLL SPECIFIC CODE
// ------------------------------------------------------------------------------------------------ //
// ------------------------------------------------------------------------------------------------ //
#endif
|