2021-11-30 16:47:21 -07:00
|
|
|
using Content.Server.Body.Components;
|
|
|
|
|
using Content.Server.Chemistry.EntitySystems;
|
2022-04-05 04:02:33 +12:00
|
|
|
using Content.Server.Chemistry.ReactionEffects;
|
2022-02-17 15:00:41 -07:00
|
|
|
using Content.Server.Fluids.EntitySystems;
|
2023-03-31 07:49:25 +03:00
|
|
|
using Content.Server.Forensics;
|
2022-02-18 23:03:15 -07:00
|
|
|
using Content.Server.HealthExaminable;
|
2022-02-20 17:18:24 -07:00
|
|
|
using Content.Server.Popups;
|
2023-07-26 02:28:35 +05:00
|
|
|
using Content.Shared.Alert;
|
2021-11-30 16:47:21 -07:00
|
|
|
using Content.Shared.Chemistry.Components;
|
2022-04-05 04:02:33 +12:00
|
|
|
using Content.Shared.Chemistry.Reaction;
|
2022-02-17 15:00:41 -07:00
|
|
|
using Content.Shared.Damage;
|
|
|
|
|
using Content.Shared.Damage.Prototypes;
|
2021-11-30 16:47:21 -07:00
|
|
|
using Content.Shared.FixedPoint;
|
2022-07-10 18:36:53 -07:00
|
|
|
using Content.Shared.IdentityManagement;
|
2022-07-09 02:09:52 -07:00
|
|
|
using Content.Shared.Popups;
|
2022-07-30 22:24:24 -04:00
|
|
|
using Content.Shared.Drunk;
|
2023-01-13 16:57:10 -08:00
|
|
|
using Content.Shared.Mobs.Components;
|
|
|
|
|
using Content.Shared.Mobs.Systems;
|
2022-09-14 19:30:56 +02:00
|
|
|
using Content.Shared.Rejuvenate;
|
2023-03-16 15:27:28 -07:00
|
|
|
using Robust.Server.GameObjects;
|
2022-02-17 15:00:41 -07:00
|
|
|
using Robust.Shared.Audio;
|
|
|
|
|
using Robust.Shared.Player;
|
|
|
|
|
using Robust.Shared.Prototypes;
|
|
|
|
|
using Robust.Shared.Random;
|
2023-05-05 21:46:52 +08:00
|
|
|
using Content.Shared.Speech.EntitySystems;
|
2021-11-30 16:47:21 -07:00
|
|
|
|
|
|
|
|
namespace Content.Server.Body.Systems;
|
|
|
|
|
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class BloodstreamSystem : EntitySystem
|
2021-11-30 16:47:21 -07:00
|
|
|
{
|
2022-02-17 15:00:41 -07:00
|
|
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
|
|
|
|
[Dependency] private readonly IRobustRandom _robustRandom = default!;
|
2023-03-16 15:27:28 -07:00
|
|
|
[Dependency] private readonly AudioSystem _audio = default!;
|
2023-04-10 15:37:03 +10:00
|
|
|
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
|
|
|
|
|
[Dependency] private readonly PopupSystem _popupSystem = default!;
|
|
|
|
|
[Dependency] private readonly PuddleSystem _puddleSystem = default!;
|
|
|
|
|
[Dependency] private readonly MobStateSystem _mobStateSystem = default!;
|
2022-07-30 22:24:24 -04:00
|
|
|
[Dependency] private readonly SharedDrunkSystem _drunkSystem = default!;
|
2023-04-10 15:37:03 +10:00
|
|
|
[Dependency] private readonly SolutionContainerSystem _solutionContainerSystem = default!;
|
2023-05-05 21:46:52 +08:00
|
|
|
[Dependency] private readonly SharedStutteringSystem _stutteringSystem = default!;
|
2023-07-26 02:28:35 +05:00
|
|
|
[Dependency] private readonly AlertsSystem _alertsSystem = default!;
|
2022-07-30 22:24:24 -04:00
|
|
|
|
2021-11-30 16:47:21 -07:00
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
|
|
|
|
|
|
|
|
|
SubscribeLocalEvent<BloodstreamComponent, ComponentInit>(OnComponentInit);
|
2022-02-17 15:00:41 -07:00
|
|
|
SubscribeLocalEvent<BloodstreamComponent, DamageChangedEvent>(OnDamageChanged);
|
2022-02-18 23:03:15 -07:00
|
|
|
SubscribeLocalEvent<BloodstreamComponent, HealthBeingExaminedEvent>(OnHealthBeingExamined);
|
2022-02-18 15:57:42 -07:00
|
|
|
SubscribeLocalEvent<BloodstreamComponent, BeingGibbedEvent>(OnBeingGibbed);
|
2022-04-15 18:53:52 -04:00
|
|
|
SubscribeLocalEvent<BloodstreamComponent, ApplyMetabolicMultiplierEvent>(OnApplyMetabolicMultiplier);
|
2022-04-05 04:02:33 +12:00
|
|
|
SubscribeLocalEvent<BloodstreamComponent, ReactionAttemptEvent>(OnReactionAttempt);
|
2022-09-14 19:30:56 +02:00
|
|
|
SubscribeLocalEvent<BloodstreamComponent, RejuvenateEvent>(OnRejuvenate);
|
2022-04-05 04:02:33 +12:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnReactionAttempt(EntityUid uid, BloodstreamComponent component, ReactionAttemptEvent args)
|
|
|
|
|
{
|
|
|
|
|
if (args.Solution.Name != BloodstreamComponent.DefaultBloodSolutionName
|
|
|
|
|
&& args.Solution.Name != BloodstreamComponent.DefaultChemicalsSolutionName
|
|
|
|
|
&& args.Solution.Name != BloodstreamComponent.DefaultBloodTemporarySolutionName)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
foreach (var effect in args.Reaction.Effects)
|
|
|
|
|
{
|
|
|
|
|
switch (effect)
|
|
|
|
|
{
|
|
|
|
|
case CreateEntityReactionEffect: // Prevent entities from spawning in the bloodstream
|
|
|
|
|
case AreaReactionEffect: // No spontaneous smoke or foam leaking out of blood vessels.
|
|
|
|
|
args.Cancel();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The area-reaction effect canceling is part of avoiding smoke-fork-bombs (create two smoke bombs, that when
|
|
|
|
|
// ingested by mobs create more smoke). This also used to act as a rapid chemical-purge, because all the
|
|
|
|
|
// reagents would get carried away by the smoke/foam. This does still work for the stomach (I guess people vomit
|
|
|
|
|
// up the smoke or spawned entities?).
|
|
|
|
|
|
|
|
|
|
// TODO apply organ damage instead of just blocking the reaction?
|
|
|
|
|
// Having cheese-clots form in your veins can't be good for you.
|
2022-02-17 15:00:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Update(float frameTime)
|
|
|
|
|
{
|
|
|
|
|
base.Update(frameTime);
|
|
|
|
|
|
2023-03-17 14:40:20 +13:00
|
|
|
var query = EntityQueryEnumerator<BloodstreamComponent>();
|
2023-03-16 15:27:28 -07:00
|
|
|
while (query.MoveNext(out var uid, out var bloodstream))
|
2022-02-17 15:00:41 -07:00
|
|
|
{
|
|
|
|
|
bloodstream.AccumulatedFrametime += frameTime;
|
|
|
|
|
|
|
|
|
|
if (bloodstream.AccumulatedFrametime < bloodstream.UpdateInterval)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
bloodstream.AccumulatedFrametime -= bloodstream.UpdateInterval;
|
|
|
|
|
|
2023-04-18 23:09:22 -04:00
|
|
|
// Adds blood to their blood level if it is below the maximum; Blood regeneration. Must be alive.
|
2023-05-26 03:23:29 -04:00
|
|
|
if (bloodstream.BloodSolution.Volume < bloodstream.BloodSolution.MaxVolume && !_mobStateSystem.IsDead(uid))
|
|
|
|
|
{
|
2022-02-17 15:00:41 -07:00
|
|
|
TryModifyBloodLevel(uid, bloodstream.BloodRefreshAmount, bloodstream);
|
2023-05-26 03:23:29 -04:00
|
|
|
}
|
2022-02-17 15:00:41 -07:00
|
|
|
|
2023-04-18 23:09:22 -04:00
|
|
|
// Removes blood from the bloodstream based on bleed amount (bleed rate)
|
2022-02-17 15:00:41 -07:00
|
|
|
// as well as stop their bleeding to a certain extent.
|
|
|
|
|
if (bloodstream.BleedAmount > 0)
|
|
|
|
|
{
|
The bleed update (#14814)
* Removed arbitrary modifier scaling. The bleed amount is now 1-1 in units.
* Added some comments to explain the blood and bleed code
* added some comments
* added some comments
* profusely bleeding message scales with max bleed rate
* Added some comments
* Added some comments (tm)
* Halved the speed bleed rate heals.
* Changed the wording of a comment to make the function of the values more clear
* Changed bleed rate values, made heat heal more bleed rate
* doubled crit chance, since damage types were reduced
* Made iron restore more blood, 2->4u per 1u
* Starting to add the blood pack
* add bloodlevel to healingcomponent
* Created code support in the healing system for restoring blood
* first test of blood pack prototype
* More pack testing, and defining the yml stack
* yml syntax fix
* adds bloodpack tag
* Successfully added the item, but the effect and deletion after using the item is not working yet.
* the blood regen worksgit add -A!
* blood pack is entirely functioning
* Removed bleed rate healing from brute pack
* Comment correction
* I tried
* Removed bleed stats from corrupted corgi, they inherit same stats from basemob
* Removed bleed stats from xeno, they inherit same stats from a base mob
* Removed bleed stats from diona, they inherit same stats from a base mob
* Removed bleed stats from slimes, they inherit same stats from a base mob
* All mobs now heal bloodloss damage at a rate of 1 instead of 0.25 when healthy
* The cautery now closes bleed wounds
* Nerf blood pack bleed rate heal
* Added 2 blood packs to medicine locker
* Added 2 blood packs to wall medicine locker
* Minor YML fix to chemistry locker, no changes in game
* Added tag to medical belt for blood pack, added 2 blood packs to medical belt
* Added 1 gauze to medical belt
* 5 blood packs addded to nanomed plus
* nanomed inventory change
* 2 blood packs added to medical supplies crate from cargo
* Moved 1 gauze from med kit to advanced med kit
* Moved 1 tricord pill from advanced med kit to basic med kit
* added 2 ointment to burn kit
* Moved ina syringe from burn treatment to oxygen kit
* Removed one gauze from brute kit
* Added one bloodpack to brute med kit
* Moved tranex acid syringe from advanced first aid to brute kit
* Poison medipen moved from advanced first aid kit to toxin kit
* Removed health analyzer from advanced first aid kit
* removed one brute pack from advanced aid kit
* added one ointment to advanced aid kit
* Added one blood pack to advanced aid kit
* Added 2 blood packs to combat med kit
* Starting with adding the license for the tg sprite
* Adds the blood pack sprite and meta.json code
* I forgor to actually code the sprite in
* Advanced med kit missing one blood pack
* Replaced tricord pill with emergency medipen in cobat kit
* Removed emergency pen from combat kit, there's no space for it
* Revert "I tried"
This reverts commit 94c2e28df3200993d3f09b72ecabc838ea5ae5c0.
* Trying to fix yml test fail
* Try again
* attempt number 3
* Restock crate price was too low
* fixing merge conflict without making a HUGE mess this time
* ???
* again
* again
* Can I add the newline now maybe???
* Revert "Can I add the newline now maybe???"
This reverts commit 22d26706a65a24633f7da1dea6315012e2d3ac6f.
* Adds the doafter fix code from Keron to the blood level healing
* minor typo fix
* Feedback from Emisse and sloth; Removed chance based feedback on cauterizing
* comment fix
2023-04-03 01:59:51 -04:00
|
|
|
// Blood is removed from the bloodstream at a 1-1 rate with the bleed amount
|
|
|
|
|
TryModifyBloodLevel(uid, (-bloodstream.BleedAmount), bloodstream);
|
|
|
|
|
// Bleed rate is reduced by the bleed reduction amount in the bloodstream component.
|
2022-02-17 15:00:41 -07:00
|
|
|
TryModifyBleedAmount(uid, -bloodstream.BleedReductionAmount, bloodstream);
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-18 23:09:22 -04:00
|
|
|
// deal bloodloss damage if their blood level is below a threshold.
|
2022-02-17 15:00:41 -07:00
|
|
|
var bloodPercentage = GetBloodLevelPercentage(uid, bloodstream);
|
2023-05-26 03:23:29 -04:00
|
|
|
if (bloodPercentage < bloodstream.BloodlossThreshold && !_mobStateSystem.IsDead(uid))
|
2022-02-17 15:00:41 -07:00
|
|
|
{
|
2023-04-18 23:09:22 -04:00
|
|
|
// bloodloss damage is based on the base value, and modified by how low your blood level is.
|
2022-03-06 14:28:04 +13:00
|
|
|
var amt = bloodstream.BloodlossDamage / (0.1f + bloodPercentage);
|
2022-02-17 15:00:41 -07:00
|
|
|
|
|
|
|
|
_damageableSystem.TryChangeDamage(uid, amt, true, false);
|
2022-07-30 22:24:24 -04:00
|
|
|
|
|
|
|
|
// Apply dizziness as a symptom of bloodloss.
|
2023-04-18 23:09:22 -04:00
|
|
|
// 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);
|
2023-05-05 21:46:52 +08:00
|
|
|
_stutteringSystem.DoStutter(uid, TimeSpan.FromSeconds(bloodstream.UpdateInterval*2), false);
|
2023-04-18 23:09:22 -04:00
|
|
|
|
2023-05-05 21:46:52 +08:00
|
|
|
// storing the drunk and stutter time so we can remove it independently from other effects additions
|
|
|
|
|
bloodstream.StatusTime += bloodstream.UpdateInterval * 2;
|
2023-07-26 02:28:35 +05:00
|
|
|
}
|
2023-05-26 03:23:29 -04:00
|
|
|
else if (!_mobStateSystem.IsDead(uid))
|
2022-02-17 15:00:41 -07:00
|
|
|
{
|
|
|
|
|
// If they're healthy, we'll try and heal some bloodloss instead.
|
|
|
|
|
_damageableSystem.TryChangeDamage(uid, bloodstream.BloodlossHealDamage * bloodPercentage, true, false);
|
2023-04-18 23:09:22 -04:00
|
|
|
|
2023-05-05 21:46:52 +08:00
|
|
|
// Remove the drunk effect when healthy. Should only remove the amount of drunk and stutter added by low blood level
|
|
|
|
|
_drunkSystem.TryRemoveDrunkenessTime(uid, bloodstream.StatusTime);
|
|
|
|
|
_stutteringSystem.DoRemoveStutterTime(uid, bloodstream.StatusTime);
|
|
|
|
|
// Reset the drunk and stutter time to zero
|
|
|
|
|
bloodstream.StatusTime = 0;
|
2022-02-17 15:00:41 -07:00
|
|
|
}
|
|
|
|
|
}
|
2021-11-30 16:47:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnComponentInit(EntityUid uid, BloodstreamComponent component, ComponentInit args)
|
|
|
|
|
{
|
2022-02-17 15:00:41 -07:00
|
|
|
component.ChemicalSolution = _solutionContainerSystem.EnsureSolution(uid, BloodstreamComponent.DefaultChemicalsSolutionName);
|
|
|
|
|
component.BloodSolution = _solutionContainerSystem.EnsureSolution(uid, BloodstreamComponent.DefaultBloodSolutionName);
|
|
|
|
|
component.BloodTemporarySolution = _solutionContainerSystem.EnsureSolution(uid, BloodstreamComponent.DefaultBloodTemporarySolutionName);
|
|
|
|
|
|
|
|
|
|
component.ChemicalSolution.MaxVolume = component.ChemicalMaxVolume;
|
|
|
|
|
component.BloodSolution.MaxVolume = component.BloodMaxVolume;
|
2022-02-17 23:00:50 -07:00
|
|
|
component.BloodTemporarySolution.MaxVolume = component.BleedPuddleThreshold * 4; // give some leeway, for chemstream as well
|
2022-02-17 15:00:41 -07:00
|
|
|
|
|
|
|
|
// Fill blood solution with BLOOD
|
|
|
|
|
_solutionContainerSystem.TryAddReagent(uid, component.BloodSolution, component.BloodReagent,
|
|
|
|
|
component.BloodMaxVolume, out _);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnDamageChanged(EntityUid uid, BloodstreamComponent component, DamageChangedEvent args)
|
|
|
|
|
{
|
|
|
|
|
if (args.DamageDelta is null)
|
|
|
|
|
return;
|
|
|
|
|
|
2023-03-16 15:27:28 -07:00
|
|
|
// definitely don't make them bleed if they got healed
|
|
|
|
|
if (!args.DamageIncreased)
|
|
|
|
|
return;
|
|
|
|
|
|
2022-02-17 15:00:41 -07:00
|
|
|
// TODO probably cache this or something. humans get hurt a lot
|
|
|
|
|
if (!_prototypeManager.TryIndex<DamageModifierSetPrototype>(component.DamageBleedModifiers, out var modifiers))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var bloodloss = DamageSpecifier.ApplyModifierSet(args.DamageDelta, modifiers);
|
|
|
|
|
|
|
|
|
|
if (bloodloss.Empty)
|
|
|
|
|
return;
|
|
|
|
|
|
The bleed update (#14814)
* Removed arbitrary modifier scaling. The bleed amount is now 1-1 in units.
* Added some comments to explain the blood and bleed code
* added some comments
* added some comments
* profusely bleeding message scales with max bleed rate
* Added some comments
* Added some comments (tm)
* Halved the speed bleed rate heals.
* Changed the wording of a comment to make the function of the values more clear
* Changed bleed rate values, made heat heal more bleed rate
* doubled crit chance, since damage types were reduced
* Made iron restore more blood, 2->4u per 1u
* Starting to add the blood pack
* add bloodlevel to healingcomponent
* Created code support in the healing system for restoring blood
* first test of blood pack prototype
* More pack testing, and defining the yml stack
* yml syntax fix
* adds bloodpack tag
* Successfully added the item, but the effect and deletion after using the item is not working yet.
* the blood regen worksgit add -A!
* blood pack is entirely functioning
* Removed bleed rate healing from brute pack
* Comment correction
* I tried
* Removed bleed stats from corrupted corgi, they inherit same stats from basemob
* Removed bleed stats from xeno, they inherit same stats from a base mob
* Removed bleed stats from diona, they inherit same stats from a base mob
* Removed bleed stats from slimes, they inherit same stats from a base mob
* All mobs now heal bloodloss damage at a rate of 1 instead of 0.25 when healthy
* The cautery now closes bleed wounds
* Nerf blood pack bleed rate heal
* Added 2 blood packs to medicine locker
* Added 2 blood packs to wall medicine locker
* Minor YML fix to chemistry locker, no changes in game
* Added tag to medical belt for blood pack, added 2 blood packs to medical belt
* Added 1 gauze to medical belt
* 5 blood packs addded to nanomed plus
* nanomed inventory change
* 2 blood packs added to medical supplies crate from cargo
* Moved 1 gauze from med kit to advanced med kit
* Moved 1 tricord pill from advanced med kit to basic med kit
* added 2 ointment to burn kit
* Moved ina syringe from burn treatment to oxygen kit
* Removed one gauze from brute kit
* Added one bloodpack to brute med kit
* Moved tranex acid syringe from advanced first aid to brute kit
* Poison medipen moved from advanced first aid kit to toxin kit
* Removed health analyzer from advanced first aid kit
* removed one brute pack from advanced aid kit
* added one ointment to advanced aid kit
* Added one blood pack to advanced aid kit
* Added 2 blood packs to combat med kit
* Starting with adding the license for the tg sprite
* Adds the blood pack sprite and meta.json code
* I forgor to actually code the sprite in
* Advanced med kit missing one blood pack
* Replaced tricord pill with emergency medipen in cobat kit
* Removed emergency pen from combat kit, there's no space for it
* Revert "I tried"
This reverts commit 94c2e28df3200993d3f09b72ecabc838ea5ae5c0.
* Trying to fix yml test fail
* Try again
* attempt number 3
* Restock crate price was too low
* fixing merge conflict without making a HUGE mess this time
* ???
* again
* again
* Can I add the newline now maybe???
* Revert "Can I add the newline now maybe???"
This reverts commit 22d26706a65a24633f7da1dea6315012e2d3ac6f.
* Adds the doafter fix code from Keron to the blood level healing
* minor typo fix
* Feedback from Emisse and sloth; Removed chance based feedback on cauterizing
* comment fix
2023-04-03 01:59:51 -04:00
|
|
|
// Does the calculation of how much bleed rate should be added/removed, then applies it
|
2022-02-20 17:18:24 -07:00
|
|
|
var oldBleedAmount = component.BleedAmount;
|
2022-02-17 15:00:41 -07:00
|
|
|
var total = bloodloss.Total;
|
|
|
|
|
var totalFloat = total.Float();
|
|
|
|
|
TryModifyBleedAmount(uid, totalFloat, component);
|
|
|
|
|
|
The bleed update (#14814)
* Removed arbitrary modifier scaling. The bleed amount is now 1-1 in units.
* Added some comments to explain the blood and bleed code
* added some comments
* added some comments
* profusely bleeding message scales with max bleed rate
* Added some comments
* Added some comments (tm)
* Halved the speed bleed rate heals.
* Changed the wording of a comment to make the function of the values more clear
* Changed bleed rate values, made heat heal more bleed rate
* doubled crit chance, since damage types were reduced
* Made iron restore more blood, 2->4u per 1u
* Starting to add the blood pack
* add bloodlevel to healingcomponent
* Created code support in the healing system for restoring blood
* first test of blood pack prototype
* More pack testing, and defining the yml stack
* yml syntax fix
* adds bloodpack tag
* Successfully added the item, but the effect and deletion after using the item is not working yet.
* the blood regen worksgit add -A!
* blood pack is entirely functioning
* Removed bleed rate healing from brute pack
* Comment correction
* I tried
* Removed bleed stats from corrupted corgi, they inherit same stats from basemob
* Removed bleed stats from xeno, they inherit same stats from a base mob
* Removed bleed stats from diona, they inherit same stats from a base mob
* Removed bleed stats from slimes, they inherit same stats from a base mob
* All mobs now heal bloodloss damage at a rate of 1 instead of 0.25 when healthy
* The cautery now closes bleed wounds
* Nerf blood pack bleed rate heal
* Added 2 blood packs to medicine locker
* Added 2 blood packs to wall medicine locker
* Minor YML fix to chemistry locker, no changes in game
* Added tag to medical belt for blood pack, added 2 blood packs to medical belt
* Added 1 gauze to medical belt
* 5 blood packs addded to nanomed plus
* nanomed inventory change
* 2 blood packs added to medical supplies crate from cargo
* Moved 1 gauze from med kit to advanced med kit
* Moved 1 tricord pill from advanced med kit to basic med kit
* added 2 ointment to burn kit
* Moved ina syringe from burn treatment to oxygen kit
* Removed one gauze from brute kit
* Added one bloodpack to brute med kit
* Moved tranex acid syringe from advanced first aid to brute kit
* Poison medipen moved from advanced first aid kit to toxin kit
* Removed health analyzer from advanced first aid kit
* removed one brute pack from advanced aid kit
* added one ointment to advanced aid kit
* Added one blood pack to advanced aid kit
* Added 2 blood packs to combat med kit
* Starting with adding the license for the tg sprite
* Adds the blood pack sprite and meta.json code
* I forgor to actually code the sprite in
* Advanced med kit missing one blood pack
* Replaced tricord pill with emergency medipen in cobat kit
* Removed emergency pen from combat kit, there's no space for it
* Revert "I tried"
This reverts commit 94c2e28df3200993d3f09b72ecabc838ea5ae5c0.
* Trying to fix yml test fail
* Try again
* attempt number 3
* Restock crate price was too low
* fixing merge conflict without making a HUGE mess this time
* ???
* again
* again
* Can I add the newline now maybe???
* Revert "Can I add the newline now maybe???"
This reverts commit 22d26706a65a24633f7da1dea6315012e2d3ac6f.
* Adds the doafter fix code from Keron to the blood level healing
* minor typo fix
* Feedback from Emisse and sloth; Removed chance based feedback on cauterizing
* comment fix
2023-04-03 01:59:51 -04:00
|
|
|
/// <summary>
|
|
|
|
|
/// Critical hit. Causes target to lose blood, using the bleed rate modifier of the weapon, currently divided by 5
|
|
|
|
|
/// The crit chance is currently the bleed rate modifier divided by 25.
|
|
|
|
|
/// Higher damage weapons have a higher chance to crit!
|
|
|
|
|
/// </summary>
|
|
|
|
|
var prob = Math.Clamp(totalFloat / 25, 0, 1);
|
2022-02-20 17:18:24 -07:00
|
|
|
if (totalFloat > 0 && _robustRandom.Prob(prob))
|
2022-02-17 15:00:41 -07:00
|
|
|
{
|
|
|
|
|
TryModifyBloodLevel(uid, (-total) / 5, component);
|
2023-03-16 15:27:28 -07:00
|
|
|
_audio.PlayPvs(component.InstantBloodSound, uid);
|
2022-02-17 15:00:41 -07:00
|
|
|
}
|
The bleed update (#14814)
* Removed arbitrary modifier scaling. The bleed amount is now 1-1 in units.
* Added some comments to explain the blood and bleed code
* added some comments
* added some comments
* profusely bleeding message scales with max bleed rate
* Added some comments
* Added some comments (tm)
* Halved the speed bleed rate heals.
* Changed the wording of a comment to make the function of the values more clear
* Changed bleed rate values, made heat heal more bleed rate
* doubled crit chance, since damage types were reduced
* Made iron restore more blood, 2->4u per 1u
* Starting to add the blood pack
* add bloodlevel to healingcomponent
* Created code support in the healing system for restoring blood
* first test of blood pack prototype
* More pack testing, and defining the yml stack
* yml syntax fix
* adds bloodpack tag
* Successfully added the item, but the effect and deletion after using the item is not working yet.
* the blood regen worksgit add -A!
* blood pack is entirely functioning
* Removed bleed rate healing from brute pack
* Comment correction
* I tried
* Removed bleed stats from corrupted corgi, they inherit same stats from basemob
* Removed bleed stats from xeno, they inherit same stats from a base mob
* Removed bleed stats from diona, they inherit same stats from a base mob
* Removed bleed stats from slimes, they inherit same stats from a base mob
* All mobs now heal bloodloss damage at a rate of 1 instead of 0.25 when healthy
* The cautery now closes bleed wounds
* Nerf blood pack bleed rate heal
* Added 2 blood packs to medicine locker
* Added 2 blood packs to wall medicine locker
* Minor YML fix to chemistry locker, no changes in game
* Added tag to medical belt for blood pack, added 2 blood packs to medical belt
* Added 1 gauze to medical belt
* 5 blood packs addded to nanomed plus
* nanomed inventory change
* 2 blood packs added to medical supplies crate from cargo
* Moved 1 gauze from med kit to advanced med kit
* Moved 1 tricord pill from advanced med kit to basic med kit
* added 2 ointment to burn kit
* Moved ina syringe from burn treatment to oxygen kit
* Removed one gauze from brute kit
* Added one bloodpack to brute med kit
* Moved tranex acid syringe from advanced first aid to brute kit
* Poison medipen moved from advanced first aid kit to toxin kit
* Removed health analyzer from advanced first aid kit
* removed one brute pack from advanced aid kit
* added one ointment to advanced aid kit
* Added one blood pack to advanced aid kit
* Added 2 blood packs to combat med kit
* Starting with adding the license for the tg sprite
* Adds the blood pack sprite and meta.json code
* I forgor to actually code the sprite in
* Advanced med kit missing one blood pack
* Replaced tricord pill with emergency medipen in cobat kit
* Removed emergency pen from combat kit, there's no space for it
* Revert "I tried"
This reverts commit 94c2e28df3200993d3f09b72ecabc838ea5ae5c0.
* Trying to fix yml test fail
* Try again
* attempt number 3
* Restock crate price was too low
* fixing merge conflict without making a HUGE mess this time
* ???
* again
* again
* Can I add the newline now maybe???
* Revert "Can I add the newline now maybe???"
This reverts commit 22d26706a65a24633f7da1dea6315012e2d3ac6f.
* Adds the doafter fix code from Keron to the blood level healing
* minor typo fix
* Feedback from Emisse and sloth; Removed chance based feedback on cauterizing
* comment fix
2023-04-03 01:59:51 -04:00
|
|
|
|
|
|
|
|
// Heat damage will cauterize, causing the bleed rate to be reduced.
|
|
|
|
|
else if (totalFloat < 0 && oldBleedAmount > 0)
|
2022-02-20 17:18:24 -07:00
|
|
|
{
|
|
|
|
|
// Magically, this damage has healed some bleeding, likely
|
|
|
|
|
// because it's burn damage that cauterized their wounds.
|
|
|
|
|
|
|
|
|
|
// We'll play a special sound and popup for feedback.
|
2023-03-16 15:27:28 -07:00
|
|
|
_audio.PlayPvs(component.BloodHealedSound, uid);
|
2022-02-20 17:18:24 -07:00
|
|
|
_popupSystem.PopupEntity(Loc.GetString("bloodstream-component-wounds-cauterized"), uid,
|
2022-12-19 10:41:47 +13:00
|
|
|
uid, PopupType.Medium);
|
2023-01-19 03:56:45 +01:00
|
|
|
}
|
2022-02-17 15:00:41 -07:00
|
|
|
}
|
The bleed update (#14814)
* Removed arbitrary modifier scaling. The bleed amount is now 1-1 in units.
* Added some comments to explain the blood and bleed code
* added some comments
* added some comments
* profusely bleeding message scales with max bleed rate
* Added some comments
* Added some comments (tm)
* Halved the speed bleed rate heals.
* Changed the wording of a comment to make the function of the values more clear
* Changed bleed rate values, made heat heal more bleed rate
* doubled crit chance, since damage types were reduced
* Made iron restore more blood, 2->4u per 1u
* Starting to add the blood pack
* add bloodlevel to healingcomponent
* Created code support in the healing system for restoring blood
* first test of blood pack prototype
* More pack testing, and defining the yml stack
* yml syntax fix
* adds bloodpack tag
* Successfully added the item, but the effect and deletion after using the item is not working yet.
* the blood regen worksgit add -A!
* blood pack is entirely functioning
* Removed bleed rate healing from brute pack
* Comment correction
* I tried
* Removed bleed stats from corrupted corgi, they inherit same stats from basemob
* Removed bleed stats from xeno, they inherit same stats from a base mob
* Removed bleed stats from diona, they inherit same stats from a base mob
* Removed bleed stats from slimes, they inherit same stats from a base mob
* All mobs now heal bloodloss damage at a rate of 1 instead of 0.25 when healthy
* The cautery now closes bleed wounds
* Nerf blood pack bleed rate heal
* Added 2 blood packs to medicine locker
* Added 2 blood packs to wall medicine locker
* Minor YML fix to chemistry locker, no changes in game
* Added tag to medical belt for blood pack, added 2 blood packs to medical belt
* Added 1 gauze to medical belt
* 5 blood packs addded to nanomed plus
* nanomed inventory change
* 2 blood packs added to medical supplies crate from cargo
* Moved 1 gauze from med kit to advanced med kit
* Moved 1 tricord pill from advanced med kit to basic med kit
* added 2 ointment to burn kit
* Moved ina syringe from burn treatment to oxygen kit
* Removed one gauze from brute kit
* Added one bloodpack to brute med kit
* Moved tranex acid syringe from advanced first aid to brute kit
* Poison medipen moved from advanced first aid kit to toxin kit
* Removed health analyzer from advanced first aid kit
* removed one brute pack from advanced aid kit
* added one ointment to advanced aid kit
* Added one blood pack to advanced aid kit
* Added 2 blood packs to combat med kit
* Starting with adding the license for the tg sprite
* Adds the blood pack sprite and meta.json code
* I forgor to actually code the sprite in
* Advanced med kit missing one blood pack
* Replaced tricord pill with emergency medipen in cobat kit
* Removed emergency pen from combat kit, there's no space for it
* Revert "I tried"
This reverts commit 94c2e28df3200993d3f09b72ecabc838ea5ae5c0.
* Trying to fix yml test fail
* Try again
* attempt number 3
* Restock crate price was too low
* fixing merge conflict without making a HUGE mess this time
* ???
* again
* again
* Can I add the newline now maybe???
* Revert "Can I add the newline now maybe???"
This reverts commit 22d26706a65a24633f7da1dea6315012e2d3ac6f.
* Adds the doafter fix code from Keron to the blood level healing
* minor typo fix
* Feedback from Emisse and sloth; Removed chance based feedback on cauterizing
* comment fix
2023-04-03 01:59:51 -04:00
|
|
|
/// <summary>
|
|
|
|
|
/// Shows text on health examine, based on bleed rate and blood level.
|
|
|
|
|
/// </summary>
|
2022-02-18 23:03:15 -07:00
|
|
|
private void OnHealthBeingExamined(EntityUid uid, BloodstreamComponent component, HealthBeingExaminedEvent args)
|
2022-02-17 15:00:41 -07:00
|
|
|
{
|
The bleed update (#14814)
* Removed arbitrary modifier scaling. The bleed amount is now 1-1 in units.
* Added some comments to explain the blood and bleed code
* added some comments
* added some comments
* profusely bleeding message scales with max bleed rate
* Added some comments
* Added some comments (tm)
* Halved the speed bleed rate heals.
* Changed the wording of a comment to make the function of the values more clear
* Changed bleed rate values, made heat heal more bleed rate
* doubled crit chance, since damage types were reduced
* Made iron restore more blood, 2->4u per 1u
* Starting to add the blood pack
* add bloodlevel to healingcomponent
* Created code support in the healing system for restoring blood
* first test of blood pack prototype
* More pack testing, and defining the yml stack
* yml syntax fix
* adds bloodpack tag
* Successfully added the item, but the effect and deletion after using the item is not working yet.
* the blood regen worksgit add -A!
* blood pack is entirely functioning
* Removed bleed rate healing from brute pack
* Comment correction
* I tried
* Removed bleed stats from corrupted corgi, they inherit same stats from basemob
* Removed bleed stats from xeno, they inherit same stats from a base mob
* Removed bleed stats from diona, they inherit same stats from a base mob
* Removed bleed stats from slimes, they inherit same stats from a base mob
* All mobs now heal bloodloss damage at a rate of 1 instead of 0.25 when healthy
* The cautery now closes bleed wounds
* Nerf blood pack bleed rate heal
* Added 2 blood packs to medicine locker
* Added 2 blood packs to wall medicine locker
* Minor YML fix to chemistry locker, no changes in game
* Added tag to medical belt for blood pack, added 2 blood packs to medical belt
* Added 1 gauze to medical belt
* 5 blood packs addded to nanomed plus
* nanomed inventory change
* 2 blood packs added to medical supplies crate from cargo
* Moved 1 gauze from med kit to advanced med kit
* Moved 1 tricord pill from advanced med kit to basic med kit
* added 2 ointment to burn kit
* Moved ina syringe from burn treatment to oxygen kit
* Removed one gauze from brute kit
* Added one bloodpack to brute med kit
* Moved tranex acid syringe from advanced first aid to brute kit
* Poison medipen moved from advanced first aid kit to toxin kit
* Removed health analyzer from advanced first aid kit
* removed one brute pack from advanced aid kit
* added one ointment to advanced aid kit
* Added one blood pack to advanced aid kit
* Added 2 blood packs to combat med kit
* Starting with adding the license for the tg sprite
* Adds the blood pack sprite and meta.json code
* I forgor to actually code the sprite in
* Advanced med kit missing one blood pack
* Replaced tricord pill with emergency medipen in cobat kit
* Removed emergency pen from combat kit, there's no space for it
* Revert "I tried"
This reverts commit 94c2e28df3200993d3f09b72ecabc838ea5ae5c0.
* Trying to fix yml test fail
* Try again
* attempt number 3
* Restock crate price was too low
* fixing merge conflict without making a HUGE mess this time
* ???
* again
* again
* Can I add the newline now maybe???
* Revert "Can I add the newline now maybe???"
This reverts commit 22d26706a65a24633f7da1dea6315012e2d3ac6f.
* Adds the doafter fix code from Keron to the blood level healing
* minor typo fix
* Feedback from Emisse and sloth; Removed chance based feedback on cauterizing
* comment fix
2023-04-03 01:59:51 -04:00
|
|
|
// Shows profusely bleeding at half the max bleed rate.
|
|
|
|
|
if (component.BleedAmount > component.MaxBleedAmount / 2)
|
2022-02-18 23:03:15 -07:00
|
|
|
{
|
|
|
|
|
args.Message.PushNewline();
|
2022-07-10 18:36:53 -07:00
|
|
|
args.Message.AddMarkup(Loc.GetString("bloodstream-component-profusely-bleeding", ("target", Identity.Entity(uid, EntityManager))));
|
2022-02-18 23:03:15 -07:00
|
|
|
}
|
The bleed update (#14814)
* Removed arbitrary modifier scaling. The bleed amount is now 1-1 in units.
* Added some comments to explain the blood and bleed code
* added some comments
* added some comments
* profusely bleeding message scales with max bleed rate
* Added some comments
* Added some comments (tm)
* Halved the speed bleed rate heals.
* Changed the wording of a comment to make the function of the values more clear
* Changed bleed rate values, made heat heal more bleed rate
* doubled crit chance, since damage types were reduced
* Made iron restore more blood, 2->4u per 1u
* Starting to add the blood pack
* add bloodlevel to healingcomponent
* Created code support in the healing system for restoring blood
* first test of blood pack prototype
* More pack testing, and defining the yml stack
* yml syntax fix
* adds bloodpack tag
* Successfully added the item, but the effect and deletion after using the item is not working yet.
* the blood regen worksgit add -A!
* blood pack is entirely functioning
* Removed bleed rate healing from brute pack
* Comment correction
* I tried
* Removed bleed stats from corrupted corgi, they inherit same stats from basemob
* Removed bleed stats from xeno, they inherit same stats from a base mob
* Removed bleed stats from diona, they inherit same stats from a base mob
* Removed bleed stats from slimes, they inherit same stats from a base mob
* All mobs now heal bloodloss damage at a rate of 1 instead of 0.25 when healthy
* The cautery now closes bleed wounds
* Nerf blood pack bleed rate heal
* Added 2 blood packs to medicine locker
* Added 2 blood packs to wall medicine locker
* Minor YML fix to chemistry locker, no changes in game
* Added tag to medical belt for blood pack, added 2 blood packs to medical belt
* Added 1 gauze to medical belt
* 5 blood packs addded to nanomed plus
* nanomed inventory change
* 2 blood packs added to medical supplies crate from cargo
* Moved 1 gauze from med kit to advanced med kit
* Moved 1 tricord pill from advanced med kit to basic med kit
* added 2 ointment to burn kit
* Moved ina syringe from burn treatment to oxygen kit
* Removed one gauze from brute kit
* Added one bloodpack to brute med kit
* Moved tranex acid syringe from advanced first aid to brute kit
* Poison medipen moved from advanced first aid kit to toxin kit
* Removed health analyzer from advanced first aid kit
* removed one brute pack from advanced aid kit
* added one ointment to advanced aid kit
* Added one blood pack to advanced aid kit
* Added 2 blood packs to combat med kit
* Starting with adding the license for the tg sprite
* Adds the blood pack sprite and meta.json code
* I forgor to actually code the sprite in
* Advanced med kit missing one blood pack
* Replaced tricord pill with emergency medipen in cobat kit
* Removed emergency pen from combat kit, there's no space for it
* Revert "I tried"
This reverts commit 94c2e28df3200993d3f09b72ecabc838ea5ae5c0.
* Trying to fix yml test fail
* Try again
* attempt number 3
* Restock crate price was too low
* fixing merge conflict without making a HUGE mess this time
* ???
* again
* again
* Can I add the newline now maybe???
* Revert "Can I add the newline now maybe???"
This reverts commit 22d26706a65a24633f7da1dea6315012e2d3ac6f.
* Adds the doafter fix code from Keron to the blood level healing
* minor typo fix
* Feedback from Emisse and sloth; Removed chance based feedback on cauterizing
* comment fix
2023-04-03 01:59:51 -04:00
|
|
|
// Shows bleeding message when bleeding, but less than profusely.
|
2022-02-18 23:03:15 -07:00
|
|
|
else if (component.BleedAmount > 0)
|
|
|
|
|
{
|
|
|
|
|
args.Message.PushNewline();
|
2022-07-10 18:36:53 -07:00
|
|
|
args.Message.AddMarkup(Loc.GetString("bloodstream-component-bleeding", ("target", Identity.Entity(uid, EntityManager))));
|
2022-02-18 23:03:15 -07:00
|
|
|
}
|
|
|
|
|
|
The bleed update (#14814)
* Removed arbitrary modifier scaling. The bleed amount is now 1-1 in units.
* Added some comments to explain the blood and bleed code
* added some comments
* added some comments
* profusely bleeding message scales with max bleed rate
* Added some comments
* Added some comments (tm)
* Halved the speed bleed rate heals.
* Changed the wording of a comment to make the function of the values more clear
* Changed bleed rate values, made heat heal more bleed rate
* doubled crit chance, since damage types were reduced
* Made iron restore more blood, 2->4u per 1u
* Starting to add the blood pack
* add bloodlevel to healingcomponent
* Created code support in the healing system for restoring blood
* first test of blood pack prototype
* More pack testing, and defining the yml stack
* yml syntax fix
* adds bloodpack tag
* Successfully added the item, but the effect and deletion after using the item is not working yet.
* the blood regen worksgit add -A!
* blood pack is entirely functioning
* Removed bleed rate healing from brute pack
* Comment correction
* I tried
* Removed bleed stats from corrupted corgi, they inherit same stats from basemob
* Removed bleed stats from xeno, they inherit same stats from a base mob
* Removed bleed stats from diona, they inherit same stats from a base mob
* Removed bleed stats from slimes, they inherit same stats from a base mob
* All mobs now heal bloodloss damage at a rate of 1 instead of 0.25 when healthy
* The cautery now closes bleed wounds
* Nerf blood pack bleed rate heal
* Added 2 blood packs to medicine locker
* Added 2 blood packs to wall medicine locker
* Minor YML fix to chemistry locker, no changes in game
* Added tag to medical belt for blood pack, added 2 blood packs to medical belt
* Added 1 gauze to medical belt
* 5 blood packs addded to nanomed plus
* nanomed inventory change
* 2 blood packs added to medical supplies crate from cargo
* Moved 1 gauze from med kit to advanced med kit
* Moved 1 tricord pill from advanced med kit to basic med kit
* added 2 ointment to burn kit
* Moved ina syringe from burn treatment to oxygen kit
* Removed one gauze from brute kit
* Added one bloodpack to brute med kit
* Moved tranex acid syringe from advanced first aid to brute kit
* Poison medipen moved from advanced first aid kit to toxin kit
* Removed health analyzer from advanced first aid kit
* removed one brute pack from advanced aid kit
* added one ointment to advanced aid kit
* Added one blood pack to advanced aid kit
* Added 2 blood packs to combat med kit
* Starting with adding the license for the tg sprite
* Adds the blood pack sprite and meta.json code
* I forgor to actually code the sprite in
* Advanced med kit missing one blood pack
* Replaced tricord pill with emergency medipen in cobat kit
* Removed emergency pen from combat kit, there's no space for it
* Revert "I tried"
This reverts commit 94c2e28df3200993d3f09b72ecabc838ea5ae5c0.
* Trying to fix yml test fail
* Try again
* attempt number 3
* Restock crate price was too low
* fixing merge conflict without making a HUGE mess this time
* ???
* again
* again
* Can I add the newline now maybe???
* Revert "Can I add the newline now maybe???"
This reverts commit 22d26706a65a24633f7da1dea6315012e2d3ac6f.
* Adds the doafter fix code from Keron to the blood level healing
* minor typo fix
* Feedback from Emisse and sloth; Removed chance based feedback on cauterizing
* comment fix
2023-04-03 01:59:51 -04:00
|
|
|
// If the mob's blood level is below the damage threshhold, the pale message is added.
|
2022-02-17 15:00:41 -07:00
|
|
|
if (GetBloodLevelPercentage(uid, component) < component.BloodlossThreshold)
|
2021-11-30 16:47:21 -07:00
|
|
|
{
|
2022-02-18 23:03:15 -07:00
|
|
|
args.Message.PushNewline();
|
2022-07-10 18:36:53 -07:00
|
|
|
args.Message.AddMarkup(Loc.GetString("bloodstream-component-looks-pale", ("target", Identity.Entity(uid, EntityManager))));
|
2021-11-30 16:47:21 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-18 15:57:42 -07:00
|
|
|
private void OnBeingGibbed(EntityUid uid, BloodstreamComponent component, BeingGibbedEvent args)
|
|
|
|
|
{
|
|
|
|
|
SpillAllSolutions(uid, component);
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-15 18:53:52 -04:00
|
|
|
private void OnApplyMetabolicMultiplier(EntityUid uid, BloodstreamComponent component, ApplyMetabolicMultiplierEvent args)
|
|
|
|
|
{
|
|
|
|
|
if (args.Apply)
|
|
|
|
|
{
|
|
|
|
|
component.UpdateInterval *= args.Multiplier;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
component.UpdateInterval /= args.Multiplier;
|
|
|
|
|
// Reset the accumulator properly
|
|
|
|
|
if (component.AccumulatedFrametime >= component.UpdateInterval)
|
|
|
|
|
component.AccumulatedFrametime = component.UpdateInterval;
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-14 19:30:56 +02:00
|
|
|
private void OnRejuvenate(EntityUid uid, BloodstreamComponent component, RejuvenateEvent args)
|
|
|
|
|
{
|
|
|
|
|
TryModifyBleedAmount(uid, -component.BleedAmount, component);
|
|
|
|
|
TryModifyBloodLevel(uid, component.BloodSolution.AvailableVolume, component);
|
2023-08-05 16:51:07 -04:00
|
|
|
_solutionContainerSystem.RemoveAllSolution(uid, component.ChemicalSolution);
|
2022-09-14 19:30:56 +02:00
|
|
|
}
|
|
|
|
|
|
2021-11-30 16:47:21 -07:00
|
|
|
/// <summary>
|
|
|
|
|
/// Attempt to transfer provided solution to internal solution.
|
|
|
|
|
/// </summary>
|
2022-02-17 15:00:41 -07:00
|
|
|
public bool TryAddToChemicals(EntityUid uid, Solution solution, BloodstreamComponent? component=null)
|
|
|
|
|
{
|
|
|
|
|
if (!Resolve(uid, ref component, false))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return _solutionContainerSystem.TryAddSolution(uid, component.ChemicalSolution, solution);
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-11 00:20:44 +01:00
|
|
|
public bool FlushChemicals(EntityUid uid, string excludedReagentID, FixedPoint2 quantity, BloodstreamComponent? component = null) {
|
|
|
|
|
if (!Resolve(uid, ref component, false))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
for (var i = component.ChemicalSolution.Contents.Count - 1; i >= 0; i--)
|
|
|
|
|
{
|
|
|
|
|
var (reagentId, _) = component.ChemicalSolution.Contents[i];
|
|
|
|
|
if (reagentId != excludedReagentID)
|
|
|
|
|
{
|
|
|
|
|
_solutionContainerSystem.TryRemoveReagent(uid, component.ChemicalSolution, reagentId, quantity);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-17 15:00:41 -07:00
|
|
|
public float GetBloodLevelPercentage(EntityUid uid, BloodstreamComponent? component = null)
|
|
|
|
|
{
|
|
|
|
|
if (!Resolve(uid, ref component))
|
|
|
|
|
return 0.0f;
|
|
|
|
|
|
2023-01-12 16:41:40 +13:00
|
|
|
return component.BloodSolution.FillFraction;
|
2022-02-17 15:00:41 -07:00
|
|
|
}
|
|
|
|
|
|
2022-04-18 18:30:22 -04:00
|
|
|
public void SetBloodLossThreshold(EntityUid uid, float threshold, BloodstreamComponent? comp = null)
|
|
|
|
|
{
|
|
|
|
|
if (!Resolve(uid, ref comp))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
comp.BloodlossThreshold = threshold;
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-17 15:00:41 -07:00
|
|
|
/// <summary>
|
|
|
|
|
/// Attempts to modify the blood level of this entity directly.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool TryModifyBloodLevel(EntityUid uid, FixedPoint2 amount, BloodstreamComponent? component = null)
|
2021-11-30 16:47:21 -07:00
|
|
|
{
|
|
|
|
|
if (!Resolve(uid, ref component, false))
|
|
|
|
|
return false;
|
|
|
|
|
|
2022-02-17 15:00:41 -07:00
|
|
|
if (amount >= 0)
|
|
|
|
|
return _solutionContainerSystem.TryAddReagent(uid, component.BloodSolution, component.BloodReagent, amount, out _);
|
|
|
|
|
|
|
|
|
|
// Removal is more involved,
|
|
|
|
|
// since we also wanna handle moving it to the temporary solution
|
|
|
|
|
// and then spilling it if necessary.
|
|
|
|
|
var newSol = component.BloodSolution.SplitSolution(-amount);
|
2023-01-12 16:41:40 +13:00
|
|
|
component.BloodTemporarySolution.AddSolution(newSol, _prototypeManager);
|
2022-02-17 15:00:41 -07:00
|
|
|
|
2023-01-12 16:41:40 +13:00
|
|
|
if (component.BloodTemporarySolution.Volume > component.BleedPuddleThreshold)
|
2022-02-17 15:00:41 -07:00
|
|
|
{
|
2022-02-17 23:00:50 -07:00
|
|
|
// Pass some of the chemstream into the spilled blood.
|
2023-01-12 16:41:40 +13:00
|
|
|
var temp = component.ChemicalSolution.SplitSolution(component.BloodTemporarySolution.Volume / 10);
|
|
|
|
|
component.BloodTemporarySolution.AddSolution(temp, _prototypeManager);
|
2023-04-10 15:37:03 +10:00
|
|
|
if (_puddleSystem.TrySpillAt(uid, component.BloodTemporarySolution, out var puddleUid, false))
|
2023-03-31 07:49:25 +03:00
|
|
|
{
|
|
|
|
|
if (TryComp<DnaComponent>(uid, out var dna))
|
2023-04-10 15:37:03 +10:00
|
|
|
{
|
|
|
|
|
var comp = EnsureComp<ForensicsComponent>(puddleUid);
|
2023-03-31 07:49:25 +03:00
|
|
|
comp.DNAs.Add(dna.DNA);
|
2023-04-10 15:37:03 +10:00
|
|
|
}
|
2023-03-31 07:49:25 +03:00
|
|
|
}
|
|
|
|
|
|
2022-02-17 15:00:41 -07:00
|
|
|
component.BloodTemporarySolution.RemoveAllSolution();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Tries to make an entity bleed more or less
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool TryModifyBleedAmount(EntityUid uid, float amount, BloodstreamComponent? component = null)
|
|
|
|
|
{
|
|
|
|
|
if (!Resolve(uid, ref component, false))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
component.BleedAmount += amount;
|
2022-02-20 17:18:24 -07:00
|
|
|
component.BleedAmount = Math.Clamp(component.BleedAmount, 0, component.MaxBleedAmount);
|
2022-02-17 15:00:41 -07:00
|
|
|
|
2023-07-26 02:28:35 +05:00
|
|
|
if (component.BleedAmount == 0)
|
|
|
|
|
_alertsSystem.ClearAlert(uid, AlertType.Bleed);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var severity = (short) Math.Clamp(Math.Round(component.BleedAmount, MidpointRounding.ToZero), 0, 10);
|
|
|
|
|
_alertsSystem.ShowAlert(uid, AlertType.Bleed, severity);
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-17 15:00:41 -07:00
|
|
|
return true;
|
2021-11-30 16:47:21 -07:00
|
|
|
}
|
2022-02-18 15:57:42 -07:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// BLOOD FOR THE BLOOD GOD
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void SpillAllSolutions(EntityUid uid, BloodstreamComponent? component = null)
|
|
|
|
|
{
|
|
|
|
|
if (!Resolve(uid, ref component))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var max = component.BloodSolution.MaxVolume + component.BloodTemporarySolution.MaxVolume +
|
|
|
|
|
component.ChemicalSolution.MaxVolume;
|
|
|
|
|
var tempSol = new Solution() { MaxVolume = max };
|
|
|
|
|
|
2023-01-12 16:41:40 +13:00
|
|
|
tempSol.AddSolution(component.BloodSolution, _prototypeManager);
|
2022-05-27 02:41:18 -05:00
|
|
|
component.BloodSolution.RemoveAllSolution();
|
2023-01-12 16:41:40 +13:00
|
|
|
tempSol.AddSolution(component.BloodTemporarySolution, _prototypeManager);
|
2022-05-27 02:41:18 -05:00
|
|
|
component.BloodTemporarySolution.RemoveAllSolution();
|
2023-01-12 16:41:40 +13:00
|
|
|
tempSol.AddSolution(component.ChemicalSolution, _prototypeManager);
|
2022-05-27 02:41:18 -05:00
|
|
|
component.ChemicalSolution.RemoveAllSolution();
|
2023-03-31 07:49:25 +03:00
|
|
|
|
2023-04-10 15:37:03 +10:00
|
|
|
if (_puddleSystem.TrySpillAt(uid, tempSol, out var puddleUid))
|
2023-03-31 07:49:25 +03:00
|
|
|
{
|
|
|
|
|
if (TryComp<DnaComponent>(uid, out var dna))
|
2023-04-10 15:37:03 +10:00
|
|
|
{
|
|
|
|
|
var comp = EnsureComp<ForensicsComponent>(puddleUid);
|
2023-03-31 07:49:25 +03:00
|
|
|
comp.DNAs.Add(dna.DNA);
|
2023-04-10 15:37:03 +10:00
|
|
|
}
|
2023-03-31 07:49:25 +03:00
|
|
|
}
|
2022-02-18 15:57:42 -07:00
|
|
|
}
|
2023-07-09 15:01:35 -07:00
|
|
|
|
|
|
|
|
/// <summary>
|
2023-07-26 02:28:35 +05:00
|
|
|
/// Change what someone's blood is made of, on the fly.
|
2023-07-09 15:01:35 -07:00
|
|
|
/// </summary>
|
|
|
|
|
public void ChangeBloodReagent(EntityUid uid, string reagent, BloodstreamComponent? component = null)
|
|
|
|
|
{
|
|
|
|
|
if (!Resolve(uid, ref component, false))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if(reagent == component.BloodReagent)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var currentVolume = component.BloodSolution.Volume;
|
|
|
|
|
|
|
|
|
|
component.BloodReagent = reagent;
|
|
|
|
|
component.BloodSolution.RemoveAllSolution();
|
|
|
|
|
_solutionContainerSystem.TryAddReagent(uid, component.BloodSolution, component.BloodReagent, currentVolume, out _);
|
|
|
|
|
}
|
2021-11-30 16:47:21 -07:00
|
|
|
}
|