]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
The long overdue downfall of stun meta - Stamina resists on Nukie & ERT Suits. (...
authorBramvanZijp <56019239+BramvanZijp@users.noreply.github.com>
Mon, 14 Apr 2025 15:27:26 +0000 (17:27 +0200)
committerGitHub <noreply@github.com>
Mon, 14 Apr 2025 15:27:26 +0000 (17:27 +0200)
* Add stamina damage resistance

* Probably starting a civil war within the community.

* Tweak some values, my chart was outdated.

* Tone down the values

* Allow a way to bypass the resistances, which forks downstream can use.

* Apply suggestions from code review

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
* Comment out the changes to non-deathsquad suits.

* minor text fix e

* review

---------

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
Co-authored-by: SlamBamActionman <slambamactionman@gmail.com>
Co-authored-by: Milon <milonpl.git@proton.me>
Content.Shared/Damage/Components/StaminaResistanceComponent.cs [new file with mode: 0644]
Content.Shared/Damage/Events/BeforeStaminaDamageEvent.cs [new file with mode: 0644]
Content.Shared/Damage/Systems/SharedGodmodeSystem.cs
Content.Shared/Damage/Systems/StaminaSystem.Resistance.cs [new file with mode: 0644]
Content.Shared/Damage/Systems/StaminaSystem.cs
Content.Shared/Inventory/InventorySystem.Relay.cs
Resources/Locale/en-US/damage/stamina.ftl
Resources/Prototypes/Entities/Clothing/OuterClothing/armor.yml
Resources/Prototypes/Entities/Clothing/OuterClothing/hardsuits.yml

diff --git a/Content.Shared/Damage/Components/StaminaResistanceComponent.cs b/Content.Shared/Damage/Components/StaminaResistanceComponent.cs
new file mode 100644 (file)
index 0000000..1a0db54
--- /dev/null
@@ -0,0 +1,38 @@
+using Content.Shared.Damage.Systems;
+using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Dictionary;
+using Robust.Shared.GameStates;
+
+namespace Content.Shared.Damage.Components;
+
+/// <summary>
+/// Component that provides entities with stamina resistance.
+/// By default this is applied when worn, but to solely protect the entity itself and
+/// not the wearer use <c>worn: false</c>.
+/// </summary>
+/// <remarks>
+/// This is desirable over just using damage modifier sets, given that equipment like bomb-suits need to
+/// significantly reduce the damage, but shouldn't be silly overpowered in regular combat.
+/// </remarks>
+[NetworkedComponent, RegisterComponent, AutoGenerateComponentState]
+public sealed partial class StaminaResistanceComponent : Component
+{
+    /// <summary>
+    /// The stamina resistance coefficient, This fraction is multiplied into the total resistance.
+    /// </summary>
+    [DataField, AutoNetworkedField]
+    public float DamageCoefficient = 1;
+
+    /// <summary>
+    /// When true, resistances will be applied to the entity wearing this item.
+    /// When false, only this entity will get the resistance.
+    /// </summary>
+    [DataField]
+    public bool Worn = true;
+
+    /// <summary>
+    /// Examine string for stamina resistance.
+    /// Passed <c>value</c> from 0 to 100.
+    /// </summary>
+    [DataField]
+    public LocId Examine = "stamina-resistance-coefficient-value";
+}
diff --git a/Content.Shared/Damage/Events/BeforeStaminaDamageEvent.cs b/Content.Shared/Damage/Events/BeforeStaminaDamageEvent.cs
new file mode 100644 (file)
index 0000000..6992ad8
--- /dev/null
@@ -0,0 +1,12 @@
+using Content.Shared.Inventory;
+
+namespace Content.Shared.Damage.Events;
+
+/// <summary>
+/// Raised before stamina damage is dealt to allow other systems to cancel or modify it.
+/// </summary>
+[ByRefEvent]
+public record struct BeforeStaminaDamageEvent(float Value, bool Cancelled = false) : IInventoryRelayEvent
+{
+    SlotFlags IInventoryRelayEvent.TargetSlots =>  ~SlotFlags.POCKET;
+}
index 20e29ef4341e852f927ae5688a564c7cb988e880..4ccc56dcb8543f6e4a865578bef4b0a110ec1793 100644 (file)
@@ -1,4 +1,5 @@
 using Content.Shared.Damage.Components;
+using Content.Shared.Damage.Events;
 using Content.Shared.Rejuvenate;
 using Content.Shared.Slippery;
 using Content.Shared.StatusEffect;
diff --git a/Content.Shared/Damage/Systems/StaminaSystem.Resistance.cs b/Content.Shared/Damage/Systems/StaminaSystem.Resistance.cs
new file mode 100644 (file)
index 0000000..9ad09b8
--- /dev/null
@@ -0,0 +1,38 @@
+using Content.Shared.Armor;
+using Content.Shared.Damage.Components;
+using Content.Shared.Damage.Events;
+using Content.Shared.Inventory;
+
+namespace Content.Shared.Damage.Systems;
+
+public sealed partial class StaminaSystem
+{
+    private void InitializeResistance()
+    {
+        SubscribeLocalEvent<StaminaResistanceComponent, BeforeStaminaDamageEvent>(OnGetResistance);
+        SubscribeLocalEvent<StaminaResistanceComponent, InventoryRelayedEvent<BeforeStaminaDamageEvent>>(RelayedResistance);
+        SubscribeLocalEvent<StaminaResistanceComponent, ArmorExamineEvent>(OnArmorExamine);
+    }
+
+    private void OnGetResistance(Entity<StaminaResistanceComponent> ent, ref BeforeStaminaDamageEvent args)
+    {
+        args.Value *= ent.Comp.DamageCoefficient;
+    }
+
+    private void RelayedResistance(Entity<StaminaResistanceComponent> ent, ref InventoryRelayedEvent<BeforeStaminaDamageEvent> args)
+    {
+        if (ent.Comp.Worn)
+            OnGetResistance(ent, ref args.Args);
+    }
+
+    private void OnArmorExamine(Entity<StaminaResistanceComponent> ent, ref ArmorExamineEvent args)
+    {
+        var value = MathF.Round((1f - ent.Comp.DamageCoefficient) * 100, 1);
+
+        if (value == 0)
+            return;
+
+        args.Msg.PushNewline();
+        args.Msg.AddMarkupOrThrow(Loc.GetString(ent.Comp.Examine, ("value", value)));
+    }
+}
index d897a363d4db659aa09085dbcf7aced3e4784e6b..bd84b711e38476b0eb2a4ca695f54c377f6ead66 100644 (file)
@@ -50,6 +50,7 @@ public sealed partial class StaminaSystem : EntitySystem
         base.Initialize();
 
         InitializeModifier();
+        InitializeResistance();
 
         SubscribeLocalEvent<StaminaComponent, ComponentStartup>(OnStartup);
         SubscribeLocalEvent<StaminaComponent, ComponentShutdown>(OnShutdown);
@@ -240,7 +241,7 @@ public sealed partial class StaminaSystem : EntitySystem
     }
 
     public void TakeStaminaDamage(EntityUid uid, float value, StaminaComponent? component = null,
-        EntityUid? source = null, EntityUid? with = null, bool visual = true, SoundSpecifier? sound = null)
+        EntityUid? source = null, EntityUid? with = null, bool visual = true, SoundSpecifier? sound = null, bool ignoreResist = false)
     {
         if (!Resolve(uid, ref component, false))
             return;
@@ -250,6 +251,12 @@ public sealed partial class StaminaSystem : EntitySystem
         if (ev.Cancelled)
             return;
 
+        // Allow stamina resistance to be applied.
+        if (!ignoreResist)
+        {
+            value = ev.Value;
+        }
+
         value = UniversalStaminaDamageModifier * value;
 
         // Have we already reached the point of max stamina damage?
@@ -399,9 +406,3 @@ public sealed partial class StaminaSystem : EntitySystem
         _adminLogger.Add(LogType.Stamina, LogImpact.Low, $"{ToPrettyString(uid):user} recovered from stamina crit");
     }
 }
