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,11 +220,34 @@ 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,
pmcProfile,
allPmcsHaveSameNameAsPlayer,
pmcLevelRangeForMap,
false);
conditionPromises.push(this.generateWithBotDetails(condition, botGenerationDetails, sessionId));
}
await Promise.all(conditionPromises).then(p => Promise.all(p));
return [];
}
protected getBotGenerationDetailsForWave(
condition: Condition,
pmcProfile: IPmcData,
allPmcsHaveSameNameAsPlayer: boolean,
pmcLevelRangeForMap: MinMax,
generateAsPmc: boolean): BotGenerationDetails
{
return {
isPmc: generateAsPmc,
side: "Savage", side: "Savage",
role: condition.Role, role: condition.Role,
playerLevel: pmcProfile.Info.Level, playerLevel: this.getPlayerLevelFromProfile(pmcProfile),
playerName: pmcProfile.Info.Nickname, playerName: pmcProfile.Info.Nickname,
botRelativeLevelDeltaMax: this.pmcConfig.botRelativeLevelDeltaMax, botRelativeLevelDeltaMax: this.pmcConfig.botRelativeLevelDeltaMax,
botRelativeLevelDeltaMin: this.pmcConfig.botRelativeLevelDeltaMin, botRelativeLevelDeltaMin: this.pmcConfig.botRelativeLevelDeltaMin,
@ -233,13 +257,11 @@ export class BotController
isPlayerScav: false, isPlayerScav: false,
allPmcsHaveSameNameAsPlayer: allPmcsHaveSameNameAsPlayer, allPmcsHaveSameNameAsPlayer: allPmcsHaveSameNameAsPlayer,
}; };
conditionPromises.push(this.generateWithBotDetails(condition, botGenerationDetails, sessionId));
} }
await Promise.all(conditionPromises).then(p => Promise.all(p)); protected getPlayerLevelFromProfile(pmcProfile: IPmcData): number
{
return []; return pmcProfile.Info.Level;
} }
/** /**