From c1e21988bbfea1ee048129406569cf1a725eeae7 Mon Sep 17 00:00:00 2001 From: Marisa Kirisame Date: Sat, 9 Jun 2018 14:49:55 +0200 Subject: [PATCH] Allow refire of pulsegun and minigun during cooldown/unwind. --- zscript/minigun.zsc | 25 +++++++++++++++++++------ zscript/pulsegun.zsc | 20 +++++++++++++++++--- 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/zscript/minigun.zsc b/zscript/minigun.zsc index 8e3b987..d5d2bde 100644 --- a/zscript/minigun.zsc +++ b/zscript/minigun.zsc @@ -100,9 +100,8 @@ Class Minigun : UTWeapon A_Overlay(-2,"MuzzleFlash",true); A_OverlayFlags(-2,PSPF_RENDERSTYLE|PSPF_FORCESTYLE,true); A_OverlayRenderstyle(-2,STYLE_Add); - if ( alt ) invoker.bcnt = min(invoker.bcnt,3); - if ( invoker.bcnt-- > 0 ) return; - invoker.bcnt = alt?3:5; + if ( (alt && (invoker.bcnt++ < 3)) || (invoker.bcnt++ < 5) ) return; + invoker.bcnt = 0; if ( !weap.DepleteAmmo(weap.bAltFire,true,1) ) return; invoker.FireEffect(); UTMainHandler.DoFlash(self,Color(32,255,255,0),1); @@ -166,16 +165,30 @@ Class Minigun : UTWeapon c.Scale *= 0.5; } - action void A_MinigunRefire( statelabel flash = null ) + action void A_MinigunRefire( statelabel flash = null, bool nounwind = false ) { Weapon weap = Weapon(invoker); if ( !weap || !player ) return; if ( weap.Ammo1.Amount <= 0 ) { + if ( nounwind ) return; A_ClearRefire(); player.setpsprite(PSP_WEAPON,weap.FindState("Unwind")); return; } + if ( nounwind ) + { + if ( player.cmd.buttons&BT_ALTATTACK ) + { + weap.bAltFire = true; + flash = "AltFire"; + } + else + { + weap.bAltFire = false; + flash = "Fire"; + } + } A_Refire(flash); } @@ -403,8 +416,8 @@ Class Minigun : UTWeapon Goto Unwind; Unwind: MGNU A 0 A_PlaySound("minigun/unwind",CHAN_WEAPON); - MGNU ABCDEFGHIJKLMNOPQRSTUVWXYZ 1; - MGU2 ABCDEFGHIJKLM 1; + MGNU ABCDEFGHIJKLMNOPQRSTUVWXYZ 1 A_MinigunRefire(null,true); + MGU2 ABCDEFGHIJKLM 1 A_MinigunRefire(null,true); Goto Idle; Deselect: MGND A 1 A_StopSound(CHAN_WEAPON); diff --git a/zscript/pulsegun.zsc b/zscript/pulsegun.zsc index 778d99e..71f4847 100644 --- a/zscript/pulsegun.zsc +++ b/zscript/pulsegun.zsc @@ -497,17 +497,31 @@ Class PulseGun : UTWeapon s.vel = pvel; } } - action void A_PulseRefire( statelabel flash = null ) + action void A_PulseRefire( statelabel flash = null, bool noreload = false ) { Weapon weap = Weapon(invoker); if ( !weap || !player ) return; if ( (invoker.clipcount <= 0) || (weap.Ammo1.Amount <= 0) ) { + if ( noreload ) return; A_ClearRefire(); if ( weap.bAltFire ) player.setpsprite(PSP_WEAPON,weap.FindState("AltRelease")); else player.setpsprite(PSP_WEAPON,weap.FindState("Release")); return; } + if ( noreload ) + { + if ( player.cmd.buttons&BT_ALTATTACK ) + { + weap.bAltFire = true; + flash = "AltFire"; + } + else + { + weap.bAltFire = false; + flash = "Fire"; + } + } A_Refire(flash); } action void A_PulseFire() @@ -646,7 +660,7 @@ Class PulseGun : UTWeapon Goto Release; Release: PGNC A 0 A_PlaySound("pulse/down",CHAN_WEAPON); - PGNC ABCDEFGHIJKLMNOPQRSTUVWXY 1; + PGNC ABCDEFGHIJKLMNOPQRSTUVWXY 1 A_PulseRefire(null,true); PGNC Y 0; Goto Idle; AltFire: @@ -684,7 +698,7 @@ Class PulseGun : UTWeapon PGBL A 0 A_PulseRefire(); AltRelease: PGBE A 0 A_StopBeam(); - PGBE ABCDE 1; + PGBE ABCDE 1 A_PulseRefire(null,true); Goto Idle; Reload: PGNI A 1;