SetAmmoCapacity (Actor)

From ZDoom Wiki
(Redirected from SetAmmoCapacity (ZScript))
Jump to navigation Jump to search

Actor

void SetAmmoCapacity (class<Ammo> type, int amount)

Usage

Sets the max amount of the specified ammo type in the calling actor's inventory. If the ammo type does not exist in the inventory, then it is added to it, while having its max amount set to the desired value.

Parameters

  • class<Ammo> type
The class name of the ammo type.
  • int amount
The amount to which the max amount is set.

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.


ZScript definition

Note: The ZScript definition below is for reference and may be different in the current version of GZDoom.The most up-to-date version of this code can be found on GZDoom GitHub.
	void SetAmmoCapacity(class<Ammo> type, int amount)
	{
		if (type != NULL)
		{
			let item = FindInventory(type);
			if (item != NULL)
			{
				item.MaxAmount = amount;
			}
			else
			{
				item = GiveInventoryType(type);
				if (item != NULL)
				{
					item.MaxAmount = amount;
					item.Amount = 0;
				}
			}
		}
	}

See also