Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Blood Deficiency Bloodloss Consistent #895

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading