Funny red spacemen (nukeops) (#8073)
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
@@ -106,6 +106,7 @@ namespace Content.Client.Entry
|
|||||||
prototypes.RegisterIgnore("instantSpell");
|
prototypes.RegisterIgnore("instantSpell");
|
||||||
prototypes.RegisterIgnore("roundAnnouncement");
|
prototypes.RegisterIgnore("roundAnnouncement");
|
||||||
prototypes.RegisterIgnore("wireLayout");
|
prototypes.RegisterIgnore("wireLayout");
|
||||||
|
prototypes.RegisterIgnore("nukeopsRole");
|
||||||
|
|
||||||
ClientContentIoC.Register();
|
ClientContentIoC.Register();
|
||||||
|
|
||||||
|
|||||||
165
Content.Server/GameTicking/Rules/NukeopsRuleSystem.cs
Normal file
165
Content.Server/GameTicking/Rules/NukeopsRuleSystem.cs
Normal file
@@ -0,0 +1,165 @@
|
|||||||
|
using System.Linq;
|
||||||
|
using Content.Server.Chat.Managers;
|
||||||
|
using Content.Server.Nuke;
|
||||||
|
using Content.Server.RoundEnd;
|
||||||
|
using Content.Server.Station.Components;
|
||||||
|
using Content.Server.Station.Systems;
|
||||||
|
using Content.Shared.CCVar;
|
||||||
|
using Content.Shared.MobState;
|
||||||
|
using Content.Shared.Roles;
|
||||||
|
using Robust.Server.Maps;
|
||||||
|
using Robust.Server.Player;
|
||||||
|
using Robust.Shared.Configuration;
|
||||||
|
using Robust.Shared.Map;
|
||||||
|
using Robust.Shared.Physics.Collision.Shapes;
|
||||||
|
using Robust.Shared.Prototypes;
|
||||||
|
using Robust.Shared.Random;
|
||||||
|
using Robust.Shared.Utility;
|
||||||
|
|
||||||
|
namespace Content.Server.GameTicking.Rules;
|
||||||
|
|
||||||
|
public sealed class NukeopsRuleSystem : GameRuleSystem
|
||||||
|
{
|
||||||
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||||
|
[Dependency] private readonly IRobustRandom _random = default!;
|
||||||
|
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
||||||
|
[Dependency] private readonly IChatManager _chatManager = default!;
|
||||||
|
[Dependency] private readonly IMapLoader _mapLoader = default!;
|
||||||
|
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||||
|
[Dependency] private readonly StationSpawningSystem _stationSpawningSystem = default!;
|
||||||
|
[Dependency] private readonly StationSystem _stationSystem = default!;
|
||||||
|
[Dependency] private readonly RoundEndSystem _roundEndSystem = default!;
|
||||||
|
|
||||||
|
private Dictionary<Mind.Mind, bool> _aliveNukeops = new();
|
||||||
|
private bool _opsWon;
|
||||||
|
|
||||||
|
public override string Prototype => "Nukeops";
|
||||||
|
|
||||||
|
public override void Initialize()
|
||||||
|
{
|
||||||
|
base.Initialize();
|
||||||
|
|
||||||
|
SubscribeLocalEvent<RoundStartAttemptEvent>(OnStartAttempt);
|
||||||
|
SubscribeLocalEvent<RulePlayerSpawningEvent>(OnPlayersSpawning);
|
||||||
|
SubscribeLocalEvent<MobStateChangedEvent>(OnMobStateChanged);
|
||||||
|
SubscribeLocalEvent<RoundEndTextAppendEvent>(OnRoundEndText);
|
||||||
|
SubscribeLocalEvent<NukeExplodedEvent>(OnNukeExploded);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnNukeExploded(NukeExplodedEvent ev)
|
||||||
|
{
|
||||||
|
if (!Enabled) return;
|
||||||
|
|
||||||
|
_opsWon = true;
|
||||||
|
_roundEndSystem.EndRound();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnRoundEndText(RoundEndTextAppendEvent ev)
|
||||||
|
{
|
||||||
|
ev.AddLine(_opsWon ? Loc.GetString("nukeops-ops-won") : Loc.GetString("nukeops-crew-won"));
|
||||||
|
ev.AddLine(Loc.GetString("nukeops-list-start"));
|
||||||
|
foreach (var nukeop in _aliveNukeops)
|
||||||
|
{
|
||||||
|
ev.AddLine($"- {nukeop.Key.Session?.Name}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnMobStateChanged(MobStateChangedEvent ev)
|
||||||
|
{
|
||||||
|
if (!_aliveNukeops.TryFirstOrNull(x => x.Key.OwnedEntity == ev.Entity, out var op)) return;
|
||||||
|
|
||||||
|
_aliveNukeops[op.Value.Key] = op.Value.Key.CharacterDeadIC;
|
||||||
|
|
||||||
|
if (_aliveNukeops.Values.All(x => !x))
|
||||||
|
{
|
||||||
|
_roundEndSystem.EndRound();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnPlayersSpawning(RulePlayerSpawningEvent ev)
|
||||||
|
{
|
||||||
|
_aliveNukeops.Clear();
|
||||||
|
|
||||||
|
var numOps = (int)Math.Min(Math.Floor((double)ev.PlayerPool.Count / _cfg.GetCVar(CCVars.NukeopsPlayersPerOp)),
|
||||||
|
_cfg.GetCVar(CCVars.NukeopsMaxOps));
|
||||||
|
var ops = new IPlayerSession[numOps];
|
||||||
|
for (var i = 0; i < numOps; i++)
|
||||||
|
{
|
||||||
|
ops[i] = _random.PickAndTake(ev.PlayerPool);
|
||||||
|
}
|
||||||
|
|
||||||
|
var map = "/Maps/syndiepuddle.yml";
|
||||||
|
|
||||||
|
var aabbs = _stationSystem.Stations.SelectMany(x =>
|
||||||
|
Comp<StationDataComponent>(x).Grids.Select(x => _mapManager.GetGridComp(x).Grid.WorldBounds.CalcBoundingBox())).ToArray();
|
||||||
|
var aabb = aabbs[0];
|
||||||
|
for (int i = 1; i < aabbs.Length; i++)
|
||||||
|
{
|
||||||
|
aabb.Union(aabbs[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
var (_, grid) = _mapLoader.LoadBlueprint(GameTicker.DefaultMap, map, new MapLoadOptions
|
||||||
|
{
|
||||||
|
Offset = aabb.Center + MathF.Max(aabb.Height, aabb.Width)*2.5f
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!grid.HasValue)
|
||||||
|
{
|
||||||
|
Logger.ErrorS("NUKEOPS", $"Gridid was null when loading \"{map}\", aborting.");
|
||||||
|
foreach (var session in ops)
|
||||||
|
{
|
||||||
|
ev.PlayerPool.Add(session);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var gear = _prototypeManager.Index<StartingGearPrototype>("SyndicateOperativeGearFull");
|
||||||
|
var spawnpos = new EntityCoordinates(_mapManager.GetGridEuid(grid.Value), new Vector2(1.5f, -4.5f));
|
||||||
|
for (var i = 0; i < ops.Length; i++)
|
||||||
|
{
|
||||||
|
var session = ops[i];
|
||||||
|
var name = $"Operator #{i}";
|
||||||
|
var newMind = new Mind.Mind(session.UserId)
|
||||||
|
{
|
||||||
|
CharacterName = name
|
||||||
|
};
|
||||||
|
newMind.ChangeOwningPlayer(session.UserId);
|
||||||
|
|
||||||
|
var mob = EntityManager.SpawnEntity("MobHuman", spawnpos);
|
||||||
|
EntityManager.GetComponent<MetaDataComponent>(mob).EntityName = name;
|
||||||
|
|
||||||
|
newMind.TransferTo(mob);
|
||||||
|
_stationSpawningSystem.EquipStartingGear(mob, gear, null);
|
||||||
|
|
||||||
|
_aliveNukeops.Add(newMind, true);
|
||||||
|
|
||||||
|
GameTicker.PlayerJoinGame(session);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnStartAttempt(RoundStartAttemptEvent ev)
|
||||||
|
{
|
||||||
|
if (!Enabled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var minPlayers = _cfg.GetCVar(CCVars.NukeopsMinPlayers);
|
||||||
|
if (!ev.Forced && ev.Players.Length < minPlayers)
|
||||||
|
{
|
||||||
|
_chatManager.DispatchServerAnnouncement(Loc.GetString("nukeops-not-enough-ready-players", ("readyPlayersCount", ev.Players.Length), ("minimumPlayers", minPlayers)));
|
||||||
|
ev.Cancel();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ev.Players.Length == 0)
|
||||||
|
{
|
||||||
|
_chatManager.DispatchServerAnnouncement(Loc.GetString("nukeops-no-one-ready"));
|
||||||
|
ev.Cancel();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override void Started(){ _opsWon = false; }
|
||||||
|
|
||||||
|
public override void Ended(){ }
|
||||||
|
}
|
||||||
@@ -400,6 +400,8 @@ namespace Content.Server.Nuke
|
|||||||
component.IntensitySlope,
|
component.IntensitySlope,
|
||||||
component.MaxIntensity);
|
component.MaxIntensity);
|
||||||
|
|
||||||
|
RaiseLocalEvent(new NukeExplodedEvent());
|
||||||
|
|
||||||
EntityManager.DeleteEntity(uid);
|
EntityManager.DeleteEntity(uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -416,4 +418,6 @@ namespace Content.Server.Nuke
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public sealed class NukeExplodedEvent : EntityEventArgs {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -254,6 +254,19 @@ namespace Content.Shared.CCVar
|
|||||||
public static readonly CVarDef<int> TraitorDeathMatchStartingBalance =
|
public static readonly CVarDef<int> TraitorDeathMatchStartingBalance =
|
||||||
CVarDef.Create("traitordm.starting_balance", 20);
|
CVarDef.Create("traitordm.starting_balance", 20);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Nukeops
|
||||||
|
*/
|
||||||
|
|
||||||
|
public static readonly CVarDef<int> NukeopsMinPlayers =
|
||||||
|
CVarDef.Create("nukeops.min_players", 15);
|
||||||
|
|
||||||
|
public static readonly CVarDef<int> NukeopsMaxOps =
|
||||||
|
CVarDef.Create("nukeops.max_ops", 6);
|
||||||
|
|
||||||
|
public static readonly CVarDef<int> NukeopsPlayersPerOp =
|
||||||
|
CVarDef.Create("nukeops.players_per_op", 5);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Console
|
* Console
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
nukeops-title = Nuclear Operatives
|
||||||
|
nukeops-description = Nuclear operatives have targeted the station. Try to keep them from arming and detonating the nuke by protecting the nuke disk!
|
||||||
|
|
||||||
|
nukeops-ops-won = The nuke exploded. The nuclear operatives were successful!
|
||||||
|
nukeops-crew-won = The crew managed to defeat the nuclear operatives.
|
||||||
|
nukeops-list-start = The nuke ops were:
|
||||||
|
nukeops-not-enough-ready-players = Not enough players readied up for the game! There were {$readyPlayersCount} players readied up out of {$minimumPlayers} needed. Can't start Nukeops.
|
||||||
|
nukeops-no-one-ready = No players readied up! Can't start Nukeops.
|
||||||
File diff suppressed because it is too large
Load Diff
3
Resources/Prototypes/Access/syndicate.yml
Normal file
3
Resources/Prototypes/Access/syndicate.yml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
- type: accessLevel
|
||||||
|
id: NuclearOperative
|
||||||
|
name: Nuclear Operative
|
||||||
@@ -46,6 +46,14 @@
|
|||||||
- key: enum.NukeUiKey.Key
|
- key: enum.NukeUiKey.Key
|
||||||
type: NukeBoundUserInterface
|
type: NukeBoundUserInterface
|
||||||
|
|
||||||
|
- type: entity
|
||||||
|
parent: NuclearBomb
|
||||||
|
id: NuclearBombUnanchored
|
||||||
|
suffix: unanchored
|
||||||
|
components:
|
||||||
|
- type: Transform
|
||||||
|
anchored: false
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
parent: StorageTank
|
parent: StorageTank
|
||||||
id: NuclearBombKeg
|
id: NuclearBombKeg
|
||||||
|
|||||||
@@ -57,3 +57,13 @@
|
|||||||
rules:
|
rules:
|
||||||
- TraitorDeathMatch
|
- TraitorDeathMatch
|
||||||
- MaxTimeRestart
|
- MaxTimeRestart
|
||||||
|
|
||||||
|
- type: gamePreset
|
||||||
|
id: Nukeops
|
||||||
|
alias:
|
||||||
|
- nukeops
|
||||||
|
name: nukeops-title
|
||||||
|
description: nukeops-description
|
||||||
|
showInVote: true
|
||||||
|
rules:
|
||||||
|
- Nukeops
|
||||||
|
|||||||
@@ -7,6 +7,9 @@
|
|||||||
- type: gameRule
|
- type: gameRule
|
||||||
id: MaxTimeRestart
|
id: MaxTimeRestart
|
||||||
|
|
||||||
|
- type: gameRule
|
||||||
|
id: Nukeops
|
||||||
|
|
||||||
- type: gameRule
|
- type: gameRule
|
||||||
id: Suspicion
|
id: Suspicion
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user