Files
tbd-station-14/Content.Server/Chat/Commands/SuicideCommand.cs
Scribbles0 220aff21eb Melee Executions (#30104)
* melee executions

* fix damage bug

* cleanup

* address reviews hopefully

* resistance bypass mechanic

* component changes

* self executions (not finished yet)

* self execs part two

* ok i fixed things (still not finished)

* finish everything

* review stuff

* nuke if (kind = special)

* more review stuffs

* Make suicide system much less hardcoded and make much more use of events

* Fix a dumb bug I introduced

* self execution popups

* Integration tests

* Why did they even take 0.5 blunt damage?

* More consistent integration tests

* Destructive equals true

* Allow it to dirty-dispose

* IS THIS WHAT YOU WANT?

* FRESH AND CLEAN

* modifier to multiplier

* don't jinx the integration tests

* no file-scoped namespace

* Move the rest of execution to shared, create SuicideGhostEvent

* handled

* Get rid of unused code and add a comment

* ghost before suicide

* stop cat suicides

* popup fix + small suicide change

* make it a bit better

---------

Co-authored-by: Plykiya <58439124+Plykiya@users.noreply.github.com>
2024-08-11 13:05:54 +10:00

61 lines
1.9 KiB
C#

using Content.Server.GameTicking;
using Content.Server.Popups;
using Content.Shared.Administration;
using Content.Shared.Chat;
using Content.Shared.Mind;
using Robust.Shared.Console;
using Robust.Shared.Enums;
namespace Content.Server.Chat.Commands
{
[AnyCommand]
internal sealed class SuicideCommand : IConsoleCommand
{
[Dependency] private readonly IEntityManager _e = default!;
public string Command => "suicide";
public string Description => Loc.GetString("suicide-command-description");
public string Help => Loc.GetString("suicide-command-help-text");
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (shell.Player is not { } player)
{
shell.WriteLine(Loc.GetString("shell-cannot-run-command-from-server"));
return;
}
if (player.Status != SessionStatus.InGame || player.AttachedEntity == null)
return;
var minds = _e.System<SharedMindSystem>();
// This check also proves mind not-null for at the end when the mob is ghosted.
if (!minds.TryGetMind(player, out var mindId, out var mindComp) ||
mindComp.OwnedEntity is not { Valid: true } victim)
{
shell.WriteLine(Loc.GetString("suicide-command-no-mind"));
return;
}
var suicideSystem = _e.System<SuicideSystem>();
if (_e.HasComponent<AdminFrozenComponent>(victim))
{
var deniedMessage = Loc.GetString("suicide-command-denied");
shell.WriteLine(deniedMessage);
_e.System<PopupSystem>()
.PopupEntity(deniedMessage, victim, victim);
return;
}
if (suicideSystem.Suicide(victim))
return;
shell.WriteLine(Loc.GetString("ghost-command-denied"));
}
}
}