mirror of
https://github.com/sp-tarkov/server.git
synced 2025-02-12 15:50:42 -05:00
Improved simulation of AI player scavs, their 'pmc' name + game edtion is correctly passed to client
Pulled pscav code out of `generateUniqueBotNickname` and into its own function `simulatePlayerScavName`
This commit is contained in:
parent
e04fa4d8fe
commit
30d620d346
@ -193,6 +193,12 @@ export class BotGenerator {
|
|||||||
this.botConfig.botRolesThatMustHaveUniqueName,
|
this.botConfig.botRolesThatMustHaveUniqueName,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Only run when generating a 'fake' playerscav, not actual player scav
|
||||||
|
if (!botGenerationDetails.isPlayerScav || this.shouldSimulatePlayerScav(botRoleLowercase)) {
|
||||||
|
this.botNameService.addRandomPmcNameToBotMainProfileNicknameProperty(bot);
|
||||||
|
this.setRandomisedGameVersionAndCategory(bot.Info);
|
||||||
|
}
|
||||||
|
|
||||||
if (!this.seasonalEventService.christmasEventEnabled()) {
|
if (!this.seasonalEventService.christmasEventEnabled()) {
|
||||||
// Process all bots EXCEPT gifter, he needs christmas items
|
// Process all bots EXCEPT gifter, he needs christmas items
|
||||||
if (botGenerationDetails.role !== "gifter") {
|
if (botGenerationDetails.role !== "gifter") {
|
||||||
@ -273,6 +279,15 @@ export class BotGenerator {
|
|||||||
return bot;
|
return bot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Should this bot have a name like "name (Pmc Name)" and be alterd by client patch to be hostile to player
|
||||||
|
* @param botRole Role bot has
|
||||||
|
* @returns True if name should be simulated pscav
|
||||||
|
*/
|
||||||
|
protected shouldSimulatePlayerScav(botRole: string): boolean {
|
||||||
|
return botRole === "assault" && this.randomUtil.getChance100(this.botConfig.chanceAssaultScavHasPlayerScavName);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get exp for kill by bot difficulty
|
* Get exp for kill by bot difficulty
|
||||||
* @param experience Dict of difficulties and experience
|
* @param experience Dict of difficulties and experience
|
||||||
|
@ -66,6 +66,7 @@ export interface IUnlockedInfo {
|
|||||||
export interface IInfo {
|
export interface IInfo {
|
||||||
EntryPoint: string;
|
EntryPoint: string;
|
||||||
Nickname: string;
|
Nickname: string;
|
||||||
|
MainProfileNickname?: string;
|
||||||
LowerNickname: string;
|
LowerNickname: string;
|
||||||
Side: string;
|
Side: string;
|
||||||
SquadInviteRestriction: boolean;
|
SquadInviteRestriction: boolean;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { BotHelper } from "@spt/helpers/BotHelper";
|
import { BotHelper } from "@spt/helpers/BotHelper";
|
||||||
import { ProfileHelper } from "@spt/helpers/ProfileHelper";
|
import { ProfileHelper } from "@spt/helpers/ProfileHelper";
|
||||||
|
import { IBotBase } from "@spt/models/eft/common/tables/IBotBase";
|
||||||
import { IBotType } from "@spt/models/eft/common/tables/IBotType";
|
import { IBotType } from "@spt/models/eft/common/tables/IBotType";
|
||||||
import { ConfigTypes } from "@spt/models/enums/ConfigTypes";
|
import { ConfigTypes } from "@spt/models/enums/ConfigTypes";
|
||||||
import { IBotGenerationDetails } from "@spt/models/spt/bots/BotGenerationDetails";
|
import { IBotGenerationDetails } from "@spt/models/spt/bots/BotGenerationDetails";
|
||||||
@ -58,9 +59,9 @@ export class BotNameService {
|
|||||||
uniqueRoles?: string[],
|
uniqueRoles?: string[],
|
||||||
): string {
|
): string {
|
||||||
const isPmc = botGenerationDetails.isPmc;
|
const isPmc = botGenerationDetails.isPmc;
|
||||||
const isPlayerScav = botGenerationDetails.isPlayerScav;
|
|
||||||
const simulateScavName = isPlayerScav ? false : this.shouldSimulatePlayerScavName(botRole);
|
// Never show for players
|
||||||
const showTypeInNickname = this.botConfig.showTypeInNickname && !isPlayerScav;
|
const showTypeInNickname = !botGenerationDetails.isPlayerScav && this.botConfig.showTypeInNickname;
|
||||||
const roleShouldBeUnique = uniqueRoles?.includes(botRole.toLowerCase());
|
const roleShouldBeUnique = uniqueRoles?.includes(botRole.toLowerCase());
|
||||||
|
|
||||||
let isUnique = true;
|
let isUnique = true;
|
||||||
@ -72,12 +73,6 @@ export class BotNameService {
|
|||||||
: `${this.randomUtil.getArrayValue(botJsonTemplate.firstName)} ${this.randomUtil.getArrayValue(botJsonTemplate.lastName) || ""}`;
|
: `${this.randomUtil.getArrayValue(botJsonTemplate.firstName)} ${this.randomUtil.getArrayValue(botJsonTemplate.lastName) || ""}`;
|
||||||
name = name.trim();
|
name = name.trim();
|
||||||
|
|
||||||
// Simulate bot looking like a player scav with the PMC name in brackets.
|
|
||||||
// E.g. "ScavName (PMC Name)"
|
|
||||||
if (simulateScavName) {
|
|
||||||
return this.addPlayerScavNameSimulationSuffix(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Config is set to add role to end of bot name
|
// Config is set to add role to end of bot name
|
||||||
if (showTypeInNickname) {
|
if (showTypeInNickname) {
|
||||||
name += ` ${botRole}`;
|
name += ` ${botRole}`;
|
||||||
@ -119,19 +114,23 @@ export class BotNameService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Should this bot have a name like "name (Pmc Name)"
|
* Add random PMC name to bots MainProfileNickname property
|
||||||
* @param botRole Role bot has
|
* @param bot Bot to update
|
||||||
* @returns True if name should be simulated pscav
|
|
||||||
*/
|
*/
|
||||||
protected shouldSimulatePlayerScavName(botRole: string): boolean {
|
public addRandomPmcNameToBotMainProfileNicknameProperty(bot: IBotBase): void {
|
||||||
return botRole === "assault" && this.randomUtil.getChance100(this.botConfig.chanceAssaultScavHasPlayerScavName);
|
// Simulate bot looking like a player scav with the PMC name in brackets.
|
||||||
|
// E.g. "ScavName (PMC Name)"
|
||||||
|
bot.Info.MainProfileNickname = this.getRandomPMCName();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected addPlayerScavNameSimulationSuffix(nickname: string): string {
|
/**
|
||||||
const pmcNames = [
|
* Choose a random PMC name from bear or usec bot jsons
|
||||||
...this.databaseService.getBots().types.usec.firstName,
|
* @returns PMC name as string
|
||||||
...this.databaseService.getBots().types.bear.firstName,
|
*/
|
||||||
];
|
protected getRandomPMCName(): string {
|
||||||
return `${nickname} (${this.randomUtil.getArrayValue(pmcNames)})`;
|
const bots = this.databaseService.getBots().types;
|
||||||
|
|
||||||
|
const pmcNames = new Set([...bots.usec.firstName, ...bots.bear.firstName]);
|
||||||
|
return this.randomUtil.getArrayValue(Array.from(pmcNames));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user