mirror of
https://github.com/sp-tarkov/server.git
synced 2025-02-13 02:10:44 -05:00
Improved chatbot functionality
Easier to disable bots via mod
This commit is contained in:
parent
d32127ba1a
commit
d36443d9d1
@ -181,9 +181,7 @@
|
||||
"features": {
|
||||
"compressProfile": false,
|
||||
"chatbotFeatures": {
|
||||
"sptFriendEnabled": true,
|
||||
"sptFriendGiftsEnabled": true,
|
||||
"commandoEnabled": true,
|
||||
"commandoFeatures": {
|
||||
"giveCommandEnabled": true
|
||||
},
|
||||
@ -193,7 +191,11 @@
|
||||
"ids": {
|
||||
"commando": "6723fd51c5924c57ce0ca01e",
|
||||
"spt": "6723fd51c5924c57ce0ca01f"
|
||||
}
|
||||
},
|
||||
"enabledBots": {
|
||||
"6723fd51c5924c57ce0ca01e": true,
|
||||
"6723fd51c5924c57ce0ca01f": true
|
||||
}
|
||||
},
|
||||
"createNewProfileTypesBlacklist": []
|
||||
},
|
||||
|
@ -28,6 +28,8 @@ import { inject, injectAll, injectable } from "tsyringe";
|
||||
|
||||
@injectable()
|
||||
export class DialogueController {
|
||||
protected coreConfig: ICoreConfig;
|
||||
|
||||
constructor(
|
||||
@inject("PrimaryLogger") protected logger: ILogger,
|
||||
@inject("SaveServer") protected saveServer: SaveServer,
|
||||
@ -40,20 +42,7 @@ export class DialogueController {
|
||||
@inject("ConfigServer") protected configServer: ConfigServer,
|
||||
@injectAll("DialogueChatBot") protected dialogueChatBots: IDialogueChatBot[],
|
||||
) {
|
||||
const coreConfigs = this.configServer.getConfig<ICoreConfig>(ConfigTypes.CORE);
|
||||
// if give command is disabled or commando commands are disabled
|
||||
if (!coreConfigs.features?.chatbotFeatures?.commandoEnabled) {
|
||||
const sptCommando = this.dialogueChatBots.find(
|
||||
(c) => c.getChatBot()._id.toLocaleLowerCase() === coreConfigs.features?.chatbotFeatures.ids.commando,
|
||||
);
|
||||
this.dialogueChatBots.splice(this.dialogueChatBots.indexOf(sptCommando), 1);
|
||||
}
|
||||
if (!coreConfigs.features?.chatbotFeatures?.sptFriendEnabled) {
|
||||
const sptFriend = this.dialogueChatBots.find(
|
||||
(c) => c.getChatBot()._id.toLocaleLowerCase() === coreConfigs.features?.chatbotFeatures.ids.spt,
|
||||
);
|
||||
this.dialogueChatBots.splice(this.dialogueChatBots.indexOf(sptFriend), 1);
|
||||
}
|
||||
this.coreConfig = this.configServer.getConfig<ICoreConfig>(ConfigTypes.CORE);
|
||||
}
|
||||
|
||||
public registerChatBot(chatBot: IDialogueChatBot): void {
|
||||
@ -79,7 +68,7 @@ export class DialogueController {
|
||||
*/
|
||||
public getFriendList(sessionID: string): IGetFriendListDataResponse {
|
||||
// Add all chatbots to the friends list
|
||||
const friends = this.dialogueChatBots.map((v) => v.getChatBot());
|
||||
const friends = this.getActiveChatBots();
|
||||
|
||||
// Add any friends the user has after the chatbots
|
||||
const profile = this.profileHelper.getFullProfile(sessionID);
|
||||
@ -95,6 +84,19 @@ export class DialogueController {
|
||||
return { Friends: friends, Ignore: [], InIgnoreList: [] };
|
||||
}
|
||||
|
||||
protected getActiveChatBots(): IUserDialogInfo[] {
|
||||
const activeBots = [];
|
||||
|
||||
const chatBotConfig = this.coreConfig.features.chatbotFeatures;
|
||||
for (const bot of this.dialogueChatBots) {
|
||||
if (chatBotConfig.enabledBots[bot.getChatBot()._id]) {
|
||||
activeBots.push(bot.getChatBot());
|
||||
}
|
||||
}
|
||||
|
||||
return activeBots;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle client/mail/dialog/list
|
||||
* Create array holding trader dialogs and mail interactions with player
|
||||
|
@ -283,7 +283,7 @@ export class BotGenerator {
|
||||
}
|
||||
|
||||
/**
|
||||
* Should this bot have a name like "name (Pmc Name)" and be alterd by client patch to be hostile to player
|
||||
* Should this bot have a name like "name (Pmc Name)" and be altered by client patch to be hostile to player
|
||||
* @param botRole Role bot has
|
||||
* @returns True if name should be simulated pscav
|
||||
*/
|
||||
|
@ -16,11 +16,12 @@ export class SptCommandoCommands implements IChatCommand {
|
||||
@injectAll("SptCommand") protected sptCommands: ISptCommand[],
|
||||
) {
|
||||
const coreConfigs = this.configServer.getConfig<ICoreConfig>(ConfigTypes.CORE);
|
||||
const commandoId = coreConfigs.features?.chatbotFeatures.ids.commando;
|
||||
// if give command is disabled or commando commands are disabled
|
||||
if (
|
||||
!(
|
||||
coreConfigs.features?.chatbotFeatures?.commandoFeatures?.giveCommandEnabled &&
|
||||
coreConfigs.features?.chatbotFeatures?.commandoEnabled
|
||||
coreConfigs.features?.chatbotFeatures?.enabledBots[commandoId]
|
||||
)
|
||||
) {
|
||||
const giveCommand = this.sptCommands.find((c) => c.getCommand().toLocaleLowerCase() === "give");
|
||||
|
@ -89,12 +89,13 @@ export interface IServerFeatures {
|
||||
}
|
||||
|
||||
export interface IChatbotFeatures {
|
||||
sptFriendEnabled: boolean;
|
||||
sptFriendGiftsEnabled: boolean;
|
||||
commandoEnabled: boolean;
|
||||
commandoFeatures: ICommandoFeatures;
|
||||
commandUseLimits: Record<string, number>;
|
||||
/** Human readable id to guid for each bot */
|
||||
ids: Record<string, string>;
|
||||
/** Bot Ids player is allowed to interact with */
|
||||
enabledBots: Record<string, string>;
|
||||
}
|
||||
|
||||
export interface ICommandoFeatures {
|
||||
|
Loading…
x
Reference in New Issue
Block a user