From 5c21b4e1743a7c05ba82aef80e6219e43ea859d3 Mon Sep 17 00:00:00 2001
From: Nemanja <98561806+EmoGarbage404@users.noreply.github.com>
Date: Thu, 22 Aug 2024 10:56:46 -0400
Subject: [PATCH] Small strange jackboots buff (#30586)
* Small strange jackboots buff
* Update ClothingSlowOnDamageModifierComponent.cs
---
.../ClothingSlowOnDamageModifierComponent.cs | 17 +++++++
.../Damage/Systems/SlowOnDamageSystem.cs | 45 ++++++++++++++++++-
.../Inventory/InventorySystem.Relay.cs | 1 +
Resources/Locale/en-US/damage/stamina.ftl | 1 +
.../Entities/Clothing/Shoes/boots.yml | 2 +
.../Prototypes/Loadouts/loadout_groups.yml | 1 -
6 files changed, 65 insertions(+), 2 deletions(-)
create mode 100644 Content.Shared/Damage/Components/ClothingSlowOnDamageModifierComponent.cs
diff --git a/Content.Shared/Damage/Components/ClothingSlowOnDamageModifierComponent.cs b/Content.Shared/Damage/Components/ClothingSlowOnDamageModifierComponent.cs
new file mode 100644
index 000000000000..3d4bdd597c30
--- /dev/null
+++ b/Content.Shared/Damage/Components/ClothingSlowOnDamageModifierComponent.cs
@@ -0,0 +1,17 @@
+using Robust.Shared.GameStates;
+
+namespace Content.Shared.Damage.Components;
+
+///
+/// This is used for a clothing item that modifies the slowdown from taking damage.
+/// Used for entities with
+///
+[RegisterComponent, NetworkedComponent, Access(typeof(SlowOnDamageSystem))]
+public sealed partial class ClothingSlowOnDamageModifierComponent : Component
+{
+ ///
+ /// A coefficient modifier for the slowdown
+ ///
+ [DataField]
+ public float Modifier = 1;
+}
diff --git a/Content.Shared/Damage/Systems/SlowOnDamageSystem.cs b/Content.Shared/Damage/Systems/SlowOnDamageSystem.cs
index 833883c144c5..3e50ee355724 100644
--- a/Content.Shared/Damage/Systems/SlowOnDamageSystem.cs
+++ b/Content.Shared/Damage/Systems/SlowOnDamageSystem.cs
@@ -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 @@ public override void Initialize()
SubscribeLocalEvent(OnDamageChanged);
SubscribeLocalEvent(OnRefreshMovespeed);
+
+ SubscribeLocalEvent>(OnModifySpeed);
+ SubscribeLocalEvent(OnExamined);
+ SubscribeLocalEvent(OnGotEquipped);
+ SubscribeLocalEvent(OnGotUnequipped);
}
private void OnRefreshMovespeed(EntityUid uid, SlowOnDamageComponent component, RefreshMovementSpeedModifiersEvent args)
@@ -36,7 +44,10 @@ private void OnRefreshMovespeed(EntityUid uid, SlowOnDamageComponent component,
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 @@ private void OnDamageChanged(EntityUid uid, SlowOnDamageComponent component, Dam
_movementSpeedModifierSystem.RefreshMovementSpeedModifiers(uid);
}
+
+ private void OnModifySpeed(Entity ent, ref InventoryRelayedEvent 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 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 ent, ref ClothingGotEquippedEvent args)
+ {
+ _movementSpeedModifierSystem.RefreshMovementSpeedModifiers(args.Wearer);
+ }
+
+ private void OnGotUnequipped(Entity ent, ref ClothingGotUnequippedEvent args)
+ {
+ _movementSpeedModifierSystem.RefreshMovementSpeedModifiers(args.Wearer);
+ }
+ }
+
+ [ByRefEvent]
+ public record struct ModifySlowOnDamageSpeedEvent(float Speed) : IInventoryRelayEvent
+ {
+ public SlotFlags TargetSlots => SlotFlags.WITHOUT_POCKET;
}
}
diff --git a/Content.Shared/Inventory/InventorySystem.Relay.cs b/Content.Shared/Inventory/InventorySystem.Relay.cs
index bca9eb6cfa23..f0bb73c1922c 100644
--- a/Content.Shared/Inventory/InventorySystem.Relay.cs
+++ b/Content.Shared/Inventory/InventorySystem.Relay.cs
@@ -34,6 +34,7 @@ public void InitializeRelay()
// by-ref events
SubscribeLocalEvent(RefRelayInventoryEvent);
SubscribeLocalEvent(RefRelayInventoryEvent);
+ SubscribeLocalEvent(RefRelayInventoryEvent);
// Eye/vision events
SubscribeLocalEvent(RelayInventoryEvent);
diff --git a/Resources/Locale/en-US/damage/stamina.ftl b/Resources/Locale/en-US/damage/stamina.ftl
index 0d14a52c1ee0..da817824aa18 100644
--- a/Resources/Locale/en-US/damage/stamina.ftl
+++ b/Resources/Locale/en-US/damage/stamina.ftl
@@ -1 +1,2 @@
melee-stamina = Not enough stamina
+slow-on-damage-modifier-examine = Slowness from injuries is reduced by [color=yellow]{$mod}%[/color]
diff --git a/Resources/Prototypes/Entities/Clothing/Shoes/boots.yml b/Resources/Prototypes/Entities/Clothing/Shoes/boots.yml
index fddb5abb5897..32fd118f1cc6 100644
--- a/Resources/Prototypes/Entities/Clothing/Shoes/boots.yml
+++ b/Resources/Prototypes/Entities/Clothing/Shoes/boots.yml
@@ -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
diff --git a/Resources/Prototypes/Loadouts/loadout_groups.yml b/Resources/Prototypes/Loadouts/loadout_groups.yml
index 685b0c784fa3..868fb1f7d214 100644
--- a/Resources/Prototypes/Loadouts/loadout_groups.yml
+++ b/Resources/Prototypes/Loadouts/loadout_groups.yml
@@ -993,7 +993,6 @@
id: SecurityShoes
name: loadout-group-security-shoes
loadouts:
- - CombatBoots
- JackBoots
- SecurityWinterBoots