diff --git a/project/assets/configs/core.json b/project/assets/configs/core.json index e87a2ecb..8e60b15d 100644 --- a/project/assets/configs/core.json +++ b/project/assets/configs/core.json @@ -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": [] }, diff --git a/project/src/controllers/DialogueController.ts b/project/src/controllers/DialogueController.ts index e4a21561..57aa1795 100644 --- a/project/src/controllers/DialogueController.ts +++ b/project/src/controllers/DialogueController.ts @@ -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(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(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 diff --git a/project/src/generators/BotGenerator.ts b/project/src/generators/BotGenerator.ts index 29ae7624..310fc53d 100644 --- a/project/src/generators/BotGenerator.ts +++ b/project/src/generators/BotGenerator.ts @@ -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 */ diff --git a/project/src/helpers/Dialogue/Commando/SptCommandoCommands.ts b/project/src/helpers/Dialogue/Commando/SptCommandoCommands.ts index bb1d6c38..40b63686 100644 --- a/project/src/helpers/Dialogue/Commando/SptCommandoCommands.ts +++ b/project/src/helpers/Dialogue/Commando/SptCommandoCommands.ts @@ -16,11 +16,12 @@ export class SptCommandoCommands implements IChatCommand { @injectAll("SptCommand") protected sptCommands: ISptCommand[], ) { const coreConfigs = this.configServer.getConfig(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"); diff --git a/project/src/models/spt/config/ICoreConfig.ts b/project/src/models/spt/config/ICoreConfig.ts index 5a53482c..8c5e8fe7 100644 --- a/project/src/models/spt/config/ICoreConfig.ts +++ b/project/src/models/spt/config/ICoreConfig.ts @@ -89,12 +89,13 @@ export interface IServerFeatures { } export interface IChatbotFeatures { - sptFriendEnabled: boolean; sptFriendGiftsEnabled: boolean; - commandoEnabled: boolean; commandoFeatures: ICommandoFeatures; commandUseLimits: Record; + /** Human readable id to guid for each bot */ ids: Record; + /** Bot Ids player is allowed to interact with */ + enabledBots: Record; } export interface ICommandoFeatures {