Skip to content

Commit

Permalink
Graytide Virus Event (#1293)
Browse files Browse the repository at this point in the history
# Description

This is a simple event remake of the classic Graytide Virus event from
SS13. A virus infects "Some of the airlocks" on the station, but more
specifically it infects the security airlocks, causing them to emag
themselves after a short delay. As the name of the airlock virus
implies, this lets the prisoners out, and the greytiders in, until an
engineer can get to sec and repair the airlocks. It can be a rare and
somewhat very literal "Get Outa Jail/Second Chance" for traitors who are
caught and permabrigged earlier in the round.

# Changelog

:cl:
- add: Added the GR4YT1D3 Virus event.

---------

Co-authored-by: sleepyyapril <[email protected]>
  • Loading branch information
VMSolidus and sleepyyapril authored Jan 2, 2025
1 parent 0002c8b commit 2e66dc9
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Content.Server.StationEvents.Events;

namespace Content.Server.StationEvents.Components;

[RegisterComponent]
public sealed partial class AirlockVirusRuleComponent : Component
{
/// <summary>
/// The minimum amount of time in seconds before each infected door is self-emagged.
/// </summary>
[DataField]
public int MinimumTimeToEmag = 30;

/// <summary>
/// The maximum amount of time in seconds before each infected door is self-emagged.
/// </summary>
[DataField]
public int MaximumTimeToEmag = 120;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
namespace Content.Server.StationEvents.Components;

[RegisterComponent]
public sealed partial class AirlockVirusTargetComponent : Component { }
58 changes: 58 additions & 0 deletions Content.Server/StationEvents/Events/AirlockVirusRule.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using Content.Server.StationEvents.Components;
using Content.Shared.GameTicking.Components;
using JetBrains.Annotations;
using Robust.Shared.Player;
using Robust.Shared.Random;
using Content.Server.Announcements.Systems;
using Content.Server.GameTicking;
using Content.Shared.Emag.Systems;
using Robust.Shared.Timing;
using Content.Server.Station.Components;
using Content.Server.Station.Systems;

namespace Content.Server.StationEvents.Events;

[UsedImplicitly]
public sealed class AirlockVirusRule : StationEventSystem<AirlockVirusRuleComponent>
{
[Dependency] private readonly AnnouncerSystem _announcer = default!;
[Dependency] private readonly GameTicker _gameTicker = default!;
[Dependency] private readonly EmagSystem _emag = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly StationSystem _station = default!;

protected override void Started(EntityUid uid, AirlockVirusRuleComponent component, GameRuleComponent gameRule, GameRuleStartedEvent args)
{
base.Started(uid, component, gameRule, args);

var station = _gameTicker.GetSpawnableStations();
if (station is null)
return;
var stationGrids = new HashSet<EntityUid>();
foreach (var stations in station)
{
if (TryComp<StationDataComponent>(stations, out var data) && _station.GetLargestGrid(data) is { } grid)
stationGrids.Add(grid);
}

var query = EntityManager.EntityQueryEnumerator<AirlockVirusTargetComponent>();
while (query.MoveNext(out var airlockUid, out var _))
{
var parent = Transform(airlockUid).GridUid;
if (parent is null
|| !stationGrids.Contains(parent!.Value))
continue;

Timer.Spawn(TimeSpan.FromSeconds(_random.NextDouble(component.MinimumTimeToEmag, component.MaximumTimeToEmag)), () =>
_emag.DoEmagEffect(uid, airlockUid));
}

_announcer.SendAnnouncement(
_announcer.GetAnnouncementId(args.RuleId),
Filter.Broadcast(),
"airlock-virus-event-announcement",
null,
Color.FromHex("#18abf5"),
null, null);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
airlock-virus-event-announcement = We have detected a GR4YT1D3 virus in the station's systems. Engineering staff are to inspect all station equipment for malfunctions and affect repairs if necessary.
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@
- type: ContainerFill
containers:
board: [ DoorElectronicsSecurity ]
- type: AirlockVirusTarget

- type: entity
parent: AirlockSecurity
Expand All @@ -369,6 +370,7 @@
- type: ContainerFill
containers:
board: [ DoorElectronicsDetective ]
- type: AirlockVirusTarget

#Delta V: Removed Brig Access
#- type: entity
Expand All @@ -388,6 +390,7 @@
- type: ContainerFill
containers:
board: [ DoorElectronicsSecurityLawyer ]
- type: AirlockVirusTarget

- type: entity
parent: AirlockSecurity
Expand Down Expand Up @@ -734,6 +737,7 @@
- type: ContainerFill
containers:
board: [ DoorElectronicsSecurity ]
- type: AirlockVirusTarget

- type: entity
parent: AirlockSecurityGlass
Expand All @@ -743,6 +747,7 @@
- type: ContainerFill
containers:
board: [ DoorElectronicsDetective ]
- type: AirlockVirusTarget

#- type: entity
# parent: AirlockSecurityGlass
Expand All @@ -761,6 +766,7 @@
- type: ContainerFill
containers:
board: [ DoorElectronicsSecurityLawyer ]
- type: AirlockVirusTarget

- type: entity
parent: AirlockSecurityGlass
Expand Down Expand Up @@ -1004,6 +1010,7 @@
board: [ DoorElectronicsSecurity ]
- type: Wires
layoutId: AirlockSecurity
- type: AirlockVirusTarget

- type: entity
parent: AirlockMaintSecLocked
Expand Down
12 changes: 12 additions & 0 deletions Resources/Prototypes/GameRules/events.yml
Original file line number Diff line number Diff line change
Expand Up @@ -585,3 +585,15 @@
maxOccurrences: 1 # this event has diminishing returns on interesting-ness, so we cap it
weight: 5
- type: MobReplacementRule

- type: entity
id: AirlockVirusRule
parent: BaseGameRule
categories: [ HideSpawnMenu ]
components:
- type: StationEvent
earliestStart: 15
minimumPlayers: 5
maxOccurrences: 1
weight: 3
- type: AirlockVirusRule

0 comments on commit 2e66dc9

Please sign in to comment.