forked from DeltaV-Station/Delta-v
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make Height Sliders Affect Your Bloodstream Volume (DeltaV-Station#858)
# Description Something that just makes sense, this makes your effect character weight affect your bloodstream volume. As a minimum size felinid you will get 33% of normal blood volume, whereas as something as huge as a lamia you may get up to 3 times the normal blood volume. The resulting volume of your bloodstream can be calculated as `V = clamp(normal_volume * mass_contest ^ 0.6)` (assuming default parameters), where mass_contest is the result of a mass contest between your entity and the average humanoid. For average species like vulps, this means that their bloodstream can become up to ~40% smaller than normal (at minimum size), or up to 50% larger than normal (at maximum size). For onis the range is shifted towards higher values, a maximum size oni will have twice as much blood as an average human. This has both drawbacks and advantages. For instance, having little blood means you can bleed out easily, but at the same time it means it will take way less blood packs/saline/iron/proteins to restore your blood to the normal level. Opposite is also true, having more blood means you will be harder to heal. Also, this PR slightly refactors the HeightAdjustSystem to be more flexible. <details><summary><h1>Media</h1></summary> <p> https://github.com/user-attachments/assets/951c2391-09d8-4a4a-812b-a2394862fadd </p> </details> # Changelog :cl: - add: Your character size now affects your blood level. Smaller characters will have less blood, and larger characters will have more. --------- Signed-off-by: Mnemotechnican <[email protected]> Co-authored-by: VMSolidus <[email protected]> Co-authored-by: DEATHB4DEFEAT <[email protected]>
- Loading branch information
1 parent
0ab7da1
commit 9dd569d
Showing
6 changed files
with
96 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using Content.Server.Body.Components; | ||
using Content.Server.Chemistry.Containers.EntitySystems; | ||
using Content.Shared.CCVar; | ||
using Content.Shared.Chemistry.Reagent; | ||
using Content.Shared.Contests; | ||
using Content.Shared.HeightAdjust; | ||
using Robust.Shared.Configuration; | ||
|
||
namespace Content.Server.HeightAdjust; | ||
|
||
public sealed class BloodstreamAdjustSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly IConfigurationManager _config = default!; | ||
[Dependency] private readonly ContestsSystem _contests = default!; | ||
[Dependency] private readonly SolutionContainerSystem _solutionContainer = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
SubscribeLocalEvent<BloodstreamAffectedByMassComponent, MapInitEvent>((uid, comp, _) => TryAdjustBloodstream((uid, comp))); | ||
SubscribeLocalEvent<BloodstreamAffectedByMassComponent, HeightAdjustedEvent>((uid, comp, _) => TryAdjustBloodstream((uid, comp))); | ||
} | ||
|
||
/// <summary> | ||
/// Adjusts the bloodstream of the specified entity based on the settings provided by the component. | ||
/// </summary> | ||
public bool TryAdjustBloodstream(Entity<BloodstreamAffectedByMassComponent> ent) | ||
{ | ||
if (!TryComp<BloodstreamComponent>(ent, out var bloodstream) | ||
|| !_solutionContainer.TryGetSolution(ent.Owner, bloodstream.BloodSolutionName, out var bloodSolutionEnt) | ||
|| !_config.GetCVar(CCVars.HeightAdjustModifiesBloodstream)) | ||
return false; | ||
|
||
var bloodSolution = bloodSolutionEnt.Value.Comp.Solution; | ||
|
||
var factor = Math.Pow(_contests.MassContest(ent, bypassClamp: true, rangeFactor: 4f), ent.Comp.Power); | ||
factor = Math.Clamp(factor, ent.Comp.Min, ent.Comp.Max); | ||
|
||
var newVolume = bloodstream.BloodMaxVolume * factor; | ||
var newBloodLevel = bloodSolution.FillFraction * newVolume; | ||
bloodSolution.MaxVolume = newVolume; | ||
bloodSolution.SetContents([new ReagentQuantity(bloodstream.BloodReagent, newBloodLevel, null)], false); | ||
|
||
return true; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
Content.Server/HeightAdjust/BloodstreamAffectedByMassComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using Content.Server.Body.Components; | ||
|
||
namespace Content.Server.HeightAdjust; | ||
|
||
/// <summary> | ||
/// When applied to a humanoid or any mob, adjusts their blood level based on the mass contest between them | ||
/// and an average humanoid. | ||
/// <br/> | ||
/// The formula for the resulting bloodstream volume is <code>V = BloodMaxVolume * MassContest^Power</code> | ||
/// clamped between the specified Min and Max values. | ||
/// </summary> | ||
[RegisterComponent] | ||
public sealed partial class BloodstreamAffectedByMassComponent : Component | ||
{ | ||
/// <summary> | ||
/// Minimum and maximum resulting volume factors. A minimum value of 0.5 means that the resulting volume will be at least 50% of the original. | ||
/// </summary> | ||
[DataField] | ||
public float Min = 1 / 3f, Max = 3f; | ||
|
||
/// <summary> | ||
/// The power to which the outcome of the mass contest will be risen. | ||
/// </summary> | ||
[DataField] | ||
public float Power = 1f; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System.Numerics; | ||
|
||
namespace Content.Shared.HeightAdjust; | ||
|
||
/// <summary> | ||
/// Raised on a humanoid after their scale has been adjusted in accordance with their profile and their physics have been updated. | ||
/// </summary> | ||
public sealed class HeightAdjustedEvent : EntityEventArgs | ||
{ | ||
public Vector2 NewScale; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters