0
0
mirror of https://github.com/sp-tarkov/server.git synced 2025-02-12 21:30:43 -05:00

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)

This commit is contained in:
Chomp 2024-12-06 15:42:53 +00:00
parent 6c9e4fd0bb
commit 0397c9e121

View File

@ -100,23 +100,28 @@ export class BotWeaponModLimitService {
return true; 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); const modIsScope = this.itemHelper.isOfBaseclasses(modTemplate._id, modLimits.scopeBaseTypes);
if (this.itemHelper.isOfBaseclasses(modsParent._id, modLimits.scopeBaseTypes) && modIsScope) { if (this.itemHelper.isOfBaseclasses(modsParent._id, modLimits.scopeBaseTypes) && modIsScope) {
return false; return false;
} }
// If mod is a scope, return if limit reached // If mod is a scope , Exit early
if (modIsScope) { if (modIsScope) {
return this.weaponModLimitReached(modTemplate._id, modLimits.scope, modLimits.scopeMax, botRole); 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 ( if (
this.itemHelper.isOfBaseclass(modTemplate._id, BaseClasses.MOUNT) && modLimits.scope.count >= modLimits.scopeMax &&
modTemplate._props.Slots.some((x) => x._name === "mod_scope") &&
modTemplate._props.Slots.length === 1 && 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; return true;
} }