diff --git a/Content.Server/AlertLevel/AlertLevelSystem.cs b/Content.Server/AlertLevel/AlertLevelSystem.cs index 04e274ceeb5cf3..981835561c279c 100644 --- a/Content.Server/AlertLevel/AlertLevelSystem.cs +++ b/Content.Server/AlertLevel/AlertLevelSystem.cs @@ -96,6 +96,16 @@ private void OnPrototypeReload(PrototypesReloadedEventArgs args) 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/CommunicationInterceptionRuleComponent.cs b/Content.Server/StationEvents/Components/CommunicationInterceptionRuleComponent.cs new file mode 100644 index 00000000000000..754b08b470d131 --- /dev/null +++ b/Content.Server/StationEvents/Components/CommunicationInterceptionRuleComponent.cs @@ -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(CommunicationInterceptionRule))] +public sealed partial class CommunicationInterceptionRuleComponent : Component +{ + /// + /// Alert level to set the station to when the event starts. + /// + [DataField] + public ProtoId AlertLevel = "yellow"; +} diff --git a/Content.Server/StationEvents/Events/CommunicationInterceptionRule.cs b/Content.Server/StationEvents/Events/CommunicationInterceptionRule.cs new file mode 100644 index 00000000000000..9aad3a46b08f67 --- /dev/null +++ b/Content.Server/StationEvents/Events/CommunicationInterceptionRule.cs @@ -0,0 +1,31 @@ +using Content.Server.GameTicking.Rules.Components; +using Content.Server.StationEvents.Components; +using Content.Server.AlertLevel; +using Content.Server.Chat.Systems; +using Robust.Shared.Audio.Systems; +using Robust.Shared.Player; + +namespace Content.Server.StationEvents.Events; + +public sealed class CommunicationInterceptionRule : StationEventSystem +{ + [Dependency] private readonly AlertLevelSystem _alertLevelSystem = default!; + [Dependency] private readonly ChatSystem _chatSystem = default!; + [Dependency] private readonly SharedAudioSystem _audioSystem = default!; + + protected override void Started(EntityUid uid, CommunicationInterceptionRuleComponent 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); + _chatSystem.DispatchGlobalAnnouncement(Loc.GetString("station-event-communication-interception"), playSound: false, colorOverride: Color.Gold); + _audioSystem.PlayGlobal("/Audio/Announcements/intercept.ogg", Filter.Broadcast(), true); + } +} diff --git a/Resources/Audio/Announcements/attributions.yml b/Resources/Audio/Announcements/attributions.yml index 7bc8886f9317ac..593095a66019e2 100644 --- a/Resources/Audio/Announcements/attributions.yml +++ b/Resources/Audio/Announcements/attributions.yml @@ -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 index 00000000000000..3569a07d40193a 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 index 00000000000000..3f84b027be7a1a --- /dev/null +++ b/Resources/Locale/en-US/station-events/events/intercept.ftl @@ -0,0 +1 @@ +station-event-communication-interception = Attention! Enemy communication intercepted. Security level elevated. diff --git a/Resources/Prototypes/GameRules/events.yml b/Resources/Prototypes/GameRules/events.yml index 43155e28272baa..0e6fb79a4dfd98 100644 --- a/Resources/Prototypes/GameRules/events.yml +++ b/Resources/Prototypes/GameRules/events.yml @@ -430,6 +430,16 @@ minimumPlayers: 20 - type: ImmovableRodRule +- type: entity + id: CommunicationInterception + parent: BaseGameRule + noSpawn: true + components: + - type: StationEvent + weight: 10 + earliestStart: 5 + - type: CommunicationInterceptionRule + - type: entity noSpawn: true parent: BaseGameRule