[DECORATE] +AMMO_CHECKBOTH

Moderator: GZDoom Developers

Post Reply
User avatar
Setzer
Posts: 124
Joined: Mon Mar 13, 2006 11:12 pm
Location: nowhereville

[DECORATE] +AMMO_CHECKBOTH

Post by Setzer »

I apologize if this post is rather convoluted. I can deliver a summed-up version if needed.

Most current methods of creating reloading weapons involve two ammo types: an ammo reservoir (e.g. "Clip") and a loaded clip which counts the bullets currently in the weapon itself. A common oddity in this system, however, is that usually the clip count is defined as AmmoType2 and the reservoir as AmmoType1. This lends itself better to being properly displayed on the default HUD, but this usually means that the primary fire generally takes away from AmmoType2 (via A_TakeInventory) when firing normally.

This winds up causing some trouble when ammo becomes scarce. In the event that the player loads the last of his or her ammo into their gun (resulting in zero spare ammo but a few shots left in the clip), the engine notices the zero ammo count and will suddenly switch the gun away when attempting to fire, thinking that the weapon is empty when in reality it is not. The common solution I have seen has been to simply add +AMMO_OPTIONAL to the weapon definition, but while it fixes the zero-ammo problem, it also allows the weapon to be selected even when its ammo supply has been completely exhausted. Needless to say, this botches up auto-switching entirely, which can quickly become a major hassle. This issue manifests itself most noticably in mods such as Zen Dynamics, in which any weapon is inconveniently selectable at any time regardless of whether the weapon is empty or not.

A noble fix: the AMMO_CHECKBOTH flag. This flag, if checked, will disallow auto-switching until both AmmoTypes are depleted. The above scenario will be mended perfectly, as the engine will autoswitch if both the ammo reservoir and current clip are empty but not until then. In further practice, this would also allow a weapon that uses, say, "Clip" for AmmoType1 and "Shell" for AmmoType2 to stay selected if one ammo type is empty while the other is full. I always found it odd that such a weapon is switched away if I run out of Clips and accidentally tap my primary fire key, even though I still have a plethra of Shells remaining.

A lengthy explanation, but hopefully a justified one.
User avatar
Snarboo
Posts: 2599
Joined: Tue Nov 29, 2005 4:37 am

Re: [DECORATE] +AMMO_CHECKBOTH

Post by Snarboo »

Makes sense, and I can definitely see a use for this.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49072
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: [DECORATE] +AMMO_CHECKBOTH

Post by Graf Zahl »

Easier said than done, unfortunately... :?
Gez
 
 
Posts: 17835
Joined: Fri Jul 06, 2007 3:22 pm

Re: [DECORATE] +AMMO_CHECKBOTH

Post by Gez »

Setzer, can you try this exe and tell me if it works? I think it should but I have no weapon mods installed so I haven't tested it.
<link removed>
Last edited by Gez on Thu May 07, 2009 5:42 pm, edited 1 time in total.
User avatar
Setzer
Posts: 124
Joined: Mon Mar 13, 2006 11:12 pm
Location: nowhereville

Re: [DECORATE] +AMMO_CHECKBOTH

Post by Setzer »

I apologize for the latent response.

Unfortunately, the executable crashes when attempting to use the new flag. I cannot procure an error message either; there is no crash log aside from the standard Windows "illegal operation" routine.

Good to see you're looking in to this, however. Perhaps this may help isolate the problem:
Attachments
zpwtest.zip
A single reloadable weapon, ripped from Zero Tolerance and given the appropriate flag. It is assigned highest priority in weapon selection order as well. See if you can produce the intended behavior with this wad. I seem to be too sparse to do it myself in good time. ;)
(53.42 KiB) Downloaded 41 times
Gez
 
 
Posts: 17835
Joined: Fri Jul 06, 2007 3:22 pm

Re: [DECORATE] +AMMO_CHECKBOTH

Post by Gez »

Thanks, I'll take a look at it.

Okay, the crash is easy to understand, given the stupid goof I made. Oops. Infinite recursion. :P

But I've made a working implementation of it now, and I like it enough to suggest this thread be moved to code submission.

By the way, don't forget to give values to both Weapon.AmmoUse1 and Weapon.AmmoUse2, otherwise the flag will behave just as AMMO_OPTIONAL... The default values for those is 0, and since it checks for at least as much ammo as AmmoUse, and the amount in inventory will always be at least 0... :wink:
Last edited by Gez on Sun May 31, 2009 12:04 pm, edited 1 time in total.
Gez
 
 
Posts: 17835
Joined: Fri Jul 06, 2007 3:22 pm

Re: [DECORATE] +AMMO_CHECKBOTH

Post by Gez »

Another bump for this to be moved in code submission...
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49072
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: [DECORATE] +AMMO_CHECKBOTH

Post by Graf Zahl »

If you have a moderation request (thread moving is one!) please use the report function. That's what it's there for.
User avatar
Nash
 
 
Posts: 17439
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: [DECORATE] +AMMO_CHECKBOTH

Post by Nash »

Graf Zahl wrote:If you have a moderation request (thread moving is one!) please use the report function. That's what it's there for.
I used to think that doing that was abusing the report feature (because it doesn't state anywhere on the forum that you can use it to move threads), but I went "eh what the hell, this is the most guaranteed way to get a mod's attention"...

Sorry for the offtopicness. We return you to your regular feature implementation marathon!
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49072
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: [DECORATE] +AMMO_CHECKBOTH

Post by Graf Zahl »

Added. No idea why I overlooked it so far...
Post Reply

Return to “Closed Feature Suggestions [GZDoom]”