Fix incorrect trader messages being sent when dealing with insurance on labs (!241)

Co-authored-by: HiddenCirno <hiddencirno@noreply.dev.sp-tarkov.com>
Co-authored-by: Dev <dev@dev.sp-tarkov.com>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/241
This commit is contained in:
chomp 2024-03-03 11:06:33 +00:00
parent d828e9da7d
commit 9a28e86261
3 changed files with 17 additions and 33 deletions

View File

@ -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,11 +233,8 @@ export class InraidController
this.pmcChatResponseService.sendVictimResponse(sessionID, victims, serverPmcProfile);
}
if (mapHasInsuranceEnabled)
{
this.insuranceService.sendInsuredItems(serverPmcProfile, sessionID, map.Id);
}
}
/**
* Make changes to PMC profile after they've died in raid,

View File

@ -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);
}

View File

@ -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