From 519ecbe8eb32c0bc497930b5a32eb2c6c440fde3 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 29 Apr 2022 00:12:51 +0200 Subject: [PATCH] - added Get/SetAmmoCapacity ZScript functions --- .../static/zscript/actors/inventory_util.zs | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/wadsrc/static/zscript/actors/inventory_util.zs b/wadsrc/static/zscript/actors/inventory_util.zs index 6b65b64205..e1820a86da 100644 --- a/wadsrc/static/zscript/actors/inventory_util.zs +++ b/wadsrc/static/zscript/actors/inventory_util.zs @@ -814,6 +814,46 @@ extend class Actor } } + + int GetAmmoCapacity(class type) + { + if (type != NULL) + { + let item = FindInventory(type); + if (item != NULL) + { + return item.MaxAmount; + } + else + { + return GetDefaultByType(type).MaxAmount; + } + } + return 0; + } + + void SetAmmoCapacity(class 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; + } + } + } + } + +