@@ -3,9 +3,14 @@ import type { IPreSptLoadMod } from "@spt/models/external/IPreSptLoadMod";
33import type { ILogger } from "@spt/models/spt/utils/ILogger" ;
44import type { StaticRouterModService } from "@spt/services/mod/staticRouter/StaticRouterModService" ;
55import { DependencyContainer } from "tsyringe" ;
6+ import { RaidTimeAdjustmentService } from "@spt/services/RaidTimeAdjustmentService" ;
7+ import { IGetRaidTimeRequest } from "@spt/models/eft/game/IGetRaidTimeRequest" ;
8+ import { IGetRaidTimeResponse } from "@spt/models/eft/game/IGetRaidTimeResponse" ;
69import { LocationProcessor } from "./processors/LocationProcessor" ;
710import { RaidTimeProcessor } from "./processors/RaidTimeProcessor" ;
811import { ConfigServer } from "./servers/ConfigServer" ;
12+ import { ILocationBase } from "@spt/models/eft/common/ILocationBase" ;
13+ import { DatabaseService } from "@spt/services/DatabaseService" ;
914import type { Configuration } from "./types" ;
1015
1116/**
@@ -14,12 +19,14 @@ import type { Configuration } from "./types";
1419class CustomRaidTimes implements IPostDBLoadMod , IPreSptLoadMod {
1520 private logger : ILogger ;
1621 private config : Configuration | null = null ;
22+ private container : DependencyContainer ;
1723
1824 /**
1925 * Handle loading the configuration file and registering our custom CustomRaidTimesMatchEnd route.
2026 * Runs before the database is loaded.
2127 */
2228 public preSptLoad ( container : DependencyContainer ) : void {
29+ this . container = container ;
2330 this . logger = container . resolve < ILogger > ( "WinstonLogger" ) ;
2431
2532 // Load and validate the configuration file.
@@ -66,6 +73,46 @@ class CustomRaidTimes implements IPostDBLoadMod, IPreSptLoadMod {
6673 ] ,
6774 "CustomRaidTimesMatchEnd"
6875 ) ;
76+
77+ // Register a replacement for the RaidTimeAdjustmentService getRaidAdjustments method if the configuration is
78+ // set to override the scav raid times as well.
79+ if ( this . config ?. raidTimes ?. overrideScav ) {
80+ container . afterResolution (
81+ "RaidTimeAdjustmentService" ,
82+ ( _t , result : RaidTimeAdjustmentService ) => {
83+ result . getRaidAdjustments = (
84+ sessionId : string ,
85+ request : IGetRaidTimeRequest
86+ ) : IGetRaidTimeResponse => {
87+ return this . getRaidAdjustments ( request ) ;
88+ } ;
89+ } ,
90+ { frequency : "Always" }
91+ ) ;
92+ }
93+ }
94+
95+ /**
96+ * Return the same response as the original method, even if you're a scav.
97+ * @override @spt /services/RaidTimeAdjustmentService.getRaidAdjustments
98+ */
99+ private getRaidAdjustments ( request : IGetRaidTimeRequest ) : IGetRaidTimeResponse {
100+ const databaseService = this . container . resolve < DatabaseService > ( "DatabaseService" ) ;
101+
102+ const globals = databaseService . getGlobals ( ) ;
103+ const mapBase : ILocationBase = databaseService . getLocation ( request . Location . toLowerCase ( ) ) . base ;
104+ const baseEscapeTimeMinutes = mapBase . EscapeTimeLimit ;
105+
106+ const result : IGetRaidTimeResponse = {
107+ RaidTimeMinutes : baseEscapeTimeMinutes ,
108+ ExitChanges : [ ] ,
109+ NewSurviveTimeSeconds : undefined ,
110+ OriginalSurvivalTimeSeconds : globals . config . exp . match_end . survived_seconds_requirement ,
111+ } ;
112+
113+ this . logger . log ( "CustomRaidTimes: The `getRaidAdjustments` override has been triggered." , "cyan" ) ;
114+
115+ return result ;
69116 }
70117
71118 /**
0 commit comments