From f65c2e5c84e24ad3a2bb614d899dbe176141104c Mon Sep 17 00:00:00 2001 From: Aviu00 <93730715+Aviu00@users.noreply.github.com> Date: Mon, 22 Jul 2024 17:06:02 +0000 Subject: [PATCH] Flashbang tweaks. (#478) * - tweak: Flashbang tweaks. * - add: More flashbang stuff. --- Content.Server/Flash/FlashSystem.cs | 4 ++- .../Standing/StandingStateComponent.cs | 4 +-- .../FlashSoundSuppressionComponent.cs | 3 ++- .../FlashSoundSuppressionSystem.cs | 25 +++++++++++++------ .../Entities/Clothing/Ears/headsets_alt.yml | 2 +- .../Clothing/Head/hardsuit-helmets.yml | 24 +++++++++++++++--- .../Entities/Clothing/Head/hive_head.yml | 1 + 7 files changed, 47 insertions(+), 16 deletions(-) diff --git a/Content.Server/Flash/FlashSystem.cs b/Content.Server/Flash/FlashSystem.cs index 2e5a713192..9dbc9c76ff 100644 --- a/Content.Server/Flash/FlashSystem.cs +++ b/Content.Server/Flash/FlashSystem.cs @@ -179,8 +179,10 @@ namespace Content.Server.Flash // They shouldn't have flash removed in between right? Flash(entity, user, source, duration, slowTo, displayPopup); + var distance = (mapPosition.Position - _transform.GetMapCoordinates(entity).Position).Length(); + if (forceStun) // WD - _flashSoundSuppressionSystem.Stun(entity, duration); + _flashSoundSuppressionSystem.Stun(entity, duration, distance, range); } _audio.PlayPvs(sound, source, AudioParams.Default.WithVolume(1f).WithMaxDistance(3f)); diff --git a/Content.Shared/Standing/StandingStateComponent.cs b/Content.Shared/Standing/StandingStateComponent.cs index 7af773cdb7..c7233bc42f 100644 --- a/Content.Shared/Standing/StandingStateComponent.cs +++ b/Content.Shared/Standing/StandingStateComponent.cs @@ -23,11 +23,11 @@ namespace Content.Shared.Standing // WD EDIT [DataField, AutoNetworkedField, ViewVariables(VVAccess.ReadWrite)] - public bool CanLieDown = false; + public bool CanLieDown; // WD EDIT [DataField, AutoNetworkedField, ViewVariables(VVAccess.ReadWrite)] - public bool AutoGetUp = false; + public bool AutoGetUp = true; /// /// List of fixtures that had their collision mask changed when the entity was downed. diff --git a/Content.Shared/_White/BuffedFlashGrenade/FlashSoundSuppressionComponent.cs b/Content.Shared/_White/BuffedFlashGrenade/FlashSoundSuppressionComponent.cs index 190af15af6..467ac826b7 100644 --- a/Content.Shared/_White/BuffedFlashGrenade/FlashSoundSuppressionComponent.cs +++ b/Content.Shared/_White/BuffedFlashGrenade/FlashSoundSuppressionComponent.cs @@ -5,5 +5,6 @@ namespace Content.Shared._White.BuffedFlashGrenade; [RegisterComponent, NetworkedComponent] public sealed partial class FlashSoundSuppressionComponent : Component { - + [DataField, ViewVariables(VVAccess.ReadWrite)] + public float MaxRange = 3f; } diff --git a/Content.Shared/_White/BuffedFlashGrenade/FlashSoundSuppressionSystem.cs b/Content.Shared/_White/BuffedFlashGrenade/FlashSoundSuppressionSystem.cs index c04d650fa0..354c7b3352 100644 --- a/Content.Shared/_White/BuffedFlashGrenade/FlashSoundSuppressionSystem.cs +++ b/Content.Shared/_White/BuffedFlashGrenade/FlashSoundSuppressionSystem.cs @@ -18,26 +18,37 @@ public sealed class FlashSoundSuppressionSystem : EntitySystem private void OnGetFlashbanged(Entity ent, ref InventoryRelayedEvent args) { - args.Args.Protected = true; + args.Args.MaxRange = MathF.Min(args.Args.MaxRange, ent.Comp.MaxRange); } - public void Stun(EntityUid target, float duration) + public void Stun(EntityUid target, float duration, float distance, float range) { - if (HasComp(target)) - return; + if (TryComp(target, out var suppression)) + range = MathF.Min(range, suppression.MaxRange); var ev = new GetFlashbangedEvent(); + ev.MaxRange = range; RaiseLocalEvent(target, ev); - if (ev.Protected) + range = MathF.Min(range, ev.MaxRange); + + if (range <= 0f) + return; + if (distance < 0f) + distance = 0f; + if (distance > range) return; - _stunSystem.TryParalyze(target, TimeSpan.FromSeconds(duration / 1000f), true); + var stunTime = float.Lerp(duration, 0f, distance / range); + if (stunTime <= 0f) + return; + + _stunSystem.TryParalyze(target, TimeSpan.FromSeconds(stunTime / 1000f), true); } } public sealed class GetFlashbangedEvent : EntityEventArgs, IInventoryRelayEvent { - public bool Protected; + public float MaxRange = 7f; public SlotFlags TargetSlots => SlotFlags.EARS | SlotFlags.HEAD; } diff --git a/Resources/Prototypes/Entities/Clothing/Ears/headsets_alt.yml b/Resources/Prototypes/Entities/Clothing/Ears/headsets_alt.yml index 07247d66ef..4e0744b023 100644 --- a/Resources/Prototypes/Entities/Clothing/Ears/headsets_alt.yml +++ b/Resources/Prototypes/Entities/Clothing/Ears/headsets_alt.yml @@ -9,7 +9,7 @@ state: icon_alt - type: Clothing equippedPrefix: alt - - type: FlashSoundSuppression # WD + - type: FlashSoundSuppression - type: entity parent: ClothingHeadsetAlt diff --git a/Resources/Prototypes/Entities/Clothing/Head/hardsuit-helmets.yml b/Resources/Prototypes/Entities/Clothing/Head/hardsuit-helmets.yml index 46aacbaa80..1efe876218 100644 --- a/Resources/Prototypes/Entities/Clothing/Head/hardsuit-helmets.yml +++ b/Resources/Prototypes/Entities/Clothing/Head/hardsuit-helmets.yml @@ -185,7 +185,7 @@ Piercing: 0.9 Heat: 0.9 - type: FlashImmunity # WD edit - - type: FlashSoundSuppression # WD edit + - type: FlashSoundSuppression #Brigmedic Hardsuit - type: entity @@ -214,7 +214,7 @@ highPressureMultiplier: 0.6 lowPressureMultiplier: 1000 - type: FlashImmunity # WD edit - - type: FlashSoundSuppression # WD edit + - type: FlashSoundSuppression #Warden's Hardsuit - type: entity @@ -241,7 +241,7 @@ Piercing: 0.9 Heat: 0.9 - type: FlashImmunity # WD edit - - type: FlashSoundSuppression # WD edit + - type: FlashSoundSuppression #Captain's Hardsuit - type: entity @@ -259,7 +259,7 @@ highPressureMultiplier: 0.3 lowPressureMultiplier: 1000 - type: FlashImmunity # WD edit - - type: FlashSoundSuppression # WD edit + - type: FlashSoundSuppression #Inspector's Hardsuit - type: entity @@ -423,6 +423,7 @@ Heat: 0.9 - type: EyeProtection # WD edit - type: FlashImmunity # WD + - type: FlashSoundSuppression #Blood-red Medic Hardsuit - type: entity @@ -450,6 +451,7 @@ Heat: 0.9 - type: EyeProtection # WD edit - type: FlashImmunity # WD + - type: FlashSoundSuppression #Syndicate Elite Hardsuit - type: entity @@ -479,6 +481,7 @@ Heat: 0.9 - type: EyeProtection # WD edit - type: FlashImmunity # WD + - type: FlashSoundSuppression #Syndicate Commander Hardsuit - type: entity @@ -506,6 +509,7 @@ Heat: 0.9 - type: EyeProtection # WD edit - type: FlashImmunity # WD + - type: FlashSoundSuppression #Cybersun Juggernaut Hardsuit - type: entity @@ -531,6 +535,7 @@ Heat: 0.9 - type: EyeProtection # WD edit - type: FlashImmunity # WD + - type: FlashSoundSuppression #Wizard Hardsuit - type: entity @@ -557,6 +562,9 @@ Piercing: 0.9 Heat: 0.9 - type: WizardClothes + - type: EyeProtection + - type: FlashImmunity + - type: FlashSoundSuppression #Organic Space Suit - type: entity @@ -632,6 +640,7 @@ Heat: 0.9 - type: EyeProtection # WD edit - type: FlashImmunity # WD + - type: FlashSoundSuppression #ERT Chaplain Hardsuit - type: entity @@ -672,6 +681,7 @@ - type: EyeProtection # WD edit - type: FlashImmunity # WD + - type: FlashSoundSuppression #ERT Medical Hardsuit - type: entity parent: ClothingHeadHelmetHardsuitSyndieElite @@ -688,6 +698,7 @@ color: "#adffec" - type: EyeProtection # WD edit - type: FlashImmunity # WD + - type: FlashSoundSuppression #ERT Security Hardsuit - type: entity @@ -712,6 +723,7 @@ Heat: 0.9 - type: EyeProtection # WD edit - type: FlashImmunity # WD + - type: FlashSoundSuppression #ERT Janitor Hardsuit - type: entity @@ -729,6 +741,7 @@ color: "#cbadff" - type: EyeProtection # WD edit - type: FlashImmunity # WD + - type: FlashSoundSuppression #CBURN Hardsuit - type: entity @@ -770,6 +783,7 @@ Heat: 0.9 - type: EyeProtection # WD edit - type: FlashImmunity # WD + - type: FlashSoundSuppression #Deathsquad Hardsuit - type: entity @@ -797,6 +811,8 @@ Caustic: 0.95 - type: EyeProtection # WD edit - type: FlashImmunity # WD + - type: FlashSoundSuppression + maxRange: 0 - type: ShowHealthBars damageContainers: - Biological diff --git a/Resources/Prototypes/_White/Entities/Clothing/Head/hive_head.yml b/Resources/Prototypes/_White/Entities/Clothing/Head/hive_head.yml index c4b5c6ddf6..4a14e07660 100644 --- a/Resources/Prototypes/_White/Entities/Clothing/Head/hive_head.yml +++ b/Resources/Prototypes/_White/Entities/Clothing/Head/hive_head.yml @@ -20,6 +20,7 @@ - type: DeleteOnChangelingRefund - type: FlashImmunity - type: EyeProtection + - type: FlashSoundSuppression - type: HiveHead - type: entity