Implement TransitItemsDelivery service via expansion of the BTR item delivery handler (!413)
- Fixes exception thrown when attempting to transfer items during transit - Implements transit item transfer by expanding on the existing BTR item transfer code (They are both BTR services) Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com> Reviewed-on: https://dev.sp-tarkov.com/SPT/Server/pulls/413 Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com> Co-committed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
This commit is contained in:
parent
ca8b61a001
commit
3703698a1a
@ -102,6 +102,16 @@
|
||||
},
|
||||
"ServiceItemCost": [],
|
||||
"UniqueItems": []
|
||||
},
|
||||
"TransitItemsDelivery": {
|
||||
"TraderId": "656f0f98d80a697f855d34b1",
|
||||
"TraderServiceType": "TransitItemsDelivery",
|
||||
"Requirements": {
|
||||
"CompletedQuests": [],
|
||||
"Standings": []
|
||||
},
|
||||
"ServiceItemCost": [],
|
||||
"UniqueItems": []
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -7,5 +7,8 @@
|
||||
},
|
||||
{
|
||||
"serviceType": "BtrBotCover"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"serviceType": "TransitItemsDelivery"
|
||||
}
|
||||
]
|
||||
|
@ -5,4 +5,5 @@ export enum TraderServiceType {
|
||||
BTR_ITEMS_DELIVERY = "BtrItemsDelivery",
|
||||
PLAYER_TAXI = "PlayerTaxi",
|
||||
BTR_BOT_COVER = "BtrBotCover",
|
||||
TRANSIT_ITEMS_DELIVERY = "TransitItemsDelivery",
|
||||
}
|
||||
|
@ -311,10 +311,8 @@ export class LocationLifecycleService {
|
||||
const isDead = this.isPlayerDead(request.results);
|
||||
const isSurvived = this.isPlayerSurvived(request.results);
|
||||
|
||||
// Handle items transferred via BTR to player
|
||||
this.handleBTRItemTransferEvent(sessionId, request);
|
||||
|
||||
this.handleTransitItemTransferEvent(sessionId, request);
|
||||
// Handle items transferred via BTR or transit to player
|
||||
this.handleItemTransferEvent(sessionId, request);
|
||||
|
||||
if (!isPmc) {
|
||||
this.handlePostRaidPlayerScav(sessionId, pmcProfile, scavProfile, isDead, request);
|
||||
@ -688,23 +686,28 @@ export class LocationLifecycleService {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if player used BTR item sending service and send items to player via mail if found
|
||||
* Check if player used BTR or transit item sending service and send items to player via mail if found
|
||||
* @param sessionId Session id
|
||||
* @param request End raid request
|
||||
*/
|
||||
protected handleBTRItemTransferEvent(sessionId: string, request: IEndLocalRaidRequestData): void {
|
||||
const btrId = `${Traders.BTR}_btr`;
|
||||
let itemsToSend = request.transferItems[btrId] ?? [];
|
||||
if (itemsToSend.length === 0) {
|
||||
return;
|
||||
}
|
||||
protected handleItemTransferEvent(sessionId: string, request: IEndLocalRaidRequestData): void {
|
||||
const transferTypes = ["btr", "transit"];
|
||||
|
||||
// Filter out the btr container item from transferred items before delivering
|
||||
itemsToSend = itemsToSend.filter((item) => item._id !== btrId);
|
||||
this.btrItemDelivery(sessionId, Traders.BTR, itemsToSend);
|
||||
for (const trasferType of transferTypes) {
|
||||
const rootId = `${Traders.BTR}_${trasferType}`;
|
||||
let itemsToSend = request.transferItems[rootId] ?? [];
|
||||
|
||||
// Filter out the btr container item from transferred items before delivering
|
||||
itemsToSend = itemsToSend.filter((item) => item._id !== Traders.BTR);
|
||||
if (itemsToSend.length === 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
this.transferItemDelivery(sessionId, Traders.BTR, itemsToSend);
|
||||
}
|
||||
}
|
||||
|
||||
protected btrItemDelivery(sessionId: string, traderId: string, items: IItem[]): void {
|
||||
protected transferItemDelivery(sessionId: string, traderId: string, items: IItem[]): void {
|
||||
const serverProfile = this.saveServer.getProfile(sessionId);
|
||||
const pmcData = serverProfile.characters.pmc;
|
||||
|
||||
@ -737,18 +740,6 @@ export class LocationLifecycleService {
|
||||
);
|
||||
}
|
||||
|
||||
protected handleTransitItemTransferEvent(sessionId: string, request: IEndLocalRaidRequestData) {
|
||||
const id = "TODO_DUMP";
|
||||
const transitRootId = `${id}_transit`;
|
||||
const itemsToSend = request.transferItems[transitRootId] ?? [];
|
||||
if (itemsToSend.length === 0) {
|
||||
this.logger.error("NOT IMPLEMENTED");
|
||||
return;
|
||||
}
|
||||
|
||||
this.logger.error("NOT IMPLEMENTED");
|
||||
}
|
||||
|
||||
protected handleInsuredItemLostEvent(
|
||||
sessionId: string,
|
||||
preRaidPmcProfile: IPmcData,
|
||||
|
Loading…
x
Reference in New Issue
Block a user