Bug: +INVENTORY.AUTOACTIVATE items with MaxAmount != 0...

Is there something that doesn't work right in the latest GZDoom? Post about it here.

Moderator: GZDoom Developers

Forum rules
Please construct and post a simple demo whenever possible for all bug reports. Please provide links to everything.

If you can include a wad demonstrating the problem, please do so. Bug reports that include fully-constructed demos have a much better chance of being investigated in a timely manner than those that don't.

Please make a new topic for every bug. Don't combine multiple bugs into a single topic. Thanks!
User avatar
Player701
 
 
Posts: 1640
Joined: Wed May 13, 2009 3:15 am
Graphics Processor: nVidia with Vulkan support
Contact:

Bug: +INVENTORY.AUTOACTIVATE items with MaxAmount != 0...

Post by Player701 »

...may not activate in a certain case.

When two identical items with +INVENTORY.AUTOACTIVATE and Inventory.MaxAmount > 0 are spawned at the exact same location, only one item will actually auto-activate. The other item will just disappear and be wasted. However, it doesn't happen if MaxAmount is set to 0.

The reason for this is that there is special logic which handles auto-activation of items with MaxAmount == 0, but if the latter is not the case, then normal logic is used, which calls HandlePickup to see if any item in the player's inventory can handle the pickup, and that's where auto-activation will fail.

So, if the item class has MaxAmount == 0, then the third branch of TryPickup will execute for both items and none of the items will go to the player's inventory. However, if MaxAmount > 0, then the second branch will execute for the first item. The item will be added to the player's inventory, where its auto-activation flag will be checked and processed. However, the item will not disappear from the player's inventory for long enough so that picking up the next item will trigger the first branch because CallHandlePickup will return true. Since neither HandlePickup nor TryPickup process auto-activation in this case, the second item will simply disappear without doing anything useful.

Attached to this post is an example to demonstrate this behavior. Go to any map, open the console and type "summon TestInv" two times. Each TestInv is supposed to give the player one health point, but you will only get one. Note that spawning more than two items will usually give more health points than one, but always less than they were actually supposed to give. Now edit the example and uncomment "Inventory.MaxAmount 0", then repeat the testing procedure. You will now correctly get two health points for two spawned items.

Tested in: GZDoom 3.6.0, g3.7pre-9-g4ac43dac3
Attachments
zscript.txt
(335 Bytes) Downloaded 88 times
User avatar
Rowsol
Posts: 946
Joined: Wed Mar 06, 2013 5:31 am
Contact:

Re: Bug: +INVENTORY.AUTOACTIVATE items with MaxAmount != 0..

Post by Rowsol »

I talked about this bug 3 years ago. viewtopic.php?f=7&t=48305
User avatar
Rachael
Posts: 13542
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her
Contact:

Re: Bug: +INVENTORY.AUTOACTIVATE items with MaxAmount != 0..

Post by Rachael »

That one was closed, so I am going to leave this one open. Hopefully any further samples that may be needed will be a little more forthcoming this time around.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49066
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Bug: +INVENTORY.AUTOACTIVATE items with MaxAmount != 0..

Post by Graf Zahl »

Rowsol wrote:I talked about this bug 3 years ago. viewtopic.php?f=7&t=48305

So why didn't you give the requested feedback back then? I specifically asked for it and nothing happened for 7 months. No wonder it didn't get fixed.
The cause is very obvious based on the presented evidence here: Any item in the inventory which has been set to its 'HoldAndDestroy' state may not handle any other item given to it. But without anything to test I had to close the older report.
User avatar
Rowsol
Posts: 946
Joined: Wed Mar 06, 2013 5:31 am
Contact:

Re: Bug: +INVENTORY.AUTOACTIVATE items with MaxAmount != 0..

Post by Rowsol »

I just found it interesting that it took 3.5 years for someone else to mention it. Glad you figured it out.
Post Reply

Return to “Bugs [GZDoom]”