Clenaed up how PMC names are replaced during event

This commit is contained in:
Dev 2024-01-25 22:17:18 +00:00
parent e8ff4c01b3
commit c116adc0b9
5 changed files with 17 additions and 23 deletions

View File

@ -24,6 +24,7 @@ import { LocalisationService } from "@spt-aki/services/LocalisationService";
import { MatchBotDetailsCacheService } from "@spt-aki/services/MatchBotDetailsCacheService";
import { SeasonalEventService } from "@spt-aki/services/SeasonalEventService";
import { JsonUtil } from "@spt-aki/utils/JsonUtil";
import { RandomUtil } from "@spt-aki/utils/RandomUtil";
@injectable()
export class BotController
@ -44,6 +45,7 @@ export class BotController
@inject("ProfileHelper") protected profileHelper: ProfileHelper,
@inject("ConfigServer") protected configServer: ConfigServer,
@inject("ApplicationContext") protected applicationContext: ApplicationContext,
@inject("RandomUtil") protected randomUtil: RandomUtil,
@inject("JsonUtil") protected jsonUtil: JsonUtil,
)
{
@ -171,11 +173,13 @@ export class BotController
side: "Savage",
role: condition.Role,
playerLevel: pmcProfile.Info.Level,
playerName: pmcProfile.Info.Nickname,
botRelativeLevelDeltaMax: this.pmcConfig.botRelativeLevelDeltaMax,
botRelativeLevelDeltaMin: this.pmcConfig.botRelativeLevelDeltaMin,
botCountToGenerate: this.botConfig.presetBatch[condition.Role],
botDifficulty: condition.Difficulty,
isPlayerScav: false,
allPmcsHaveSameNameAsPlayer: this.randomUtil.getChance100(this.pmcConfig.allPMCsHavePlayerNameWithRandomPrefixChance)
};
// Event bots need special actions to occur, set data up for them
@ -240,6 +244,7 @@ export class BotController
side: "Savage",
role: requestedBot.Role,
playerLevel: pmcProfile.Info.Level,
playerName: pmcProfile.Info.Nickname,
botRelativeLevelDeltaMax: this.pmcConfig.botRelativeLevelDeltaMax,
botRelativeLevelDeltaMin: this.pmcConfig.botRelativeLevelDeltaMin,
botCountToGenerate: this.botConfig.presetBatch[requestedBot.Role],

View File

@ -221,16 +221,6 @@ export class GameController
{
this.addPlayerToPMCNames(pmcProfile);
if (this.randomUtil.getChance100(this.pmcConfig.allPMCsHavePlayerNameWithRandomPrefixChance))
{
this.pmcConfig.addPrefixToSameNamePMCAsPlayerChance = 100;
if (pmcProfile?.Info?.Nickname)
{
this.databaseServer.getTables().bots.types.bear.firstName = [pmcProfile.Info.Nickname];
this.databaseServer.getTables().bots.types.usec.firstName = [pmcProfile.Info.Nickname];
}
}
this.checkForAndRemoveUndefinedDialogs(fullProfile);
}

View File

@ -81,7 +81,6 @@ export class BotGenerator
isPmc: false,
side: "Savage",
role: role,
playerLevel: 0,
botRelativeLevelDeltaMax: 0,
botRelativeLevelDeltaMin: 0,
botCountToGenerate: 1,
@ -164,7 +163,7 @@ export class BotGenerator
bot.Info.Nickname = this.generateBotNickname(
botJsonTemplate,
botGenerationDetails.isPlayerScav,
botGenerationDetails,
botRole,
sessionId,
);
@ -247,17 +246,19 @@ export class BotGenerator
/**
* Create a bot nickname
* @param botJsonTemplate x.json from database
* @param isPlayerScav Will bot be player scav
* @param botGenerationDetails
* @param botRole role of bot e.g. assault
* @returns Nickname for bot
*/
protected generateBotNickname(
botJsonTemplate: IBotType,
isPlayerScav: boolean,
botGenerationDetails: BotGenerationDetails,
botRole: string,
sessionId: string,
): string
{
const isPlayerScav = botGenerationDetails.isPlayerScav;
let name = `${this.randomUtil.getArrayValue(botJsonTemplate.firstName)} ${
this.randomUtil.getArrayValue(botJsonTemplate.lastName) || ""
}`;
@ -285,14 +286,11 @@ export class BotGenerator
name += ` ${botRole}`;
}
// If bot name matches current players name, chance to add localised prefix to name
if (name.toLowerCase() === playerProfile.Info.Nickname.toLowerCase())
// We want to replace pmc bot names with player name + prefix
if (botGenerationDetails.isPmc && botGenerationDetails.allPmcsHaveSameNameAsPlayer)
{
if (this.randomUtil.getChance100(this.pmcConfig.addPrefixToSameNamePMCAsPlayerChance))
{
const prefix = this.localisationService.getRandomTextThatMatchesPartialKey("pmc-name_prefix_");
name = `${prefix} ${name}`;
}
const prefix = this.localisationService.getRandomTextThatMatchesPartialKey("pmc-name_prefix_");
name = `${prefix} ${botGenerationDetails.playerName}`;
}
return name;

View File

@ -7,7 +7,8 @@ export interface BotGenerationDetails
/** Side of bot */
side: string;
/** Active players current level */
playerLevel: number;
playerLevel?: number;
playerName?: string;
/** Delta of highest level of bot e.g. 50 means 50 levels above player */
botRelativeLevelDeltaMax: number;
/** Delta of lowest level of bot e.g. 50 means 50 levels below player */
@ -19,4 +20,5 @@ export interface BotGenerationDetails
/** Will the generated bot be a player scav */
isPlayerScav: boolean;
eventRole?: string;
allPmcsHaveSameNameAsPlayer?: boolean;
}

View File

@ -48,7 +48,6 @@ export interface IPmcConfig extends IBaseConfig
botRelativeLevelDeltaMin: number;
/** Force a number of healing items into PMCs secure container to ensure they can heal */
forceHealingItemsIntoSecure: boolean;
addPrefixToSameNamePMCAsPlayerChance: number;
allPMCsHavePlayerNameWithRandomPrefixChance: number;
}