2121IMPLEMENT_NETWORKCLASS_ALIASED (ASW_Weapon_Devastator, DT_ASW_Weapon_Devastator)
2222
2323BEGIN_NETWORK_TABLE(CASW_Weapon_Devastator, DT_ASW_Weapon_Devastator)
24+ #ifdef CLIENT_DLL
25+ // recvprops
26+ RecvPropBool ( RECVINFO( m_bLockedFire ) ),
27+ #else
28+ // sendprops
29+ SendPropBool ( SENDINFO( m_bLockedFire ) ),
30+ #endif
2431END_NETWORK_TABLE ()
2532
2633BEGIN_PREDICTION_DATA(CASW_Weapon_Devastator)
34+ #ifdef CLIENT_DLL
35+ DEFINE_PRED_FIELD ( m_bLockedFire, FIELD_BOOLEAN, FTYPEDESC_INSENDTABLE ),
36+ #endif
2737END_PREDICTION_DATA ()
2838
2939LINK_ENTITY_TO_CLASS(asw_weapon_devastator, CASW_Weapon_Devastator);
@@ -44,7 +54,9 @@ static void On_rd_devastator_bullet_spread_duck_Changed( IConVar* var, const cha
4454}
4555
4656ConVar rd_devastator_dynamic_bullet_spread ( " rd_devastator_dynamic_bullet_spread" , " 1" , FCVAR_REPLICATED | FCVAR_CHEAT, " Controls if crouching decreases bullet spread for devastator" );
47- ConVar rd_devastator_bullet_spread_duck ( " rd_devastator_bullet_spread_duck" , " 14" , FCVAR_REPLICATED | FCVAR_CHEAT, " Devastator's bullet spread when ducking (crouching)" , true , 1 .0f , true , 60 .0f , &On_rd_devastator_bullet_spread_duck_Changed );
57+ ConVar rd_devastator_bullet_spread_duck ( " rd_devastator_bullet_spread_duck" , " 14" , FCVAR_REPLICATED | FCVAR_CHEAT, " Devastator's bullet spread when ducking (crouching)" , true , 1 .0f , true , 60 .0f , &On_rd_devastator_bullet_spread_duck_Changed );
58+ ConVar rd_devastator_lockmode_enabled ( " rd_devastator_lockmode_enabled" , " 1" , FCVAR_REPLICATED | FCVAR_CHEAT, " Enables lock-mode secondary attack. Marine is locked in place but weapon fire rate and penetration gets higher" );
59+ ConVar rd_devastator_lockmode_firerate ( " rd_devastator_lockmode_firerate" , " 1.3" , FCVAR_REPLICATED | FCVAR_CHEAT, " Scale factor of the fire rate in lock-mode" , true , 0 .2f , true , 3 .0f );
4860
4961CASW_Weapon_Devastator::CASW_Weapon_Devastator ()
5062{
@@ -55,27 +67,12 @@ CASW_Weapon_Devastator::~CASW_Weapon_Devastator()
5567
5668}
5769
58- void CASW_Weapon_Devastator::SecondaryAttack ()
59- {
60- CASW_Player *pPlayer = GetCommander ();
61- if ( !pPlayer )
62- return ;
63-
64- CASW_Marine *pMarine = GetMarine ();
65- if ( !pMarine )
66- return ;
67-
68- // dry fire
69- SendWeaponAnim ( ACT_VM_DRYFIRE );
70- BaseClass::WeaponSound ( EMPTY );
71- m_flNextSecondaryAttack = gpGlobals->curtime + 0 .5f ;
72- }
73-
7470void CASW_Weapon_Devastator::Precache ()
7571{
7672 PrecacheModel ( " swarm/sprites/whiteglow1.vmt" );
7773 PrecacheModel ( " swarm/sprites/greylaser1.vmt" );
7874 PrecacheScriptSound ( " ASW_Weapon.Empty" );
75+ PrecacheScriptSound ( " ASW_Weapon.Reload3" );
7976 PrecacheScriptSound ( " ASW_Weapon_Devastator.SingleFP" );
8077 PrecacheScriptSound ( " ASW_Weapon_Devastator.Single" );
8178 PrecacheScriptSound ( " ASW_Weapon_Devastator.ReloadA" );
@@ -101,6 +98,10 @@ int CASW_Weapon_Devastator::GetWeaponSubSkillId()
10198
10299float CASW_Weapon_Devastator::GetMovementScale ()
103100{
101+ if ( m_bLockedFire )
102+ {
103+ return 0 .000001f ; // 0 makes marine run faster for some reason
104+ }
104105 return ShouldMarineMoveSlow () ? 0 .3f : 0 .9f ;
105106}
106107
@@ -118,12 +119,17 @@ const char *CASW_Weapon_Devastator::GetPartialReloadSound( int iPart )
118119}
119120#endif
120121
122+ bool CASW_Weapon_Devastator::HasSecondaryAttack ()
123+ {
124+ return rd_devastator_lockmode_enabled.GetBool ();
125+ }
126+
121127bool CASW_Weapon_Devastator::ShouldMarineMoveSlow ()
122128{
123129 bool bAttack1, bAttack2, bReload, bOldReload, bOldAttack1;
124130 GetButtons (bAttack1, bAttack2, bReload, bOldReload, bOldAttack1);
125131
126- return ( BaseClass::ShouldMarineMoveSlow () || bAttack1 );
132+ return ( BaseClass::ShouldMarineMoveSlow () || bAttack1 || m_bLockedFire );
127133}
128134
129135void CASW_Weapon_Devastator::FireShotgunPellet ( CASW_Inhabitable_NPC *pNPC, const FireBulletsInfo_t &info, int iSeed )
@@ -136,6 +142,9 @@ void CASW_Weapon_Devastator::FireShotgunPellet( CASW_Inhabitable_NPC *pNPC, cons
136142 }
137143
138144 float fPiercingChance = MarineSkills ()->GetSkillBasedValueByMarine ( pMarine, ASW_MARINE_SKILL_STOPPING_POWER, ASW_MARINE_SUBSKILL_PIERCING_CHANCE );
145+ if (m_bLockedFire)
146+ fPiercingChance = 1 ;
147+
139148 if (fPiercingChance > 0 )
140149 {
141150 pMarine->FirePenetratingBullets (info, 1 , fPiercingChance , iSeed, false );
@@ -146,7 +155,7 @@ void CASW_Weapon_Devastator::FireShotgunPellet( CASW_Inhabitable_NPC *pNPC, cons
146155 }
147156}
148157
149- const Vector & CASW_Weapon_Devastator::GetAngularBulletSpread ()
158+ const Vector& CASW_Weapon_Devastator::GetAngularBulletSpread ()
150159{
151160 const static Vector cone ( 22 , 22 , 22 );
152161
@@ -159,3 +168,93 @@ const Vector &CASW_Weapon_Devastator::GetAngularBulletSpread()
159168 }
160169 return cone;
161170}
171+
172+ bool CASW_Weapon_Devastator::Reload ( void )
173+ {
174+ m_bLockedFire = false ;
175+
176+ return BaseClass::Reload ();
177+ }
178+
179+ bool CASW_Weapon_Devastator::Holster ( CBaseCombatWeapon *pSwitchingTo )
180+ {
181+ m_bLockedFire = false ;
182+
183+ return BaseClass::Holster ( pSwitchingTo );
184+ }
185+
186+ void CASW_Weapon_Devastator::Drop ( const Vector &vecVelocity )
187+ {
188+ m_bLockedFire = false ;
189+
190+ BaseClass::Drop ( vecVelocity );
191+ }
192+
193+ void CASW_Weapon_Devastator::ItemPostFrame ( void )
194+ {
195+ BaseClass::ItemPostFrame ();
196+
197+ CASW_Marine* pMarine = GetMarine ();
198+ if ( !pMarine || !pMarine->IsAlive () )
199+ {
200+ m_bLockedFire = false ;
201+ return ;
202+ }
203+ if ( pMarine->GetCurrentMeleeAttack () )
204+ m_bLockedFire = false ;
205+ }
206+
207+ void CASW_Weapon_Devastator::ItemBusyFrame ( void )
208+ {
209+ BaseClass::ItemBusyFrame ();
210+
211+ CASW_Marine* pMarine = GetMarine ();
212+ if ( !pMarine || !pMarine->IsAlive () )
213+ {
214+ m_bLockedFire = false ;
215+ return ;
216+ }
217+ if ( pMarine->GetCurrentMeleeAttack () )
218+ m_bLockedFire = false ;
219+ }
220+
221+ void CASW_Weapon_Devastator::SecondaryAttack ()
222+ {
223+ if ( rd_devastator_lockmode_enabled.GetBool () )
224+ {
225+ m_bLockedFire = !m_bLockedFire;
226+ m_flNextSecondaryAttack = gpGlobals->curtime + 1 .0f ;
227+ if ( m_bLockedFire )
228+ {
229+ m_flNextPrimaryAttack = gpGlobals->curtime + 0 .5f ;
230+ WeaponSound ( BURST );
231+ }
232+ }
233+ else
234+ {
235+ CASW_Player *pPlayer = GetCommander ();
236+ if ( !pPlayer )
237+ return ;
238+
239+ CASW_Marine *pMarine = GetMarine ();
240+ if ( !pMarine )
241+ return ;
242+
243+ // dry fire
244+ SendWeaponAnim ( ACT_VM_DRYFIRE );
245+ BaseClass::WeaponSound ( EMPTY );
246+ m_flNextSecondaryAttack = gpGlobals->curtime + 0 .5f ;
247+ }
248+ }
249+
250+ float CASW_Weapon_Devastator::GetFireRate ()
251+ {
252+ if ( m_bLockedFire )
253+ {
254+ return GetEquipItem ()->m_flFireRate / rd_devastator_lockmode_firerate.GetFloat ();
255+ }
256+ else
257+ {
258+ return GetEquipItem ()->m_flFireRate ;
259+ }
260+ }
0 commit comments