diff --git a/project/src/callbacks/BotCallbacks.ts b/project/src/callbacks/BotCallbacks.ts index 3867921a..966104ac 100644 --- a/project/src/callbacks/BotCallbacks.ts +++ b/project/src/callbacks/BotCallbacks.ts @@ -4,6 +4,7 @@ import { BotController } from "@spt-aki/controllers/BotController"; import { IGenerateBotsRequestData } from "@spt-aki/models/eft/bot/IGenerateBotsRequestData"; import { IEmptyRequestData } from "@spt-aki/models/eft/common/IEmptyRequestData"; import { IBotBase } from "@spt-aki/models/eft/common/tables/IBotBase"; +import { Difficulties } from "@spt-aki/models/eft/common/tables/IBotType"; import { IGetBodyResponseData } from "@spt-aki/models/eft/httpResponse/IGetBodyResponseData"; import { HttpResponseUtil } from "@spt-aki/utils/HttpResponseUtil"; @@ -44,6 +45,15 @@ export class BotCallbacks return this.httpResponse.noBody(this.botController.getBotDifficulty(type, difficulty)); } + /** + * Handle singleplayer/settings/bot/difficulties + * @returns dictionary of every bot and its diffiulty settings + */ + public getAllBotDifficulties(url: string, info: IEmptyRequestData, sessionID: string): Record + { + return this.httpResponse.noBody(this.botController.getAllBotDifficulties()); + } + /** * Handle client/game/bot/generate * @returns IGetBodyResponseData diff --git a/project/src/controllers/BotController.ts b/project/src/controllers/BotController.ts index 42f740d0..908333a5 100644 --- a/project/src/controllers/BotController.ts +++ b/project/src/controllers/BotController.ts @@ -83,7 +83,7 @@ export class BotController /** * Get bot difficulty settings - * adjust PMC settings to ensure they engage the correct bot types + * Adjust PMC settings to ensure they engage the correct bot types * @param type what bot the server is requesting settings for * @param diffLevel difficulty level server requested settings for * @returns Difficulty object @@ -104,7 +104,7 @@ export class BotController // Check value chosen in pre-raid difficulty dropdown // If value is not 'asonline', change requested difficulty to be what was chosen in dropdown - const botDifficultyDropDownValue = raidConfig.wavesSettings.botDifficulty.toLowerCase(); + const botDifficultyDropDownValue = raidConfig?.wavesSettings.botDifficulty.toLowerCase() ?? "asonline"; if (botDifficultyDropDownValue !== "asonline") { difficulty = this.botDifficultyHelper.convertBotDifficultyDropdownToBotDifficulty( @@ -140,6 +140,31 @@ export class BotController return difficultySettings; } + public getAllBotDifficulties(): Record + { + const result = {}; + + const botDb = this.databaseServer.getTables().bots.types; + const botTypes = Object.keys(botDb); + for (const botType of botTypes) + { + const botDetails = botDb[botType]; + if (!botDetails.difficulty) + { + continue; + } + const botDifficulties = Object.keys(botDetails.difficulty); + + result[botType] = {}; + for (const difficulty of botDifficulties) + { + result[botType][difficulty] = this.getBotDifficulty(botType, difficulty); + } + } + + return result; + } + /** * Generate bot profiles and store in cache * @param sessionId Session id diff --git a/project/src/routers/dynamic/BotDynamicRouter.ts b/project/src/routers/dynamic/BotDynamicRouter.ts index df65c79b..323912c4 100644 --- a/project/src/routers/dynamic/BotDynamicRouter.ts +++ b/project/src/routers/dynamic/BotDynamicRouter.ts @@ -23,6 +23,13 @@ export class BotDynamicRouter extends DynamicRouter return this.botCallbacks.getBotDifficulty(url, info, sessionID); }, ), + new RouteAction( + "/singleplayer/settings/bot/difficulties/", + (url: string, info: any, sessionID: string, output: string): any => + { + return this.botCallbacks.getAllBotDifficulties(url, info, sessionID); + }, + ), new RouteAction( "/singleplayer/settings/bot/maxCap", (url: string, info: any, sessionID: string, output: string): any =>