2021-11-24 16:52:31 -06:00
|
|
|
using Content.Server.Administration.Logs;
|
2022-05-12 22:30:30 -07:00
|
|
|
using Content.Server.CombatMode;
|
2021-10-10 12:47:26 +02:00
|
|
|
using Content.Server.Popups;
|
|
|
|
|
using Content.Shared.Audio;
|
2021-11-28 14:56:53 +01:00
|
|
|
using Content.Shared.Database;
|
2021-10-10 12:47:26 +02:00
|
|
|
using Content.Shared.Popups;
|
2021-10-15 14:45:04 -07:00
|
|
|
using Content.Shared.StatusEffect;
|
2021-10-10 12:47:26 +02:00
|
|
|
using Content.Shared.Stunnable;
|
|
|
|
|
using Robust.Shared.Audio;
|
|
|
|
|
using Robust.Shared.Player;
|
|
|
|
|
using Robust.Shared.Random;
|
|
|
|
|
|
|
|
|
|
namespace Content.Server.Stunnable
|
|
|
|
|
{
|
|
|
|
|
public sealed class StunSystem : SharedStunSystem
|
|
|
|
|
{
|
|
|
|
|
[Dependency] private readonly IRobustRandom _random = default!;
|
2022-05-28 23:41:17 -07:00
|
|
|
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
2021-10-10 12:47:26 +02:00
|
|
|
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
|
|
|
|
|
2022-02-26 18:24:08 +13:00
|
|
|
SubscribeLocalEvent<StatusEffectsComponent, DisarmedEvent>(OnDisarmed);
|
2021-10-10 12:47:26 +02:00
|
|
|
}
|
|
|
|
|
|
2022-02-26 18:24:08 +13:00
|
|
|
private void OnDisarmed(EntityUid uid, StatusEffectsComponent status, DisarmedEvent args)
|
2021-10-10 12:47:26 +02:00
|
|
|
{
|
|
|
|
|
if (args.Handled || !_random.Prob(args.PushProbability))
|
|
|
|
|
return;
|
|
|
|
|
|
2021-12-07 09:18:07 +03:00
|
|
|
if (!TryParalyze(uid, TimeSpan.FromSeconds(4f), true, status))
|
2021-10-15 14:45:04 -07:00
|
|
|
return;
|
2021-10-10 12:47:26 +02:00
|
|
|
|
|
|
|
|
var source = args.Source;
|
|
|
|
|
var target = args.Target;
|
|
|
|
|
|
2021-12-26 15:32:45 +13:00
|
|
|
var knock = EntityManager.GetComponent<KnockedDownComponent>(uid);
|
2022-06-12 19:45:47 -04:00
|
|
|
SoundSystem.Play(knock.StunAttemptSound.GetSound(), Filter.Pvs(source), source, AudioHelpers.WithVariation(0.025f));
|
2021-12-26 15:32:45 +13:00
|
|
|
|
|
|
|
|
// TODO: Use PopupSystem
|
|
|
|
|
source.PopupMessageOtherClients(Loc.GetString("stunned-component-disarm-success-others", ("source", Name(source)), ("target", Name(target))));
|
|
|
|
|
source.PopupMessageCursor(Loc.GetString("stunned-component-disarm-success", ("target", Name(target))));
|
2021-10-10 12:47:26 +02:00
|
|
|
|
2022-05-28 23:41:17 -07:00
|
|
|
_adminLogger.Add(LogType.DisarmedKnockdown, LogImpact.Medium, $"{ToPrettyString(args.Source):user} knocked down {ToPrettyString(args.Target):target}");
|
2021-11-24 16:52:31 -06:00
|
|
|
|
2021-10-10 12:47:26 +02:00
|
|
|
args.Handled = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|