Added system to set min level for PMCs spawned on sandbox_high to 20
This commit is contained in:
parent
a63f1c3890
commit
297e35a1ff
@ -17,6 +17,7 @@ import { WildSpawnTypeNumber } from "@spt-aki/models/enums/WildSpawnTypeNumber";
|
|||||||
import { BotGenerationDetails } from "@spt-aki/models/spt/bots/BotGenerationDetails";
|
import { BotGenerationDetails } from "@spt-aki/models/spt/bots/BotGenerationDetails";
|
||||||
import { IBotConfig } from "@spt-aki/models/spt/config/IBotConfig";
|
import { IBotConfig } from "@spt-aki/models/spt/config/IBotConfig";
|
||||||
import { IPmcConfig } from "@spt-aki/models/spt/config/IPmcConfig";
|
import { IPmcConfig } from "@spt-aki/models/spt/config/IPmcConfig";
|
||||||
|
import { IRaidChanges } from "@spt-aki/models/spt/location/IRaidChanges";
|
||||||
import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
|
import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
|
||||||
import { ConfigServer } from "@spt-aki/servers/ConfigServer";
|
import { ConfigServer } from "@spt-aki/servers/ConfigServer";
|
||||||
import { DatabaseServer } from "@spt-aki/servers/DatabaseServer";
|
import { DatabaseServer } from "@spt-aki/servers/DatabaseServer";
|
||||||
@ -208,6 +209,12 @@ export class BotController
|
|||||||
// Clear bot cache before any work starts
|
// Clear bot cache before any work starts
|
||||||
this.botGenerationCacheService.clearStoredBots();
|
this.botGenerationCacheService.clearStoredBots();
|
||||||
|
|
||||||
|
const minimumPmcLevel = this.getMinimumPmcLevelForRaid(
|
||||||
|
this.applicationContext.getLatestValue(ContextVariableType.RAID_CONFIGURATION)?.getValue<
|
||||||
|
IGetRaidConfigurationRequestData
|
||||||
|
>(),
|
||||||
|
);
|
||||||
|
|
||||||
const allPmcsHaveSameNameAsPlayer = this.randomUtil.getChance100(
|
const allPmcsHaveSameNameAsPlayer = this.randomUtil.getChance100(
|
||||||
this.pmcConfig.allPMCsHavePlayerNameWithRandomPrefixChance,
|
this.pmcConfig.allPMCsHavePlayerNameWithRandomPrefixChance,
|
||||||
);
|
);
|
||||||
@ -224,6 +231,7 @@ export class BotController
|
|||||||
botRelativeLevelDeltaMin: this.pmcConfig.botRelativeLevelDeltaMin,
|
botRelativeLevelDeltaMin: this.pmcConfig.botRelativeLevelDeltaMin,
|
||||||
botCountToGenerate: this.botConfig.presetBatch[condition.Role],
|
botCountToGenerate: this.botConfig.presetBatch[condition.Role],
|
||||||
botDifficulty: condition.Difficulty,
|
botDifficulty: condition.Difficulty,
|
||||||
|
minimumPmcLevel: minimumPmcLevel,
|
||||||
isPlayerScav: false,
|
isPlayerScav: false,
|
||||||
allPmcsHaveSameNameAsPlayer: allPmcsHaveSameNameAsPlayer,
|
allPmcsHaveSameNameAsPlayer: allPmcsHaveSameNameAsPlayer,
|
||||||
};
|
};
|
||||||
@ -236,6 +244,21 @@ export class BotController
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the lowest level a bot can be generated with
|
||||||
|
* @param raidConfig IGetRaidConfigurationRequestData from applicationContext.getLatestValue(ContextVariableType.RAID_CONFIGURATION)
|
||||||
|
* @returns Number
|
||||||
|
*/
|
||||||
|
protected getMinimumPmcLevelForRaid(raidConfig: IGetRaidConfigurationRequestData): number
|
||||||
|
{
|
||||||
|
if (raidConfig?.location.toLowerCase() === "sandbox_high")
|
||||||
|
{
|
||||||
|
return 20;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
||||||
@ -315,6 +338,12 @@ export class BotController
|
|||||||
const pmcProfile = this.profileHelper.getPmcProfile(sessionId);
|
const pmcProfile = this.profileHelper.getPmcProfile(sessionId);
|
||||||
const requestedBot = request.conditions[0];
|
const requestedBot = request.conditions[0];
|
||||||
|
|
||||||
|
const minimumPmcLevel = this.getMinimumPmcLevelForRaid(
|
||||||
|
this.applicationContext.getLatestValue(ContextVariableType.RAID_CONFIGURATION)?.getValue<
|
||||||
|
IGetRaidConfigurationRequestData
|
||||||
|
>(),
|
||||||
|
);
|
||||||
|
|
||||||
// Create gen request for when cache is empty
|
// Create gen request for when cache is empty
|
||||||
const botGenerationDetails: BotGenerationDetails = {
|
const botGenerationDetails: BotGenerationDetails = {
|
||||||
isPmc: false,
|
isPmc: false,
|
||||||
@ -326,6 +355,7 @@ export class BotController
|
|||||||
botRelativeLevelDeltaMin: this.pmcConfig.botRelativeLevelDeltaMin,
|
botRelativeLevelDeltaMin: this.pmcConfig.botRelativeLevelDeltaMin,
|
||||||
botCountToGenerate: this.botConfig.presetBatch[requestedBot.Role],
|
botCountToGenerate: this.botConfig.presetBatch[requestedBot.Role],
|
||||||
botDifficulty: requestedBot.Difficulty,
|
botDifficulty: requestedBot.Difficulty,
|
||||||
|
minimumPmcLevel: minimumPmcLevel,
|
||||||
isPlayerScav: false,
|
isPlayerScav: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -86,6 +86,7 @@ export class BotGenerator
|
|||||||
botRelativeLevelDeltaMin: 0,
|
botRelativeLevelDeltaMin: 0,
|
||||||
botCountToGenerate: 1,
|
botCountToGenerate: 1,
|
||||||
botDifficulty: difficulty,
|
botDifficulty: difficulty,
|
||||||
|
minimumPmcLevel: 1, // unused here
|
||||||
isPlayerScav: true,
|
isPlayerScav: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -21,9 +21,9 @@ export class BotLevelGenerator
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a randomised bot level and exp value
|
* Return a randomised bot level and exp value
|
||||||
* @param levelDetails min and max of level for bot
|
* @param levelDetails Min and max of level for bot
|
||||||
* @param botGenerationDetails Deatils to help generate a bot
|
* @param botGenerationDetails Deatils to help generate a bot
|
||||||
* @param bot being level is being generated for
|
* @param bot Bot the level is being generated for
|
||||||
* @returns IRandomisedBotLevelResult object
|
* @returns IRandomisedBotLevelResult object
|
||||||
*/
|
*/
|
||||||
public generateBotLevel(
|
public generateBotLevel(
|
||||||
@ -39,12 +39,7 @@ export class BotLevelGenerator
|
|||||||
levelDetails,
|
levelDetails,
|
||||||
expTable,
|
expTable,
|
||||||
);
|
);
|
||||||
const lowestLevel = this.getLowestRelativeBotLevel(
|
const lowestLevel = this.getLowestRelativeBotLevel(botGenerationDetails, levelDetails, expTable);
|
||||||
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;
|
||||||
@ -93,19 +88,30 @@ export class BotLevelGenerator
|
|||||||
* Get the lowest level a bot can be relative to the players level, but no lower than 1
|
* Get the lowest level a bot can be relative to the players level, but no lower than 1
|
||||||
* @param playerLevel Players current level
|
* @param playerLevel Players current level
|
||||||
* @param relativeDeltaMin Min delta below player level to go
|
* @param relativeDeltaMin Min delta below player level to go
|
||||||
|
* @param expTable exp table to calculate level
|
||||||
* @returns lowest level possible for bot
|
* @returns lowest level possible for bot
|
||||||
*/
|
*/
|
||||||
protected getLowestRelativeBotLevel(
|
protected getLowestRelativeBotLevel(
|
||||||
playerLevel: number,
|
botGenerationDetails: BotGenerationDetails,
|
||||||
relativeDeltaMin: number,
|
|
||||||
levelDetails: MinMax,
|
levelDetails: MinMax,
|
||||||
expTable: IExpTable[],
|
expTable: IExpTable[],
|
||||||
): number
|
): number
|
||||||
|
{
|
||||||
|
let minPossibleLevel: number;
|
||||||
|
if (botGenerationDetails.isPmc)
|
||||||
|
{
|
||||||
|
minPossibleLevel = Math.min(
|
||||||
|
Math.max(levelDetails.min, botGenerationDetails.minimumPmcLevel),
|
||||||
|
expTable.length,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
// Some bots have a max level of 1
|
// Some bots have a max level of 1
|
||||||
const minPossibleLevel = Math.min(levelDetails.min, expTable.length);
|
minPossibleLevel = Math.min(levelDetails.min, expTable.length);
|
||||||
|
}
|
||||||
|
|
||||||
let level = playerLevel - relativeDeltaMin;
|
let level = botGenerationDetails.playerLevel - botGenerationDetails.botRelativeLevelDeltaMin;
|
||||||
if (level < minPossibleLevel)
|
if (level < minPossibleLevel)
|
||||||
{
|
{
|
||||||
level = minPossibleLevel;
|
level = minPossibleLevel;
|
||||||
|
@ -9,6 +9,8 @@ export interface BotGenerationDetails
|
|||||||
/** Active players current level */
|
/** Active players current level */
|
||||||
playerLevel?: number;
|
playerLevel?: number;
|
||||||
playerName?: string;
|
playerName?: string;
|
||||||
|
/** Lowest level a PMC can be generated with */
|
||||||
|
minimumPmcLevel: number;
|
||||||
/** Delta of highest level of bot e.g. 50 means 50 levels above player */
|
/** 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 */
|
/** Delta of lowest level of bot e.g. 50 means 50 levels below player */
|
||||||
|
Loading…
Reference in New Issue
Block a user