/// <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();
/// </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;
}
}
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)
{
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;
+
}
}
}