-
-/// <summary>
-///     Raised before stamina damage is dealt to allow other systems to cancel it.
-/// </summary>
-[ByRefEvent]
-public record struct BeforeStaminaDamageEvent(float Value, bool Cancelled = false);
index 8fac406eb558ef3feb4678d2f9fa183853a6051c..efa88fb23a706d642bee77f4d0f6209283a0d7f3 100644 (file)
@@ -5,6 +5,7 @@ using Content.Shared.Chemistry;
 using Content.Shared.Chemistry.Hypospray.Events;
 using Content.Shared.Climbing.Events;
 using Content.Shared.Damage;
+using Content.Shared.Damage.Events;
 using Content.Shared.Electrocution;
 using Content.Shared.Explosion;
 using Content.Shared.Eye.Blinding.Systems;
@@ -45,6 +46,7 @@ public partial class InventorySystem
         SubscribeLocalEvent<InventoryComponent, CoefficientQueryEvent>(RelayInventoryEvent);
 
         // by-ref events
+        SubscribeLocalEvent<InventoryComponent, BeforeStaminaDamageEvent>(RefRelayInventoryEvent);
         SubscribeLocalEvent<InventoryComponent, GetExplosionResistanceEvent>(RefRelayInventoryEvent);
         SubscribeLocalEvent<InventoryComponent, IsWeightlessEvent>(RefRelayInventoryEvent);
         SubscribeLocalEvent<InventoryComponent, GetSpeedModifierContactCapEvent>(RefRelayInventoryEvent);
