From fa39bec1e75de87041452b962e9b1ee41464d129 Mon Sep 17 00:00:00 2001 From: Chris Adamson Date: Tue, 24 Jun 2025 13:05:58 -0500 Subject: [PATCH] added a random chance between config and 100 for infected to be present in the map --- .../SPT_Data/configs/seasonalevents.json | 16 ++++++++-------- .../Services/SeasonalEventService.cs | 14 +++++++++++--- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/Libraries/SPTarkov.Server.Assets/SPT_Data/configs/seasonalevents.json b/Libraries/SPTarkov.Server.Assets/SPT_Data/configs/seasonalevents.json index 2d0e240d..d4c59f42 100644 --- a/Libraries/SPTarkov.Server.Assets/SPT_Data/configs/seasonalevents.json +++ b/Libraries/SPTarkov.Server.Assets/SPT_Data/configs/seasonalevents.json @@ -9691,14 +9691,14 @@ "Sandbox": 5, "factory4": 5, "laboratory": 100, - "Woods": 5, - "bigmap": 5, - "Shoreline": 5, - "Interchange": 5, - "RezervBase": 5, - "laboratory": 5, - "Lighthouse": 5, - "TarkovStreets": 5 + "Woods": 5, + "bigmap": 5, + "Shoreline": 5, + "Interchange": 5, + "RezervBase": 5, + "laboratory": 5, + "Lighthouse": 5, + "TarkovStreets": 5 } } }, diff --git a/Libraries/SPTarkov.Server.Core/Services/SeasonalEventService.cs b/Libraries/SPTarkov.Server.Core/Services/SeasonalEventService.cs index 604bcb8e..f1ce16d5 100644 --- a/Libraries/SPTarkov.Server.Core/Services/SeasonalEventService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/SeasonalEventService.cs @@ -8,6 +8,7 @@ using SPTarkov.Server.Core.Models.Spt.Config; using SPTarkov.Server.Core.Models.Utils; using SPTarkov.Server.Core.Servers; using SPTarkov.Server.Core.Utils; +using LogLevel = SPTarkov.Server.Core.Models.Spt.Logging.LogLevel; namespace SPTarkov.Server.Core.Services; @@ -20,7 +21,7 @@ public class SeasonalEventService( LocalisationService _localisationService, ProfileHelper _profileHelper, ConfigServer _configServer, - LocaleService _localeService + RandomUtil _randomUtil ) { private bool _christmasEventActive; @@ -804,19 +805,26 @@ public class SeasonalEventService( var globalInfectionDict = globals.LocationInfection.GetAllPropsAsDict(); foreach (var (locationId, infectionPercentage) in zombieSettings.MapInfectionAmount) { + // calculate a random value unless the rate is 100 + double randomInfectionPercentage = infectionPercentage == 100 + ? infectionPercentage + : Convert.ToDouble(_randomUtil.GetInt(Convert.ToInt32(infectionPercentage), 100)); + if (_logger.IsLogEnabled(LogLevel.Debug)) + _logger.Debug($"Percent infected from map {locationId} is {randomInfectionPercentage}"); // Infection rates sometimes apply to multiple maps, e.g. Factory day/night or Sandbox/sandbox_high // Get the list of maps that should have infection value applied to their base // 90% of locations are just 1 map e.g. bigmap = customs var mappedLocations = GetLocationFromInfectedLocation(locationId); foreach (var locationKey in mappedLocations) { + _databaseService .GetLocation(locationKey) - .Base.Events.Halloween2024.InfectionPercentage = infectionPercentage; + .Base.Events.Halloween2024.InfectionPercentage = randomInfectionPercentage; } // Globals data needs value updated too - globalInfectionDict[locationId] = infectionPercentage; + globalInfectionDict[locationId] = randomInfectionPercentage; } foreach (var locationId in zombieSettings.DisableBosses)