From 81c7b8751bf93829ff3f186dcd1abd323d9104b8 Mon Sep 17 00:00:00 2001 From: Dev Date: Tue, 14 May 2024 11:23:02 +0100 Subject: [PATCH] Extracted 2 functions from `generateBotsFirstTime()` to allow easier overriding for mod authors --- project/src/controllers/BotController.ts | 50 +++++++++++++++++------- 1 file changed, 36 insertions(+), 14 deletions(-) diff --git a/project/src/controllers/BotController.ts b/project/src/controllers/BotController.ts index bc15b3fc..3d7b3210 100644 --- a/project/src/controllers/BotController.ts +++ b/project/src/controllers/BotController.ts @@ -25,6 +25,7 @@ import { MatchBotDetailsCacheService } from "@spt-aki/services/MatchBotDetailsCa import { SeasonalEventService } from "@spt-aki/services/SeasonalEventService"; import { ICloner } from "@spt-aki/utils/cloners/ICloner"; import { RandomUtil } from "@spt-aki/utils/RandomUtil"; +import { MinMax } from "@spt-aki/models/common/MinMax"; @injectable() export class BotController @@ -219,20 +220,12 @@ export class BotController const conditionPromises: Promise[] = []; for (const condition of request.conditions) { - const botGenerationDetails: BotGenerationDetails = { - isPmc: false, - side: "Savage", - role: condition.Role, - playerLevel: pmcProfile.Info.Level, - playerName: pmcProfile.Info.Nickname, - botRelativeLevelDeltaMax: this.pmcConfig.botRelativeLevelDeltaMax, - botRelativeLevelDeltaMin: this.pmcConfig.botRelativeLevelDeltaMin, - botCountToGenerate: this.botConfig.presetBatch[condition.Role], - botDifficulty: condition.Difficulty, - locationSpecificPmcLevelOverride: pmcLevelRangeForMap, - isPlayerScav: false, - allPmcsHaveSameNameAsPlayer: allPmcsHaveSameNameAsPlayer, - }; + const botGenerationDetails = this.getBotGenerationDetailsForWave( + condition, + pmcProfile, + allPmcsHaveSameNameAsPlayer, + pmcLevelRangeForMap, + false); conditionPromises.push(this.generateWithBotDetails(condition, botGenerationDetails, sessionId)); } @@ -242,6 +235,35 @@ export class BotController return []; } + protected getBotGenerationDetailsForWave( + condition: Condition, + pmcProfile: IPmcData, + allPmcsHaveSameNameAsPlayer: boolean, + pmcLevelRangeForMap: MinMax, + generateAsPmc: boolean): BotGenerationDetails + + { + return { + isPmc: generateAsPmc, + side: "Savage", + role: condition.Role, + playerLevel: this.getPlayerLevelFromProfile(pmcProfile), + playerName: pmcProfile.Info.Nickname, + botRelativeLevelDeltaMax: this.pmcConfig.botRelativeLevelDeltaMax, + botRelativeLevelDeltaMin: this.pmcConfig.botRelativeLevelDeltaMin, + botCountToGenerate: this.botConfig.presetBatch[condition.Role], + botDifficulty: condition.Difficulty, + locationSpecificPmcLevelOverride: pmcLevelRangeForMap, + isPlayerScav: false, + allPmcsHaveSameNameAsPlayer: allPmcsHaveSameNameAsPlayer, + }; + } + + protected getPlayerLevelFromProfile(pmcProfile: IPmcData): number + { + return pmcProfile.Info.Level; + } + /** * Generate many bots and store then on the cache * @param condition the condition details to generate the bots with