diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index c688f0b98b..d5c5e93ea6 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -831,9 +831,11 @@ bool AActor::GiveInventory(PClassActor *type, int amount, bool givecheat) { if (givecheat) { - item->Amount = MIN(amount, type->IsDescendantOf(NAME_Ammo) - ? item->IntVar("BackpackMaxAmount") - : item->MaxAmount); + const AInventory *const haveitem = FindInventory(type); + + item->Amount = MIN(amount, nullptr == haveitem + ? static_cast(GetDefaultByType(type))->MaxAmount + : haveitem->MaxAmount); } else {