Added handling of BTR item delivery

This commit is contained in:
Dev 2024-07-05 19:02:02 +01:00
parent 21d8a5fe10
commit 31ba17a327
7 changed files with 60 additions and 60 deletions

View File

@ -158,8 +158,8 @@
"MapID": "TarkovStreets",
"ChanceSpawn": 100,
"SpawnPeriod": {
"x": 300,
"y": 600,
"x": 0,
"y": 10,
"z": 0
},
"MoveSpeed": 8,
@ -183,8 +183,8 @@
"MapID": "Woods",
"ChanceSpawn": 100,
"SpawnPeriod": {
"x": 180,
"y": 360,
"x": 0,
"y": 10,
"z": 0
},
"MoveSpeed": 8,

View File

@ -2,7 +2,6 @@ import { inject, injectable } from "tsyringe";
import { InraidController } from "@spt/controllers/InraidController";
import { IEmptyRequestData } from "@spt/models/eft/common/IEmptyRequestData";
import { INullResponseData } from "@spt/models/eft/httpResponse/INullResponseData";
import { IItemDeliveryRequestData } from "@spt/models/eft/inRaid/IItemDeliveryRequestData";
import { IRegisterPlayerRequestData } from "@spt/models/eft/inRaid/IRegisterPlayerRequestData";
import { ISaveProgressRequestData } from "@spt/models/eft/inRaid/ISaveProgressRequestData";
import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil";
@ -93,15 +92,6 @@ export class InraidCallbacks
return this.httpResponse.noBody(this.inraidController.getTraderServices(sessionId, traderId));
}
/**
* Handle singleplayer/traderServices/itemDelivery
*/
public itemDelivery(url: string, request: IItemDeliveryRequestData, sessionId: string): INullResponseData
{
this.inraidController.itemDelivery(sessionId, request.traderId, request.items);
return this.httpResponse.nullResponse();
}
public getTraitorScavHostileChance(url: string, info: IEmptyRequestData, sessionId: string): string
{
return this.httpResponse.noBody(this.inraidController.getTraitorScavHostileChance(url, sessionId));
@ -114,6 +104,6 @@ export class InraidCallbacks
public getBossConvertSettings(url: string, info: IEmptyRequestData, sessionId: string): string
{
return this.httpResponse.noBody(this.inraidController.getBossConvertSettings(url, sessionId))
return this.httpResponse.noBody(this.inraidController.getBossConvertSettings(url, sessionId));
}
}

View File

