]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Small strange jackboots buff (#30586)
authorNemanja <98561806+EmoGarbage404@users.noreply.github.com>
Thu, 22 Aug 2024 14:56:46 +0000 (10:56 -0400)
committerGitHub <noreply@github.com>
Thu, 22 Aug 2024 14:56:46 +0000 (10:56 -0400)
* Small strange jackboots buff

* Update ClothingSlowOnDamageModifierComponent.cs

Content.Shared/Damage/Components/ClothingSlowOnDamageModifierComponent.cs [new file with mode: 0644]
Content.Shared/Damage/Systems/SlowOnDamageSystem.cs
Content.Shared/Inventory/InventorySystem.Relay.cs
Resources/Locale/en-US/damage/stamina.ftl
Resources/Prototypes/Entities/Clothing/Shoes/boots.yml
Resources/Prototypes/Loadouts/loadout_groups.yml

diff --git a/Content.Shared/Damage/Components/ClothingSlowOnDamageModifierComponent.cs b/Content.Shared/Damage/Components/ClothingSlowOnDamageModifierComponent.cs
new file mode 100644 (file)
index 0000000..3d4bdd5
--- /dev/null
@@ -0,0 +1,17 @@
+using Robust.Shared.GameStates;
+
+namespace Content.Shared.Damage.Components;
+
+/// <summary>
+/// This is used for a clothing item that modifies the slowdown from taking damage.
+/// Used for entities with <see cref="SlowOnDamageComponent"/>
+/// </summary>
+[RegisterComponent, NetworkedComponent, Access(typeof(SlowOnDamageSystem))]
+public sealed partial class ClothingSlowOnDamageModifierComponent : Component
+{
+    /// <summary>
+    /// A coefficient modifier for the slowdown
+    /// </summary>
+    [DataField]
+    public float Modifier = 1;
+}
index 833883c144c58fcd70f13fb48051f04de700b17a..3e50ee3557241fa95aec6e77ea3344971449bc30 100644 (file)
@@ -1,5 +1,8 @@
+using Content.Shared.Clothing;
 using Content.Shared.Damage.Components;
+using Content.Shared.Examine;
 using Content.Shared.FixedPoint;
+using Content.Shared.Inventory;
 using Content.Shared.Movement.Systems;
 
 namespace Content.Shared.Damage
@@ -14,6 +17,11 @@ namespace Content.Shared.Damage
 
             SubscribeLocalEvent<SlowOnDamageComponent, DamageChangedEvent>(OnDamageChanged);
             SubscribeLocalEvent<SlowOnDamageComponent, RefreshMovementSpeedModifiersEvent>(OnRefreshMovespeed);
+
+            SubscribeLocalEvent<ClothingSlowOnDamageModifierComponent, InventoryRelayedEvent<ModifySlowOnDamageSpeedEvent>>(OnModifySpeed);
+            SubscribeLocalEvent<ClothingSlowOnDamageModifierComponent, ExaminedEvent>(OnExamined);
+            SubscribeLocalEvent<ClothingSlowOnDamageModifierComponent, ClothingGotEquippedEvent>(OnGotEquipped);
+            SubscribeLocalEvent<ClothingSlowOnDamageModifierComponent, ClothingGotUnequippedEvent>(OnGotUnequipped);
         }
 
         private void OnRefreshMovespeed(EntityUid uid, SlowOnDamageComponent component, RefreshMovementSpeedModifiersEvent args)
@@ -36,7 +44,10 @@ namespace Content.Shared.Damage
             if (closest != FixedPoint2.Zero)
             {
                 var speed = component.SpeedModifierThresholds[closest];
-                args.ModifySpeed(speed, speed);
+
+                var ev = new ModifySlowOnDamageSpeedEvent(speed);
+                RaiseLocalEvent(uid, ref ev);
+                args.ModifySpeed(ev.Speed, ev.Speed);
             }
         }
 
@@ -47,5 +58,37 @@ namespace Content.Shared.Damage
 
             _movementSpeedModifierSystem.RefreshMovementSpeedModifiers(uid);
         }
+
+        private void OnModifySpeed(Entity<ClothingSlowOnDamageModifierComponent> ent, ref InventoryRelayedEvent<ModifySlowOnDamageSpeedEvent> args)
+        {
+            var dif = 1 - args.Args.Speed;
+            if (dif <= 0)
+                return;
+
+            // reduces the slowness modifier by the given coefficient
+            args.Args.Speed += dif * ent.Comp.Modifier;
+        }
+
+        private void OnExamined(Entity<ClothingSlowOnDamageModifierComponent> ent, ref ExaminedEvent args)
+        {
+            var msg = Loc.GetString("slow-on-damage-modifier-examine", ("mod", (1 - ent.Comp.Modifier) * 100));
+            args.PushMarkup(msg);
+        }
+
+        private void OnGotEquipped(Entity<ClothingSlowOnDamageModifierComponent> ent, ref ClothingGotEquippedEvent args)
+        {
+            _movementSpeedModifierSystem.RefreshMovementSpeedModifiers(args.Wearer);
+        }
+
+        private void OnGotUnequipped(Entity<ClothingSlowOnDamageModifierComponent> ent, ref ClothingGotUnequippedEvent args)
+        {
+            _movementSpeedModifierSystem.RefreshMovementSpeedModifiers(args.Wearer);
+        }
+    }
+
+    [ByRefEvent]
+    public record struct ModifySlowOnDamageSpeedEvent(float Speed) : IInventoryRelayEvent
+    {
+        public SlotFlags TargetSlots => SlotFlags.WITHOUT_POCKET;
     }
 }
index bca9eb6cfa23c13e8a3b06ad9a0f40ea5312a8e3..f0bb73c1922cc111dff1f3b1718b3bd40ce3ae3f 100644 (file)
@@ -34,6 +34,7 @@ public partial class InventorySystem
         // by-ref events
         SubscribeLocalEvent<InventoryComponent, GetExplosionResistanceEvent>(RefRelayInventoryEvent);
         SubscribeLocalEvent<InventoryComponent, IsWeightlessEvent>(RefRelayInventoryEvent);
+        SubscribeLocalEvent<InventoryComponent, ModifySlowOnDamageSpeedEvent>(RefRelayInventoryEvent);
 
         // Eye/vision events
         SubscribeLocalEvent<InventoryComponent, CanSeeAttemptEvent>(RelayInventoryEvent);
index 0d14a52c1ee0c95ba15860c0eb52c873116e456b..da817824aa184a691fd96e47328a7d8bb34d4321 100644 (file)
@@ -1 +1,2 @@
 melee-stamina = Not enough stamina
+slow-on-damage-modifier-examine = Slowness from injuries is reduced by [color=yellow]{$mod}%[/color]
index fddb5abb589747fe19b3cb7ee5909f227a5d543f..32fd118f1cc6bcecb24394736d169c1aadb65e58 100644 (file)
@@ -20,6 +20,8 @@
     sprite: Clothing/Shoes/Boots/jackboots.rsi
   - type: Clothing
     sprite: Clothing/Shoes/Boots/jackboots.rsi
+  - type: ClothingSlowOnDamageModifier
+    modifier: 0.5
 
 - type: entity
   parent: ClothingShoesBaseButcherable
index 685b0c784fa3dee668899e7efab56d07b8b8b2c4..868fb1f7d214ec2408e28601d44b38a70585430c 100644 (file)
   id: SecurityShoes
   name: loadout-group-security-shoes
   loadouts:
-  - CombatBoots
   - JackBoots
   - SecurityWinterBoots