More events (#6894)
* Implements bureaucratic error and random sentience. * Adds the Vent Critters event. * bug moment * forgot ignores. * undo something i included in the PR by mistake. * address review
This commit is contained in:
@@ -118,7 +118,7 @@ namespace Content.Server.Chat.Managers
|
||||
_logs.Add(LogType.Chat, LogImpact.Low, $"Server announcement: {message}");
|
||||
}
|
||||
|
||||
public void DispatchStationAnnouncement(string message, string sender = "CentComm", bool playDefaultSound = true)
|
||||
public void DispatchStationAnnouncement(string message, string sender = "Central Command", bool playDefaultSound = true)
|
||||
{
|
||||
var messageWrap = Loc.GetString("chat-manager-sender-announcement-wrap-message", ("sender", sender));
|
||||
NetMessageToAll(ChatChannel.Radio, message, messageWrap);
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Content.Server.StationEvents.Components;
|
||||
|
||||
[RegisterComponent]
|
||||
public sealed class SentienceTargetComponent : Component
|
||||
{
|
||||
[DataField("flavorKind", required: true)]
|
||||
public string FlavorKind = default!;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Content.Server.StationEvents.Components;
|
||||
|
||||
[RegisterComponent]
|
||||
public sealed class VentCritterSpawnLocationComponent : Component
|
||||
{
|
||||
|
||||
}
|
||||
63
Content.Server/StationEvents/Events/BureaucraticError.cs
Normal file
63
Content.Server/StationEvents/Events/BureaucraticError.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using System.Linq;
|
||||
using Content.Server.Station;
|
||||
using Content.Shared.Roles;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Server.StationEvents.Events;
|
||||
|
||||
[UsedImplicitly]
|
||||
public sealed class BureaucraticError : StationEvent
|
||||
{
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
public override string? StartAnnouncement =>
|
||||
Loc.GetString("station-event-bureaucratic-error-announcement");
|
||||
public override string Name => "BureaucraticError";
|
||||
|
||||
public override string? StartAudio => "/Audio/Announcements/announce.ogg";
|
||||
|
||||
public override int MinimumPlayers => 25;
|
||||
|
||||
public override float Weight => WeightLow;
|
||||
|
||||
public override int? MaxOccurrences => 2;
|
||||
|
||||
protected override float EndAfter => 1f;
|
||||
|
||||
public override void Startup()
|
||||
{
|
||||
base.Startup();
|
||||
var chosenStation = _random.Pick(EntitySystem.Get<StationSystem>().StationInfo.Values.ToList());
|
||||
var jobList = chosenStation.JobList.Keys.Where(x => !_prototypeManager.Index<JobPrototype>(x).IsHead).ToList();
|
||||
|
||||
// Low chance to completely change up the late-join landscape by closing all positions except infinite slots.
|
||||
// Lower chance than the /tg/ equivalent of this event.
|
||||
if (_random.Prob(0.25f))
|
||||
{
|
||||
var chosenJob = _random.PickAndTake(jobList);
|
||||
chosenStation.AdjustJobAmount(chosenJob, -1); // INFINITE chaos.
|
||||
foreach (var job in jobList)
|
||||
{
|
||||
if (chosenStation.JobList[job] == -1)
|
||||
continue;
|
||||
chosenStation.AdjustJobAmount(job, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Changing every role is maybe a bit too chaotic so instead change 20-30% of them.
|
||||
for (var i = 0; i < _random.Next((int)(jobList.Count * 0.20), (int)(jobList.Count * 0.30)); i++)
|
||||
{
|
||||
var chosenJob = _random.PickAndTake(jobList);
|
||||
if (chosenStation.JobList[chosenJob] == -1)
|
||||
continue;
|
||||
|
||||
var adj = Math.Max(chosenStation.JobList[chosenJob] + _random.Next(-3, 6), 0);
|
||||
chosenStation.AdjustJobAmount(chosenJob, adj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,8 +10,8 @@ namespace Content.Server.StationEvents.Events;
|
||||
|
||||
public sealed class KudzuGrowth : StationEvent
|
||||
{
|
||||
[Dependency] private IRobustRandom _robustRandom = default!;
|
||||
[Dependency] private IEntityManager _entityManager = default!;
|
||||
[Dependency] private readonly IRobustRandom _robustRandom = default!;
|
||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||
|
||||
public override string Name => "KudzuGrowth";
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@ namespace Content.Server.StationEvents.Events
|
||||
{
|
||||
// Based on Goonstation style radiation storm with some TG elements (announcer, etc.)
|
||||
|
||||
[Dependency] private IEntityManager _entityManager = default!;
|
||||
[Dependency] private IRobustRandom _robustRandom = default!;
|
||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||
[Dependency] private readonly IRobustRandom _robustRandom = default!;
|
||||
|
||||
public override string Name => "RadiationStorm";
|
||||
public override string StartAnnouncement => Loc.GetString("station-event-radiation-storm-start-announcement");
|
||||
|
||||
55
Content.Server/StationEvents/Events/RandomSentience.cs
Normal file
55
Content.Server/StationEvents/Events/RandomSentience.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using System.Linq;
|
||||
using Content.Server.Chat.Managers;
|
||||
using Content.Server.Mind.Commands;
|
||||
using Content.Server.StationEvents.Components;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Server.StationEvents.Events;
|
||||
|
||||
public sealed class RandomSentience : StationEvent
|
||||
{
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||
[Dependency] private readonly IChatManager _chatManager = default!;
|
||||
|
||||
public override string Name => "RandomSentience";
|
||||
|
||||
public override float Weight => WeightNormal;
|
||||
|
||||
protected override float EndAfter => 1.0f;
|
||||
|
||||
public override void Startup()
|
||||
{
|
||||
base.Startup();
|
||||
|
||||
var targetList = _entityManager.EntityQuery<SentienceTargetComponent>().ToList();
|
||||
_random.Shuffle(targetList);
|
||||
|
||||
var toMakeSentient = _random.Next(2, 5);
|
||||
var groups = new HashSet<string>();
|
||||
|
||||
foreach (var target in targetList)
|
||||
{
|
||||
if (toMakeSentient-- == 0)
|
||||
break;
|
||||
|
||||
MakeSentientCommand.MakeSentient(target.Owner, _entityManager);
|
||||
_entityManager.RemoveComponent<SentienceTargetComponent>(target.Owner);
|
||||
groups.Add(target.FlavorKind);
|
||||
}
|
||||
|
||||
if (groups.Count == 0)
|
||||
return;
|
||||
|
||||
var groupList = groups.ToList();
|
||||
var kind1 = groupList.Count > 0 ? groupList[0] : "???";
|
||||
var kind2 = groupList.Count > 1 ? groupList[1] : "???";
|
||||
var kind3 = groupList.Count > 2 ? groupList[2] : "???";
|
||||
_chatManager.DispatchStationAnnouncement(
|
||||
Loc.GetString("station-event-random-sentience-announcement",
|
||||
("kind1", kind1), ("kind2", kind2), ("kind3", kind3), ("amount", groupList.Count),
|
||||
("data", Loc.GetString($"random-sentience-event-data-{_random.Next(1, 6)}")),
|
||||
("strength", Loc.GetString($"random-sentience-event-strength-{_random.Next(1, 8)}")))
|
||||
);
|
||||
}
|
||||
}
|
||||
52
Content.Server/StationEvents/Events/VentCritters.cs
Normal file
52
Content.Server/StationEvents/Events/VentCritters.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using System.Linq;
|
||||
using Content.Server.StationEvents.Components;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Server.StationEvents.Events;
|
||||
|
||||
public sealed class VentCritters : StationEvent
|
||||
{
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||
|
||||
public static List<string> SpawnedPrototypeChoices = new List<string>()
|
||||
{"MobGiantSpiderAngry", "MobMouse", "MobMouse1", "MobMouse2"};
|
||||
|
||||
public override string Name => "VentCritters";
|
||||
|
||||
public override string? StartAnnouncement =>
|
||||
Loc.GetString("station-event-vent-spiders-start-announcement", ("data", Loc.GetString(Loc.GetString($"random-sentience-event-data-{_random.Next(1, 6)}"))));
|
||||
|
||||
public override string? StartAudio => "/Audio/Announcements/bloblarm.ogg";
|
||||
|
||||
public override int EarliestStart => 15;
|
||||
|
||||
public override int MinimumPlayers => 15;
|
||||
|
||||
public override float Weight => WeightLow;
|
||||
|
||||
public override int? MaxOccurrences => 2;
|
||||
|
||||
protected override float StartAfter => 30f;
|
||||
|
||||
protected override float EndAfter => 60;
|
||||
|
||||
public override void Startup()
|
||||
{
|
||||
base.Startup();
|
||||
var spawnChoice = _random.Pick(SpawnedPrototypeChoices);
|
||||
var spawnLocations = _entityManager.EntityQuery<VentCritterSpawnLocationComponent>().ToList();
|
||||
_random.Shuffle(spawnLocations);
|
||||
|
||||
var spawnAmount = _random.Next(4, 12); // A small colony of critters.
|
||||
foreach (var location in spawnLocations)
|
||||
{
|
||||
if (spawnAmount-- == 0)
|
||||
break;
|
||||
|
||||
var coords = _entityManager.GetComponent<TransformComponent>(location.Owner);
|
||||
|
||||
_entityManager.SpawnEntity(spawnChoice, coords.Coordinates);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user