From 246f0d503036737df008aae6d97d9067e1fd03dc Mon Sep 17 00:00:00 2001 From: DrakiaXYZ Date: Thu, 7 Mar 2024 08:43:15 +0000 Subject: [PATCH] Fix give command not working on armor presets and not marking presets as FiR (!250) - Commando `give` command now handles all presets in the same way, so if BSG adds new types of presets in the future they should be supported without changes - Commando `give` command now marks all given items as FiR for consistency Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com> Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/250 Co-authored-by: DrakiaXYZ Co-committed-by: DrakiaXYZ --- .../Commando/SptCommands/GiveSptCommand.ts | 17 +++++------------ project/src/helpers/ItemHelper.ts | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/project/src/helpers/Dialogue/Commando/SptCommands/GiveSptCommand.ts b/project/src/helpers/Dialogue/Commando/SptCommands/GiveSptCommand.ts index de74514f..644c1835 100644 --- a/project/src/helpers/Dialogue/Commando/SptCommands/GiveSptCommand.ts +++ b/project/src/helpers/Dialogue/Commando/SptCommands/GiveSptCommand.ts @@ -88,19 +88,9 @@ export class GiveSptCommand implements ISptCommand } const itemsToSend: Item[] = []; - if (this.itemHelper.isOfBaseclass(checkedItem[1]._id, BaseClasses.WEAPON)) + const preset = this.presetHelper.getDefaultPreset(checkedItem[1]._id); + if (preset) { - const preset = this.presetHelper.getDefaultPreset(checkedItem[1]._id); - if (!preset) - { - this.mailSendService.sendUserMessageToPlayer( - sessionId, - commandHandler, - "Invalid weapon template ID requested. There are no default presets for this weapon.", - ); - return request.dialogId; - } - for (let i = 0; i < +quantity; i++) { // Make sure IDs are unique before adding to array - prevent collisions @@ -128,6 +118,9 @@ export class GiveSptCommand implements ISptCommand itemsToSend.push(...this.itemHelper.splitStack(item)); } + // Flag the items as FiR + this.itemHelper.setFoundInRaid(itemsToSend); + this.mailSendService.sendSystemMessageToPlayer(sessionId, "Give command!", itemsToSend); return request.dialogId; } diff --git a/project/src/helpers/ItemHelper.ts b/project/src/helpers/ItemHelper.ts index c1fdf69e..ae18b015 100644 --- a/project/src/helpers/ItemHelper.ts +++ b/project/src/helpers/ItemHelper.ts @@ -809,6 +809,24 @@ export class ItemHelper return items; } + /** + * Mark the passed in array of items as found in raid. + * Modifies passed in items + * @param items The list of items to mark as FiR + */ + public setFoundInRaid(items: Item[]): void + { + for (const item of items) + { + if (!item.upd) + { + item.upd = {}; + } + + item.upd.SpawnedInSession = true; + } + } + /** * WARNING, SLOW. Recursively loop down through an items hierarchy to see if any of the ids match the supplied list, return true if any do * @param {string} tpl Items tpl to check parents of