]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Add syndicate sleeper agents random event (#27501)
authorMr. 27 <45323883+Dutch-VanDerLinde@users.noreply.github.com>
Fri, 3 May 2024 00:13:35 +0000 (20:13 -0400)
committerGitHub <noreply@github.com>
Fri, 3 May 2024 00:13:35 +0000 (10:13 +1000)
* Intercept rule (#10)

* add

* b

* add this back lol

* fix test fails (alert levels dont have prototypes)

* tweaks

Content.Server/AlertLevel/AlertLevelSystem.cs
Content.Server/StationEvents/Components/AlertLevelInterceptionRuleComponent.cs [new file with mode: 0644]
Content.Server/StationEvents/Events/AlertLevelInterceptionRule.cs [new file with mode: 0644]
Resources/Audio/Announcements/attributions.yml
Resources/Audio/Announcements/intercept.ogg [new file with mode: 0644]
Resources/Locale/en-US/station-events/events/intercept.ftl [new file with mode: 0644]
Resources/Prototypes/GameRules/events.yml

index 848170ba9dc03051b8e9365b23bb6dd1812a7ebd..0b49d7e4bfa897dcc9ec4067100930b1c24ba899 100644 (file)
@@ -96,6 +96,16 @@ public sealed class AlertLevelSystem : EntitySystem
         RaiseLocalEvent(new AlertLevelPrototypeReloadedEvent());
     }
 
+    public string GetLevel(EntityUid station, AlertLevelComponent? alert = null)
+    {
+        if (!Resolve(station, ref alert))
+        {
+            return string.Empty;
+        }
+
+        return alert.CurrentLevel;
+    }
+
     public float GetAlertLevelDelay(EntityUid station, AlertLevelComponent? alert = null)
     {
         if (!Resolve(station, ref alert))
diff --git a/Content.Server/StationEvents/Components/AlertLevelInterceptionRuleComponent.cs b/Content.Server/StationEvents/Components/AlertLevelInterceptionRuleComponent.cs
new file mode 100644 (file)
index 0000000..6907aa6
--- /dev/null
@@ -0,0 +1,15 @@
+using Content.Server.StationEvents.Events;
+using Content.Server.AlertLevel;
+using Robust.Shared.Prototypes;
+
+namespace Content.Server.StationEvents.Components;
+
+[RegisterComponent, Access(typeof(AlertLevelInterceptionRule))]
+public sealed partial class AlertLevelInterceptionRuleComponent : Component
+{
+    /// <summary>
+    /// Alert level to set the station to when the event starts.
+    /// </summary>
+    [DataField]
+    public string AlertLevel = "blue";
+}
diff --git a/Content.Server/StationEvents/Events/AlertLevelInterceptionRule.cs b/Content.Server/StationEvents/Events/AlertLevelInterceptionRule.cs
new file mode 100644 (file)
index 0000000..a78a542
--- /dev/null
@@ -0,0 +1,23 @@
+using Content.Server.GameTicking.Components;
+using Content.Server.StationEvents.Components;
+using Content.Server.AlertLevel;
+
+namespace Content.Server.StationEvents.Events;
+
+public sealed class AlertLevelInterceptionRule : StationEventSystem<AlertLevelInterceptionRuleComponent>
+{
+    [Dependency] private readonly AlertLevelSystem _alertLevelSystem = default!;
+
+    protected override void Started(EntityUid uid, AlertLevelInterceptionRuleComponent component, GameRuleComponent gameRule,
+        GameRuleStartedEvent args)
+    {
+        base.Started(uid, component, gameRule, args);
+
+        if (!TryGetRandomStation(out var chosenStation))
+            return;
+        if (_alertLevelSystem.GetLevel(chosenStation.Value) != "green")
+            return;
+
+        _alertLevelSystem.SetLevel(chosenStation.Value, component.AlertLevel, true, true, true);
+    }
+}
\ No newline at end of file
index 7bc8886f9317acf556199b02f5a929980aeb52c9..593095a66019e2af8844ccbe0c82da30dac777f9 100644 (file)
@@ -42,3 +42,8 @@
   license: "CC-BY-SA-3.0"
   copyright: "Paradise, volume and pitch changed, merged with redalert.ogg"
   source: "https://github.com/ParadiseSS13/Paradise/blob/07b26ee6b4a11a0607986d322ee007020569feae/sound/effects/siren.ogg"
+
+- files: ["intercept.ogg"]
+  license: "CC-BY-SA-3.0"
+  copyright: "Taken from tgstation"
+  source: "https://github.com/tgstation/tgstation/blob/95731342b97167d7883ff091d389f79c36442ee6/sound/ai/default/intercept.ogg"
diff --git a/Resources/Audio/Announcements/intercept.ogg b/Resources/Audio/Announcements/intercept.ogg
new file mode 100644 (file)
index 0000000..3569a07
Binary files /dev/null and b/Resources/Audio/Announcements/intercept.ogg differ
diff --git a/Resources/Locale/en-US/station-events/events/intercept.ftl b/Resources/Locale/en-US/station-events/events/intercept.ftl
new file mode 100644 (file)
index 0000000..3f84b02
--- /dev/null
@@ -0,0 +1 @@
+station-event-communication-interception = Attention! Enemy communication intercepted. Security level elevated.
index afc3a10cbd85f6fe790a4252ef64e8c4bd23accc..73475a1184ef3ab022117fdfb789e8d2172ea942 100644 (file)
       - type: NukeopsRole
         prototype: Nukeops
 
+- type: entity
+  id: SleeperAgentsRule
+  parent: BaseGameRule
+  noSpawn: true
+  components:
+  - type: StationEvent
+    earliestStart: 25
+    weight: 15
+    minimumPlayers: 15
+    reoccurrenceDelay: 60
+    startAnnouncement: station-event-communication-interception
+    startAudio:
+      path: /Audio/Announcements/intercept.ogg
+  - type: AlertLevelInterceptionRule
+  - type: TraitorRule
+  - type: AntagSelection
+    definitions:
+    - prefRoles: [ Traitor ]
+      min: 1
+      max: 2
+      playerRatio: 10
+      mindComponents:
+      - type: TraitorRole
+        prototype: Traitor
+
 - type: entity
   id: MassHallucinations
   parent: BaseGameRule