GetMaxInventory

From ZDoom Wiki
Jump to navigation Jump to search

int GetMaxInventory (int tid, string inventory);

Usage

Retrieves the maximum amount of the specified inventory item. If the item is present in the inventory of the actor on which to perform the check (henceforth called "reference actor"), the function retrieves the current maximum amount of that item. If, however, the item is absent from the inventory, the maximum amount of the item as defined by its actor class is retrieved, instead.

The function has a special handling for when "Health" is passed as inventory; if the reference actor is a player, it retrieves its current maximum health, otherwise it retrieves the spawn health if the actor is a non-player. This behaves exactly like GetActorProperty with APROP_SpawnHealth.

Parameters

  • tid: The tid of the reference actor. If this is 0, the check is performed on the activator of the script.
  • inventory: The inventory item to get its maximum amount.

Return value

The function returns 0 if the reference actor is non-existent, otherwise the value returned is as explained above.

Zandronum

Unfortunately, Zandronum 3.0 does not support GetMaxInventory, and will always return 0. Tip: You can use GetAmmoCapacity as a work-around.

Examples

Nuvolachalk.png Note: This article lists no examples. If you make use of this feature in your own project(s) or know of any basic examples that could be shared, please add them. This will make it easier to understand for future authors seeking assistance. Your contributions are greatly appreciated.


Using GetAmmoCapacity for Zandronum

Define and get the player's max level using GetAmmoCapacity.

DECORATE

ACTOR PlayerLevel : Inventory
{
   Inventory.Amount 1
   Inventory.MaxAmount 10
}
ACTOR PlayerMaxLevel : Ammo // For GetAmmoCapacity()
{
   Inventory.MaxAmount 10 // Same value as MaxAmount for PlayerLevel.
}

ACS

script 1 ENTER
{
   Print(s:"Max level is: ",d:GetAmmoCapacity("PlayerMaxLevel"));
}