Allow wave adjustment to be controlled via config param

Prevent bot wave min/max from falling  below 0
This commit is contained in:
Dev 2023-11-29 17:18:45 +00:00
parent dde5c7e8af
commit 000e48ca4c
3 changed files with 51 additions and 21 deletions

View File

@ -811,7 +811,8 @@
"60": 2, "60": 2,
"70": 2, "70": 2,
"80": 1 "80": 1
} },
"adjustWaves": true
}, },
"factory4_day": { "factory4_day": {
"reduceLootByPercent": true, "reduceLootByPercent": true,
@ -829,7 +830,8 @@
"70": 2, "70": 2,
"80": 2, "80": 2,
"85": 1 "85": 1
} },
"adjustWaves": true
}, },
"factory4_night": { "factory4_night": {
"reduceLootByPercent": true, "reduceLootByPercent": true,
@ -843,7 +845,8 @@
"60": 2, "60": 2,
"70": 2, "70": 2,
"80": 1 "80": 1
} },
"adjustWaves": true
}, },
"interchange": { "interchange": {
"reduceLootByPercent": true, "reduceLootByPercent": true,
@ -859,7 +862,8 @@
"50": 5, "50": 5,
"60": 2, "60": 2,
"80": 1 "80": 1
} },
"adjustWaves": true
}, },
"rezervbase": { "rezervbase": {
"reduceLootByPercent": true, "reduceLootByPercent": true,
@ -875,7 +879,8 @@
"60": 2, "60": 2,
"70": 1, "70": 1,
"80": 1 "80": 1
} },
"adjustWaves": true
}, },
"laboratory": { "laboratory": {
"reduceLootByPercent": true, "reduceLootByPercent": true,
@ -889,7 +894,8 @@
"50": 5, "50": 5,
"60": 2, "60": 2,
"80": 1 "80": 1
} },
"adjustWaves": true
}, },
"lighthouse": { "lighthouse": {
"reduceLootByPercent": true, "reduceLootByPercent": true,
@ -904,7 +910,8 @@
"50": 4, "50": 4,
"60": 2, "60": 2,
"80": 1 "80": 1
} },
"adjustWaves": true
}, },
"shoreline": { "shoreline": {
"reduceLootByPercent": true, "reduceLootByPercent": true,
@ -921,7 +928,8 @@
"60": 2, "60": 2,
"70": 1, "70": 1,
"80": 1 "80": 1
} },
"adjustWaves": true
}, },
"tarkovstreets": { "tarkovstreets": {
"reduceLootByPercent": true, "reduceLootByPercent": true,
@ -936,7 +944,8 @@
"60": 4, "60": 4,
"70": 1, "70": 1,
"80": 1 "80": 1
} },
"adjustWaves": true
}, },
"woods": { "woods": {
"reduceLootByPercent": true, "reduceLootByPercent": true,
@ -951,7 +960,8 @@
"60": 1, "60": 1,
"70": 1, "70": 1,
"80": 1 "80": 1
} },
"adjustWaves": true
}, },
"default": { "default": {
"reduceLootByPercent": true, "reduceLootByPercent": true,
@ -967,7 +977,8 @@
"60": 2, "60": 2,
"70": 1, "70": 1,
"80": 1 "80": 1
} },
"adjustWaves": true
} }
} }
} }

View File

@ -51,6 +51,8 @@ export interface IScavRaidTimeLocationSettings
/** Chance raid time is reduced */ /** Chance raid time is reduced */
reducedChancePercent: number; reducedChancePercent: number;
reductionPercentWeights: Record<string, number>; reductionPercentWeights: Record<string, number>;
/** Should bot waves be removed / spawn times be adjusted */
adjustWaves: boolean;
} }
export interface IContainerRandomistionSettings export interface IContainerRandomistionSettings

View File

@ -7,7 +7,7 @@ import { ILocationBase } from "@spt-aki/models/eft/common/ILocationBase";
import { IGetRaidTimeRequest } from "@spt-aki/models/eft/game/IGetRaidTimeRequest"; import { IGetRaidTimeRequest } from "@spt-aki/models/eft/game/IGetRaidTimeRequest";
import { ExtractChange, IGetRaidTimeResponse } from "@spt-aki/models/eft/game/IGetRaidTimeResponse"; import { ExtractChange, IGetRaidTimeResponse } from "@spt-aki/models/eft/game/IGetRaidTimeResponse";
import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes"; 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 { IRaidChanges } from "@spt-aki/models/spt/location/IRaidChanges";
import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
import { ConfigServer } from "@spt-aki/servers/ConfigServer"; import { ConfigServer } from "@spt-aki/servers/ConfigServer";
@ -45,9 +45,13 @@ export class RaidTimeAdjustmentService
this.adjustLootMultipliers(this.locationConfig.looseLootMultiplier, raidAdjustments.dynamicLootPercent); this.adjustLootMultipliers(this.locationConfig.looseLootMultiplier, raidAdjustments.dynamicLootPercent);
this.adjustLootMultipliers(this.locationConfig.staticLootMultiplier, raidAdjustments.staticLootPercent); 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 // Make alterations to bot spawn waves now player is simulated spawning later
this.adjustWaves(mapBase, raidAdjustments) this.adjustWaves(mapBase, raidAdjustments)
} }
}
/** /**
* Adjust the loot multiplier values passed in to be a % of their original value * Adjust the loot multiplier values passed in to be a % of their original value
@ -76,8 +80,9 @@ export class RaidTimeAdjustmentService
// Adjust wave min/max times to match new simulated start // Adjust wave min/max times to match new simulated start
for (const wave of mapBase.waves) for (const wave of mapBase.waves)
{ {
wave.time_min -= raidAdjustments.simulatedRaidStartSeconds; // Dont let time fall below 0
wave.time_max -= raidAdjustments.simulatedRaidStartSeconds; 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`); 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 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 mapBase: ILocationBase = db.locations[request.Location.toLowerCase()].base;
const baseEscapeTimeMinutes = mapBase.EscapeTimeLimit; const baseEscapeTimeMinutes = mapBase.EscapeTimeLimit;
@ -111,12 +116,7 @@ export class RaidTimeAdjustmentService
} }
// We're scav adjust values // We're scav adjust values
let mapSettings = this.locationConfig.scavRaidTimeSettings[request.Location.toLowerCase()]; const mapSettings = this.getMapSettings(request.Location);
if (!mapSettings)
{
this.logger.warning(`Unable to find scav raid time settings for map: ${request.Location}, using defaults`);
mapSettings = this.locationConfig.scavRaidTimeSettings.default;
}
// Chance of reducing raid time for scav, not guaranteed // Chance of reducing raid time for scav, not guaranteed
if (!this.randomUtil.getChance100(mapSettings.reducedChancePercent)) if (!this.randomUtil.getChance100(mapSettings.reducedChancePercent))
@ -164,6 +164,23 @@ export class RaidTimeAdjustmentService
return result; 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 * Adjust exit times to handle scavs entering raids part-way through
* @param mapBase Map base file player is on * @param mapBase Map base file player is on