From 0397c9e121cbd51c09dfb606ec5a8993aedf084c Mon Sep 17 00:00:00 2001 From: Chomp Date: Fri, 6 Dec 2024 15:42:53 +0000 Subject: [PATCH] Improved weapon mod limit check for mounts - do not prevent sub-mounts being added to existing mounts (e.g. red dots on top of scope mounts) --- .../src/services/BotWeaponModLimitService.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/project/src/services/BotWeaponModLimitService.ts b/project/src/services/BotWeaponModLimitService.ts index 14313ed3..9a957866 100644 --- a/project/src/services/BotWeaponModLimitService.ts +++ b/project/src/services/BotWeaponModLimitService.ts @@ -100,23 +100,28 @@ export class BotWeaponModLimitService { return true; } - // mods parent is scope and mod is scope, allow it (adds those mini-sights to the tops of sights) + // Mods parent is scope and mod is scope, allow it (adds those mini-sights to the tops of sights) const modIsScope = this.itemHelper.isOfBaseclasses(modTemplate._id, modLimits.scopeBaseTypes); if (this.itemHelper.isOfBaseclasses(modsParent._id, modLimits.scopeBaseTypes) && modIsScope) { return false; } - // If mod is a scope, return if limit reached + // If mod is a scope , Exit early if (modIsScope) { return this.weaponModLimitReached(modTemplate._id, modLimits.scope, modLimits.scopeMax, botRole); } - // Mod is a mount that can hold only scopes and limit is reached (dont want to add empty mounts if limit is reached) + // Don't allow multple mounts on a weapon (except when mount is on another mount) + // Fail when: + // Over or at scope limit on weapon + // Item being added is a mount but the parent item is NOT a mount (Allows red dot sub-mounts on mounts) + // Mount has one slot and its for a mod_scope if ( - this.itemHelper.isOfBaseclass(modTemplate._id, BaseClasses.MOUNT) && - modTemplate._props.Slots.some((x) => x._name === "mod_scope") && + modLimits.scope.count >= modLimits.scopeMax && modTemplate._props.Slots.length === 1 && - modLimits.scope.count >= modLimits.scopeMax + this.itemHelper.isOfBaseclass(modTemplate._id, BaseClasses.MOUNT) && + !this.itemHelper.isOfBaseclass(modsParent._id, BaseClasses.MOUNT) && + modTemplate._props.Slots.some((slot) => slot._name === "mod_scope") ) { return true; }