- added Get/SetAmmoCapacity ZScript functions

This commit is contained in:
Christoph Oelckers 2022-04-29 00:12:51 +02:00
parent 63bba40d7d
commit 519ecbe8eb

View file

@ -814,6 +814,46 @@ extend class Actor
}
}
int GetAmmoCapacity(class<Ammo> type)
{
if (type != NULL)
{
let item = FindInventory(type);
if (item != NULL)
{
return item.MaxAmount;
}
else
{
return GetDefaultByType(type).MaxAmount;
}
}
return 0;
}
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;
}
}
}
}