diff --git a/Core/Controllers/BotController.cs b/Core/Controllers/BotController.cs index c72c0227..f67c761f 100644 --- a/Core/Controllers/BotController.cs +++ b/Core/Controllers/BotController.cs @@ -316,7 +316,7 @@ public class BotController _matchBotDetailsCacheService.CacheBot(botToCache); } - private void UpdateBotGenerationDetailsToRandomBoss(BotGenerationDetails botGenerationDetails, Dictionary bossesToConvertToWeights) + private void UpdateBotGenerationDetailsToRandomBoss(BotGenerationDetails botGenerationDetails, Dictionary bossesToConvertToWeights) { // Seems Actual bosses have the same Brain issues like PMC gaining Boss Brains We can't use all bosses botGenerationDetails.Role = _weightedRandomHelper.GetWeightedValue(bossesToConvertToWeights); diff --git a/Core/Generators/BotGenerator.cs b/Core/Generators/BotGenerator.cs index d4c92a43..85b1badd 100644 --- a/Core/Generators/BotGenerator.cs +++ b/Core/Generators/BotGenerator.cs @@ -434,7 +434,7 @@ public class BotGenerator public void AddAdditionalPocketLootWeightsForUnheardBot(BotType botJsonTemplate) { // Adjust pocket loot weights to allow for 5 or 6 items - var pocketWeights = botJsonTemplate.BotGeneration.Items["pocketLoot"].Weights; + var pocketWeights = botJsonTemplate.BotGeneration.Items.PocketLoot.Weights; pocketWeights[5] = 1; pocketWeights[6] = 1; } diff --git a/Core/Generators/BotLootGenerator.cs b/Core/Generators/BotLootGenerator.cs index d736f74b..9cabb240 100644 --- a/Core/Generators/BotLootGenerator.cs +++ b/Core/Generators/BotLootGenerator.cs @@ -97,36 +97,33 @@ public class BotLootGenerator var itemCounts = botJsonTemplate.BotGeneration.Items; if ( - itemCounts["backpackLoot"].Weights is null || - itemCounts["pocketLoot"].Weights is null || - itemCounts["vestLoot"].Weights is null || - itemCounts["specialItems"].Weights is null || - itemCounts["healing"].Weights is null || - itemCounts["drugs"].Weights is null || - itemCounts["food"].Weights is null || - itemCounts["drink"].Weights is null || - itemCounts["currency"].Weights is null || - itemCounts["stims"].Weights is null || - itemCounts["grenades"].Weights is null + itemCounts.BackpackLoot.Weights is null || + itemCounts.PocketLoot.Weights is null || + itemCounts.VestLoot.Weights is null || + itemCounts.SpecialItems.Weights is null || + itemCounts.Healing.Weights is null || + itemCounts.Drugs.Weights is null || + itemCounts.Food.Weights is null || + itemCounts.Drink.Weights is null || + itemCounts.Currency.Weights is null || + itemCounts.Stims.Weights is null || + itemCounts.Grenades.Weights is null ) { _logger.Warning(_localisationService.GetText("bot-unable_to_generate_bot_loot", botRole)); return; } - var backpackLootCount = _weightedRandomHelper.GetWeightedValue(itemCounts["backpackLoot"].Weights); - var pocketLootCount = _weightedRandomHelper.GetWeightedValue(itemCounts["pocketLoot"].Weights); - var vestLootCount = _weightedRandomHelper.GetWeightedValue(itemCounts["vestLoot"].Weights); - var specialLootItemCount = _weightedRandomHelper.GetWeightedValue(itemCounts["specialItems"].Weights); - var healingItemCount = _weightedRandomHelper.GetWeightedValue(itemCounts["healing"].Weights); - var drugItemCount = _weightedRandomHelper.GetWeightedValue(itemCounts["drugs"].Weights); - - var foodItemCount = _weightedRandomHelper.GetWeightedValue(itemCounts["food"].Weights); - var drinkItemCount = _weightedRandomHelper.GetWeightedValue(itemCounts["drink"].Weights); - - var currencyItemCount = _weightedRandomHelper.GetWeightedValue(itemCounts["currency"].Weights); - - var stimItemCount = _weightedRandomHelper.GetWeightedValue(itemCounts["stims"].Weights); - var grenadeCount = _weightedRandomHelper.GetWeightedValue(itemCounts["grenades"].Weights); + var backpackLootCount = _weightedRandomHelper.GetWeightedValue(itemCounts.BackpackLoot.Weights); + var pocketLootCount = _weightedRandomHelper.GetWeightedValue(itemCounts.PocketLoot.Weights); + var vestLootCount = _weightedRandomHelper.GetWeightedValue(itemCounts.VestLoot.Weights); + var specialLootItemCount = _weightedRandomHelper.GetWeightedValue(itemCounts.SpecialItems.Weights); + var healingItemCount = _weightedRandomHelper.GetWeightedValue(itemCounts.Healing.Weights); + var drugItemCount = _weightedRandomHelper.GetWeightedValue(itemCounts.Drugs.Weights); + var foodItemCount = _weightedRandomHelper.GetWeightedValue(itemCounts.Food.Weights); + var drinkItemCount = _weightedRandomHelper.GetWeightedValue(itemCounts.Drink.Weights); + var currencyItemCount = _weightedRandomHelper.GetWeightedValue(itemCounts.Currency.Weights); + var stimItemCount = _weightedRandomHelper.GetWeightedValue(itemCounts.Stims.Weights); + var grenadeCount = _weightedRandomHelper.GetWeightedValue(itemCounts.Grenades.Weights); // If bot has been flagged as not having loot, set below counts to 0 if (_botConfig.DisableLootOnBotTypes.Contains(botRole.ToLower())) diff --git a/Core/Generators/PlayerScavGenerator.cs b/Core/Generators/PlayerScavGenerator.cs index 84f6fc96..e93fcf4e 100644 --- a/Core/Generators/PlayerScavGenerator.cs +++ b/Core/Generators/PlayerScavGenerator.cs @@ -278,9 +278,11 @@ public class PlayerScavGenerator } // Adjust item spawn quantity values + var props = baseBotNode.BotGeneration.Items.GetType().GetProperties(); foreach (var itemLimitKvP in karmaSettings.ItemLimits) { - baseBotNode.BotGeneration.Items[itemLimitKvP.Key] = itemLimitKvP.Value; + var prop = props.FirstOrDefault(x => x.Name == itemLimitKvP.Key); + prop.SetValue(baseBotNode.BotGeneration.Items, itemLimitKvP.Value); } // Blacklist equipment, keyed by equipment slot diff --git a/Core/Models/Eft/Common/Tables/BotType.cs b/Core/Models/Eft/Common/Tables/BotType.cs index c75acce2..9792f17f 100644 --- a/Core/Models/Eft/Common/Tables/BotType.cs +++ b/Core/Models/Eft/Common/Tables/BotType.cs @@ -41,22 +41,22 @@ public class BotType public class Appearance { [JsonPropertyName("body")] - public Dictionary? Body { get; set; } + public Dictionary? Body { get; set; } [JsonPropertyName("feet")] - public Dictionary? Feet { get; set; } + public Dictionary? Feet { get; set; } [JsonPropertyName("hands")] [JsonConverter(typeof(ArrayToObjectFactoryConverter))] - public Dictionary? Hands { get; set; } + public Dictionary? Hands { get; set; } [JsonPropertyName("head")] [JsonConverter(typeof(ArrayToObjectFactoryConverter))] - public Dictionary? Head { get; set; } + public Dictionary? Head { get; set; } [JsonPropertyName("voice")] [JsonConverter(typeof(ArrayToObjectFactoryConverter))] - public Dictionary? Voice { get; set; } + public Dictionary? Voice { get; set; } } public class Chances @@ -303,7 +303,7 @@ public class GenerationData { /** key: number of items, value: weighting */ [JsonPropertyName("weights")] - public Dictionary? Weights { get; set; } + public Dictionary? Weights { get; set; } /** Array of item tpls */ [JsonPropertyName("whitelist")] diff --git a/Core/Models/Spt/Config/BotConfig.cs b/Core/Models/Spt/Config/BotConfig.cs index b9c15c59..a034d7c6 100644 --- a/Core/Models/Spt/Config/BotConfig.cs +++ b/Core/Models/Spt/Config/BotConfig.cs @@ -106,7 +106,7 @@ public class AssaultToBossConversion public bool BossConvertEnabled { get; set; } [JsonPropertyName("bossesToConvertToWeights")] - public Dictionary BossesToConvertToWeights { get; set; } + public Dictionary BossesToConvertToWeights { get; set; } [JsonPropertyName("bossConvertMinMax")] public Dictionary BossConvertMinMax { get; set; } diff --git a/Core/Models/Spt/Config/PmcConfig.cs b/Core/Models/Spt/Config/PmcConfig.cs index eaf4b093..8ed2fd9e 100644 --- a/Core/Models/Spt/Config/PmcConfig.cs +++ b/Core/Models/Spt/Config/PmcConfig.cs @@ -12,11 +12,11 @@ public class PmcConfig : BaseConfig /** What game version should the PMC have */ [JsonPropertyName("gameVersionWeight")] - public Dictionary GameVersionWeight { get; set; } + public Dictionary GameVersionWeight { get; set; } /** What account type should the PMC have */ [JsonPropertyName("accountTypeWeight")] - public Dictionary AccountTypeWeight { get; set; } + public Dictionary AccountTypeWeight { get; set; } /** Global whitelist/blacklist of vest loot for PMCs */ [JsonPropertyName("vestLoot")] diff --git a/Core/Models/Spt/Config/WeatherConfig.cs b/Core/Models/Spt/Config/WeatherConfig.cs index f64fe8ab..f5190889 100644 --- a/Core/Models/Spt/Config/WeatherConfig.cs +++ b/Core/Models/Spt/Config/WeatherConfig.cs @@ -8,16 +8,16 @@ namespace Core.Models.Spt.Config; public class WeatherConfig : BaseConfig { [JsonPropertyName("kind")] - public string Kind { get; set; } = "spt-weather"; + public string? Kind { get; set; } = "spt-weather"; [JsonPropertyName("acceleration")] - public double Acceleration { get; set; } + public double? Acceleration { get; set; } [JsonPropertyName("weather")] - public WeatherValues Weather { get; set; } + public WeatherValues? Weather { get; set; } [JsonPropertyName("seasonDates")] - public List SeasonDates { get; set; } + public List? SeasonDates { get; set; } [JsonPropertyName("overrideSeason")] public Season? OverrideSeason { get; set; } @@ -26,86 +26,86 @@ public class WeatherConfig : BaseConfig public class SeasonDateTimes { [JsonPropertyName("seasonType")] - public Season SeasonType { get; set; } + public Season? SeasonType { get; set; } [JsonPropertyName("name")] - public string Name { get; set; } + public string? Name { get; set; } [JsonPropertyName("startDay")] [JsonConverter(typeof(StringToNumberFactoryConverter))] - public int StartDay { get; set; } + public int? StartDay { get; set; } [JsonPropertyName("startMonth")] [JsonConverter(typeof(StringToNumberFactoryConverter))] - public int StartMonth { get; set; } + public int? StartMonth { get; set; } [JsonPropertyName("endDay")] [JsonConverter(typeof(StringToNumberFactoryConverter))] - public int EndDay { get; set; } + public int? EndDay { get; set; } [JsonPropertyName("endMonth")] [JsonConverter(typeof(StringToNumberFactoryConverter))] - public int EndMonth { get; set; } + public int? EndMonth { get; set; } } public class WeatherValues { [JsonPropertyName("seasonValues")] - public Dictionary SeasonValues { get; set; } + public Dictionary? SeasonValues { get; set; } /** How many hours to generate weather data into the future */ [JsonPropertyName("generateWeatherAmountHours")] - public int GenerateWeatherAmountHours { get; set; } + public int? GenerateWeatherAmountHours { get; set; } /** Length of each weather period */ [JsonPropertyName("timePeriod")] - public WeatherSettings TimePeriod { get; set; } + public WeatherSettings? TimePeriod { get; set; } } public class SeasonalValues { [JsonPropertyName("clouds")] - public WeatherSettings Clouds { get; set; } + public WeatherSettings? Clouds { get; set; } [JsonPropertyName("windSpeed")] - public WeatherSettings WindSpeed { get; set; } + public WeatherSettings? WindSpeed { get; set; } [JsonPropertyName("windDirection")] - public WeatherSettings WindDirection { get; set; } + public WeatherSettings? WindDirection { get; set; } [JsonPropertyName("windGustiness")] - public MinMax WindGustiness { get; set; } + public MinMax? WindGustiness { get; set; } [JsonPropertyName("rain")] - public WeatherSettings Rain { get; set; } + public WeatherSettings? Rain { get; set; } [JsonPropertyName("rainIntensity")] - public MinMax RainIntensity { get; set; } + public MinMax? RainIntensity { get; set; } [JsonPropertyName("fog")] - public WeatherSettings Fog { get; set; } + public WeatherSettings? Fog { get; set; } [JsonPropertyName("temp")] - public TempDayNight Temp { get; set; } + public TempDayNight? Temp { get; set; } [JsonPropertyName("pressure")] - public MinMax Pressure { get; set; } + public MinMax? Pressure { get; set; } } public class TempDayNight { [JsonPropertyName("day")] - public MinMax Day { get; set; } + public MinMax? Day { get; set; } [JsonPropertyName("night")] - public MinMax Night { get; set; } + public MinMax? Night { get; set; } } public class WeatherSettings { [JsonPropertyName("values")] - public List Values { get; set; } + public List? Values { get; set; } [JsonPropertyName("weights")] - public List Weights { get; set; } + public List? Weights { get; set; } } diff --git a/Core/Services/RaidWeatherService.cs b/Core/Services/RaidWeatherService.cs index a1813cee..35f6f818 100644 --- a/Core/Services/RaidWeatherService.cs +++ b/Core/Services/RaidWeatherService.cs @@ -54,7 +54,7 @@ public class RaidWeatherService var staringTimestampMs = _timeUtil.GetTodayMidnightTimeStamp(); // How far into future do we generate weather - var futureTimestampToReachMs = staringTimestampMs + _timeUtil.GetHoursAsSeconds(_weatherConfig.Weather.GenerateWeatherAmountHours) * 1000; // Convert to milliseconds + var futureTimestampToReachMs = staringTimestampMs + _timeUtil.GetHoursAsSeconds(_weatherConfig.Weather.GenerateWeatherAmountHours ?? 1) * 1000; // Convert to milliseconds // Keep adding new weather until we have reached desired future date var nextTimestampMs = staringTimestampMs; diff --git a/Core/Services/SeasonalEventService.cs b/Core/Services/SeasonalEventService.cs index 51cce4fc..39328d7a 100644 --- a/Core/Services/SeasonalEventService.cs +++ b/Core/Services/SeasonalEventService.cs @@ -320,13 +320,14 @@ public class SeasonalEventService if ( DateIsBetweenTwoDates( currentDate, - seasonRange.StartMonth, - seasonRange.StartDay, - seasonRange.EndMonth, - seasonRange.EndDay) + seasonRange.StartMonth ?? 0, + seasonRange.StartDay ?? 0, + seasonRange.EndMonth ?? 0, + seasonRange.EndDay ?? 0 + ) ) { - return seasonRange.SeasonType; + return seasonRange.SeasonType ?? Season.SUMMER; } }