-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathasw_weapon_minigun.cpp
More file actions
645 lines (538 loc) · 17.2 KB
/
asw_weapon_minigun.cpp
File metadata and controls
645 lines (538 loc) · 17.2 KB
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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
#include "cbase.h"
#include "asw_weapon_minigun.h"
#include "in_buttons.h"
#ifdef CLIENT_DLL
#include "c_asw_player.h"
#include "c_asw_weapon.h"
#include "c_asw_marine.h"
#include "c_asw_marine_resource.h"
#include "c_te_legacytempents.h"
#include "c_asw_gun_smoke_emitter.h"
#include "soundenvelope.h"
#define CASW_Marine_Resource C_ASW_Marine_Resource
#define CASW_Marine C_ASW_Marine
#else
#include "asw_lag_compensation.h"
#include "asw_marine.h"
#include "asw_player.h"
#include "asw_weapon.h"
#include "npcevent.h"
#include "shot_manipulator.h"
#include "asw_weapon_ammo_bag_shared.h"
#include "asw_marine_resource.h"
#endif
#include "asw_marine_skills.h"
#include "asw_weapon_parse.h"
#include "asw_deathmatch_mode_light.h"
#include "asw_marine_profile.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
ConVar asw_minigun_spin_rate_threshold( "asw_minigun_spin_rate_threshold", "0.75f", FCVAR_CHEAT | FCVAR_REPLICATED, "Minimum barrel spin rate before minigun will fire" );
ConVar asw_minigun_spin_up_rate( "asw_minigun_spin_up_rate", "1.0", FCVAR_CHEAT | FCVAR_REPLICATED, "Spin up speed of minigun" );
ConVar asw_minigun_spin_down_rate( "asw_minigun_spin_down_rate", "0.4", FCVAR_CHEAT | FCVAR_REPLICATED, "Spin down speed of minigun" );
ConVar rd_minigun_additional_piercing_chance("rd_minigun_additional_piercing_chance", "0.2", FCVAR_CHEAT | FCVAR_REPLICATED, "Additional piercing chance after rd_minigun_additional_piercing_delay of continuous shooting");
ConVar rd_minigun_additional_piercing_delay("rd_minigun_additional_piercing_delay", "3.0", FCVAR_CHEAT | FCVAR_REPLICATED, "After this time piercing chance increased");
extern ConVar asw_weapon_max_shooting_distance;
extern ConVar asw_weapon_force_scale;
extern ConVar asw_DebugAutoAim;
#ifdef CLIENT_DLL
extern ConVar rd_tracer_tint_self;
extern ConVar rd_tracer_tint_other;
#endif
IMPLEMENT_NETWORKCLASS_ALIASED( ASW_Weapon_Minigun, DT_ASW_Weapon_Minigun )
BEGIN_NETWORK_TABLE( CASW_Weapon_Minigun, DT_ASW_Weapon_Minigun )
#ifdef CLIENT_DLL
RecvPropFloat( RECVINFO( m_flSpinRate ) ),
RecvPropBool( RECVINFO( m_bHalfShot ) ),
#else
SendPropFloat( SENDINFO( m_flSpinRate ), 0, SPROP_NOSCALE ),
SendPropBool( SENDINFO( m_bHalfShot ) ),
#endif
END_NETWORK_TABLE()
#ifdef CLIENT_DLL
BEGIN_PREDICTION_DATA( CASW_Weapon_Minigun )
DEFINE_PRED_FIELD_TOL( m_flSpinRate, FIELD_FLOAT, FTYPEDESC_INSENDTABLE, TD_MSECTOLERANCE ),
DEFINE_PRED_FIELD( m_bHalfShot, FIELD_BOOLEAN, FTYPEDESC_INSENDTABLE ),
DEFINE_PRED_FIELD( m_bShouldUpdateActivityClient, FIELD_BOOLEAN, FTYPEDESC_PRIVATE ),
END_PREDICTION_DATA()
#endif
LINK_ENTITY_TO_CLASS( asw_weapon_minigun, CASW_Weapon_Minigun );
PRECACHE_WEAPON_REGISTER( asw_weapon_minigun );
BEGIN_ENT_SCRIPTDESC( CASW_Weapon_Minigun, CASW_Weapon, "IAF Minigun" )
DEFINE_SCRIPTFUNC_NAMED( ScriptClip1, "Clip1", "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptGetMaxClip1, "GetMaxClip1", "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptGetDefaultClip1, "GetDefaultClip1", "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptGetMaxAmmo1, "GetMaxAmmo1", "" )
#ifdef GAME_DLL
DEFINE_SCRIPTFUNC_NAMED( ScriptSetClip1, "SetClip1", "" )
#endif
END_SCRIPTDESC()
#ifndef CLIENT_DLL
extern ConVar asw_debug_marine_damage;
//---------------------------------------------------------
// Save/Restore
//---------------------------------------------------------
BEGIN_DATADESC( CASW_Weapon_Minigun )
END_DATADESC()
void CASW_Weapon_Minigun::Spawn()
{
BaseClass::Spawn();
UseClientSideAnimation();
}
void CASW_Weapon_Minigun::SecondaryAttack( void )
{
CASW_Player *pPlayer = GetCommander();
if (!pPlayer)
return;
CASW_Marine *pMarine = GetMarine();
if (!pMarine)
return;
// dry fire
//SendWeaponAnim( ACT_VM_DRYFIRE );
//BaseClass::WeaponSound( EMPTY );
m_flNextSecondaryAttack = gpGlobals->curtime + 0.5f;
}
#endif /* not client */
CASW_Weapon_Minigun::CASW_Weapon_Minigun()
{
#ifdef CLIENT_DLL
m_pBarrelSpinSound = NULL;
m_flLastMuzzleFlashTime = 0;
m_bShouldUpdateActivityClient = false;
#endif
m_flTimeFireStarted = 0;
m_bHalfShot = false;
}
bool CASW_Weapon_Minigun::Holster( CBaseCombatWeapon *pSwitchingTo )
{
// stop the barrel spinning
m_flSpinRate = 0.0f;
return BaseClass::Holster( pSwitchingTo );
}
CASW_Weapon_Minigun::~CASW_Weapon_Minigun()
{
}
void CASW_Weapon_Minigun::Precache()
{
PrecacheScriptSound("ASW_Autogun.ReloadA");
PrecacheScriptSound("ASW_Autogun.ReloadB");
PrecacheScriptSound("ASW_Autogun.ReloadC");
PrecacheScriptSound( "ASW_Minigun.Spin" );
BaseClass::Precache();
}
void CASW_Weapon_Minigun::PrimaryAttack()
{
// can't attack until the minigun barrel has spun up
if ( GetSpinRate() < asw_minigun_spin_rate_threshold.GetFloat() )
return;
// If my clip is empty (and I use clips) start reload
if ( UsesClipsForAmmo1() && !m_iClip1 )
{
Reload();
return;
}
CASW_Player *pPlayer = GetCommander();
CASW_Marine *pMarine = GetMarine();
if ( !pMarine )
return;
m_bIsFiring = true;
// MUST call sound before removing a round from the clip of a CMachineGun
//WeaponSound(SINGLE);
if (m_iClip1 <= AmmoClickPoint())
{
LowAmmoSound();
}
// tell the marine to tell its weapon to draw the muzzle flash
pMarine->DoMuzzleFlash();
// sets the animation on the weapon model itself
SendWeaponAnim( GetPrimaryAttackActivity() );
// sets the animation on the marine holding this weapon
//pMarine->SetAnimation( PLAYER_ATTACK1 );
#ifdef GAME_DLL // check for turning on lag compensation
if (pPlayer && pMarine->IsInhabited())
{
CASW_Lag_Compensation::RequestLagCompensation( pPlayer, pPlayer->GetCurrentUserCommand() );
}
#endif
FireBulletsInfo_t info;
info.m_vecSrc = pMarine->Weapon_ShootPosition( );
if ( pPlayer && pMarine->IsInhabited() )
{
info.m_vecDirShooting = pPlayer->GetAutoaimVectorForMarine(pMarine, GetAutoAimAmount(), GetVerticalAdjustOnlyAutoAimAmount()); // 45 degrees = 0.707106781187
}
else
{
#ifdef CLIENT_DLL
Msg("Error, clientside firing of a weapon that's being controlled by an AI marine\n");
#else
info.m_vecDirShooting = pMarine->GetActualShootTrajectory( info.m_vecSrc );
#endif
}
// To make the firing framerate independent, we may have to fire more than one bullet here on low-framerate systems,
// especially if the weapon we're firing has a really fast rate of fire.
info.m_iShots = 0;
float fireRate = GetFireRate() * ( 1.0f / MAX( GetSpinRate(), asw_minigun_spin_rate_threshold.GetFloat() ) );
while ( m_flNextPrimaryAttack <= gpGlobals->curtime )
{
m_flNextPrimaryAttack = m_flNextPrimaryAttack + fireRate;
info.m_iShots++;
if ( !fireRate )
break;
}
// Make sure we don't fire more than the amount in the clip
if ( UsesClipsForAmmo1() )
{
int iEffectiveClip = m_iClip1 * 2;
if ( m_bHalfShot && iEffectiveClip )
{
iEffectiveClip--;
}
info.m_iShots = MIN( info.m_iShots, iEffectiveClip );
iEffectiveClip -= info.m_iShots;
m_iClip1 = ( iEffectiveClip + 1 ) / 2;
m_bHalfShot = ( iEffectiveClip & 1 ) != 0;
NotifyIfNoneClip1Ammo( pMarine );
}
else
{
info.m_iShots = MIN( info.m_iShots, pMarine->GetAmmoCount( m_iPrimaryAmmoType ) );
pMarine->RemoveAmmo( info.m_iShots, m_iPrimaryAmmoType );
}
info.m_flDistance = asw_weapon_max_shooting_distance.GetFloat();
info.m_iAmmoType = m_iPrimaryAmmoType;
info.m_iTracerFreq = 1; // asw tracer test everytime
info.m_flDamageForceScale = asw_weapon_force_scale.GetFloat();
info.m_vecSpread = GetBulletSpread();
info.m_flDamage = GetWeaponDamage();
#ifndef CLIENT_DLL
if (asw_debug_marine_damage.GetBool())
Msg("Weapon dmg = %f\n", info.m_flDamage);
CASW_Marine_Resource* pPMR = pMarine->GetMarineResource();
if ( pPMR )
pPMR->OnFired_ScaleDamage( info );
if (asw_DebugAutoAim.GetBool())
{
NDebugOverlay::Line(info.m_vecSrc, info.m_vecSrc + info.m_vecDirShooting * info.m_flDistance, 64, 0, 64, true, 1.0);
}
#endif
if ( !m_flTimeFireStarted )
m_flTimeFireStarted = gpGlobals->curtime;
FireBullets(pMarine, info);
// increment shooting stats
#ifndef CLIENT_DLL
if (pPMR)
{
pPMR->UsedWeapon(this, info.m_iShots);
pMarine->OnWeaponFired( this, info.m_iShots );
}
#endif
}
void CASW_Weapon_Minigun::FireBullets( CASW_Marine* pMarine, const FireBulletsInfo_t& info )
{
float fPiercingChance = MarineSkills()->GetSkillBasedValueByMarine( pMarine, ASW_MARINE_SKILL_STOPPING_POWER, ASW_MARINE_SUBSKILL_PIERCING_CHANCE );
if ( gpGlobals->curtime - m_flTimeFireStarted > rd_minigun_additional_piercing_delay.GetFloat() )
{
float addChance = rd_minigun_additional_piercing_chance.GetFloat();
addChance = MAX(0, addChance);
fPiercingChance += addChance;
}
if ( fPiercingChance > 0 )
{
pMarine->FirePenetratingBullets( info, 1, fPiercingChance, 0 );
}
else
{
pMarine->FireRegularBullets( info );
}
}
void CASW_Weapon_Minigun::OnStoppedFiring()
{
BaseClass::OnStoppedFiring();
m_flTimeFireStarted = 0.0f;
}
void CASW_Weapon_Minigun::ItemPostFrame( void )
{
BaseClass::ItemPostFrame();
UpdateSpinRate();
}
void CASW_Weapon_Minigun::ItemBusyFrame( void )
{
BaseClass::ItemBusyFrame();
UpdateSpinRate();
}
void CASW_Weapon_Minigun::UpdateSpinRate()
{
bool bAttack1, bAttack2, bReload, bOldReload, bOldAttack1;
GetButtons(bAttack1, bAttack2, bReload, bOldReload, bOldAttack1 );
CASW_Marine *pMarine = GetMarine();
bool bMeleeing = pMarine && ( pMarine->GetCurrentMeleeAttack() != NULL );
bool bWalking = pMarine && ( pMarine->m_bWalking.Get() || pMarine->m_bForceWalking.Get()
#ifdef GAME_DLL
// the logic for bot crouching is somewhat complicated; just check their animation
|| ( !pMarine->IsInhabited() && pMarine->GetActivity() == ACT_CROUCHIDLE )
#endif
);
bool bSpinUp = !m_bInReload && !bMeleeing && ( bAttack1 || bAttack2 || bWalking );
if ( bSpinUp )
{
m_flSpinRate = MIN( 1.0f, GetSpinRate() + gpGlobals->frametime * asw_minigun_spin_up_rate.GetFloat() );
}
else
{
m_flSpinRate = MAX( 0.0f, GetSpinRate() - gpGlobals->frametime * asw_minigun_spin_down_rate.GetFloat() * ( ( m_bInReload || bMeleeing ) ? 3.0f : 1.0f ) );
}
}
#ifdef CLIENT_DLL
void CASW_Weapon_Minigun::OnMuzzleFlashed()
{
BaseClass::OnMuzzleFlashed();
//m_flPlaybackRate = 1.0f;
m_flLastMuzzleFlashTime = gpGlobals->curtime;
//Vector attachOrigin;
//QAngle attachAngles;
int iAttachment = LookupAttachment( "eject1" );
if( iAttachment != -1 )
{
// tempents->EjectBrass( attachOrigin, attachAngles, GetAbsAngles(), 1 ); // 0 = brass shells, 2 = grey shells, 3 = plastic shotgun shell casing
EjectParticleBrass( "weapon_shell_casing_rifle", iAttachment );
}
if ( m_hGunSmoke.IsValid() )
{
m_hGunSmoke->OnFired();
}
}
float CASW_Weapon_Minigun::GetMuzzleFlashScale( void )
{
// if we haven't calculated the muzzle scale based on the carrying marine's skill yet, then do so
if (m_fMuzzleFlashScale == -1)
{
C_ASW_Marine *pMarine = GetMarine();
if (pMarine)
m_fMuzzleFlashScale = 2.0f * MarineSkills()->GetSkillBasedValueByMarine(pMarine, ASW_MARINE_SKILL_AUTOGUN, ASW_MARINE_SUBSKILL_AUTOGUN_MUZZLE);
else
return 2.0f;
}
return m_fMuzzleFlashScale;
}
Vector CASW_Weapon_Minigun::GetMuzzleFlashTint()
{
HACK_GETLOCALPLAYER_GUARD( "need local player to see what color the muzzle flash should be" );
C_ASW_Player *pLocalPlayer = C_ASW_Player::GetLocalASWPlayer();
C_ASW_Inhabitable_NPC *pViewNPC = pLocalPlayer ? pLocalPlayer->GetViewNPC() : NULL;
Vector vecColor = pViewNPC && GetOwner() == pViewNPC ? rd_tracer_tint_self.GetColorAsVector() : rd_tracer_tint_other.GetColorAsVector();
if ( ( GetMuzzleFlashScale() / 2.0f ) >= 1.15f ) // red if our muzzle flash is the biggest size based on our skill
{
vecColor.y *= 0.65f;
vecColor.z *= 0.65f;
}
return vecColor;
}
#endif
float CASW_Weapon_Minigun::GetMovementScale()
{
return ShouldMarineMoveSlow() ? 0.4f : 0.95f;
}
bool CASW_Weapon_Minigun::ShouldMarineMoveSlow()
{
bool bAttack1, bAttack2, bReload, bOldReload, bOldAttack1;
GetButtons(bAttack1, bAttack2, bReload, bOldReload, bOldAttack1 );
return ( BaseClass::ShouldMarineMoveSlow() || bAttack2 || bAttack1 || GetSpinRate() >= 0.99f );
}
float CASW_Weapon_Minigun::GetWeaponBaseDamageOverride()
{
extern ConVar rd_minigun_dmg_base;
return rd_minigun_dmg_base.GetFloat();
}
int CASW_Weapon_Minigun::GetWeaponSkillId()
{
return ASW_MARINE_SKILL_AUTOGUN;
}
int CASW_Weapon_Minigun::GetWeaponSubSkillId()
{
return ASW_MARINE_SUBSKILL_AUTOGUN_MINIGUN_DMG;
}
const Vector &CASW_Weapon_Minigun::GetBulletSpread( void )
{
const static Vector cone = Vector( 0.13053, 0.02618, 0.13053 ); // VECTOR_CONE_15DEGREES with flattened Y (vertical) VECTOR_CONE_3DEGREES
const static Vector cone_duck = Vector( 0.05234, 0.00873, 0.05234 ); // VECTOR_CONE_6DEGREES with flattened Y (vertical) VECTOR_CONE_1DEGREES
CASW_Marine *marine = GetMarine();
if ( marine )
{
if ( marine->GetLocalVelocity().IsZero() && marine->m_bWalking )
return cone_duck;
}
return cone;
}
#ifdef CLIENT_DLL
const char* CASW_Weapon_Minigun::GetPartialReloadSound(int iPart)
{
switch (iPart)
{
case 1: return "ASW_Autogun.ReloadB"; break;
case 2: return "ASW_Autogun.ReloadC"; break;
default: break;
};
return "ASW_Autogun.ReloadA";
}
void CASW_Weapon_Minigun::OnDataChanged( DataUpdateType_t updateType )
{
BaseClass::OnDataChanged( updateType );
if ( updateType == DATA_UPDATE_CREATED )
{
CreateGunSmoke();
SetNextClientThink( CLIENT_THINK_ALWAYS );
}
}
void CASW_Weapon_Minigun::ClientThink()
{
BaseClass::ClientThink();
UpdateSpinningBarrel();
}
ConVar asw_minigun_pitch_min( "asw_minigun_pitch_min", "50", FCVAR_CHEAT | FCVAR_REPLICATED, "Pitch of barrel spin sound" );
ConVar asw_minigun_pitch_max( "asw_minigun_pitch_max", "150", FCVAR_CHEAT | FCVAR_REPLICATED, "Pitch of barrel spin sound" );
void CASW_Weapon_Minigun::UpdateSpinningBarrel()
{
if ( GetSpinRate() > 0.1 && GetSequenceActivity( GetSequence() ) != ACT_VM_PRIMARYATTACK )
{
SetActivity( ACT_VM_PRIMARYATTACK, 0 );
m_bShouldUpdateActivityClient = true;
}
if ( GetSpinRate() < 0.1 && m_bShouldUpdateActivityClient )
{
SetActivity( ACT_VM_IDLE, 0 );
m_bShouldUpdateActivityClient = false;
}
if ( GetSpinRate() > 0.01f ) //seems always > 0 due to computations, lets increase it a little.
{
if( !m_pBarrelSpinSound )
{
CPASAttenuationFilter filter( this );
m_pBarrelSpinSound = CSoundEnvelopeController::GetController().SoundCreate( filter, entindex(), "ASW_Minigun.Spin" );
CSoundEnvelopeController::GetController().Play( m_pBarrelSpinSound, 0.0, 100 );
}
CSoundEnvelopeController::GetController().SoundChangeVolume( m_pBarrelSpinSound, MIN( 1.0f, GetSpinRate() * 3.0f ), 0.0f );
CSoundEnvelopeController::GetController().SoundChangePitch( m_pBarrelSpinSound, asw_minigun_pitch_min.GetFloat() + ( GetSpinRate() * ( asw_minigun_pitch_max.GetFloat() - asw_minigun_pitch_min.GetFloat() ) ), 0.0f );
}
else
{
if ( m_pBarrelSpinSound )
{
CSoundEnvelopeController::GetController().SoundDestroy( m_pBarrelSpinSound );
m_pBarrelSpinSound = NULL;
}
}
}
void CASW_Weapon_Minigun::CreateGunSmoke()
{
int iAttachment = LookupAttachment( "muzzle" );
if ( iAttachment <= 0 )
{
Msg("error, couldn't find muzzle attachment for flamer tip\n");
return;
}
C_ASW_Gun_Smoke_Emitter *pEnt = new C_ASW_Gun_Smoke_Emitter;
if (!pEnt)
{
Msg("Error, couldn't create new C_ASW_Gun_Smoke_Emitter for autogun smoke\n");
return;
}
if ( !pEnt->InitializeAsClientEntity( NULL, false ) )
{
Msg("Error, couldn't InitializeAsClientEntity for autogun smoke\n");
UTIL_Remove( pEnt );
return;
}
Vector vecMuzzle;
QAngle angMuzzle;
GetAttachment( iAttachment, vecMuzzle, angMuzzle );
Q_snprintf(pEnt->m_szTemplateName, sizeof(pEnt->m_szTemplateName), "autogunsmoke");
pEnt->m_fScale = 1.0f;
pEnt->m_bEmit = false;
pEnt->SetAbsOrigin(vecMuzzle);
pEnt->CreateEmitter();
pEnt->SetAbsOrigin(vecMuzzle);
pEnt->SetAbsAngles(angMuzzle);
pEnt->ClientAttach(this, "muzzle");
m_hGunSmoke = pEnt;
}
void CASW_Weapon_Minigun::SetDormant( bool bDormant )
{
if ( bDormant )
{
if ( m_pBarrelSpinSound )
{
CSoundEnvelopeController::GetController().SoundDestroy(m_pBarrelSpinSound);
m_pBarrelSpinSound = NULL;
}
}
BaseClass::SetDormant( bDormant );
}
void CASW_Weapon_Minigun::UpdateOnRemove()
{
if ( m_hGunSmoke.IsValid() && m_hGunSmoke.Get())
{
UTIL_Remove( m_hGunSmoke.Get() );
}
if ( m_pBarrelSpinSound )
{
CSoundEnvelopeController::GetController().SoundDestroy( m_pBarrelSpinSound );
m_pBarrelSpinSound = NULL;
}
BaseClass::UpdateOnRemove();
}
#else
void CASW_Weapon_Minigun::Drop( const Vector &vecVelocity )
{
// stop the barrel spinning
m_flSpinRate = 0.0f;
BaseClass::Drop( vecVelocity );
}
#endif
#ifdef CLIENT_DLL
// if true, the marine shoots from minigun
bool CASW_Weapon_Minigun::ShouldMarineMinigunShoot()
{
return IsFiring();
}
#endif
int CASW_Weapon_Minigun::DisplayClip1()
{
int iClip1 = Clip1() * 2;
if ( m_bHalfShot )
{
iClip1--;
}
return iClip1;
}
int CASW_Weapon_Minigun::DisplayMaxClip1()
{
return GetMaxClip1() * 2;
}
int CASW_Weapon_Minigun::ScriptClip1()
{
return DisplayClip1();
}
int CASW_Weapon_Minigun::ScriptGetMaxClip1()
{
return DisplayMaxClip1();
}
int CASW_Weapon_Minigun::ScriptGetDefaultClip1()
{
return GetDefaultClip1() * 2;
}
int CASW_Weapon_Minigun::ScriptGetMaxAmmo1()
{
return BaseClass::ScriptGetMaxAmmo1() * 2;
}
#ifdef GAME_DLL
void CASW_Weapon_Minigun::ScriptSetClip1( int iAmmo )
{
BaseClass::ScriptSetClip1( ( iAmmo + 1 ) / 2 );
m_bHalfShot = ( iAmmo & 1 ) != 0;
}
#endif
void CASW_Weapon_Minigun::FinishReload()
{
BaseClass::FinishReload();
m_bHalfShot = false;
}