From 000e48ca4c57f519ccd32e5fdeda92a8150c9cc1 Mon Sep 17 00:00:00 2001 From: Dev Date: Wed, 29 Nov 2023 17:18:45 +0000 Subject: [PATCH] Allow wave adjustment to be controlled via config param Prevent bot wave min/max from falling below 0 --- project/assets/configs/location.json | 33 +++++++++++------ .../src/models/spt/config/ILocationConfig.ts | 2 + .../src/services/RaidTimeAdjustmentService.ts | 37 ++++++++++++++----- 3 files changed, 51 insertions(+), 21 deletions(-) diff --git a/project/assets/configs/location.json b/project/assets/configs/location.json index 0fcc0eb5..8d08f25d 100644 --- a/project/assets/configs/location.json +++ b/project/assets/configs/location.json @@ -811,7 +811,8 @@ "60": 2, "70": 2, "80": 1 - } + }, + "adjustWaves": true }, "factory4_day": { "reduceLootByPercent": true, @@ -829,7 +830,8 @@ "70": 2, "80": 2, "85": 1 - } + }, + "adjustWaves": true }, "factory4_night": { "reduceLootByPercent": true, @@ -843,7 +845,8 @@ "60": 2, "70": 2, "80": 1 - } + }, + "adjustWaves": true }, "interchange": { "reduceLootByPercent": true, @@ -859,7 +862,8 @@ "50": 5, "60": 2, "80": 1 - } + }, + "adjustWaves": true }, "rezervbase": { "reduceLootByPercent": true, @@ -875,7 +879,8 @@ "60": 2, "70": 1, "80": 1 - } + }, + "adjustWaves": true }, "laboratory": { "reduceLootByPercent": true, @@ -889,7 +894,8 @@ "50": 5, "60": 2, "80": 1 - } + }, + "adjustWaves": true }, "lighthouse": { "reduceLootByPercent": true, @@ -904,7 +910,8 @@ "50": 4, "60": 2, "80": 1 - } + }, + "adjustWaves": true }, "shoreline": { "reduceLootByPercent": true, @@ -921,7 +928,8 @@ "60": 2, "70": 1, "80": 1 - } + }, + "adjustWaves": true }, "tarkovstreets": { "reduceLootByPercent": true, @@ -936,7 +944,8 @@ "60": 4, "70": 1, "80": 1 - } + }, + "adjustWaves": true }, "woods": { "reduceLootByPercent": true, @@ -951,7 +960,8 @@ "60": 1, "70": 1, "80": 1 - } + }, + "adjustWaves": true }, "default": { "reduceLootByPercent": true, @@ -967,7 +977,8 @@ "60": 2, "70": 1, "80": 1 - } + }, + "adjustWaves": true } } } diff --git a/project/src/models/spt/config/ILocationConfig.ts b/project/src/models/spt/config/ILocationConfig.ts index c13fcae3..172f390e 100644 --- a/project/src/models/spt/config/ILocationConfig.ts +++ b/project/src/models/spt/config/ILocationConfig.ts @@ -51,6 +51,8 @@ export interface IScavRaidTimeLocationSettings /** Chance raid time is reduced */ reducedChancePercent: number; reductionPercentWeights: Record; + /** Should bot waves be removed / spawn times be adjusted */ + adjustWaves: boolean; } export interface IContainerRandomistionSettings diff --git a/project/src/services/RaidTimeAdjustmentService.ts b/project/src/services/RaidTimeAdjustmentService.ts index 27308a46..0fd2d27a 100644 --- a/project/src/services/RaidTimeAdjustmentService.ts +++ b/project/src/services/RaidTimeAdjustmentService.ts @@ -7,7 +7,7 @@ import { ILocationBase } from "@spt-aki/models/eft/common/ILocationBase"; import { IGetRaidTimeRequest } from "@spt-aki/models/eft/game/IGetRaidTimeRequest"; import { ExtractChange, IGetRaidTimeResponse } from "@spt-aki/models/eft/game/IGetRaidTimeResponse"; import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes"; -import { ILocationConfig, LootMultiplier } from "@spt-aki/models/spt/config/ILocationConfig"; +import { ILocationConfig, IScavRaidTimeLocationSettings, LootMultiplier } from "@spt-aki/models/spt/config/ILocationConfig"; import { IRaidChanges } from "@spt-aki/models/spt/location/IRaidChanges"; import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; import { ConfigServer } from "@spt-aki/servers/ConfigServer"; @@ -45,8 +45,12 @@ export class RaidTimeAdjustmentService this.adjustLootMultipliers(this.locationConfig.looseLootMultiplier, raidAdjustments.dynamicLootPercent); this.adjustLootMultipliers(this.locationConfig.staticLootMultiplier, raidAdjustments.staticLootPercent); + const mapSettings = this.getMapSettings(mapBase.Id); + if (mapSettings.adjustWaves) + { // Make alterations to bot spawn waves now player is simulated spawning later this.adjustWaves(mapBase, raidAdjustments) + } } /** @@ -76,8 +80,9 @@ export class RaidTimeAdjustmentService // Adjust wave min/max times to match new simulated start for (const wave of mapBase.waves) { - wave.time_min -= raidAdjustments.simulatedRaidStartSeconds; - wave.time_max -= raidAdjustments.simulatedRaidStartSeconds; + // Dont let time fall below 0 + wave.time_min -= Math.max(raidAdjustments.simulatedRaidStartSeconds, 0); + wave.time_max -= Math.max(raidAdjustments.simulatedRaidStartSeconds, 0); } this.logger.debug(`Removed ${originalWaveCount - mapBase.waves.length} wave from map due to simulated raid start time of ${raidAdjustments.simulatedRaidStartSeconds / 60} minutes`); @@ -91,7 +96,7 @@ export class RaidTimeAdjustmentService */ public getRaidAdjustments(sessionId: string, request: IGetRaidTimeRequest): IGetRaidTimeResponse { - const db = this.databaseServer.getTables() + const db = this.databaseServer.getTables(); const mapBase: ILocationBase = db.locations[request.Location.toLowerCase()].base; const baseEscapeTimeMinutes = mapBase.EscapeTimeLimit; @@ -111,12 +116,7 @@ export class RaidTimeAdjustmentService } // We're scav adjust values - let mapSettings = this.locationConfig.scavRaidTimeSettings[request.Location.toLowerCase()]; - if (!mapSettings) - { - this.logger.warning(`Unable to find scav raid time settings for map: ${request.Location}, using defaults`); - mapSettings = this.locationConfig.scavRaidTimeSettings.default; - } + const mapSettings = this.getMapSettings(request.Location); // Chance of reducing raid time for scav, not guaranteed if (!this.randomUtil.getChance100(mapSettings.reducedChancePercent)) @@ -164,6 +164,23 @@ export class RaidTimeAdjustmentService return result; } + /** + * Get raid start time settings for specific map + * @param location Map Location e.g. bigmap + * @returns IScavRaidTimeLocationSettings + */ + protected getMapSettings(location: string): IScavRaidTimeLocationSettings + { + const mapSettings = this.locationConfig.scavRaidTimeSettings[location.toLowerCase()]; + if (!mapSettings) + { + this.logger.warning(`Unable to find scav raid time settings for map: ${location}, using defaults`); + return this.locationConfig.scavRaidTimeSettings.default; + } + + return mapSettings; + } + /** * Adjust exit times to handle scavs entering raids part-way through * @param mapBase Map base file player is on