Inventory vs CustomInventory

Ask about mapping, UDMF, using DoomBuilder/editor of choice, etc, 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.
Post Reply
User avatar
Curunir
Posts: 1040
Joined: Sun Nov 02, 2003 11:24 am
Graphics Processor: ATI/AMD with Vulkan/Metal Support

Inventory vs CustomInventory

Post by Curunir »

I have an item that is required to exit the level. I have it in Decorate like this:

Code: Select all

actor Purifier : CustomInventory 12349
{
  Inventory.PickupMessage "You got the purification device."
  Inventory.PickupSound "items/armorpickup"
  Inventory.Amount 1
  Inventory.MaxAmount 1
  
  +SOLID

  States
  {
  Spawn:
    BART A -1
    Stop
  Pickup:
	TNT1 A 0 ACS_NamedExecute("SlowMeDown", 0)
	Stop	
  }
}
There is a linedef that runs the following script that checks if the player has the item and can exit the level:

Code: Select all

script 2 (void)
{
	if (CheckInventory("Purifier") == 1)
			Exit_Normal(0);
	else
			Print(s:"You don't have the purification device.");
}
The issue is, with the item defined with CustomInventory, the "SlowMeDown" script gets called and executes, but the linedef script won't find the item on me.
If I change the item definition from CustomInventory to just Inventory, the "SlowMeDown" script doesn't work, but the linedef script DOES find the item and ends the level.

What do I do?
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: Inventory vs CustomInventory

Post by Graf Zahl »

A CustomInventory item never gets added to the inventory if it only has a Pickup state. If you want it added it also requires a Use state. The Use state doesn't need to do anything but it needs to be present.
User avatar
Curunir
Posts: 1040
Joined: Sun Nov 02, 2003 11:24 am
Graphics Processor: ATI/AMD with Vulkan/Metal Support

Re: Inventory vs CustomInventory

Post by Curunir »

Thanks a lot, Graf!

I did notice the wiki for CustomInventory says "If there is no Use state the item will be removed from the map and not be placed in the actor's inventory", but I had no idea how to define a use state for something that's never really used, didn't know it could be empty and work!

That fixed it! Thanks again!
Post Reply

Return to “Mapping”