Can select/cycle certain weapons with empty ammo

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 a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: Can select/cycle certain weapons with empty ammo

Re: Can select/cycle certain weapons with empty ammo

by unknownna » Wed Oct 12, 2016 5:38 pm

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.

Re: Can select/cycle certain weapons with empty ammo

by Graf Zahl » Wed Oct 12, 2016 12:08 pm

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.

Re: Can select/cycle certain weapons with empty ammo

by NeuralStunner » Wed Oct 12, 2016 11:52 am

Is WEAPON.AMMO_CHECKBOTH obsolete/useless, then? Or does it only apply if AmmoUes* is >0, not just positive as the wiki page says?

Re: Can select/cycle certain weapons with empty ammo

by Graf Zahl » Wed Oct 12, 2016 11:36 am

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.

Re: Can select/cycle certain weapons with empty ammo

by NeuralStunner » Wed Oct 12, 2016 11:26 am

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!

Can select/cycle certain weapons with empty ammo

by unknownna » Tue Oct 11, 2016 12:55 pm

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
        }
    }

Top