index da817824aa184a691fd96e47328a7d8bb34d4321..cbda507865875dcbf3476f349341b8077f611ed2 100644 (file)
@@ -1,2 +1,3 @@
 melee-stamina = Not enough stamina
 slow-on-damage-modifier-examine = Slowness from injuries is reduced by [color=yellow]{$mod}%[/color]
+stamina-resistance-coefficient-value = - [color=lightyellow]Stamina[/color] damage reduced by [color=lightblue]{$value}%[/color].
index 7835ace80f2e301b6f366acc93d7d4667833de58..acb44c8ad8814ea3b03065741202bde3d54f8a48 100644 (file)
         Caustic: 0.5
   - type: ExplosionResistance
     damageCoefficient: 0.35
+  #- type: StaminaResistance
+  #  damageCoefficient: 0.45
   - type: ClothingSpeedModifier
     walkModifier: 0.9
     sprintModifier: 0.9
index 6c2a6714469a9f17e5cb32d1cc128e11025472fb..71eef999cf84d6794747e2bd40f5ca20f77bd0ed 100644 (file)
     lowPressureMultiplier: 1000
   - type: ExplosionResistance
     damageCoefficient: 0.5
+  #- type: StaminaResistance
+  #  damageCoefficient: 0.75
   - type: Armor
     modifiers:
       coefficients:
     damageCoefficient: 0.2
   - type: FireProtection
     reduction: 0.8
+  #- type: StaminaResistance
+  #  damageCoefficient: 0.6
   - type: Armor
     modifiers:
       coefficients:
     lowPressureMultiplier: 1000
   - type: ExplosionResistance
     damageCoefficient: 0.5
+  #- type: StaminaResistance
+  #  damageCoefficient: 0.6
   - type: Armor
     modifiers:
       coefficients:
     lowPressureMultiplier: 1000
   - type: ExplosionResistance
     damageCoefficient: 0.3
+  #- type: StaminaResistance # Should not have stamina resistance, this is purely so people know it was not forgotten.
+  #  damageCoefficient: 0.99
   - type: Armor
     modifiers:
       coefficients:
     damageCoefficient: 0.2
   - type: FireProtection
     reduction: 0.8
+  - type: StaminaResistance
+    damageCoefficient: 0.15 # Needs 21 hits with a disabler to stun :godo:
   - type: Armor
     modifiers:
       coefficients: