Extracted 2 functions from generateBotsFirstTime() to allow easier overriding for mod authors

This commit is contained in:
Dev 2024-05-14 11:23:02 +01:00
parent 512054d29f
commit 81c7b8751b

View File

@ -25,6 +25,7 @@ import { MatchBotDetailsCacheService } from "@spt-aki/services/MatchBotDetailsCa
import { SeasonalEventService } from "@spt-aki/services/SeasonalEventService"; import { SeasonalEventService } from "@spt-aki/services/SeasonalEventService";
import { ICloner } from "@spt-aki/utils/cloners/ICloner"; import { ICloner } from "@spt-aki/utils/cloners/ICloner";
import { RandomUtil } from "@spt-aki/utils/RandomUtil"; import { RandomUtil } from "@spt-aki/utils/RandomUtil";
import { MinMax } from "@spt-aki/models/common/MinMax";
@injectable() @injectable()
export class BotController export class BotController
@ -219,20 +220,12 @@ export class BotController
const conditionPromises: Promise<void>[] = []; const conditionPromises: Promise<void>[] = [];
for (const condition of request.conditions) for (const condition of request.conditions)
{ {
const botGenerationDetails: BotGenerationDetails = { const botGenerationDetails = this.getBotGenerationDetailsForWave(
isPmc: false, condition,
side: "Savage", pmcProfile,
role: condition.Role, allPmcsHaveSameNameAsPlayer,
playerLevel: pmcProfile.Info.Level, pmcLevelRangeForMap,
playerName: pmcProfile.Info.Nickname, false);
botRelativeLevelDeltaMax: this.pmcConfig.botRelativeLevelDeltaMax,
botRelativeLevelDeltaMin: this.pmcConfig.botRelativeLevelDeltaMin,
botCountToGenerate: this.botConfig.presetBatch[condition.Role],
botDifficulty: condition.Difficulty,
locationSpecificPmcLevelOverride: pmcLevelRangeForMap,
isPlayerScav: false,
allPmcsHaveSameNameAsPlayer: allPmcsHaveSameNameAsPlayer,
};
conditionPromises.push(this.generateWithBotDetails(condition, botGenerationDetails, sessionId)); conditionPromises.push(this.generateWithBotDetails(condition, botGenerationDetails, sessionId));
} }
@ -242,6 +235,35 @@ export class BotController
return []; 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 * Generate many bots and store then on the cache
* @param condition the condition details to generate the bots with * @param condition the condition details to generate the bots with