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
This commit is contained in:
Whisper
2023-04-18 23:09:22 -04:00
committed by GitHub
parent c52db39077
commit 1b31da956a
3 changed files with 38 additions and 13 deletions

View 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;
}
}
}