From aacf5a1c5af4b522ed2703878d78d7b370d7f8ae Mon Sep 17 00:00:00 2001 From: deltanedas <@deltanedas:kde.org> Date: Sat, 21 Dec 2024 09:18:29 +0000 Subject: [PATCH 1/5] vent critters rework --- .../Components/VentCrittersRuleComponent.cs | 25 ++++++ .../StationEvents/Events/VentCrittersRule.cs | 86 ++++++++++++++----- .../station-events/events/vent-critters.ftl | 1 + Resources/Prototypes/GameRules/events.yml | 9 +- 4 files changed, 94 insertions(+), 27 deletions(-) create mode 100644 Resources/Locale/en-US/deltav/station-events/events/vent-critters.ftl diff --git a/Content.Server/StationEvents/Components/VentCrittersRuleComponent.cs b/Content.Server/StationEvents/Components/VentCrittersRuleComponent.cs index f280468fc34..bc72bab5f86 100644 --- a/Content.Server/StationEvents/Components/VentCrittersRuleComponent.cs +++ b/Content.Server/StationEvents/Components/VentCrittersRuleComponent.cs @@ -1,5 +1,6 @@ using Content.Server.StationEvents.Events; using Content.Shared.Storage; +using Robust.Shared.Map; // DeltaV namespace Content.Server.StationEvents.Components; @@ -14,4 +15,28 @@ public sealed partial class VentCrittersRuleComponent : Component /// [DataField("specialEntries")] public List SpecialEntries = new(); + + /// + /// DeltaV: The location of the vent that got picked. + /// + [ViewVariables] + public EntityCoordinates? Location = new(); + + /// + /// DeltaV: Base minimum number of critters to spawn. + /// + [DataField] + public int Min = 2; + + /// + /// DeltaV: Base maximum number of critters to spawn. + /// + [DataField] + public int Max = 3; + + /// + /// DeltaV: Min and max get multiplied by the player count then divided by this. + /// + [DataField] + public int PlayerRatio = 25; } diff --git a/Content.Server/StationEvents/Events/VentCrittersRule.cs b/Content.Server/StationEvents/Events/VentCrittersRule.cs index aee141f2dba..b60f803775d 100644 --- a/Content.Server/StationEvents/Events/VentCrittersRule.cs +++ b/Content.Server/StationEvents/Events/VentCrittersRule.cs @@ -1,13 +1,23 @@ -using Content.Server.StationEvents.Components; +using Content.Server.Antag; using Content.Server.GameTicking.Rules.Components; +using Content.Server.Pinpointer; +using Content.Server.StationEvents.Components; using Content.Shared.GameTicking.Components; using Content.Shared.Station.Components; using Content.Shared.Storage; using Robust.Shared.Map; +using Robust.Shared.Player; using Robust.Shared.Random; namespace Content.Server.StationEvents.Events; +/// +/// DeltaV: Reworked vent critters to spawn a number of mobs at a single telegraphed location. +/// This gives players time to run away and let sec do their job. +/// +/// +/// This entire file is rewritten, ignore upstream changes. +/// public sealed class VentCrittersRule : StationEventSystem { /* @@ -15,45 +25,75 @@ public sealed class VentCrittersRule : StationEventSystem _locations = new(); + + protected override void Added(EntityUid uid, VentCrittersRuleComponent component, GameRuleComponent gameRule, GameRuleAddedEvent args) + { + PickLocation(component); + if (component.Location is not {} coords) { + ForceEndSelf(uid, gameRule); return; } - var locations = EntityQueryEnumerator(); - var validLocations = new List(); - while (locations.MoveNext(out _, out _, out var transform)) + var mapCoords = _transform.ToMapCoordinates(coords); + if (!_navMap.TryGetNearestBeacon(mapCoords, out var beacon, out _)) + return; + + var nearest = beacon?.Comp?.Text!; + Comp(uid).StartAnnouncement = Loc.GetString("station-event-vent-creatures-start-announcement-deltav", ("location", nearest)); + + base.Added(uid, component, gameRule, args); + } + + protected override void Ended(EntityUid uid, VentCrittersRuleComponent comp, GameRuleComponent gameRule, GameRuleEndedEvent args) + { + base.Ended(uid, comp, gameRule, args); + + if (comp.Location is not {} coords) + return; + + var players = _antag.GetTotalPlayerCount(_player.Sessions); + var min = comp.Min * players / comp.PlayerRatio; + var max = comp.Max * players / comp.PlayerRatio; + var count = Math.Max(RobustRandom.Next(min, max), 1); + for (int i = 0; i < count; i++) { - if (CompOrNull(transform.GridUid)?.Station == station) + foreach (var spawn in EntitySpawnCollection.GetSpawns(comp.Entries, RobustRandom)) { - validLocations.Add(transform.Coordinates); - foreach (var spawn in EntitySpawnCollection.GetSpawns(component.Entries, RobustRandom)) - { - Spawn(spawn, transform.Coordinates); - } + Spawn(spawn, coords); } } - if (component.SpecialEntries.Count == 0 || validLocations.Count == 0) - { + if (comp.SpecialEntries.Count == 0) return; - } // guaranteed spawn - var specialEntry = RobustRandom.Pick(component.SpecialEntries); - var specialSpawn = RobustRandom.Pick(validLocations); - Spawn(specialEntry.PrototypeId, specialSpawn); + var specialEntry = RobustRandom.Pick(comp.SpecialEntries); + Spawn(specialEntry.PrototypeId, coords); + } + + private void PickLocation(VentCrittersRuleComponent component) + { + if (!TryGetRandomStation(out var station)) + return; - foreach (var location in validLocations) + var locations = EntityQueryEnumerator(); + _locations.Clear(); + while (locations.MoveNext(out _, out _, out var transform)) { - foreach (var spawn in EntitySpawnCollection.GetSpawns(component.SpecialEntries, RobustRandom)) + if (CompOrNull(transform.GridUid)?.Station == station) { - Spawn(spawn, location); + _locations.Add(transform.Coordinates); } } + + if (_locations.Count > 0) + component.Location = RobustRandom.Pick(_locations); } } diff --git a/Resources/Locale/en-US/deltav/station-events/events/vent-critters.ftl b/Resources/Locale/en-US/deltav/station-events/events/vent-critters.ftl new file mode 100644 index 00000000000..046b0ca7126 --- /dev/null +++ b/Resources/Locale/en-US/deltav/station-events/events/vent-critters.ftl @@ -0,0 +1 @@ +station-event-vent-creatures-start-announcement-deltav = Attention. A large influx of unknown life forms has been detected in ventilation systems near {$location}. All personnel must vacate the area immediately. diff --git a/Resources/Prototypes/GameRules/events.yml b/Resources/Prototypes/GameRules/events.yml index b22bc621c80..2ca3b91f27a 100644 --- a/Resources/Prototypes/GameRules/events.yml +++ b/Resources/Prototypes/GameRules/events.yml @@ -389,7 +389,7 @@ earliestStart: 20 minimumPlayers: 15 weight: 5 - duration: 60 + duration: 15 # DeltaV: was 60, used as a delay now - type: PrecognitionResult # DeltaV - Precogniton message: psionic-power-precognition-slimes-spawn-result-message - type: VentCrittersRule @@ -412,7 +412,7 @@ earliestStart: 20 minimumPlayers: 15 weight: 5 - duration: 60 + duration: 15 # DeltaV: was 60, used as a delay now - type: PrecognitionResult # DeltaV - Precogniton message: psionic-power-precognition-snake-spawn-result-message - type: VentCrittersRule @@ -435,7 +435,7 @@ earliestStart: 20 minimumPlayers: 15 weight: 5 - duration: 60 + duration: 15 # DeltaV: was 60, used as a delay now - type: PrecognitionResult # DeltaV - Precogniton message: psionic-power-precognition-spider-spawn-result-message - type: VentCrittersRule @@ -454,10 +454,11 @@ earliestStart: 45 # DeltaV - was 20 minimumPlayers: 30 # DeltaV - was 20 weight: 1 # DeltaV - was 1.5 - duration: 60 + duration: 15 # DeltaV: was 60, used as a delay now - type: PrecognitionResult # DeltaV - Precogniton message: psionic-power-precognition-spider-clown-spawn-result-message - type: VentCrittersRule + playerRatio: 35 # DeltaV: Clown spiders are very robust entries: - id: MobClownSpider prob: 0.03 # DeltaV - was 0.05 From 1e289355b5d93bea33f3e4eae23a1010e024db0a Mon Sep 17 00:00:00 2001 From: deltanedas <@deltanedas:kde.org> Date: Sat, 21 Dec 2024 09:23:03 +0000 Subject: [PATCH 2/5] change pests timer to 15 --- Resources/Prototypes/GameRules/pests.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Resources/Prototypes/GameRules/pests.yml b/Resources/Prototypes/GameRules/pests.yml index 0bc1e582e37..c20256e6dff 100644 --- a/Resources/Prototypes/GameRules/pests.yml +++ b/Resources/Prototypes/GameRules/pests.yml @@ -27,7 +27,7 @@ path: /Audio/Announcements/attention.ogg earliestStart: 15 weight: 6 - duration: 50 + duration: 15 # DeltaV: was 50, used as a delay now - type: PrecognitionResult # DeltaV - Precogniton message: psionic-power-precognition-mouse-migration-result-message - type: VentCrittersRule @@ -52,7 +52,7 @@ path: /Audio/Announcements/attention.ogg earliestStart: 15 weight: 6 - duration: 50 + duration: 15 # DeltaV: was 50, used as a delay now minimumPlayers: 30 # Hopefully this is enough for the Rat King's potential Army (it was not, raised from 15 -> 30) - type: PrecognitionResult # DeltaV - Precogniton message: psionic-power-precognition-king-rat-migration-result-message @@ -79,7 +79,7 @@ startAudio: path: /Audio/Announcements/attention.ogg weight: 6 - duration: 50 + duration: 15 # DeltaV: was 50, used as a delay now - type: PrecognitionResult # DeltaV - Precogniton message: psionic-power-precognition-cockroach-migration-result-message - type: VentCrittersRule @@ -98,7 +98,7 @@ startAudio: path: /Audio/Announcements/attention.ogg weight: 6 - duration: 50 + duration: 15 # DeltaV: was 50, used as a delay now - type: PrecognitionResult # DeltaV - Precogniton message: psionic-power-precognition-snail-migration-result-message - type: VentCrittersRule @@ -120,7 +120,7 @@ path: /Audio/Announcements/attention.ogg earliestStart: 15 weight: 6 - duration: 50 + duration: 15 # DeltaV: was 50, used as a delay now minimumPlayers: 30 - type: PrecognitionResult # DeltaV - Precogniton message: psionic-power-precognition-snail-migration-result-message From 5ca8acf92da3c4150953573690bb1309ca2d8f18 Mon Sep 17 00:00:00 2001 From: deltanedas <@deltanedas:kde.org> Date: Sat, 21 Dec 2024 11:39:18 +0000 Subject: [PATCH 3/5] nullspace check and loggy --- .../StationEvents/Events/VentCrittersRule.cs | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Content.Server/StationEvents/Events/VentCrittersRule.cs b/Content.Server/StationEvents/Events/VentCrittersRule.cs index b60f803775d..25ec3920be3 100644 --- a/Content.Server/StationEvents/Events/VentCrittersRule.cs +++ b/Content.Server/StationEvents/Events/VentCrittersRule.cs @@ -32,10 +32,10 @@ public sealed class VentCrittersRule : StationEventSystem _locations = new(); - protected override void Added(EntityUid uid, VentCrittersRuleComponent component, GameRuleComponent gameRule, GameRuleAddedEvent args) + protected override void Added(EntityUid uid, VentCrittersRuleComponent comp, GameRuleComponent gameRule, GameRuleAddedEvent args) { - PickLocation(component); - if (component.Location is not {} coords) + PickLocation((uid, comp)); + if (comp.Location is not {} coords) { ForceEndSelf(uid, gameRule); return; @@ -48,7 +48,7 @@ protected override void Added(EntityUid uid, VentCrittersRuleComponent component var nearest = beacon?.Comp?.Text!; Comp(uid).StartAnnouncement = Loc.GetString("station-event-vent-creatures-start-announcement-deltav", ("location", nearest)); - base.Added(uid, component, gameRule, args); + base.Added(uid, comp, gameRule, args); } protected override void Ended(EntityUid uid, VentCrittersRuleComponent comp, GameRuleComponent gameRule, GameRuleEndedEvent args) @@ -78,22 +78,26 @@ protected override void Ended(EntityUid uid, VentCrittersRuleComponent comp, Gam Spawn(specialEntry.PrototypeId, coords); } - private void PickLocation(VentCrittersRuleComponent component) + private void PickLocation(Entity ent) { if (!TryGetRandomStation(out var station)) + { + Log.Warning($"{ToPrettyString(ent):rule} failed to get a station!"); return; + } var locations = EntityQueryEnumerator(); _locations.Clear(); - while (locations.MoveNext(out _, out _, out var transform)) + while (locations.MoveNext(out var uid, out _, out var transform)) { - if (CompOrNull(transform.GridUid)?.Station == station) + if (transform.MapID != MapId.Nullspace && CompOrNull(transform.GridUid)?.Station == station) { + Log.Debug($"Picking {ToPrettyString(uid)}"); _locations.Add(transform.Coordinates); } } if (_locations.Count > 0) - component.Location = RobustRandom.Pick(_locations); + ent.Comp.Location = RobustRandom.Pick(_locations); } } From 7ac42980d15edaeb75520169610420bc3db083ea Mon Sep 17 00:00:00 2001 From: deltanedas <@deltanedas:kde.org> Date: Sat, 21 Dec 2024 11:56:32 +0000 Subject: [PATCH 4/5] OH --- .../Components/VentCrittersRuleComponent.cs | 2 +- .../StationEvents/Events/VentCrittersRule.cs | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/Content.Server/StationEvents/Components/VentCrittersRuleComponent.cs b/Content.Server/StationEvents/Components/VentCrittersRuleComponent.cs index bc72bab5f86..a575075632e 100644 --- a/Content.Server/StationEvents/Components/VentCrittersRuleComponent.cs +++ b/Content.Server/StationEvents/Components/VentCrittersRuleComponent.cs @@ -20,7 +20,7 @@ public sealed partial class VentCrittersRuleComponent : Component /// DeltaV: The location of the vent that got picked. /// [ViewVariables] - public EntityCoordinates? Location = new(); + public EntityCoordinates? Location; /// /// DeltaV: Base minimum number of critters to spawn. diff --git a/Content.Server/StationEvents/Events/VentCrittersRule.cs b/Content.Server/StationEvents/Events/VentCrittersRule.cs index 25ec3920be3..20143a77591 100644 --- a/Content.Server/StationEvents/Events/VentCrittersRule.cs +++ b/Content.Server/StationEvents/Events/VentCrittersRule.cs @@ -34,7 +34,7 @@ public sealed class VentCrittersRule : StationEventSystem ent) + private void PickLocation(VentCrittersRuleComponent comp) { if (!TryGetRandomStation(out var station)) - { - Log.Warning($"{ToPrettyString(ent):rule} failed to get a station!"); return; - } var locations = EntityQueryEnumerator(); _locations.Clear(); while (locations.MoveNext(out var uid, out _, out var transform)) { - if (transform.MapID != MapId.Nullspace && CompOrNull(transform.GridUid)?.Station == station) + if (CompOrNull(transform.GridUid)?.Station == station) { - Log.Debug($"Picking {ToPrettyString(uid)}"); _locations.Add(transform.Coordinates); } } if (_locations.Count > 0) - ent.Comp.Location = RobustRandom.Pick(_locations); + comp.Location = RobustRandom.Pick(_locations); } } From 9078cda38ab3b716f240f7d77f4d8ceba0504512 Mon Sep 17 00:00:00 2001 From: deltanedas <@deltanedas:kde.org> Date: Mon, 23 Dec 2024 10:42:35 +0000 Subject: [PATCH 5/5] 15 -> 30 seconds --- Resources/Prototypes/DeltaV/GameRules/events.yml | 4 ++-- Resources/Prototypes/GameRules/events.yml | 8 ++++---- Resources/Prototypes/GameRules/pests.yml | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Resources/Prototypes/DeltaV/GameRules/events.yml b/Resources/Prototypes/DeltaV/GameRules/events.yml index 45a6a1d0237..94217ab589a 100644 --- a/Resources/Prototypes/DeltaV/GameRules/events.yml +++ b/Resources/Prototypes/DeltaV/GameRules/events.yml @@ -45,7 +45,7 @@ earliestStart: 45 minimumPlayers: 20 weight: 1 - duration: 60 + duration: 30 - type: PrecognitionResult message: psionic-power-precognition-xeno-vents-result-message - type: VentCrittersRule @@ -75,7 +75,7 @@ earliestStart: 15 minimumPlayers: 15 weight: 4 - duration: 60 + duration: 30 - type: PrecognitionResult message: psionic-power-precognition-mothroach-spawn-result-message - type: VentCrittersRule diff --git a/Resources/Prototypes/GameRules/events.yml b/Resources/Prototypes/GameRules/events.yml index 2ca3b91f27a..849a9418be8 100644 --- a/Resources/Prototypes/GameRules/events.yml +++ b/Resources/Prototypes/GameRules/events.yml @@ -389,7 +389,7 @@ earliestStart: 20 minimumPlayers: 15 weight: 5 - duration: 15 # DeltaV: was 60, used as a delay now + duration: 30 # DeltaV: was 60, used as a delay now - type: PrecognitionResult # DeltaV - Precogniton message: psionic-power-precognition-slimes-spawn-result-message - type: VentCrittersRule @@ -412,7 +412,7 @@ earliestStart: 20 minimumPlayers: 15 weight: 5 - duration: 15 # DeltaV: was 60, used as a delay now + duration: 30 # DeltaV: was 60, used as a delay now - type: PrecognitionResult # DeltaV - Precogniton message: psionic-power-precognition-snake-spawn-result-message - type: VentCrittersRule @@ -435,7 +435,7 @@ earliestStart: 20 minimumPlayers: 15 weight: 5 - duration: 15 # DeltaV: was 60, used as a delay now + duration: 30 # DeltaV: was 60, used as a delay now - type: PrecognitionResult # DeltaV - Precogniton message: psionic-power-precognition-spider-spawn-result-message - type: VentCrittersRule @@ -454,7 +454,7 @@ earliestStart: 45 # DeltaV - was 20 minimumPlayers: 30 # DeltaV - was 20 weight: 1 # DeltaV - was 1.5 - duration: 15 # DeltaV: was 60, used as a delay now + duration: 30 # DeltaV: was 60, used as a delay now - type: PrecognitionResult # DeltaV - Precogniton message: psionic-power-precognition-spider-clown-spawn-result-message - type: VentCrittersRule diff --git a/Resources/Prototypes/GameRules/pests.yml b/Resources/Prototypes/GameRules/pests.yml index c20256e6dff..8ddde7e1a61 100644 --- a/Resources/Prototypes/GameRules/pests.yml +++ b/Resources/Prototypes/GameRules/pests.yml @@ -27,7 +27,7 @@ path: /Audio/Announcements/attention.ogg earliestStart: 15 weight: 6 - duration: 15 # DeltaV: was 50, used as a delay now + duration: 30 # DeltaV: was 50, used as a delay now - type: PrecognitionResult # DeltaV - Precogniton message: psionic-power-precognition-mouse-migration-result-message - type: VentCrittersRule @@ -52,7 +52,7 @@ path: /Audio/Announcements/attention.ogg earliestStart: 15 weight: 6 - duration: 15 # DeltaV: was 50, used as a delay now + duration: 30 # DeltaV: was 50, used as a delay now minimumPlayers: 30 # Hopefully this is enough for the Rat King's potential Army (it was not, raised from 15 -> 30) - type: PrecognitionResult # DeltaV - Precogniton message: psionic-power-precognition-king-rat-migration-result-message @@ -79,7 +79,7 @@ startAudio: path: /Audio/Announcements/attention.ogg weight: 6 - duration: 15 # DeltaV: was 50, used as a delay now + duration: 30 # DeltaV: was 50, used as a delay now - type: PrecognitionResult # DeltaV - Precogniton message: psionic-power-precognition-cockroach-migration-result-message - type: VentCrittersRule @@ -98,7 +98,7 @@ startAudio: path: /Audio/Announcements/attention.ogg weight: 6 - duration: 15 # DeltaV: was 50, used as a delay now + duration: 30 # DeltaV: was 50, used as a delay now - type: PrecognitionResult # DeltaV - Precogniton message: psionic-power-precognition-snail-migration-result-message - type: VentCrittersRule @@ -120,7 +120,7 @@ path: /Audio/Announcements/attention.ogg earliestStart: 15 weight: 6 - duration: 15 # DeltaV: was 50, used as a delay now + duration: 30 # DeltaV: was 50, used as a delay now minimumPlayers: 30 - type: PrecognitionResult # DeltaV - Precogniton message: psionic-power-precognition-snail-migration-result-message