[ZScript] Trouble with CustomInventory Weapon Pickup

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.

[ZScript] Trouble with CustomInventory Weapon Pickup

Postby SanyaWaffles » Mon Jan 08, 2018 12:52 pm

I posted about this in the ZDoom Discord, but I kept monopolizing the dedicated channel so I didn't wanna keep doing that.

Plus it might help to keep everything neat here.

The Code Snipplets (Gist.Github)

Spoiler: Video


The video demonstrates the problem. The code works flawlessly when it comes to picking up a weapon you aren't carrying (in this case, carrying a Bazooka but wanting to pick up a Textwall) but when picking up a weapon you all ready carry, it just picks up the weapon anyway, not dropping the one you were carrying.

The behavior is supposed to be similar to Rise of the Triad's weapon system (with the addition of +use being a safeguard against accidentally picking up the inventory). In that you could only carry one "heavy weapon" at a time, and picking up another pickup would have you "drop" the one you were carrying.

I've heard A_DropInventory be suggested, but A_DropInventory I don't think would offer the flexibility of this. I dunno if it could work on a generic Weapon pickup. The reason I used CustomInventory was because IMO it was the logical approach to do a heavily scripted item, plus I knew TryPickup could definitely be overridden (while IIRC Inventory's is protected?)

Maybe this is an overly complex way of doing what I want. All I know is the code almost works except for picking up the same weapon you all ready are carrying. See video under spoiler to see exactly what I mean.
User avatar
SanyaWaffles
Now I've awoken, and I'm taking back control.
 
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: [ZScript] Trouble with CustomInventory Weapon Pickup

Postby SanyaWaffles » Mon Jan 08, 2018 6:02 pm

Not to double-post, but I finally fixed it after several hours of debugging.

https://gist.github.com/SanyaWaffles/5f ... 467fa7c163

It's fixed. Some additional testing is required though.

In short, it seems I had to do things in a certain order. Most of the work was done in the Pickup: state and required me to do some major refactoring, simplifying the boolean checks. I have left some unused boolean checks in the Git Gist to show that one of the boolean checks ended up not being necessary. I will be removing this boolean check once I confirm that this works.

This kind of shows how complex of a beast CustomInventory items can be.
User avatar
SanyaWaffles
Now I've awoken, and I'm taking back control.
 
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


Return to Scripting

Who is online

Users browsing this forum: Trustdeth and 2 guests