Add botRelativeLevelDeltaMin to pmc.json to allow configuration of lowest level of pmc relative to player

This commit is contained in:
Dev 2024-01-06 15:19:04 +00:00
parent d1b17ad1ea
commit 52a5380c33
6 changed files with 40 additions and 2 deletions

View File

@ -173,6 +173,7 @@
"useDifficultyOverride": false, "useDifficultyOverride": false,
"difficulty": "AsOnline", "difficulty": "AsOnline",
"botRelativeLevelDeltaMax": 10, "botRelativeLevelDeltaMax": 10,
"botRelativeLevelDeltaMin": 70,
"_isUsec": "Percentage chance PMC will be USEC", "_isUsec": "Percentage chance PMC will be USEC",
"isUsec": 50, "isUsec": 50,
"chanceSameSideIsHostilePercent": 80, "chanceSameSideIsHostilePercent": 80,

View File

@ -153,6 +153,7 @@ export class BotController
role: condition.Role, role: condition.Role,
playerLevel: pmcProfile.Info.Level, playerLevel: pmcProfile.Info.Level,
botRelativeLevelDeltaMax: this.pmcConfig.botRelativeLevelDeltaMax, botRelativeLevelDeltaMax: this.pmcConfig.botRelativeLevelDeltaMax,
botRelativeLevelDeltaMin: this.pmcConfig.botRelativeLevelDeltaMin,
botCountToGenerate: this.botConfig.presetBatch[condition.Role], botCountToGenerate: this.botConfig.presetBatch[condition.Role],
botDifficulty: condition.Difficulty, botDifficulty: condition.Difficulty,
isPlayerScav: false, isPlayerScav: false,

View File

@ -83,6 +83,7 @@ export class BotGenerator
role: role, role: role,
playerLevel: 0, playerLevel: 0,
botRelativeLevelDeltaMax: 0, botRelativeLevelDeltaMax: 0,
botRelativeLevelDeltaMin: 0,
botCountToGenerate: 1, botCountToGenerate: 1,
botDifficulty: difficulty, botDifficulty: difficulty,
isPlayerScav: true, isPlayerScav: true,

View File

@ -39,10 +39,15 @@ export class BotLevelGenerator
levelDetails, levelDetails,
expTable, expTable,
); );
const lowestLevel = this.getLowestRelativeBotLevel(
botGenerationDetails.playerLevel,
botGenerationDetails.botRelativeLevelDeltaMin,
levelDetails,
expTable);
// Get random level based on the exp table. // Get random level based on the exp table.
let exp = 0; let exp = 0;
const level = this.randomUtil.getInt(1, highestLevel); const level = this.randomUtil.getInt(lowestLevel, highestLevel);
for (let i = 0; i < level; i++) for (let i = 0; i < level; i++)
{ {
@ -71,6 +76,7 @@ export class BotLevelGenerator
expTable: IExpTable[], expTable: IExpTable[],
): number ): number
{ {
// Some bots have a max level of 1
const maxPossibleLevel = Math.min(levelDetails.max, expTable.length); const maxPossibleLevel = Math.min(levelDetails.max, expTable.length);
let level = playerLevel + relativeDeltaMax; let level = playerLevel + relativeDeltaMax;
@ -81,4 +87,29 @@ export class BotLevelGenerator
return level; return level;
} }
/**
* Get the highest level a bot can be relative to the players level, but no further than the max size from globals.exp_table
* @param playerLevel Players current level
* @param relativeDeltaMax max delta above player level to go
* @returns highest level possible for bot
*/
protected getLowestRelativeBotLevel(
playerLevel: number,
relativeDeltaMin: number,
levelDetails: MinMax,
expTable: IExpTable[],
): number
{
// Some bots have a max level of 1
const minPossibleLevel = Math.min(levelDetails.min, expTable.length);
let level = playerLevel - relativeDeltaMin;
if (level < minPossibleLevel)
{
level = minPossibleLevel;
}
return level;
}
} }

View File

@ -8,8 +8,10 @@ export interface BotGenerationDetails
side: string; side: string;
/** Active players current level */ /** Active players current level */
playerLevel: number; playerLevel: number;
/** Delta of highest level of bot */ /** Delta of highest level of bot e.g. 50 means 50 levels above player */
botRelativeLevelDeltaMax: number; botRelativeLevelDeltaMax: number;
/** Delta of lowest level of bot e.g. 50 means 50 levels below player */
botRelativeLevelDeltaMin: number;
/** How many to create and store */ /** How many to create and store */
botCountToGenerate: number; botCountToGenerate: number;
/** Desired difficulty of the bot */ /** Desired difficulty of the bot */

View File

@ -44,6 +44,8 @@ export interface IPmcConfig extends IBaseConfig
enemyTypes: string[]; enemyTypes: string[];
/** How many levels above player level can a PMC be */ /** How many levels above player level can a PMC be */
botRelativeLevelDeltaMax: number; botRelativeLevelDeltaMax: number;
/** How many levels below player level can a PMC be */
botRelativeLevelDeltaMin: number;
/** Force a number of healing items into PMCs secure container to ensure they can heal */ /** Force a number of healing items into PMCs secure container to ensure they can heal */
forceHealingItemsIntoSecure: boolean; forceHealingItemsIntoSecure: boolean;
addPrefixToSameNamePMCAsPlayerChance: number; addPrefixToSameNamePMCAsPlayerChance: number;