From de36ebe2dfbcba11866b61a69d46c2d27077ee76 Mon Sep 17 00:00:00 2001 From: Kara Date: Sun, 25 Feb 2024 15:04:51 -0700 Subject: [PATCH] Don't double-dip survival intensity scaling (#25570) --- .../StationEvents/Events/AnomalySpawnRule.cs | 2 +- .../Events/BluespaceArtifactRule.cs | 2 +- .../Events/BureaucraticErrorRule.cs | 8 +++----- .../StationEvents/Events/GasLeakRule.cs | 4 +--- .../StationEvents/Events/MeteorSwarmRule.cs | 7 ++----- .../Events/RandomSentienceRule.cs | 3 +-- .../Events/StationEventSystem.cs | 20 ------------------- .../StationEvents/Events/VentClogRule.cs | 9 +++------ .../RampingStationEventSchedulerSystem.cs | 20 ------------------- 9 files changed, 12 insertions(+), 63 deletions(-) diff --git a/Content.Server/StationEvents/Events/AnomalySpawnRule.cs b/Content.Server/StationEvents/Events/AnomalySpawnRule.cs index a59af52f6d..48a3b900c4 100644 --- a/Content.Server/StationEvents/Events/AnomalySpawnRule.cs +++ b/Content.Server/StationEvents/Events/AnomalySpawnRule.cs @@ -33,7 +33,7 @@ public sealed class AnomalySpawnRule : StationEventSystem(uid, out var stationEvent)) return; - var mod = MathF.Sqrt(GetSeverityModifier()); - // Essentially we'll pick out a target amount of gas to leak, then a rate to leak it at, then work out the duration from there. if (TryFindRandomTile(out component.TargetTile, out var target, out component.TargetGrid, out component.TargetCoords)) { @@ -29,7 +27,7 @@ namespace Content.Server.StationEvents.Events component.LeakGas = RobustRandom.Pick(component.LeakableGases); // Was 50-50 on using normal distribution. - var totalGas = RobustRandom.Next(component.MinimumGas, component.MaximumGas) * mod; + var totalGas = RobustRandom.Next(component.MinimumGas, component.MaximumGas); var startAfter = stationEvent.StartDelay; component.MolesPerSecond = RobustRandom.Next(component.MinimumMolesPerSecond, component.MaximumMolesPerSecond); diff --git a/Content.Server/StationEvents/Events/MeteorSwarmRule.cs b/Content.Server/StationEvents/Events/MeteorSwarmRule.cs index ef84d0a9ae..192a620c9f 100644 --- a/Content.Server/StationEvents/Events/MeteorSwarmRule.cs +++ b/Content.Server/StationEvents/Events/MeteorSwarmRule.cs @@ -17,8 +17,7 @@ namespace Content.Server.StationEvents.Events { base.Started(uid, component, gameRule, args); - var mod = Math.Sqrt(GetSeverityModifier()); - component.WaveCounter = (int) (RobustRandom.Next(component.MinimumWaves, component.MaximumWaves) * mod); + component.WaveCounter = RobustRandom.Next(component.MinimumWaves, component.MaximumWaves); } protected override void ActiveTick(EntityUid uid, MeteorSwarmRuleComponent component, GameRuleComponent gameRule, float frameTime) @@ -29,8 +28,6 @@ namespace Content.Server.StationEvents.Events return; } - var mod = GetSeverityModifier(); - component.Cooldown -= frameTime; if (component.Cooldown > 0f) @@ -38,7 +35,7 @@ namespace Content.Server.StationEvents.Events component.WaveCounter--; - component.Cooldown += (component.MaximumCooldown - component.MinimumCooldown) * RobustRandom.NextFloat() / mod + component.MinimumCooldown; + component.Cooldown += (component.MaximumCooldown - component.MinimumCooldown) * RobustRandom.NextFloat() + component.MinimumCooldown; Box2? playableArea = null; var mapId = GameTicker.DefaultMap; diff --git a/Content.Server/StationEvents/Events/RandomSentienceRule.cs b/Content.Server/StationEvents/Events/RandomSentienceRule.cs index d90361fe96..4b7606d01f 100644 --- a/Content.Server/StationEvents/Events/RandomSentienceRule.cs +++ b/Content.Server/StationEvents/Events/RandomSentienceRule.cs @@ -11,7 +11,6 @@ public sealed class RandomSentienceRule : StationEventSystem stationsToNotify = new(); - var mod = GetSeverityModifier(); var targetList = new List>(); var query = EntityQueryEnumerator(); while (query.MoveNext(out var targetUid, out var target)) @@ -21,7 +20,7 @@ public sealed class RandomSentienceRule : StationEventSystem(); foreach (var target in targetList) diff --git a/Content.Server/StationEvents/Events/StationEventSystem.cs b/Content.Server/StationEvents/Events/StationEventSystem.cs index 221beccee7..a4f6bc70df 100644 --- a/Content.Server/StationEvents/Events/StationEventSystem.cs +++ b/Content.Server/StationEvents/Events/StationEventSystem.cs @@ -134,25 +134,5 @@ public abstract partial class StationEventSystem : GameRuleSystem where T GameTicker.EndGameRule(uid, component); } - public float GetSeverityModifier() - { - var ev = new GetSeverityModifierEvent(); - RaiseLocalEvent(ev); - return ev.Modifier; - } - #endregion } - -/// -/// Raised broadcast to determine what the severity modifier should be for an event, some positive number that can be multiplied with various things. -/// Handled by usually other game rules (like the ramping scheduler). -/// Most events should try and make use of this if possible. -/// -public sealed class GetSeverityModifierEvent : EntityEventArgs -{ - /// - /// Should be multiplied/added to rather than set, for commutativity. - /// - public float Modifier = 1.0f; -} diff --git a/Content.Server/StationEvents/Events/VentClogRule.cs b/Content.Server/StationEvents/Events/VentClogRule.cs index f378aec3fb..e263a5f4f6 100644 --- a/Content.Server/StationEvents/Events/VentClogRule.cs +++ b/Content.Server/StationEvents/Events/VentClogRule.cs @@ -28,9 +28,6 @@ public sealed class VentClogRule : StationEventSystem .Where(x => !x.Abstract) .Select(x => x.ID).ToList(); - // TODO: This is gross, but not much can be done until event refactor, which needs Dynamic. - var mod = (float) Math.Sqrt(GetSeverityModifier()); - foreach (var (_, transform) in EntityManager.EntityQuery()) { if (CompOrNull(transform.GridUid)?.Station != chosenStation) @@ -40,14 +37,14 @@ public sealed class VentClogRule : StationEventSystem var solution = new Solution(); - if (!RobustRandom.Prob(Math.Min(0.33f * mod, 1.0f))) + if (!RobustRandom.Prob(0.33f)) continue; - var pickAny = RobustRandom.Prob(Math.Min(0.05f * mod, 1.0f)); + var pickAny = RobustRandom.Prob(0.05f); var reagent = RobustRandom.Pick(pickAny ? allReagents : component.SafeishVentChemicals); var weak = component.WeakReagents.Contains(reagent); - var quantity = (weak ? component.WeakReagentQuantity : component.ReagentQuantity) * mod; + var quantity = weak ? component.WeakReagentQuantity : component.ReagentQuantity; solution.AddReagent(reagent, quantity); var foamEnt = Spawn("Foam", transform.Coordinates); diff --git a/Content.Server/StationEvents/RampingStationEventSchedulerSystem.cs b/Content.Server/StationEvents/RampingStationEventSchedulerSystem.cs index 5c972df52e..ef3b5cf18a 100644 --- a/Content.Server/StationEvents/RampingStationEventSchedulerSystem.cs +++ b/Content.Server/StationEvents/RampingStationEventSchedulerSystem.cs @@ -25,13 +25,6 @@ public sealed class RampingStationEventSchedulerSystem : GameRuleSystem(OnGetSeverityModifier); - } - protected override void Started(EntityUid uid, RampingStationEventSchedulerComponent component, GameRuleComponent gameRule, GameRuleStartedEvent args) { base.Started(uid, component, gameRule, args); @@ -73,19 +66,6 @@ public sealed class RampingStationEventSchedulerSystem : GameRuleSystem(); - while (query.MoveNext(out var uid, out var scheduler, out var gameRule)) - { - if (!GameTicker.IsGameRuleActive(uid, gameRule)) - return; - - ev.Modifier *= GetChaosModifier(uid, scheduler); - Logger.Info($"Ramping set modifier to {ev.Modifier}"); - } - } - private void PickNextEventTime(EntityUid uid, RampingStationEventSchedulerComponent component) { var mod = GetChaosModifier(uid, component); -- 2.52.0