Updated convertIntoPmcChance to work per map

Removed unused `shouldBotBePmc` function
This commit is contained in:
Dev 2024-09-22 13:58:55 +01:00
parent 35fb02c009
commit 6de8740dcc
4 changed files with 72 additions and 54 deletions

View File

@ -744,34 +744,66 @@
"maxPocketLootTotalRub": 50000, "maxPocketLootTotalRub": 50000,
"maxVestLootTotalRub": 50000, "maxVestLootTotalRub": 50000,
"convertIntoPmcChance": { "convertIntoPmcChance": {
"assault": { "default":{
"min": 25, "assault": {
"max": 35 "min": 25,
}, "max": 35
"cursedassault": { },
"min": 15, "cursedassault": {
"max": 30 "min": 15,
}, "max": 30
"pmcbot": { },
"min": 5, "pmcbot": {
"max": 10 "min": 5,
}, "max": 10
"exusec": { },
"min": 5, "exusec": {
"max": 5 "min": 5,
}, "max": 5
"arenafighter": { },
"min": 0, "arenafighter": {
"max": 0 "min": 0,
}, "max": 0
"arenafighterevent": { },
"min": 0, "arenafighterevent": {
"max": 0 "min": 0,
}, "max": 0
"crazyassaultevent": { },
"min": 0, "crazyassaultevent": {
"max": 0 "min": 0,
} "max": 0
}
},
"factory4_day":{
"assault": {
"min": 10,
"max": 15
},
"cursedassault": {
"min": 15,
"max": 30
},
"pmcbot": {
"min": 5,
"max": 10
},
"exusec": {
"min": 5,
"max": 5
},
"arenafighter": {
"min": 0,
"max": 0
},
"arenafighterevent": {
"min": 0,
"max": 0
},
"crazyassaultevent": {
"min": 0,
"max": 0
}
}
}, },
"hostilitySettings": { "hostilitySettings": {
"pmcusec": { "pmcusec": {

View File

@ -394,7 +394,7 @@ export class BotController {
} }
// Roll chance to be pmc if type is allowed to be one // Roll chance to be pmc if type is allowed to be one
const botConvertRateMinMax = this.pmcConfig.convertIntoPmcChance[requestedBot.Role.toLowerCase()]; const botConvertRateMinMax = this.getPmcConversionMinMaxForLocation(requestedBot.Role, raidSettings?.location);
if (botConvertRateMinMax) { if (botConvertRateMinMax) {
// Should bot become PMC // Should bot become PMC
const convertToPmc = this.botHelper.rollChanceToBePmc(requestedBot.Role, botConvertRateMinMax); const convertToPmc = this.botHelper.rollChanceToBePmc(requestedBot.Role, botConvertRateMinMax);
@ -450,6 +450,15 @@ export class BotController {
return [desiredBot]; return [desiredBot];
} }
protected getPmcConversionMinMaxForLocation(requestedBotRole: string, location: string) {
const mapSpecificConversionValues = this.pmcConfig.convertIntoPmcChance[location?.toLowerCase()];
if (!mapSpecificConversionValues) {
return mapSpecificConversionValues.default;
}
return mapSpecificConversionValues[requestedBotRole?.toLowerCase()];
}
protected updateBotGenerationDetailsToRandomBoss( protected updateBotGenerationDetailsToRandomBoss(
botGenerationDetails: BotGenerationDetails, botGenerationDetails: BotGenerationDetails,
possibleBossTypeWeights: Record<string, number>, possibleBossTypeWeights: Record<string, number>,

View File

@ -92,29 +92,6 @@ export class BotHelper {
} }
} }
/**
* Choose if a bot should become a PMC by checking if bot type is allowed to become a Pmc in botConfig.convertFromChances and doing a random int check
* @param botRole the bot role to check if should be a pmc
* @returns true if should be a pmc
*/
public shouldBotBePmc(botRole: string): boolean {
const botRoleLowered = botRole.toLowerCase();
// Handle when map waves have these types in the bot type
if (this.botRoleIsPmc(botRoleLowered)) {
return true;
}
const botConvertMinMax = this.pmcConfig.convertIntoPmcChance[botRoleLowered];
// no bot type defined in config, default to false
if (!botConvertMinMax) {
return false;
}
return this.rollChanceToBePmc(botRoleLowered, botConvertMinMax);
}
public rollChanceToBePmc(role: string, botConvertMinMax: MinMax): boolean { public rollChanceToBePmc(role: string, botConvertMinMax: MinMax): boolean {
return ( return (
role.toLowerCase() in this.pmcConfig.convertIntoPmcChance && role.toLowerCase() in this.pmcConfig.convertIntoPmcChance &&

View File

@ -36,8 +36,8 @@ export interface IPmcConfig extends IBaseConfig {
maxBackpackLootTotalRub: MinMaxLootValue[]; maxBackpackLootTotalRub: MinMaxLootValue[];
maxPocketLootTotalRub: number; maxPocketLootTotalRub: number;
maxVestLootTotalRub: number; maxVestLootTotalRub: number;
/** Percentage chance a bot from a wave is converted into a PMC, key = bot wildspawn tpye (assault/exusec), value: min+max chance to be converted */ /** Percentage chance a bot from a wave is converted into a PMC, first key = map, second key = bot wildspawn type (assault/exusec), value: min+max chance to be converted */
convertIntoPmcChance: Record<string, MinMax>; convertIntoPmcChance: Record<string, Record<string, MinMax>>;
/** 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 */ /** How many levels below player level can a PMC be */