Weapon pickups don't autoswitch
Moderator: GZDoom Developers
Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.
- Chris
- Posts: 2971
- Joined: Thu Jul 17, 2003 12:07 am
- Graphics Processor: ATI/AMD with Vulkan/Metal Support
Weapon pickups don't autoswitch
I've been noticing this ever since I came back to playing ZDoom. I don't know if it's intended behavior, but it strikes me as at least inconsitent behavior.
If you have a weapon, say a shutgun, and run out of ammo, it'll autoswitch to something else; like the pistol. If you then pickup some shotgun shells, it'll autoswitch back to the shotgun. But if you picked up another shotgun instead, it won't switch back to it, even though you get ammo for it all the same.
It seems if it'll switch back once you reacquire ammo for it, IMO, it should do so regardless of where that ammo came from.
If you have a weapon, say a shutgun, and run out of ammo, it'll autoswitch to something else; like the pistol. If you then pickup some shotgun shells, it'll autoswitch back to the shotgun. But if you picked up another shotgun instead, it won't switch back to it, even though you get ammo for it all the same.
It seems if it'll switch back once you reacquire ammo for it, IMO, it should do so regardless of where that ammo came from.
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49230
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: Weapon pickups don't autoswitch
You know what? This has been bugging me forever since 2.0.90 but I never made the connection between the differences of weapon/ammo pickups...
Re: Weapon pickups don't autoswitch
Behavior is still inconsistent with when you pick up a backpack, or get ammo through another mean (cheat, custominventory item giving ammo through DECORATE code, etc.).
Re: Weapon pickups don't autoswitch
Funnily enough, this bug has been annoying me for some time too, but I couldn't quite figure out what it was that wasn't happening correctly. I just knew that *something* wasn't right.
Anyway, I just checked doom2.exe. If you have switched to the pistol from the shotgun due to lack of shotgun ammo, then pick up a backpack, you switch back to the shotgun. In Zdoom (r1333) you do not.
Anyway, I just checked doom2.exe. If you have switched to the pistol from the shotgun due to lack of shotgun ammo, then pick up a backpack, you switch back to the shotgun. In Zdoom (r1333) you do not.
Re: Weapon pickups don't autoswitch
Did you mean that? Or, is it supposed to be reversed?Enjay wrote: If you have switched to the pistol from the shotgun due to lack of shotgun ammo,
Re: Weapon pickups don't autoswitch
"switched to the pistol from the shotgun" and "switched from the shotgun to the pistol" have exactly the same meaning. What he said is what he meant, and is absolutely correct.dennisj1 wrote:Did you mean that? Or, is it supposed to be reversed?Enjay wrote: If you have switched to the pistol from the shotgun due to lack of shotgun ammo,
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49230
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: Weapon pickups don't autoswitch
Enjay wrote: Anyway, I just checked doom2.exe. If you have switched to the pistol from the shotgun due to lack of shotgun ammo, then pick up a backpack, you switch back to the shotgun. In Zdoom (r1333) you do not.
ZDoom's weapon switching works differently than vanilla's and I'm afraid that the backpack is a victim of that which is not that easily restored. What decides which weapon is supposed to be activated when a backpack is being picked up?
- Ryan Cordell
- Posts: 4349
- Joined: Sun Feb 06, 2005 6:39 am
- Preferred Pronouns: No Preference
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia (Modern GZDoom)
- Location: Capital of Explodistan
Re: Weapon pickups don't autoswitch
Last weapon which had no ammo? 

- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49230
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: Weapon pickups don't autoswitch
No matter what can be done - it would be different than always switching to the shotgun unless such weapons get specially flagged.
Re: Weapon pickups don't autoswitch
How about this? (please forgive the Javasque code)Blade Nightflame wrote:Last weapon which had no ammo?
Code: Select all
int mostValuedWeaponIndex = currentlyUsedWeapon;
for ( int i = 0; i < weaponsInInventory.length; i++ )
{
if ( weaponsInInventory[ i ].SelectionOrder < currentlyUsedWeapon.SelectionOrder )
{
mostValuedWeaponIndex = currentlyUsedWeapon;
}
}
SelectWeapon( weaponsInInventory[ mostValuedWeaponIndex ] );

- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49230
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: Weapon pickups don't autoswitch
Sure this can be done - but it will never be the same as Doom.exe which always selected the shotgun.
Re: Weapon pickups don't autoswitch
We could consider a "BackupWeapon" property on the PlayerPawn, which took a classname. That sounds like an adventure in itself though. :S