From 1fa1e4c7227aa87fd6d2b2ae5d61bbb465dc136f Mon Sep 17 00:00:00 2001 From: Marisa Kirisame Date: Mon, 30 Mar 2020 22:00:18 +0200 Subject: [PATCH] Adjusted how Spreadgun ammo autoswitch is handled. --- zscript/swwm_shot.zsc | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/zscript/swwm_shot.zsc b/zscript/swwm_shot.zsc index 5fa469cfd..31f03da58 100644 --- a/zscript/swwm_shot.zsc +++ b/zscript/swwm_shot.zsc @@ -2409,7 +2409,6 @@ Class Spreadgun : SWWMWeapon A_StartSound("spreadgun/hammer",CHAN_WEAPON,CHANF_OVERLAP); invoker.fired = false; } - if ( CountInv(invoker.nextammo) <= 0 ) A_SwitchAmmoType(true); } override void AttachToOwner( Actor other ) @@ -2437,23 +2436,37 @@ Class Spreadgun : SWWMWeapon cur = i; break; } - for ( int i=0; i<7; i++ ) + int ridx = -1; + if ( rev ) { - int ridx; - if ( rev ) + // check backwards from what we currently had + for ( int i=cur; i>=0; i-- ) { - ridx = cur-i; - if ( ridx < 0 ) break; + if ( CountInv(types[i]) <= 0 ) continue; + ridx = i; + break; } - else ridx = (i+cur+1)%7; - if ( CountInv(types[ridx]) <= 0 ) continue; - next = ridx; - break; + if ( ridx == -1 ) + { + // check forwards instead, but avoid golden shells + for ( int i=0; i<6; i++ ) + { + if ( CountInv(types[i]) <= 0 ) continue; + ridx = i; + break; + } + } + if ( ridx != -1 ) next = ridx; } - if ( rev && ((invoker.nextammo == types[next]) || (CountInv(invoker.nextammo) <= 0)) ) + else { - A_SwitchAmmoType(false); // recheck forward - return; + for ( int i=0; i<7; i++ ) + { + ridx = (i+cur+1)%7; + if ( CountInv(types[ridx]) <= 0 ) continue; + next = ridx; + break; + } } if ( invoker.nextammo != types[next] ) A_StartSound("misc/invchange",CHAN_WEAPONEXTRA,CHANF_UI|CHANF_LOCAL); invoker.nextammo = types[next]; @@ -2522,8 +2535,9 @@ Class Spreadgun : SWWMWeapon Ready: XZW2 A 1 { + if ( CountInv(invoker.nextammo) <= 0 ) A_SwitchAmmoType(true); int flg = WRF_ALLOWZOOM|WRF_ALLOWUSER1; - if ( invoker.nextammo && (CountInv(invoker.nextammo) > 0) ) + if ( invoker.nextammo && (CountInv(invoker.nextammo) > 0) && (invoker.loadammo != invoker.nextammo) ) flg |= WRF_ALLOWRELOAD; A_WeaponReady(flg); } @@ -2531,6 +2545,7 @@ Class Spreadgun : SWWMWeapon ReadyFired: XZW2 Z 1 { + if ( CountInv(invoker.nextammo) <= 0 ) A_SwitchAmmoType(true); int flg = WRF_ALLOWZOOM|WRF_ALLOWUSER1; if ( invoker.nextammo && (CountInv(invoker.nextammo) > 0) ) flg |= WRF_ALLOWRELOAD;