0
0
mirror of https://github.com/sp-tarkov/server.git synced 2025-02-13 02:30:43 -05:00

Added a weighting bias to the level chosen for bots, favors the higher value

This commit is contained in:
Dev 2024-07-25 10:34:54 +01:00
parent adcd0194bf
commit 797d75fd4f
2 changed files with 8 additions and 2 deletions

View File

@ -183,6 +183,7 @@ export class BotEquipmentModGenerator {
continue;
}
// Get chosen mods db template and check it fits into slot
const modTemplate = this.itemHelper.getItem(modTpl);
if (!this.isModValidForSlot(modTemplate, itemSlotTemplate, modSlotName, parentTemplate, settings.botRole)) {
continue;

View File

@ -4,6 +4,7 @@ import { IBotBase } from "@spt/models/eft/common/tables/IBotBase";
import { BotGenerationDetails } from "@spt/models/spt/bots/BotGenerationDetails";
import { ILogger } from "@spt/models/spt/utils/ILogger";
import { DatabaseService } from "@spt/services/DatabaseService";
import { MathUtil } from "@spt/utils/MathUtil";
import { RandomUtil } from "@spt/utils/RandomUtil";
import { inject, injectable } from "tsyringe";
@ -13,6 +14,7 @@ export class BotLevelGenerator {
@inject("PrimaryLogger") protected logger: ILogger,
@inject("RandomUtil") protected randomUtil: RandomUtil,
@inject("DatabaseService") protected databaseService: DatabaseService,
@inject("MathUtil") protected mathUtil: MathUtil,
) {}
/**
@ -33,8 +35,7 @@ export class BotLevelGenerator {
// Get random level based on the exp table.
let exp = 0;
const level = this.randomUtil.getInt(lowestLevel, highestLevel);
const level = this.chooseBotLevel(lowestLevel, highestLevel, 1, 1.15);
for (let i = 0; i < level; i++) {
exp += expTable[i].exp;
}
@ -47,6 +48,10 @@ export class BotLevelGenerator {
return { level, exp };
}
protected chooseBotLevel(min: number, max: number, shift: number, number: number): number {
return this.randomUtil.getBiasedRandomNumber(min, max, shift, number);
}
/**
* 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 botGenerationDetails Details to help generate a bot