]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix puncturase cauterizing bleeding (#38289)
authorslarticodefast <161409025+slarticodefast@users.noreply.github.com>
Fri, 13 Jun 2025 16:11:15 +0000 (18:11 +0200)
committerGitHub <noreply@github.com>
Fri, 13 Jun 2025 16:11:15 +0000 (12:11 -0400)
fix puncturase cauterizing bleeding

Content.Server/Body/Systems/BloodstreamSystem.cs
Content.Shared/Damage/DamageSpecifier.cs
Resources/Prototypes/Damage/modifier_sets.yml

index 9816c8c3f6b1f1d0bd0ba6c09e7973d3e73cff58..6d85affad36c95b21da3204a9adea6781945b162 100644 (file)
@@ -205,10 +205,13 @@ public sealed class BloodstreamSystem : EntitySystem
         }
 
         // TODO probably cache this or something. humans get hurt a lot
-        if (!_prototypeManager.TryIndex<DamageModifierSetPrototype>(ent.Comp.DamageBleedModifiers, out var modifiers))
+        if (!_prototypeManager.TryIndex(ent.Comp.DamageBleedModifiers, out var modifiers))
             return;
 
-        var bloodloss = DamageSpecifier.ApplyModifierSet(args.DamageDelta, modifiers);
+        // some reagents may deal and heal different damage types in the same tick, which means DamageIncreased will be true
+        // but we only want to consider the dealt damage when causing bleeding
+        var damage = DamageSpecifier.GetPositive(args.DamageDelta);
+        var bloodloss = DamageSpecifier.ApplyModifierSet(damage, modifiers);
 
         if (bloodloss.Empty)
             return;
@@ -227,7 +230,7 @@ public sealed class BloodstreamSystem : EntitySystem
         var prob = Math.Clamp(totalFloat / 25, 0, 1);
         if (totalFloat > 0 && _robustRandom.Prob(prob))
         {
-            TryModifyBloodLevel(ent, (-total) / 5, ent);
+            TryModifyBloodLevel(ent, -total / 5, ent);
             _audio.PlayPvs(ent.Comp.InstantBloodSound, ent);
         }
 
index 7f505b807f776820577470fd0945412e67626e34..51472a56bd2a2685a82f6801d6e11c7f52b156d4 100644 (file)
@@ -23,7 +23,7 @@ namespace Content.Shared.Damage
         [JsonPropertyName("types")]
         [DataField("types", customTypeSerializer: typeof(PrototypeIdDictionarySerializer<FixedPoint2, DamageTypePrototype>))]
         [UsedImplicitly]
-        private Dictionary<string,FixedPoint2>? _damageTypeDictionary;
+        private Dictionary<string, FixedPoint2>? _damageTypeDictionary;
 
         [JsonPropertyName("groups")]
         [DataField("groups", customTypeSerializer: typeof(PrototypeIdDictionarySerializer<FixedPoint2, DamageGroupPrototype>))]
@@ -152,7 +152,7 @@ namespace Content.Shared.Damage
                 if (modifierSet.Coefficients.TryGetValue(key, out var coefficient))
                     newValue *= coefficient; // coefficients can heal you, e.g. cauterizing bleeding
 
-                if(newValue != 0)
+                if (newValue != 0)
                     newDamage.DamageDict[key] = FixedPoint2.New(newValue);
             }
 
@@ -183,6 +183,38 @@ namespace Content.Shared.Damage
             return newDamage;
         }
 
+        /// <summary>
+        /// Returns a new DamageSpecifier that only contains the entries with positive value.
+        /// </summary>
+        public static DamageSpecifier GetPositive(DamageSpecifier damageSpec)
+        {
+            DamageSpecifier newDamage = new();
+
+            foreach (var (key, value) in damageSpec.DamageDict)
+            {
+                if (value > 0)
+                    newDamage.DamageDict[key] = value;
+            }
+
+            return newDamage;
+        }
+
+        /// <summary>
+        /// Returns a new DamageSpecifier that only contains the entries with negative value.
+        /// </summary>
+        public static DamageSpecifier GetNegative(DamageSpecifier damageSpec)
+        {
+            DamageSpecifier newDamage = new();
+
+            foreach (var (key, value) in damageSpec.DamageDict)
+            {
+                if (value < 0)
+                    newDamage.DamageDict[key] = value;
+            }
+
+            return newDamage;
+        }
+
         /// <summary>
         ///     Remove any damage entries with zero damage.
         /// </summary>
index 3a3a372b6e97202c5f0ca9c172bbbf8326c9a776..0f023e247014b323bdc996160959a62da85389af 100644 (file)
 
 # Represents which damage types should be modified
 # in relation to how they cause bleed rate.
+# Make sure to add any new damage type here.
 - type: damageModifierSet
   id: BloodlossHuman
   coefficients:
+    Asphyxiation: 0.0
+    Bloodloss: 0.0 # no double dipping
     Blunt: 0.08
-    Slash: 0.25
-    Piercing: 0.2
-    Shock: 0.0
+    Caustic: 0.0
+    Cellular: 0.0
     Cold: 0.0
     Heat: -0.5 # heat damage cauterizes wounds, but will still hurt obviously.
+    Holy: 0
+    Piercing: 0.2
     Poison: 0.0
     Radiation: 0.0
-    Asphyxiation: 0.0
-    Bloodloss: 0.0 # no double dipping
-    Cellular: 0.0
-    Caustic: 0.0
+    Shock: 0.0
+    Slash: 0.25
+    Structural: 0.0
 
 - type: damageModifierSet
   id: SlimePet # Very survivable slimes