Less naive PickWeapon rewrite.
This commit is contained in:
parent
a708ecc618
commit
b460d84ee2
2 changed files with 22 additions and 7 deletions
|
|
@ -1,3 +1,3 @@
|
|||
[default]
|
||||
SWWM_MODVER="\cyDEMOLITIONIST \cw1.3pre r117 \cu(Mon 13 Jun 09:38:41 CEST 2022)\c-";
|
||||
SWWM_SHORTVER="\cw1.3pre r117 \cu(2022-06-13 09:38:41)\c-";
|
||||
SWWM_MODVER="\cyDEMOLITIONIST \cw1.3pre r118 \cu(Mon 13 Jun 10:05:16 CEST 2022)\c-";
|
||||
SWWM_SHORTVER="\cw1.3pre r118 \cu(2022-06-13 10:05:16)\c-";
|
||||
|
|
|
|||
|
|
@ -3179,11 +3179,9 @@ Class Demolitionist : PlayerPawn
|
|||
//
|
||||
// I could rewrite PickNextWeapon and PickPrevWeapon as well, but nah
|
||||
// those always call CheckAmmo so it's fine
|
||||
override Weapon PickWeapon( int slot, bool checkammo )
|
||||
private Weapon TraverseSlot( int slot, bool checkammo, int start, int end, Weapon cur )
|
||||
{
|
||||
int slotsize = player.weapons.SlotSize(slot);
|
||||
let cur = player.ReadyWeapon;
|
||||
for ( int i=slotsize-1; i>=0; i-- )
|
||||
for ( int i=start; i>=end; i-- )
|
||||
{
|
||||
let type = player.weapons.GetWeapon(slot,i);
|
||||
let w = Weapon(player.mo.FindInventory(type));
|
||||
|
|
@ -3195,7 +3193,24 @@ Class Demolitionist : PlayerPawn
|
|||
|| w.CheckAmmo(Weapon.EitherFire,false) )
|
||||
return w;
|
||||
}
|
||||
return cur;
|
||||
return null;
|
||||
}
|
||||
override Weapon PickWeapon( int slot, bool checkammo )
|
||||
{
|
||||
int slotsize = player.weapons.SlotSize(slot);
|
||||
let cur = player.ReadyWeapon;
|
||||
bool found = false;
|
||||
int cs, ci;
|
||||
if ( cur ) [found, cs, ci] = player.weapons.LocateWeapon(cur.GetClass());
|
||||
if ( found && (cs == slot) )
|
||||
{
|
||||
// traverse the slot down from current index
|
||||
let w = TraverseSlot(slot,checkammo,ci-1,0,cur);
|
||||
if ( !w ) w = TraverseSlot(slot,checkammo,slotsize-1,ci+1,cur);
|
||||
return w?w:cur;
|
||||
}
|
||||
let w = TraverseSlot(slot,checkammo,slotsize-1,0,cur);
|
||||
return w?w:cur;
|
||||
}
|
||||
override void MarkPrecacheSounds()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue