From 8984711cbaa47813d0886f09bcce7e9cfc2f07af Mon Sep 17 00:00:00 2001 From: Dev Date: Fri, 15 Mar 2024 13:46:31 +0000 Subject: [PATCH] Allow custom item server to add weapons to weapon shelf --- project/src/services/mod/CustomItemService.ts | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/project/src/services/mod/CustomItemService.ts b/project/src/services/mod/CustomItemService.ts index c76b580a..0044d8da 100644 --- a/project/src/services/mod/CustomItemService.ts +++ b/project/src/services/mod/CustomItemService.ts @@ -2,6 +2,7 @@ import { inject, injectable } from "tsyringe"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { ITemplateItem, Props } from "@spt-aki/models/eft/common/tables/ITemplateItem"; +import { BaseClasses } from "@spt-aki/models/enums/BaseClasses"; import { CreateItemResult, LocaleDetails, @@ -72,6 +73,11 @@ export class CustomItemService this.addToFleaPriceDb(newItemId, newItemDetails.fleaPriceRoubles); + if (this.itemHelper.isOfBaseclass(itemClone._id, BaseClasses.WEAPON)) + { + this.addToWeaponShelf(newItemId); + } + result.success = true; result.itemId = newItemId; @@ -109,6 +115,11 @@ export class CustomItemService this.addToFleaPriceDb(newItem._id, newItemDetails.fleaPriceRoubles); + if (this.itemHelper.isOfBaseclass(newItem._id, BaseClasses.WEAPON)) + { + this.addToWeaponShelf(newItem._id); + } + result.itemId = newItemDetails.newItem._id; result.success = true; @@ -200,6 +211,26 @@ export class CustomItemService this.tables.templates.prices[newItemId] = fleaPriceRoubles; } + /** + * Add a weapon to the hideout weapon shelf whitelist + * @param newItemId Weapon id to add + */ + protected addToWeaponShelf(newItemId: string): void + { + this.databaseServer.getTables().templates.items; + + // Ids for wall stashes in db + const wallStashIds = ["6401c7b213d9b818bf0e7dd7", "64381b582bb1c5dedd0fc925", "64381b6e44b37a080d0245b9"]; + for (const wallId of wallStashIds) + { + const wall = this.itemHelper.getItem(wallId); + if (wall[0]) + { + wall[1]._props.Grids[0]._props.filters[0].Filter.push(newItemId); + } + } + } + /** * Add a custom weapon to PMCs loadout * @param weaponTpl Custom weapon tpl to add to PMCs