]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fixed bola effect stacking (#34723)
authorpubbi <63283968+impubbi@users.noreply.github.com>
Tue, 4 Feb 2025 16:11:46 +0000 (10:11 -0600)
committerGitHub <noreply@github.com>
Tue, 4 Feb 2025 16:11:46 +0000 (11:11 -0500)
Content.Shared/Ensnaring/Components/EnsnareableComponent.cs
Content.Shared/Ensnaring/Components/EnsnaringComponent.cs
Content.Shared/Ensnaring/SharedEnsnareableSystem.cs
Resources/Prototypes/Entities/Objects/Weapons/Throwable/bola.yml

index 307a5e19863306b637bac3e9204ce0d207e18784..126031dc6b0c9468c3dcab635cb6209b7ce8d556 100644 (file)
@@ -13,13 +13,13 @@ public sealed partial class EnsnareableComponent : Component
     /// <summary>
     /// How much should this slow down the entities walk?
     /// </summary>
-    [DataField]
+    [DataField, AutoNetworkedField]
     public float WalkSpeed = 1.0f;
 
     /// <summary>
     /// How much should this slow down the entities sprint?
     /// </summary>
-    [DataField]
+    [DataField, AutoNetworkedField]
     public float SprintSpeed = 1.0f;
 
     /// <summary>
index f900d863c2a9aaf59b82fbfeb1780f24e08896f0..b05ce151d84b8e1b9b0c021f0de7fc0c3369ae9c 100644 (file)
@@ -38,6 +38,12 @@ public sealed partial class EnsnaringComponent : Component
     [DataField]
     public float StaminaDamage = 55f;
 
+    /// <summary>
+    /// How many times can the ensnare be applied to the same target?
+    /// </summary>
+    [DataField]
+    public float MaxEnsnares = 1;
+
     /// <summary>
     /// Should this ensnare someone when thrown?
     /// </summary>
index 551c76ff8d5f53d4137a99750d4cc0ab5e93e83a..dacb773470862d40a098b8e51f0d9990fd89ed1a 100644 (file)
@@ -256,23 +256,18 @@ public abstract class SharedEnsnareableSystem : EntitySystem
         if (!TryComp<EnsnareableComponent>(target, out var ensnareable))
             return false;
 
-        // Need to insert before free legs check.
-        Container.Insert(ensnare, ensnareable.Container);
-
-        var legs = _body.GetBodyChildrenOfType(target, BodyPartType.Leg).Count();
-        var ensnaredLegs = (2 * ensnareable.Container.ContainedEntities.Count);
-        var freeLegs = legs - ensnaredLegs;
+        var numEnsnares = ensnareable.Container.ContainedEntities.Count;
 
-        if (freeLegs > 0)
+        //Don't do anything if the maximum number of ensnares is applied.
+        if (numEnsnares >= component.MaxEnsnares)
             return false;
 
-        // Apply stamina damage to target if they weren't ensnared before.
-        if (ensnareable.IsEnsnared != true)
+        Container.Insert(ensnare, ensnareable.Container);
+
+        // Apply stamina damage to target
+        if (TryComp<StaminaComponent>(target, out var stamina))
         {
-            if (TryComp<StaminaComponent>(target, out var stamina))
-            {
-                _stamina.TakeStaminaDamage(target, component.StaminaDamage, with: ensnare, component: stamina);
-            }
+            _stamina.TakeStaminaDamage(target, component.StaminaDamage, with: ensnare, component: stamina);
         }
 
         component.Ensnared = target;
index f8d5efb8c68e090b0386e1530275191c22dec5b2..f6630adbb322f379a7f6f9850b8eafd126de50d1 100644 (file)
@@ -47,4 +47,5 @@
     staminaDamage: 0 # anything but this is gamebreaking
     canThrowTrigger: true
     canMoveBreakout: true
+    maxEnsnares: 1
   - type: LandAtCursor