Can select/cycle certain weapons with empty ammo

Bugs that have been investigated and resolved somehow.

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.
Post Reply
unknownna
Posts: 215
Joined: Sat Oct 06, 2007 4:45 pm

Can select/cycle certain weapons with empty ammo

Post by unknownna »

0002880: cl_noammoswitch switches to empty weapons if Weapon.AmmoUse is 0 or when AltFire state is present
unknownna wrote:
Edward-san wrote:
unknownna wrote:I was testing some mods and got confused wondering why the client was able to switch over to weapons without any ammo despite having cl_noammoswitch set to false. I investigated the issue further and narrowed it down to cl_noammoswitch not working if the weapons have Weapon.AmmoUse1/2 set to 0 or if the weapons have an AltFire state present in the DECORATE code.
Does changing sv_dontcheckammo on/off change the behavior?
I just tried it and it doesn't seem to change anything. I can still select both empty weapons. I also tested ZDoom 2.8.1 and you can also select both weapons there, so it might be a bug/side-effect inherited from the ZDoom behavior.

Although Weapon.AmmoUse 0 is technically like having infinite ammo, many mods don't seem to actually fire the weapon in the fire state unless the player has another ammo item present in the inventory.
Steps to reproduce:

pwo_ammotype_02.wad

1. zdoom -iwad doom2.wad -file pwo_ammotype_02.wad +map map01
2. Fire the chaingun, using up the ammo.
3. Notice how you can still cycle between your empty weapons despite not having any ammo.

Code: Select all

    Actor Pistol_02 : Pistol
    {
        Weapon.SlotNumber 2
        Weapon.AmmoUse1 0
        Weapon.AmmoUse2 0
        Weapon.AmmoType1 "Clip"
        Weapon.AmmoType2 "Clip"
        Tag "Pistol Weapon.AmmoUse1/2 0"
    }

    Actor Chaingun_02 : Chaingun
    {
        Weapon.SlotNumber 4
        Tag "Chaingun AltFire State Present"
        States
    {		
        AltFire:
            CHGG A 4 A_GiveInventory ("Clip", 1)
            Goto Ready
        }
    }
User avatar
NeuralStunner
 
 
Posts: 12328
Joined: Tue Jul 21, 2009 12:04 pm
Preferred Pronouns: No Preference
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support
Location: capital N, capital S, no space
Contact:

Re: Can select/cycle certain weapons with empty ammo

Post by NeuralStunner »

For the AltFire issue, AmmoUse2 is 0 by default. Still, the existence of [wiki=Actor_flags#WEAPON.AMMO_CHECKBOTH]this flag[/wiki] indicates that it shouldn't be making this allowance implicitly.

As for AmmoUse 0, I don't see a bug. It's doing exactly what you've told it to: The weapon meets the ammo requirement, so it's not empty, and therefore it's selectable. You already said as much yourself:
unknownna wrote:Although Weapon.AmmoUse 0 is technically like having infinite ammo, many mods don't seem to actually fire the weapon in the fire state unless the player has another ammo item present in the inventory.
It's not the engine's fault if you're working around built-in functionality in weird ways, and then the built-in functionality doesn't work right!
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49230
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Can select/cycle certain weapons with empty ammo

Post by Graf Zahl »

If AmmoUse2 is 0 and an AltFire state present, the weapon must be selectable, because otherwise you wouldn't be able to use the AltFire if the primary ammo was depleted.
User avatar
NeuralStunner
 
 
Posts: 12328
Joined: Tue Jul 21, 2009 12:04 pm
Preferred Pronouns: No Preference
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support
Location: capital N, capital S, no space
Contact:

Re: Can select/cycle certain weapons with empty ammo

Post by NeuralStunner »

Is WEAPON.AMMO_CHECKBOTH obsolete/useless, then? Or does it only apply if AmmoUes* is >0, not just positive as the wiki page says?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49230
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Can select/cycle certain weapons with empty ammo

Post by Graf Zahl »

That's not what the flag does. Normally it checks only the attack that's currently being performed. This flag tells the engine to check both attacks, not just the current one, and succeed if any of them has enough. Obviously a secondary attack which uses no ammo always passes.

The cycling code passes EitherFire in there so that this flag never has an effect on the result. You can cycle to a weapon whenever there is enough ammo in the inventory to perform one of its attacks.
unknownna
Posts: 215
Joined: Sat Oct 06, 2007 4:45 pm

Re: Can select/cycle certain weapons with empty ammo

Post by unknownna »

NeuralStunner wrote:For the AltFire issue, AmmoUse2 is 0 by default.
I see, so you have to explicitly define "Weapon.AmmoUse1/2 1" as the engine assumes "Weapon.AmmoUse1/2 0" by default if omitted.

As for the "Weapon.AmmoUse1/2 0" case, some mods such as Zombie Horde set these to 0 and use A_Jump* combined with A_Give/TakeInventory to control their ammo and reloading. To me this seems to be a case of mods working around the system, allowing their weapons to bypass any "empty" status by using A_Jump* combined with A_Give/TakeInventory to manually control the ammo instead.
Post Reply

Return to “Closed Bugs [GZDoom]”