]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Blood tweaks & fixes (#14648)
authorKara <lunarautomaton6@gmail.com>
Thu, 16 Mar 2023 22:27:28 +0000 (15:27 -0700)
committerGitHub <noreply@github.com>
Thu, 16 Mar 2023 22:27:28 +0000 (15:27 -0700)
Content.Server/Body/Components/BloodstreamComponent.cs
Content.Server/Body/Systems/BloodstreamSystem.cs

index 11c02d86cdfd5ddcf0734c8cee64110c436ea7e0..50a652d9a3800339d0d4d8c84d8fd7fb77cffc62 100644 (file)
@@ -72,7 +72,7 @@ namespace Content.Server.Body.Components
         ///     How much reagent of blood should be restored each update interval?
         /// </summary>
         [DataField("bloodRefreshAmount")]
-        public float BloodRefreshAmount = 0.2f;
+        public float BloodRefreshAmount = 0.1f;
 
         /// <summary>
         ///     How much blood needs to be in the temporary solution in order to create a puddle?
index b17601a6f02d1430b8f5d79e7654e0b3a2bca8ad..a54eb72af57bb3c62e3efd838326038a8ab3cfb7 100644 (file)
@@ -15,6 +15,7 @@ using Content.Shared.Drunk;
 using Content.Shared.Mobs.Components;
 using Content.Shared.Mobs.Systems;
 using Content.Shared.Rejuvenate;
+using Robust.Server.GameObjects;
 using Robust.Shared.Audio;
 using Robust.Shared.Player;
 using Robust.Shared.Prototypes;
@@ -31,13 +32,9 @@ public sealed class BloodstreamSystem : EntitySystem
     [Dependency] private readonly MobStateSystem _mobStateSystem = default!;
     [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
     [Dependency] private readonly IRobustRandom _robustRandom = default!;
-
+    [Dependency] private readonly AudioSystem _audio = default!;
     [Dependency] private readonly SharedDrunkSystem _drunkSystem = default!;
 
-    // TODO here
-    // Update over time. Modify bloodloss damage in accordance with (amount of blood / max blood level), and reduce bleeding over time
-    // Sub to damage changed event and modify bloodloss if incurring large hits of slashing/piercing
-
     public override void Initialize()
     {
         base.Initialize();
@@ -82,7 +79,8 @@ public sealed class BloodstreamSystem : EntitySystem
     {
         base.Update(frameTime);
 
-        foreach (var bloodstream in EntityManager.EntityQuery<BloodstreamComponent>())
+        var query = new EntityQueryEnumerator<BloodstreamComponent>();
+        while (query.MoveNext(out var uid, out var bloodstream))
         {
             bloodstream.AccumulatedFrametime += frameTime;
 
@@ -91,7 +89,6 @@ public sealed class BloodstreamSystem : EntitySystem
 
             bloodstream.AccumulatedFrametime -= bloodstream.UpdateInterval;
 
-            var uid = bloodstream.Owner;
             if (TryComp<MobStateComponent>(uid, out var state) && _mobStateSystem.IsDead(uid, state))
                 continue;
 
@@ -103,7 +100,7 @@ public sealed class BloodstreamSystem : EntitySystem
             // as well as stop their bleeding to a certain extent.
             if (bloodstream.BleedAmount > 0)
             {
-                TryModifyBloodLevel(uid, (-bloodstream.BleedAmount) / 20, bloodstream);
+                TryModifyBloodLevel(uid, (-bloodstream.BleedAmount) / 10, bloodstream);
                 TryModifyBleedAmount(uid, -bloodstream.BleedReductionAmount, bloodstream);
             }
 
@@ -149,6 +146,10 @@ public sealed class BloodstreamSystem : EntitySystem
         if (args.DamageDelta is null)
             return;
 
+        // definitely don't make them bleed if they got healed
+        if (!args.DamageIncreased)
+            return;
+
         // TODO probably cache this or something. humans get hurt a lot
         if (!_prototypeManager.TryIndex<DamageModifierSetPrototype>(component.DamageBleedModifiers, out var modifiers))
             return;
@@ -168,7 +169,7 @@ public sealed class BloodstreamSystem : EntitySystem
         if (totalFloat > 0 && _robustRandom.Prob(prob))
         {
             TryModifyBloodLevel(uid, (-total) / 5, component);
-            SoundSystem.Play(component.InstantBloodSound.GetSound(), Filter.Pvs(uid), uid, AudioParams.Default);
+            _audio.PlayPvs(component.InstantBloodSound, uid);
         }
         else if (totalFloat < 0 && oldBleedAmount > 0 && _robustRandom.Prob(healPopupProb))
         {
@@ -176,7 +177,7 @@ public sealed class BloodstreamSystem : EntitySystem
             // because it's burn damage that cauterized their wounds.
 
             // We'll play a special sound and popup for feedback.
-            SoundSystem.Play(component.BloodHealedSound.GetSound(), Filter.Pvs(uid), uid, AudioParams.Default);
+            _audio.PlayPvs(component.BloodHealedSound, uid);
             _popupSystem.PopupEntity(Loc.GetString("bloodstream-component-wounds-cauterized"), uid,
                 uid, PopupType.Medium);
         }