From: Whisper <121047731+QuietlyWhisper@users.noreply.github.com>
Date: Wed, 19 Apr 2023 03:09:22 +0000 (-0400)
Subject: Bloodloss drunk status no longer persists after being healthy AND dead bodies will...
X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=1b31da956abb935caa8943151fd379a3c5b950f4;p=space-station-14.git
Bloodloss drunk status no longer persists after being healthy AND dead bodies will still bleed (#15189)
* 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
---
diff --git a/Content.Server/Body/Components/BloodstreamComponent.cs b/Content.Server/Body/Components/BloodstreamComponent.cs
index 0f8dc688fd..29806908e3 100644
--- a/Content.Server/Body/Components/BloodstreamComponent.cs
+++ b/Content.Server/Body/Components/BloodstreamComponent.cs
@@ -51,12 +51,14 @@ namespace Content.Server.Body.Components
///
/// The base bloodloss damage to be incurred if below
+ /// The default values are defined per mob/species in YML.
///
[DataField("bloodlossDamage", required: true)]
public DamageSpecifier BloodlossDamage = new();
///
/// The base bloodloss damage to be healed if above
+ /// The default values are defined per mob/species in YML.
///
[DataField("bloodlossHealDamage", required: true)]
public DamageSpecifier BloodlossHealDamage = new();
@@ -146,5 +148,11 @@ namespace Content.Server.Body.Components
///
[ViewVariables(VVAccess.ReadWrite)]
public Solution BloodTemporarySolution = default!;
+
+ ///
+ /// Variable that stores the amount of drunk time added by having a low blood level.
+ ///
+ [ViewVariables(VVAccess.ReadWrite)]
+ public float DrunkTime;
}
}
diff --git a/Content.Server/Body/Systems/BloodstreamSystem.cs b/Content.Server/Body/Systems/BloodstreamSystem.cs
index b5958d8561..fa8b9055f2 100644
--- a/Content.Server/Body/Systems/BloodstreamSystem.cs
+++ b/Content.Server/Body/Systems/BloodstreamSystem.cs
@@ -90,14 +90,11 @@ public sealed class BloodstreamSystem : EntitySystem
bloodstream.AccumulatedFrametime -= bloodstream.UpdateInterval;
- if (TryComp(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;
+
}
}
}
diff --git a/Content.Shared/Drunk/DrunkSystem.cs b/Content.Shared/Drunk/DrunkSystem.cs
index f09f260817..4fb91f7213 100644
--- a/Content.Shared/Drunk/DrunkSystem.cs
+++ b/Content.Shared/Drunk/DrunkSystem.cs
@@ -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));
+ }
+
}