@ -234,7 +234,11 @@ export class MatchCallbacks
}
/** Handle client/match/offline/end */
public endOfflineRaid(url: string, info: IEndOfflineRaidRequestData, sessionID: string): INullResponseData
public endOfflineRaid(
url: string,
info: IEndOfflineRaidRequestData,
sessionID: string,
): INullResponseData
{
this.matchController.endOfflineRaid(info, sessionID);
return this.httpResponse.nullResponse();

View File

@ -11,17 +11,16 @@ import { TraderHelper } from "@spt/helpers/TraderHelper";
import { ILocationBase } from "@spt/models/eft/common/ILocationBase";
import { IPmcData } from "@spt/models/eft/common/IPmcData";
import { BodyPartHealth } from "@spt/models/eft/common/tables/IBotBase";
import { Item } from "@spt/models/eft/common/tables/IItem";
import { IRegisterPlayerRequestData } from "@spt/models/eft/inRaid/IRegisterPlayerRequestData";
import { ISaveProgressRequestData } from "@spt/models/eft/inRaid/ISaveProgressRequestData";
import { ConfigTypes } from "@spt/models/enums/ConfigTypes";
import { ItemTpl } from "@spt/models/enums/ItemTpl";
import { MessageType } from "@spt/models/enums/MessageType";
import { PlayerRaidEndState } from "@spt/models/enums/PlayerRaidEndState";
import { QuestStatus } from "@spt/models/enums/QuestStatus";
import { SkillTypes } from "@spt/models/enums/SkillTypes";
import { Traders } from "@spt/models/enums/Traders";
import { IAirdropConfig } from "@spt/models/spt/config/IAirdropConfig";
import { IBotConfig } from "@spt/models/spt/config/IBotConfig";
import { IBTRConfig } from "@spt/models/spt/config/IBTRConfig";
import { IHideoutConfig } from "@spt/models/spt/config/IHideoutConfig";
import { IInRaidConfig } from "@spt/models/spt/config/IInRaidConfig";
@ -41,7 +40,6 @@ import { PmcChatResponseService } from "@spt/services/PmcChatResponseService";
import { TraderServicesService } from "@spt/services/TraderServicesService";
import { RandomUtil } from "@spt/utils/RandomUtil";
import { TimeUtil } from "@spt/utils/TimeUtil";
import { IBotConfig } from "@spt/models/spt/config/IBotConfig";
/**
* Logic for handling In Raid callbacks
@ -662,40 +660,6 @@ export class InraidController
return this.traderServicesService.getTraderServices(sessionId, traderId);
}
/**
* Handle singleplayer/traderServices/itemDelivery
*/
public itemDelivery(sessionId: string, traderId: string, items: Item[]): void
{
const serverProfile = this.saveServer.getProfile(sessionId);
const pmcData = serverProfile.characters.pmc;
const dialogueTemplates = this.databaseService.getTrader(traderId).dialogue;
if (!dialogueTemplates)
{
this.logger.error(this.localisationService.getText("inraid-unable_to_deliver_item_no_trader_found", traderId));
return;
}
const messageId = this.randomUtil.getArrayValue(dialogueTemplates.itemsDelivered);
const messageStoreTime = this.timeUtil.getHoursAsSeconds(this.traderConfig.fence.btrDeliveryExpireHours);
// Remove any items that were returned by the item delivery, but also insured, from the player's insurance list
// This is to stop items being duplicated by being returned from both the item delivery, and insurance
const deliveredItemIds = items.map((x) => x._id);
pmcData.InsuredItems = pmcData.InsuredItems.filter((x) => !deliveredItemIds.includes(x.itemId));
// Send the items to the player
this.mailSendService.sendLocalisedNpcMessageToPlayer(
sessionId,
this.traderHelper.getTraderById(traderId),
MessageType.BTR_ITEMS_DELIVERY,
messageId,
items,
messageStoreTime,
);
}
public getTraitorScavHostileChance(url: string, sessionID: string): number
{
return this.inRaidConfig.playerScavHostileChancePercent;

View File

@ -35,6 +35,7 @@ import { SaveServer } from "@spt/servers/SaveServer";
import { BotGenerationCacheService } from "@spt/services/BotGenerationCacheService";
import { BotLootCacheService } from "@spt/services/BotLootCacheService";
import { DatabaseService } from "@spt/services/DatabaseService";
import { LocalisationService } from "@spt/services/LocalisationService";
import { MailSendService } from "@spt/services/MailSendService";
import { MatchBotDetailsCacheService } from "@spt/services/MatchBotDetailsCacheService";
import { MatchLocationService } from "@spt/services/MatchLocationService";
@ -71,6 +72,7 @@ export class MatchController
@inject("PmcChatResponseService") protected pmcChatResponseService: PmcChatResponseService,
@inject("TraderHelper") protected traderHelper: TraderHelper,
@inject("BotLootCacheService") protected botLootCacheService: BotLootCacheService,
@inject("LocalisationService") protected localisationService: LocalisationService,
@inject("ConfigServer") protected configServer: ConfigServer,
@inject("ProfileSnapshotService") protected profileSnapshotService: ProfileSnapshotService,
@inject("BotGenerationCacheService") protected botGenerationCacheService: BotGenerationCacheService,
@ -472,6 +474,50 @@ export class MatchController
// Player killed PMCs, send some responses to them
this.pmcChatResponseService.sendVictimResponse(sessionId, victims, pmcProfile);
}
// Handle items transferred via BTR to player
const btrKey = "BTRTransferStash";
const btrContainerAndItems = request.transferItems[btrKey] ?? [];
if (btrContainerAndItems.length > 0)
{
const itemsToSend = btrContainerAndItems.filter((item) => item._id !== btrKey);
this.btrItemDelivery(sessionId, Traders.BTR, itemsToSend);
}
}
/**
* Handle singleplayer/traderServices/itemDelivery
*/
protected btrItemDelivery(sessionId: string, traderId: string, items: Item[]): void
{
const serverProfile = this.saveServer.getProfile(sessionId);
const pmcData = serverProfile.characters.pmc;
const dialogueTemplates = this.databaseService.getTrader(traderId).dialogue;
if (!dialogueTemplates)
{
this.logger.error(this.localisationService.getText("inraid-unable_to_deliver_item_no_trader_found", traderId));
return;
}
const messageId = this.randomUtil.getArrayValue(dialogueTemplates.itemsDelivered);
const messageStoreTime = this.timeUtil.getHoursAsSeconds(this.traderConfig.fence.btrDeliveryExpireHours);
// Remove any items that were returned by the item delivery, but also insured, from the player's insurance list
// This is to stop items being duplicated by being returned from both item delivery and insurance
const deliveredItemIds = items.map((item) => item._id);
pmcData.InsuredItems = pmcData.InsuredItems
.filter((insuredItem) => !deliveredItemIds.includes(insuredItem.itemId));
// Send the items to the player
this.mailSendService.sendLocalisedNpcMessageToPlayer(
sessionId,
this.traderHelper.getTraderById(traderId),
MessageType.BTR_ITEMS_DELIVERY,
messageId,
items,
messageStoreTime,
);
}
/**

View File

@ -4,9 +4,12 @@ import { Item } from "../common/tables/IItem";
export interface IEndLocalRaidRequestData
{
/** ID of server player just left */
serverId: string
results: IEndRaidResult
/** Insured items left in raid by player */
lostInsuredItems: Item[]
/** Items sent via traders to player, keyed to service e.g. BTRTransferStash */
transferItems: Record<string, Item[]>
}

View File

@ -44,13 +44,6 @@ export class InraidStaticRouter extends StaticRouter
return this.inraidCallbacks.getBTRConfig();
},
),
new RouteAction(
"/singleplayer/traderServices/itemDelivery",
async (url: string, info: any, sessionID: string, output: string): Promise<INullResponseData> =>
{
return this.inraidCallbacks.itemDelivery(url, info, sessionID);
},
),
new RouteAction(
"/singleplayer/scav/traitorscavhostile",
async (url: string, info: any, sessionID: string, output: string): Promise<string> =>