SetAmmoCapacity (Actor)
(Redirected from SetAmmoCapacity (Actor function))
Jump to navigation
Jump to search
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
This version of the DoomPlayer will have its ammo capacity for all the default Doom ammo classes set to 1000 as soon as it spawns:
class MyCustomPlayer : DoomPlayer
{
override void PostBeginPlay()
{
Super.PostBeginPlay();
if (self.player && self.player.mo == self) //voodoo doll check
{
SetAmmoCapacity('Clip', 1000);
SetAmmoCapacity('Shell', 1000);
SetAmmoCapacity('RocketAmmo', 1000);
SetAmmoCapacity('Cell', 1000);
}
}
}
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;
}
}
}
}