]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Bloodloss drunk status no longer persists after being healthy AND dead bodies will...
authorWhisper <121047731+QuietlyWhisper@users.noreply.github.com>
Wed, 19 Apr 2023 03:09:22 +0000 (23:09 -0400)
committerGitHub <noreply@github.com>
Wed, 19 Apr 2023 03:09:22 +0000 (23:09 -0400)
* removing drunk scaling with missing blood, drunk will apply until blood restored

* added new drunk function to go with new bloodloss drunk code

* initial tryremovetime code for drunk system. Still need to code it into bloodloss and test.

* initial tryremovetime code for drunk system. Still need to code it into bloodloss and test.

* Drunk status added by low blood level should be removed when healthy

* Everything is working in the dev enviroment. Cleaning up code.

* Dead bodies bleed, do not recover blood, and do not take further bloodloss damage to missing blood

* Last commit

Content.Server/Body/Components/BloodstreamComponent.cs
Content.Server/Body/Systems/BloodstreamSystem.cs
Content.Shared/Drunk/DrunkSystem.cs

index 0f8dc688fd17ed412c82c344953288de775c98ae..29806908e3b7b2372e435dcf2d06d443f8d76dff 100644 (file)
@@ -51,12 +51,14 @@ namespace Content.Server.Body.Components
 
         /// <summary>
         ///     The base bloodloss damage to be incurred if below <see cref="BloodlossThreshold"/>
+        ///     The default values are defined per mob/species in YML.
         /// </summary>
         [DataField("bloodlossDamage", required: true)]
         public DamageSpecifier BloodlossDamage = new();
 
         /// <summary>
         ///     The base bloodloss damage to be healed if above <see cref="BloodlossThreshold"/>
+        ///     The default values are defined per mob/species in YML.
         /// </summary>
         [DataField("bloodlossHealDamage", required: true)]
         public DamageSpecifier BloodlossHealDamage = new();
@@ -146,5 +148,11 @@ namespace Content.Server.Body.Components
         /// </summary>
         [ViewVariables(VVAccess.ReadWrite)]
         public Solution BloodTemporarySolution = default!;
+
+        /// <summary>
+        /// Variable that stores the amount of drunk time added by having a low blood level.
+        /// </summary>
+        [ViewVariables(VVAccess.ReadWrite)]
+        public float DrunkTime;
     }
 }
index b5958d8561e32c26d145b72476277efb37b7ce94..fa8b9055f271bb4c0913170b9723c40e182b6a93 100644 (file)
@@ -90,14 +90,11 @@ public sealed class BloodstreamSystem : EntitySystem
 
             bloodstream.AccumulatedFrametime -= bloodstream.UpdateInterval;
 
-            if (TryComp<MobStateComponent>(uid, out var state) && _mobStateSystem.IsDead(uid, state))
-                continue;
-
-            // First, let's refresh their blood if possible.
-            if (bloodstream.BloodSolution.Volume < bloodstream.BloodSolution.MaxVolume)
+            // Adds blood to their blood level if it is below the maximum; Blood regeneration. Must be alive.
+            if (bloodstream.BloodSolution.Volume < bloodstream.BloodSolution.MaxVolume && _mobStateSystem.IsAlive(uid))
                 TryModifyBloodLevel(uid, bloodstream.BloodRefreshAmount, bloodstream);
 
-            // Next, let's remove some blood from them according to their bleed level.
+            // Removes blood from the bloodstream based on bleed amount (bleed rate)
             // as well as stop their bleeding to a certain extent.
             if (bloodstream.BleedAmount > 0)
             {
@@ -107,24 +104,34 @@ public sealed class BloodstreamSystem : EntitySystem
                 TryModifyBleedAmount(uid, -bloodstream.BleedReductionAmount, bloodstream);
             }
 
-            // Next, we'll deal some bloodloss damage if their blood level is below a threshold.
+            // deal bloodloss damage if their blood level is below a threshold.
             var bloodPercentage = GetBloodLevelPercentage(uid, bloodstream);
-            if (bloodPercentage < bloodstream.BloodlossThreshold)
+            if (bloodPercentage < bloodstream.BloodlossThreshold && _mobStateSystem.IsAlive(uid))
             {
-                // TODO use a better method for determining this.
+                // bloodloss damage is based on the base value, and modified by how low your blood level is.
                 var amt = bloodstream.BloodlossDamage / (0.1f + bloodPercentage);
 
                 _damageableSystem.TryChangeDamage(uid, amt, true, false);
 
                 // Apply dizziness as a symptom of bloodloss.
-                // So, threshold is 0.9, you have 0.85 percent blood, it adds (5 * 1.05) or 5.25 seconds of drunkenness.
-                // So, it'd max at 1.9 by default with 0% blood.
-                _drunkSystem.TryApplyDrunkenness(uid, bloodstream.UpdateInterval * (1 + (bloodstream.BloodlossThreshold - bloodPercentage)), false);
+                // The effect is applied in a way that it will never be cleared without being healthy.
+                // Multiplying by 2 is arbitrary but works for this case, it just prevents the time from running out
+                _drunkSystem.TryApplyDrunkenness(uid, bloodstream.UpdateInterval*2, false);
+
+                // storing the drunk time so we can remove it independently from other effects additions
+                bloodstream.DrunkTime += bloodstream.UpdateInterval * 2;
+
             }
-            else
+            else if (_mobStateSystem.IsAlive(uid))
             {
                 // If they're healthy, we'll try and heal some bloodloss instead.
                 _damageableSystem.TryChangeDamage(uid, bloodstream.BloodlossHealDamage * bloodPercentage, true, false);
+
+                // Remove the drunk effect when healthy. Should only remove the amount of drunk added by low blood level
+                _drunkSystem.TryRemoveDrunkenessTime(uid, bloodstream.DrunkTime);
+                // Reset the drunk time to zero
+                bloodstream.DrunkTime = 0;
+
             }
         }
     }
index f09f260817b18d574e45816d0a12a7b0dcfc959a..4fb91f721353ebe0e9046e38ad17f40930483026 100644 (file)
@@ -32,4 +32,14 @@ public abstract class SharedDrunkSystem : EntitySystem
             _statusEffectsSystem.TryAddTime(uid, DrunkKey, TimeSpan.FromSeconds(boozePower), status);
         }
     }
+
+    public void TryRemoveDrunkenness(EntityUid uid)
+    {
+        _statusEffectsSystem.TryRemoveStatusEffect(uid, DrunkKey);
+    }
+    public void TryRemoveDrunkenessTime(EntityUid uid, double timeRemoved)
+    {
+        _statusEffectsSystem.TryRemoveTime(uid, DrunkKey, TimeSpan.FromSeconds(timeRemoved));
+    }
+
 }