Antag Rolebans (#35966)

Co-authored-by: beck-thompson <beck314159@hotmail.com>
Co-authored-by: Hannah Giovanna Dawson <karakkaraz@gmail.com>
This commit is contained in:
Errant
2025-09-17 23:59:07 +02:00
committed by GitHub
parent e1ba33814b
commit b692b6e33e
33 changed files with 898 additions and 283 deletions

View File

@@ -1,7 +1,9 @@
using Content.Server.Administration.Managers;
using Content.Server.Atmos.Components;
using Content.Server.Body.Components;
using Content.Server.Chat;
using Content.Server.Chat.Managers;
using Content.Server.Ghost;
using Content.Server.Ghost.Roles.Components;
using Content.Server.Humanoid;
using Content.Server.IdentityManagement;
@@ -14,6 +16,7 @@ using Content.Server.StationEvents.Components;
using Content.Server.Speech.Components;
using Content.Server.Temperature.Components;
using Content.Shared.Body.Components;
using Content.Shared.Chat;
using Content.Shared.CombatMode;
using Content.Shared.CombatMode.Pacification;
using Content.Shared.Damage;
@@ -40,6 +43,7 @@ using Content.Shared.Tag;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Content.Shared.NPC.Prototypes;
using Content.Shared.Roles;
namespace Content.Server.Zombies;
@@ -52,23 +56,27 @@ namespace Content.Server.Zombies;
public sealed partial class ZombieSystem
{
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly IBanManager _ban = default!;
[Dependency] private readonly IChatManager _chatMan = default!;
[Dependency] private readonly SharedCombatModeSystem _combat = default!;
[Dependency] private readonly NpcFactionSystem _faction = default!;
[Dependency] private readonly GhostSystem _ghost = default!;
[Dependency] private readonly SharedHandsSystem _hands = default!;
[Dependency] private readonly HumanoidAppearanceSystem _humanoidAppearance = default!;
[Dependency] private readonly IdentitySystem _identity = default!;
[Dependency] private readonly ServerInventorySystem _inventory = default!;
[Dependency] private readonly MindSystem _mind = default!;
[Dependency] private readonly MovementSpeedModifierSystem _movementSpeedModifier = default!;
[Dependency] private readonly NameModifierSystem _nameMod = default!;
[Dependency] private readonly NPCSystem _npc = default!;
[Dependency] private readonly TagSystem _tag = default!;
[Dependency] private readonly NameModifierSystem _nameMod = default!;
[Dependency] private readonly ISharedPlayerManager _player = default!;
private static readonly ProtoId<TagPrototype> InvalidForGlobalSpawnSpellTag = "InvalidForGlobalSpawnSpell";
private static readonly ProtoId<TagPrototype> CannotSuicideTag = "CannotSuicide";
private static readonly ProtoId<NpcFactionPrototype> ZombieFaction = "Zombie";
private static readonly string MindRoleZombie = "MindRoleZombie";
private static readonly List<ProtoId<AntagPrototype>> BannableZombiePrototypes = ["Zombie"];
/// <summary>
/// Handles an entity turning into a zombie when they die or go into crit
@@ -103,6 +111,24 @@ public sealed partial class ZombieSystem
if (!Resolve(target, ref mobState, logMissing: false))
return;
// Detach role-banned players before zombification
if (TryComp<ActorComponent>(target, out var actor) && _ban.IsRoleBanned(actor.PlayerSession, BannableZombiePrototypes))
{
var sess = actor.PlayerSession;
var message = Loc.GetString("zombie-roleban-ghosted");
if (_mind.TryGetMind(sess, out var playerMindEnt, out var playerMind))
{
// Detach
_ghost.SpawnGhost((playerMindEnt, playerMind), target);
// Notify
_chatMan.DispatchServerMessage(sess, message);
}
else
Log.Error($"Mind for session '{sess}' could not be found");
}
//you're a real zombie now, son.
var zombiecomp = AddComp<ZombieComponent>(target);
@@ -245,7 +271,7 @@ public sealed partial class ZombieSystem
if (hasMind && mind != null && _player.TryGetSessionById(mind.UserId, out var session))
{
//Zombie role for player manifest
_role.MindAddRole(mindId, "MindRoleZombie", mind: null, silent: true);
_role.MindAddRole(mindId, MindRoleZombie, mind: null, silent: true);
//Greeting message for new bebe zombers
_chatMan.DispatchServerMessage(session, Loc.GetString("zombie-infection-greeting"));
@@ -266,6 +292,7 @@ public sealed partial class ZombieSystem
ghostRole.RoleName = Loc.GetString("zombie-generic");
ghostRole.RoleDescription = Loc.GetString("zombie-role-desc");
ghostRole.RoleRules = Loc.GetString("zombie-role-rules");
ghostRole.MindRoles.Add(MindRoleZombie);
}
if (TryComp<HandsComponent>(target, out var handsComp))