Files
wwdpublic/Content.Server/_Goobstation/Flashbang/FlashbangSystem.cs
Eagle-0 e4c3993afd Security Buffs But Real (#2022)
# Description
Ports Security buffs from
[/Goob-Station#953](https://github.com/Goob-Station/Goob-Station/pull/953)

## Once Again, I am John Combat
I don't have the energy today for the witty PR jokes. Apologies, people.

# TODO
* [x] Oil floats on water
* [x] Cover yourself in oil
* [x] Wait for it to rain
* [x] :trollface:

# Media

# Changelog
🆑 Eagle

* add: Flashbangs now stun and knockdown people. Wear over-ear headset
or combat hardsuit helmet to reduce flashbang effective range.
 * add: All sec and command members received over-ear headsets.
* add: Wearing security, ert, syndie or deathsquad gas mask blocks smoke
inhalation even if internals are off.
 * tweak: Epinephrine now speeds up by 10%.
* add: Jackboots, combat and mercenary boots now reduce all stun and
knockdown times by 20%.
 * add: Combat hardsuit helmets now protect from flashes.
 * tweak: Tear gas is now stronger.
 * tweak: Stamcrit stun time is once again 6 seconds.
 * tweak: Security hardsuits now have heat resistance.

---------

Signed-off-by: VMSolidus <evilexecutive@gmail.com>
Co-authored-by: Aviu00 <93730715+Aviu00@users.noreply.github.com>
Co-authored-by: VMSolidus <evilexecutive@gmail.com>

(cherry picked from commit 9bae47bc6d3e44fba8b86e18c78e6b0f3fe00ed6)
2025-03-21 18:53:10 +03:00

75 lines
2.5 KiB
C#

using Content.Server.Stunnable;
using Content.Shared._Goobstation.Flashbang;
using Content.Shared.Examine;
using Content.Shared.Inventory;
namespace Content.Server._Goobstation.Flashbang;
public sealed class FlashbangSystem : EntitySystem
{
[Dependency] private readonly StunSystem _stun = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<FlashbangComponent, AreaFlashEvent>(OnFlash);
SubscribeLocalEvent<FlashSoundSuppressionComponent, InventoryRelayedEvent<GetFlashbangedEvent>>(
OnInventoryFlashbanged);
SubscribeLocalEvent<FlashSoundSuppressionComponent, GetFlashbangedEvent>(OnFlashbanged);
SubscribeLocalEvent<FlashSoundSuppressionComponent, ExaminedEvent>(OnExamined);
}
private void OnExamined(Entity<FlashSoundSuppressionComponent> ent, ref ExaminedEvent args)
{
var range = ent.Comp.ProtectionRange;
var message = range > 0
? Loc.GetString("flash-sound-suppression-examine", ("range", range))
: Loc.GetString("flash-sound-suppression-fully-examine");
args.PushMarkup(message);
}
private void OnFlashbanged(Entity<FlashSoundSuppressionComponent> ent, ref GetFlashbangedEvent args)
{
args.ProtectionRange = MathF.Min(args.ProtectionRange, ent.Comp.ProtectionRange);
}
private void OnInventoryFlashbanged(Entity<FlashSoundSuppressionComponent> ent,
ref InventoryRelayedEvent<GetFlashbangedEvent> args)
{
args.Args.ProtectionRange = MathF.Min(args.Args.ProtectionRange, ent.Comp.ProtectionRange);
}
private void OnFlash(Entity<FlashbangComponent> ent, ref AreaFlashEvent args)
{
var comp = ent.Comp;
if (comp is { KnockdownTime: <= 0, StunTime: <= 0 })
return;
var ev = new GetFlashbangedEvent(args.Range);
RaiseLocalEvent(args.Target, ev);
var protectionRange = ev.ProtectionRange;
if (protectionRange <= 0f)
return;
var distance = MathF.Max(0f, args.Distance);
if (distance > protectionRange)
return;
var ratio = distance / protectionRange;
var knockdownTime = float.Lerp(comp.KnockdownTime, 0f, ratio);
if (knockdownTime > 0f)
_stun.TryKnockdown(args.Target, TimeSpan.FromSeconds(knockdownTime), true);
var stunTime = float.Lerp(comp.StunTime, 0f, ratio);
if (stunTime > 0f)
_stun.TryStun(args.Target, TimeSpan.FromSeconds(stunTime), true);
}
}