Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sleeper agent fake announcement #28321

Closed
wants to merge 13 commits into from
11 changes: 11 additions & 0 deletions Content.Server/GameTicking/GameTicker.GameRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Robust.Shared.Console;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;

namespace Content.Server.GameTicking;

Expand Down Expand Up @@ -150,6 +151,16 @@ public bool StartGameRule(EntityUid ruleEntity, GameRuleComponent? ruleData = nu
_allPreviousGameRules.Add((currentTime, id));
}

if (ruleData.FalseActivationProb != 0f)
{
if (_robustRandom.Prob(ruleData.FalseActivationProb))
{
_adminLogger.Add(LogType.EventStarted, LogImpact.High, $"Event fake started: {ToPrettyString(ruleEntity)}");
EndGameRule(ruleEntity, ruleData);
return false;
}
}

_sawmill.Info($"Started game rule {ToPrettyString(ruleEntity)}");
_adminLogger.Add(LogType.EventStarted, $"Started game rule {ToPrettyString(ruleEntity)}");

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Content.Server.StationEvents.Events;

namespace Content.Server.StationEvents.Components;

[RegisterComponent, Access(typeof(StartStationEventRule))]
public sealed partial class StartStationEventRuleComponent : Component
{

}
15 changes: 15 additions & 0 deletions Content.Server/StationEvents/Components/StationEventComponent.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using Robust.Shared.Audio;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
using Content.Server.AlertLevel;

namespace Content.Server.StationEvents.Components;

Expand Down Expand Up @@ -48,6 +50,19 @@ public sealed partial class StationEventComponent : Component
[DataField]
public int ReoccurrenceDelay = 30;


/// <summary>
/// Alert level to set the station to when the event starts.
/// </summary>
[DataField]
public ProtoId<AlertLevelPrototype>? AlertLevel;

/// <summary>
/// Alarm level that will NOT be ignored when the event starts
/// </summary>
[DataField]
public ProtoId<AlertLevelPrototype>? NotIgnoredAlarmLevel = "green";

/// <summary>
/// How long the event lasts.
/// </summary>
Expand Down
23 changes: 0 additions & 23 deletions Content.Server/StationEvents/Events/AlertLevelInterceptionRule.cs

This file was deleted.

15 changes: 15 additions & 0 deletions Content.Server/StationEvents/Events/StartStationEventRule.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Content.Server.StationEvents.Components;
using Content.Shared.GameTicking.Components;

namespace Content.Server.StationEvents.Events;

//TO DO: delete and forget about this as the worst joke ever.
public sealed class StartStationEventRule : StationEventSystem<StartStationEventRuleComponent>
{
protected override void Started(EntityUid uid, StartStationEventRuleComponent component, GameRuleComponent gameRule, GameRuleStartedEvent args)
{
if (!TryComp<StationEventComponent>(uid, out var stationEvent))
return;
base.Started(uid, component, gameRule, args);
}
}
13 changes: 13 additions & 0 deletions Content.Server/StationEvents/Events/StationEventSystem.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using Content.Server.Administration.Logs;
using Content.Server.Chat.Systems;
using Content.Server.GameTicking.Rules;
using Content.Server.GameTicking.Rules.Components;
using Content.Server.AlertLevel;
using Content.Server.Station.Systems;
using Content.Server.StationEvents.Components;
using Content.Shared.Database;
Expand All @@ -21,6 +23,7 @@ public abstract class StationEventSystem<T> : GameRuleSystem<T> where T : ICompo
[Dependency] protected readonly ChatSystem ChatSystem = default!;
[Dependency] protected readonly SharedAudioSystem Audio = default!;
[Dependency] protected readonly StationSystem StationSystem = default!;
[Dependency] protected readonly AlertLevelSystem _alertLevelSystem = default!;

protected ISawmill Sawmill = default!;

Expand All @@ -44,6 +47,16 @@ protected override void Added(EntityUid uid, T component, GameRuleComponent game
if (stationEvent.StartAnnouncement != null)
ChatSystem.DispatchGlobalAnnouncement(Loc.GetString(stationEvent.StartAnnouncement), playSound: false, colorOverride: stationEvent.StartAnnouncementColor);

if (stationEvent.AlertLevel != null)
{
if (!TryGetRandomStation(out var chosenStation))
return;
if (_alertLevelSystem.GetLevel(chosenStation.Value) != stationEvent.NotIgnoredAlarmLevel)
return;

_alertLevelSystem.SetLevel(chosenStation.Value, stationEvent.AlertLevel, true, true, true);
}

Audio.PlayGlobal(stationEvent.StartAudio, Filter.Broadcast(), true);
}

Expand Down
6 changes: 6 additions & 0 deletions Content.Shared/GameTicking/Components/GameRuleComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ public sealed partial class GameRuleComponent : Component
/// </summary>
[DataField(customTypeSerializer: typeof(TimeOffsetSerializer))]
public TimeSpan ActivatedAt;

/// <summary>
/// A floating indicator of how often an event can be falsely triggered
/// </summary>
[DataField]
public float FalseActivationProb = 0f;

/// <summary>
/// The minimum amount of players needed for this game rule.
Expand Down
5 changes: 4 additions & 1 deletion Resources/Prototypes/GameRules/events.yml
Original file line number Diff line number Diff line change
Expand Up @@ -447,16 +447,19 @@
parent: BaseTraitorRule
id: SleeperAgents
components:
- type: GameRule
falseActivationProb: 0.5
- type: StationEvent
earliestStart: 30
weight: 8
minimumPlayers: 15
alertLevel: blue
maxOccurrences: 1 # can only happen once per round
startAnnouncement: station-event-communication-interception
startAudio:
path: /Audio/Announcements/intercept.ogg
duration: null # the rule has to last the whole round not 1 second
- type: AlertLevelInterceptionRule
- type: StartStationEventRule
- type: AntagSelection
definitions:
- prefRoles: [ TraitorSleeper ]
Expand Down
Loading