How To: Halve item amount in different conditions/scenarios

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.

How To: Halve item amount in different conditions/scenarios

Postby StroggVorbis » Fri Feb 16, 2018 12:00 pm

In standard Doom, a weapon or ammo item grants half the defined amount of ammo when it is dropped/tossed by a killed monster. However, this doesn't automatically apply when the amount is given indirectly, such as through a WeaponPickup actor, that has the amount defined in its Pickup state, or when using A_DropItem/A_SpawnItemEx, so the half/reduced ammo has to be defined seperately.

Using D3athStalker's DoomIncarnate as a base:

Code: Select allExpand view
HandgunPickup : CustomInventory
{
...
States
{
Spawn:
HGNP A 1
Loop
Pickup:
TNT1 A 0 A_GiveInventory("Handgun", 1)
TNT1 A 0 A_GiveInventory("Handguncounter", 1)
TNT1 A 0 A_CheckFlag("TOSSED","HalfTheAmmo)
TNT1 A 0 A_GiveInventory("9mmBullets", 20)
Stop

HalfTheAmmo:
TNT1 A 0 A_GiveInventory("9mmBullets",10)


I expected the above code to work, but it doesn't. So I have a few questions how to solve this problem:
The way it is now, the console prints an error message upon pickup, because it checks the player for the flag, instead of the weapon or monster. I tried all AAPTR pointers, but had no luck. Can A_CheckFlag ("TOSSED") be used in any state other than the Spawn state in the first place? I also tried using A_JumpIf (Tossed == 1), which of course also didn't work. I searched the Wiki high and low but couldn't find anything of use, so I don't know if JumpIf can actually be used with flags. The documentation was a bit sparse so to say. Or do two different Handgun actors need to be defined, each with a different Weapon.AmmoGive property?
I wonder if there is any "best" or "official" way to handle such a case. I'm all out of ideas and would appreciate any help in leading me in the right direction :)

Thx in advance.
User avatar
StroggVorbis
Donut eat me pls!
 
Joined: 08 Nov 2017
Location: Germany
Discord: StroggVorbis#2466
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: How To: Halve item amount in different conditions/scenar

Postby Blue Shadow » Sat Feb 17, 2018 8:49 am

Checking for the item's flags (which what is needed here) from the Pickup state is not possible in DECORATE. But with ZScript, it is trivial.

Whether you prefer using ZScript or not is something I don't know, but I made something:

giveweapon.pk3
You do not have the required permissions to view the files attached to this post.
User avatar
Blue Shadow
 
Joined: 14 Nov 2010
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: ATI/AMD (Modern GZDoom)

Re: How To: Halve item amount in different conditions/scenar

Postby StroggVorbis » Mon Feb 19, 2018 6:07 pm

Thank you for your help, much appreciated :)

But I still have one last question, how would one accomplish this in DECORATE? :P
User avatar
StroggVorbis
Donut eat me pls!
 
Joined: 08 Nov 2017
Location: Germany
Discord: StroggVorbis#2466
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: How To: Halve item amount in different conditions/scenar

Postby Blue Shadow » Tue Feb 20, 2018 5:45 am

DabbingSquidward wrote:But I still have one last question, how would one accomplish this in DECORATE? :P

Have two items with different ammo amounts, one to replace map-spawned pickups, and one to be dropped by monsters. For the latter, you need to edit the monsters so that they drop the item.
User avatar
Blue Shadow
 
Joined: 14 Nov 2010
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: ATI/AMD (Modern GZDoom)

Re: How To: Halve item amount in different conditions/scenar

Postby StroggVorbis » Wed Feb 21, 2018 4:07 pm

Alright, got it.
Much OBLIGEd (heh) :D :P
User avatar
StroggVorbis
Donut eat me pls!
 
Joined: 08 Nov 2017
Location: Germany
Discord: StroggVorbis#2466
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support


Return to Scripting

Who is online

Users browsing this forum: No registered users and 1 guest