Ammo Limit Questions

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.

Ammo Limit Questions

Postby TheOldKingCole » Thu Jan 23, 2020 4:20 pm

So I was having a look at the wiki page for SetAmmoLimit and didn't find it very helpful.
If I want to limit a weapons ammo, how would I do so?
Also I'm Using Decorate
TheOldKingCole
 
Joined: 31 Jan 2019

Re: Ammo Limit Questions

Postby SanyaWaffles » Thu Jan 23, 2020 10:09 pm

In Decorate the easiest way to set an ammo limit is on the Ammo type for the weapon.

https://zdoom.org/wiki/Classes:Clip

Code: Select allExpand view
Inventory.MaxAmount 200


is the limit without backpacks.

Code: Select allExpand view
Ammo.BackpackMaxAmount 400


is the limit with a default backpack

To change the ammo capacity specifically there is an ACS function:

https://zdoom.org/wiki/SetAmmoCapacity

There's probably a ZScript way to do it, but I'm not familiar with it. DECORATE is a bit limited as you can tell.
User avatar
SanyaWaffles
Navy Did Nothing Wrong
 
Joined: 25 Apr 2013
Location: Eastern Ohio
Discord: SanyaWaffles#5095
Twitch ID: sanyawaffles
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Ammo Limit Questions

Postby Player701 » Fri Jan 24, 2020 9:01 am

It is not possible to alter existing ammo types in a neat way. I've seen somewhat lengthy discussions about this issue somewhere on these forums, but I'm afraid I don't remember where exactly they happened. Not sure if it matters, anyway...

The problem: subclassing an existing ammo type creates a new ammo pickup for that type, but the ammo capacity is read from the MaxAmount value of the parent ammo class (for example, Clip is the parent type, and ClipBox is a pickup type for ammo type Clip). And you can't modify classes that have already been defined in gzdoom.pk3 neither with DECORATE nor with ZScript. However, ACS has SetAmmoCapacity, which will do what you want.

Another solution I can think of, which does not involve ACS, is to define a custom ammo type that mimics the original in everything except MaxAmount and/or BackpackMaxAmount, but this means you will also need to subclass and replace all existing weapons that use the original ammo type, so that they use your new ammo type instead.

Unfortunately, I'm not aware of any recent developments that could provide a better solution to this problem.
User avatar
Player701
 
Joined: 13 May 2009
Location: Russian Federation
Discord: Player701#8214
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Ammo Limit Questions

Postby TheOldKingCole » Fri Jan 24, 2020 12:06 pm

SanyaWaffles wrote:In Decorate the easiest way to set an ammo limit is on the Ammo type for the weapon.

https://zdoom.org/wiki/Classes:Clip

Code: Select allExpand view
Inventory.MaxAmount 200


is the limit without backpacks.

Code: Select allExpand view
Ammo.BackpackMaxAmount 400


is the limit with a default backpack

To change the ammo capacity specifically there is an ACS function:

https://zdoom.org/wiki/SetAmmoCapacity

There's probably a ZScript way to do it, but I'm not familiar with it. DECORATE is a bit limited as you can tell.


Would this work with rockets?
TheOldKingCole
 
Joined: 31 Jan 2019

Re: Ammo Limit Questions

Postby Jarewill » Fri Jan 24, 2020 12:29 pm

TheOldKingCole wrote:Would this work with rockets?

Yes, though keep in mind that rockets are actually named RocketAmmo, as just Rocket is the fired rocket projectile.

Also there is a method to change ammo amount without defining new ammo types using DeHackEd.
Jarewill
 
 
 
Joined: 21 Jul 2019


Return to Scripting

Who is online

Users browsing this forum: No registered users and 0 guests