Skip to content

Commit

Permalink
Make Blood Deficiency Bloodloss Consistent (Simple-Station#895)
Browse files Browse the repository at this point in the history
# Description

With Simple-Station#858 (Make
Height Sliders Affect Your Bloodstream Volume) being merged, it
introduced variable blood volumes for differing sizes, whereas before
everyone had the same blood volume (300u).

Because Blood Deficiency subtracted a flat amount from the bloodstream,
it resulted in an unintended consequence where small characters died
very quickly due to blood loss, while large characters could live for
hours. This makes the blood loss amount of Blood Deficiency a
**percentage** of the entity's max blood volume, which means that the
time to become low blood is now the same regardless of blood volume.

# Changelog

:cl: Skubman
- fix: Blood Deficiency now makes you lose a consistent percentage of
blood regardless of your blood volume, which is dictated by size. This
makes the time to low blood and death consistent for every character of
all sizes with this trait.
  • Loading branch information
angelofallars authored Sep 12, 2024
1 parent 67a17ae commit 093ab48
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Content.Server/Body/Components/BloodstreamComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ public sealed partial class BloodstreamComponent : Component
public bool HasBloodDeficiency = false;

/// <summary>
/// How much reagent of blood should be removed with blood deficiency in each update interval?
/// How much percentage of max blood volume should be removed with blood deficiency in each update interval?
/// </summary>
[DataField]
public FixedPoint2 BloodDeficiencyLossAmount;
public float BloodDeficiencyLossPercentage;
}
}
10 changes: 9 additions & 1 deletion Content.Server/Body/Systems/BloodstreamSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public override void Update(float frameTime)
if (bloodstream.HasBloodDeficiency)
{
if (!_mobStateSystem.IsDead(uid))
RemoveBlood(uid, bloodstream.BloodDeficiencyLossAmount, bloodstream);
RemoveBlood(uid, bloodstream.BloodMaxVolume * bloodstream.BloodDeficiencyLossPercentage, bloodstream);
}
// Adds blood to their blood level if it is below the maximum.
else if (bloodSolution.Volume < bloodSolution.MaxVolume && !_mobStateSystem.IsDead(uid))
Expand Down Expand Up @@ -349,6 +349,14 @@ public void SetBloodLossThreshold(EntityUid uid, float threshold, BloodstreamCom
comp.BloodlossThreshold = threshold;
}

public void SetBloodMaxVolume(EntityUid uid, FixedPoint2 volume, BloodstreamComponent? comp = null)
{
if (!Resolve(uid, ref comp))
return;

comp.BloodMaxVolume = volume;
}

/// <summary>
/// Attempts to modify the blood level of this entity directly.
/// </summary>
Expand Down
4 changes: 4 additions & 0 deletions Content.Server/HeightAdjust/BloodstreamAdjustSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Content.Server.Body.Components;
using Content.Server.Body.Systems;
using Content.Server.Chemistry.Containers.EntitySystems;
using Content.Shared.CCVar;
using Content.Shared.Chemistry.Reagent;
Expand All @@ -10,6 +11,7 @@ namespace Content.Server.HeightAdjust;

public sealed class BloodstreamAdjustSystem : EntitySystem
{
[Dependency] private readonly BloodstreamSystem _bloodstream = default!;
[Dependency] private readonly IConfigurationManager _config = default!;
[Dependency] private readonly ContestsSystem _contests = default!;
[Dependency] private readonly SolutionContainerSystem _solutionContainer = default!;
Expand Down Expand Up @@ -40,6 +42,8 @@ public bool TryAdjustBloodstream(Entity<BloodstreamAffectedByMassComponent> ent)
bloodSolution.MaxVolume = newVolume;
bloodSolution.SetContents([new ReagentQuantity(bloodstream.BloodReagent, newBloodLevel, null)], false);

_bloodstream.SetBloodMaxVolume(ent.Owner, newVolume, bloodstream);

return true;
}
}
4 changes: 2 additions & 2 deletions Content.Server/Traits/BloodDeficiencyComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ namespace Content.Server.Traits.Assorted;
public sealed partial class BloodDeficiencyComponent : Component
{
// <summary>
// How much reagent of blood should be removed in each update interval?
/// How much percentage of max blood volume should be removed in each update interval?
// </summary>
[DataField(required: true)]
public float BloodLossAmount;
public float BloodLossPercentage;
}
2 changes: 1 addition & 1 deletion Content.Server/Traits/BloodDeficiencySystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ private void OnStartup(EntityUid uid, BloodDeficiencyComponent component, Compon
return;

bloodstream.HasBloodDeficiency = true;
bloodstream.BloodDeficiencyLossAmount = component.BloodLossAmount;
bloodstream.BloodDeficiencyLossPercentage = component.BloodLossPercentage;
}
}
4 changes: 2 additions & 2 deletions Resources/Prototypes/Traits/disabilities.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@
species:
- IPC
components:
- type: BloodDeficiency # 0.07 = start taking bloodloss damage at around ~21.4 minutes,
bloodLossAmount: 0.07 # then become crit ~10 minutes later
- type: BloodDeficiency # by default, start taking bloodloss damage at around ~21.4 minutes,
bloodLossPercentage: 0.0002333333 # then become crit ~10 minutes

- type: trait
id: Hemophilia
Expand Down

0 comments on commit 093ab48

Please sign in to comment.