From ca48f0e83cab72652d47a043364af6299b88f3ef Mon Sep 17 00:00:00 2001 From: Dev Date: Mon, 17 Jul 2023 14:40:54 +0100 Subject: [PATCH] Add property to location config to allow adding bot min/max spawn limits for maps Limit marksman on customs/woods/streets between 2 and 4, woods to 2 and 5 --- project/assets/configs/location.json | 8 +++- project/src/controllers/GameController.ts | 48 +++++++++++++++++++ .../src/models/eft/common/ILocationBase.ts | 5 +- .../src/models/spt/config/ILocationConfig.ts | 10 ++++ 4 files changed, 68 insertions(+), 3 deletions(-) diff --git a/project/assets/configs/location.json b/project/assets/configs/location.json index b7bcd489..23cce109 100644 --- a/project/assets/configs/location.json +++ b/project/assets/configs/location.json @@ -647,7 +647,13 @@ "enabled": true, "ignoreMaps": ["base", "develop", "hideout", "privatearea", "suburbs", "terminal", "town"] }, - "fitLootIntoContainerAttempts": 2 + "fitLootIntoContainerAttempts": 2, "addOpenZonesToAllMaps": true, "addCustomBotWavesToMaps": true, + "enableBotTypeLimits": true, + "botTypeLimits": { + "tarkovstreets": [{"type": "marksman", "min": 2, "max": 4}], + "woods": [{"type": "marksman", "min": 2, "max": 5}], + "bigmap": [{"type": "marksman", "min": 2, "max": 4}] + } } diff --git a/project/src/controllers/GameController.ts b/project/src/controllers/GameController.ts index 71526642..a549ca71 100644 --- a/project/src/controllers/GameController.ts +++ b/project/src/controllers/GameController.ts @@ -89,6 +89,11 @@ export class GameController this.customLocationWaveService.applyWaveChangesToAllMaps(); } + if (this.locationConfig.enableBotTypeLimits) + { + this.adjustMapBotLimits(); + } + // repeatableQuests are stored by in profile.Quests due to the responses of the client (e.g. Quests in offraidData) // Since we don't want to clutter the Quests list, we need to remove all completed (failed / successful) repeatable quests. // We also have to remove the Counters from the repeatableQuests @@ -167,6 +172,49 @@ export class GameController } } + protected adjustMapBotLimits(): void + { + const mapsDb = this.databaseServer.getTables().locations; + if (!this.locationConfig.botTypeLimits) + { + return; + } + + for (const mapId in this.locationConfig.botTypeLimits) + { + const map: ILocationData = mapsDb[mapId]; + if (!map) + { + this.logger.warning(`Unable to edit bot limits of map: ${mapId} as it cannot be found`); + } + + for (const botToLimit of this.locationConfig.botTypeLimits[mapId]) + { + const index = map.base.MinMaxBots.findIndex(x => x.WildSpawnType === botToLimit.type); + if (index !== -1) + { + // Existing bot type found in MinMaxBots array, edit + const limitObjectToUpdate = map.base.MinMaxBots[index]; + limitObjectToUpdate.min = botToLimit.min; + limitObjectToUpdate.max = botToLimit.max; + } + else + { + map.base.MinMaxBots.push( + { + // Bot type not found, add new object + WildSpawnType: botToLimit.type, + min: botToLimit.min, + max: botToLimit.max + } + ); + } + + } + + } + } + /** * Handle client/game/config */ diff --git a/project/src/models/eft/common/ILocationBase.ts b/project/src/models/eft/common/ILocationBase.ts index 212b9ff4..9b01ad21 100644 --- a/project/src/models/eft/common/ILocationBase.ts +++ b/project/src/models/eft/common/ILocationBase.ts @@ -160,7 +160,7 @@ export interface BotLocationModifier export interface MinMaxBot { - WildSpawnType: WildSpawnType + WildSpawnType: WildSpawnType | string max: number min: number } @@ -250,5 +250,6 @@ export interface Wave export enum WildSpawnType { ASSAULT = "assault", - MARKSMAN = "marksman" + MARKSMAN = "marksman", + PMCBOT = "pmcbot" } \ No newline at end of file diff --git a/project/src/models/spt/config/ILocationConfig.ts b/project/src/models/spt/config/ILocationConfig.ts index 9df92bb0..823ce4fd 100644 --- a/project/src/models/spt/config/ILocationConfig.ts +++ b/project/src/models/spt/config/ILocationConfig.ts @@ -20,6 +20,9 @@ export interface ILocationConfig extends IBaseConfig addOpenZonesToAllMaps: boolean /** Allow addition of custom bot waves designed by SPT to be added to maps - defined in configs/location.json.customWaves*/ addCustomBotWavesToMaps: boolean + enableBotTypeLimits: boolean + /** Add limits to a maps base.MinMaxBots array*/ + botTypeLimits: Record } export interface IFixEmptyBotWavesSettings @@ -47,6 +50,13 @@ export interface CustomWaves normal: Record } +export interface IBotTypeLimit +{ + type: string + min: number + max: number +} + export interface LootMultiplier { bigmap: number