My shotgun can still be selected with 0 ammo

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
User avatar
Jekyll Grim Payne
Global Moderator
Posts: 1118
Joined: Mon Jul 21, 2008 4:08 am
Preferred Pronouns: He/Him
Graphics Processor: nVidia (Modern GZDoom)
Contact:

My shotgun can still be selected with 0 ammo

Post by Jekyll Grim Payne »

It's not a huge problem but it's weird, and I can't figure out why it's the case.

The properties are as follows

Code: Select all

Actor BD_Shotgun : Shotgun replaces Shotgun
{
weapon.selectionorder 130
inventory.pickupsound "weapons/shotgun/pump"
attacksound ""
+NOALERT //for melee
weapon.slotnumber 3
weapon.slotpriority 1
States
	{
...
	}
}
The alternative attack is a melee attack that doesn't use any ammo. However, I thought that since I don't have ALT_AMMO_OPTIONAL, the shotgun will become unavailable as soon as its main ammo is. But it doesn't seem to be the case: it can be selected without ammo. How come?

P.S. I can post the states code but I don't think anything there could affect that.
Blue Shadow
Posts: 5043
Joined: Sun Nov 14, 2010 12:59 am

Re: My shotgun can still be selected with 0 ammo

Post by Blue Shadow »

Jekyll Grim Payne wrote:The alternative attack is a melee attack that doesn't use any ammo.
There. This is why. If you think about it, the chainsaw, for instance, doesn't use ammo, yet you can still select and use it. It's the same thing here. Your weapon can always be selected because its alt fire is always usable, even if you can't use its primary fire due to lack of ammo.
I thought that since I don't have ALT_AMMO_OPTIONAL, the shotgun will become unavailable as soon as its main ammo is.
Since the weapon doesn't utilize a secondary ammo type, setting or clearing that flag doesn't change anything.
User avatar
Jekyll Grim Payne
Global Moderator
Posts: 1118
Joined: Mon Jul 21, 2008 4:08 am
Preferred Pronouns: He/Him
Graphics Processor: nVidia (Modern GZDoom)
Contact:

Re: My shotgun can still be selected with 0 ammo

Post by Jekyll Grim Payne »

Is there any way to block the selection when it runs out of primary ammo type?
User avatar
wildweasel
Posts: 21706
Joined: Tue Jul 15, 2003 7:33 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): A lot of them
Graphics Processor: Not Listed
Contact:

Re: My shotgun can still be selected with 0 ammo

Post by wildweasel »

The trick I was shown was giving it the flag WEAPON.AMMO_CHECKBOTH. The wiki says you need to give both ammo types a positive AmmoUse value, but there's nothing stopping you from setting it to 1 and then setting any attack functions to not use ammo.
Post Reply

Return to “Scripting”