Fix fillMagazineWithCartridge() failing to get a cartridge size when weapon is the rotating grenade launcher

This commit is contained in:
Dev 2023-12-30 18:43:17 +00:00
parent 30c15ec9f0
commit ffc3a28dc8

View File

@ -1032,7 +1032,10 @@ export class ItemHelper
const cartridgeMaxStackSize = cartridgeDetails[1]._props.StackMaxSize; const cartridgeMaxStackSize = cartridgeDetails[1]._props.StackMaxSize;
// Get max number of cartridges in magazine, choose random value between min/max // Get max number of cartridges in magazine, choose random value between min/max
const magazineCartridgeMaxCount = magTemplate._props.Cartridges[0]?._max_count; const magazineCartridgeMaxCount = (this.isOfBaseclass(magTemplate._id, BaseClasses.SPRING_DRIVEN_CYLINDER))
? magTemplate._props.Slots.length // Edge case for rotating grenade launcher magazine
: magTemplate._props.Cartridges[0]?._max_count;
if (!magazineCartridgeMaxCount) if (!magazineCartridgeMaxCount)
{ {
this.logger.warning(`Magazine: ${magTemplate._id} ${magTemplate._name} lacks a Cartridges array, unable to fill magazine with ammo`); this.logger.warning(`Magazine: ${magTemplate._id} ${magTemplate._name} lacks a Cartridges array, unable to fill magazine with ammo`);