From 9a28e862611d5648795bf8a3fbbdf1f26631e63a Mon Sep 17 00:00:00 2001 From: chomp Date: Sun, 3 Mar 2024 11:06:33 +0000 Subject: [PATCH] Fix incorrect trader messages being sent when dealing with insurance on labs (!241) Co-authored-by: HiddenCirno Co-authored-by: Dev Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/241 --- project/src/controllers/InraidController.ts | 9 ++------ .../src/controllers/InsuranceController.ts | 18 ++++++++++++--- project/src/services/InsuranceService.ts | 23 ------------------- 3 files changed, 17 insertions(+), 33 deletions(-) diff --git a/project/src/controllers/InraidController.ts b/project/src/controllers/InraidController.ts index ea405792..8f7236ac 100644 --- a/project/src/controllers/InraidController.ts +++ b/project/src/controllers/InraidController.ts @@ -172,9 +172,7 @@ export class InraidController if (gearToStore.length > 0) { - mapHasInsuranceEnabled - ? this.insuranceService.storeGearLostInRaidToSendLater(sessionID, gearToStore) - : this.insuranceService.sendLostInsuranceMessage(sessionID, locationName); + this.insuranceService.storeGearLostInRaidToSendLater(sessionID, gearToStore); } // Edge case - Handle usec players leaving lighthouse with Rogues angry at them @@ -235,10 +233,7 @@ export class InraidController this.pmcChatResponseService.sendVictimResponse(sessionID, victims, serverPmcProfile); } - if (mapHasInsuranceEnabled) - { - this.insuranceService.sendInsuredItems(serverPmcProfile, sessionID, map.Id); - } + this.insuranceService.sendInsuredItems(serverPmcProfile, sessionID, map.Id); } /** diff --git a/project/src/controllers/InsuranceController.ts b/project/src/controllers/InsuranceController.ts index b1fd72b2..fe681f3f 100644 --- a/project/src/controllers/InsuranceController.ts +++ b/project/src/controllers/InsuranceController.ts @@ -522,10 +522,22 @@ export class InsuranceController { // After all of the item filtering that we've done, if there are no items remaining, the insurance has // successfully "failed" to return anything and an appropriate message should be sent to the player. - if (insurance.items.length === 0) + const traderDialogMessages = this.databaseServer.getTables().traders[insurance.traderId].dialogue; + if (insurance.systemData?.location.toLowerCase() === "laboratory") { - const insuranceFailedTemplates = - this.databaseServer.getTables().traders[insurance.traderId].dialogue.insuranceFailed; + // Trader has labs-specific messages + // Wipe out returnable items + if (traderDialogMessages.insuranceFailedLabs?.length > 0) + { + const insuranceFailedLabTemplates = traderDialogMessages.insuranceFailedLabs; + insurance.messageTemplateId = this.randomUtil.getArrayValue(insuranceFailedLabTemplates); + insurance.items = []; + } + } + else if (insurance.items.length === 0) + { + // Not labs and no items to return + const insuranceFailedTemplates = traderDialogMessages.insuranceFailed; insurance.messageTemplateId = this.randomUtil.getArrayValue(insuranceFailedTemplates); } diff --git a/project/src/services/InsuranceService.ts b/project/src/services/InsuranceService.ts index a92202d3..ceacb5c7 100644 --- a/project/src/services/InsuranceService.ts +++ b/project/src/services/InsuranceService.ts @@ -142,29 +142,6 @@ export class InsuranceService this.resetInsurance(sessionID); } - /** - * Send a message to player informing them gear was completely lost - * @param sessionId Session id - * @param locationName name of map insurance was lost on - */ - public sendLostInsuranceMessage(sessionId: string, locationName = ""): void - { - const dialogueTemplates = this.databaseServer.getTables().traders[Traders.PRAPOR].dialogue; // todo: get trader id instead of hard coded prapor - const randomResponseId = locationName?.toLowerCase() === "laboratory" - ? this.randomUtil.getArrayValue(dialogueTemplates.insuranceFailedLabs) - : this.randomUtil.getArrayValue(dialogueTemplates.insuranceFailed); - - this.mailSendService.sendLocalisedNpcMessageToPlayer( - sessionId, - this.traderHelper.getTraderById(Traders.PRAPOR), - MessageType.NPC_TRADER, - randomResponseId, - [], - null, - { location: locationName }, - ); - } - /** * Check all root insured items and remove location property + set slotId to 'hideout' * @param sessionId Session id