From 0ac8fbfe8ea269210a59618c857b1200196ef8dd Mon Sep 17 00:00:00 2001 From: Dev Date: Sat, 6 Jul 2024 09:41:40 +0100 Subject: [PATCH] Regenerated pscav data on raid end Moved pmc code into own function --- project/src/controllers/MatchController.ts | 43 ++++++++++++++++++---- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/project/src/controllers/MatchController.ts b/project/src/controllers/MatchController.ts index bcf9d813..09b9f3be 100644 --- a/project/src/controllers/MatchController.ts +++ b/project/src/controllers/MatchController.ts @@ -4,6 +4,7 @@ import { ContextVariableType } from "@spt/context/ContextVariableType"; import { InraidController } from "@spt/controllers/InraidController"; import { LocationController } from "@spt/controllers/LocationController"; import { LootGenerator } from "@spt/generators/LootGenerator"; +import { PlayerScavGenerator } from "@spt/generators/PlayerScavGenerator"; import { HealthHelper } from "@spt/helpers/HealthHelper"; import { InRaidHelper } from "@spt/helpers/InRaidHelper"; import { ProfileHelper } from "@spt/helpers/ProfileHelper"; @@ -71,6 +72,7 @@ export class MatchController @inject("MatchLocationService") protected matchLocationService: MatchLocationService, @inject("MatchBotDetailsCacheService") protected matchBotDetailsCacheService: MatchBotDetailsCacheService, @inject("PmcChatResponseService") protected pmcChatResponseService: PmcChatResponseService, + @inject("PlayerScavGenerator") protected playerScavGenerator: PlayerScavGenerator, @inject("TraderHelper") protected traderHelper: TraderHelper, @inject("BotLootCacheService") protected botLootCacheService: BotLootCacheService, @inject("LocalisationService") protected localisationService: LocalisationService, @@ -419,16 +421,48 @@ export class MatchController const locationName = serverDetails[0].toLowerCase(); const isPmc = serverDetails[1].toLowerCase() === "pmc"; - const map = this.databaseService.getLocation(locationName).base; + const mapBase = this.databaseService.getLocation(locationName).base; const isDead = this.isPlayerDead(request.results); if (!isPmc) { - this.handlePostRaidPlayerScav(); + this.handlePostRaidPlayerScav(sessionId, pmcProfile, scavProfile, isDead); return; } + this.handlePostRaidPmc(sessionId, pmcProfile, scavProfile, postRaidProfile, isDead, request); + } + + protected handlePostRaidPlayerScav( + sessionId: string, + pmcProfile: IPmcData, + scavProfile: IPmcData, + isDead: boolean, + ): void + { + // Scav died, regen scav loadout and set timer + if (isDead) + { + this.playerScavGenerator.generate(sessionId); + } + + // Update last played property + pmcProfile.Info.LastTimePlayedAsSavage = this.timeUtil.getTimestamp(); + + // Force a profile save + this.saveServer.saveProfile(sessionId); + } + + protected handlePostRaidPmc( + sessionId: string, + pmcProfile: IPmcData, + scavProfile: IPmcData, + postRaidProfile: IPmcData, + isDead: boolean, + request: IEndLocalRaidRequestData, + ): void + { // Update inventory this.inRaidHelper.setInventory(sessionId, pmcProfile, postRaidProfile); @@ -511,11 +545,6 @@ export class MatchController } } - protected handlePostRaidPlayerScav(): void - { - // TODO - } - /** * Handle singleplayer/traderServices/itemDelivery */