2021-11-30 16:47:21 -07:00
|
|
|
using Content.Server.Body.Components;
|
2023-12-29 04:47:43 -08:00
|
|
|
using Content.Server.Chemistry.Containers.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-12-29 04:47:43 -08: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-05-25 02:13:10 +06:00
|
|
|
using Content.Server.White.EndOfRoundStats.BloodLost;
|
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;
|
2023-10-14 09:45:28 -07:00
|
|
|
using Content.Shared.Chemistry.EntitySystems;
|
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;
|
2023-11-15 02:03:02 -08:00
|
|
|
using Content.Shared.Drunk;
|
2021-11-30 16:47:21 -07:00
|
|
|
using Content.Shared.FixedPoint;
|
2022-07-10 18:36:53 -07:00
|
|
|
using Content.Shared.IdentityManagement;
|
2023-01-13 16:57:10 -08:00
|
|
|
using Content.Shared.Mobs.Systems;
|
2023-11-15 02:03:02 -08:00
|
|
|
using Content.Shared.Popups;
|
2022-09-14 19:30:56 +02:00
|
|
|
using Content.Shared.Rejuvenate;
|
2023-11-15 02:03:02 -08:00
|
|
|
using Content.Shared.Speech.EntitySystems;
|
2023-12-29 04:47:43 -08:00
|
|
|
using Robust.Server.Audio;
|
2022-02-17 15:00:41 -07:00
|
|
|
using Robust.Shared.Prototypes;
|
|
|
|
|
using Robust.Shared.Random;
|
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!;
|
2023-12-15 04:52:55 -05:00
|
|
|
[Dependency] private readonly ForensicsSystem _forensicsSystem = 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);
|
2023-12-29 04:47:43 -08:00
|
|
|
SubscribeLocalEvent<BloodstreamComponent, SolutionRelayEvent<ReactionAttemptEvent>>(OnReactionAttempt);
|
2022-09-14 19:30:56 +02:00
|
|
|
SubscribeLocalEvent<BloodstreamComponent, RejuvenateEvent>(OnRejuvenate);
|
2022-04-05 04:02:33 +12:00
|
|
|
}
|
|
|
|
|
|
2023-12-29 04:47:43 -08:00
|
|
|
private void OnReactionAttempt(Entity<BloodstreamComponent> entity, ref ReactionAttemptEvent args)
|
2022-04-05 04:02:33 +12:00
|
|
|
{
|
2023-12-29 04:47:43 -08:00
|
|
|
if (args.Cancelled)
|
2022-04-05 04:02:33 +12:00
|
|
|
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.
|
2023-12-29 04:47:43 -08:00
|
|
|
args.Cancelled = true;
|
2022-04-05 04:02:33 +12:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2023-12-29 04:47:43 -08:00
|
|
|
private void OnReactionAttempt(Entity<BloodstreamComponent> entity, ref SolutionRelayEvent<ReactionAttemptEvent> args)
|
|
|
|
|
{
|
|
|
|
|
if (args.Name != entity.Comp.BloodSolutionName
|
|
|
|
|
&& args.Name != entity.Comp.ChemicalSolutionName
|
|
|
|
|
&& args.Name != entity.Comp.BloodTemporarySolutionName)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
OnReactionAttempt(entity, ref args.Event);
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-17 15:00:41 -07:00
|
|
|
public override void Update(float frameTime)
|
|
|
|
|
{
|
|
|
|
|
base.Update(frameTime);
|
|
|
|
|
|
2023-05-25 02:13:10 +06:00
|
|
|
var totalBloodLost = 0f; // White-EndOfRoundStats
|
|
|
|
|
|
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-12-29 04:47:43 -08:00
|
|
|
if (!_solutionContainerSystem.ResolveSolution(uid, bloodstream.BloodSolutionName, ref bloodstream.BloodSolution, out var bloodSolution))
|
|
|
|
|
continue;
|
2023-04-25 01:24:58 +06:00
|
|
|
//WD-EDIT
|
|
|
|
|
if (bloodstream.IsBleeding)
|
2024-01-10 21:14:43 +07:00
|
|
|
_alertsSystem.ShowAlert(uid, AlertType.Bleeding);
|
2023-04-25 01:24:58 +06:00
|
|
|
else
|
2024-01-10 21:14:43 +07:00
|
|
|
_alertsSystem.ClearAlert(uid, AlertType.Bleeding);
|
2023-04-25 01:24:58 +06:00
|
|
|
//WD-EDIT
|
2023-12-29 04:47:43 -08:00
|
|
|
|
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-12-29 04:47:43 -08:00
|
|
|
if (bloodSolution.Volume < bloodSolution.MaxVolume && !_mobStateSystem.IsDead(uid))
|
2023-05-26 03:23:29 -04:00
|
|
|
{
|
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-05-25 02:13:10 +06:00
|
|
|
totalBloodLost += bloodstream.BleedAmount; // White - EndOfRoundStats
|
2022-02-17 15:00:41 -07:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
2023-11-15 02:03:02 -08:00
|
|
|
_damageableSystem.TryChangeDamage(uid, amt, false, 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
|
|
|
}
|
|
|
|
|
}
|
2023-05-25 02:13:10 +06:00
|
|
|
RaiseLocalEvent(new BloodLostStatEvent(totalBloodLost)); // White-EndOfRoundStats
|
2021-11-30 16:47:21 -07:00
|
|
|
}
|
|
|
|
|
|
2023-12-29 04:47:43 -08:00
|
|
|
private void OnComponentInit(Entity<BloodstreamComponent> entity, ref ComponentInit args)
|
2021-11-30 16:47:21 -07:00
|
|
|
{
|
2023-12-29 04:47:43 -08:00
|
|
|
var chemicalSolution = _solutionContainerSystem.EnsureSolution(entity.Owner, entity.Comp.ChemicalSolutionName);
|
|
|
|
|
var bloodSolution = _solutionContainerSystem.EnsureSolution(entity.Owner, entity.Comp.BloodSolutionName);
|
|
|
|
|
var tempSolution = _solutionContainerSystem.EnsureSolution(entity.Owner, entity.Comp.BloodTemporarySolutionName);
|
2022-02-17 15:00:41 -07:00
|
|
|
|
2023-12-29 04:47:43 -08:00
|
|
|
chemicalSolution.MaxVolume = entity.Comp.ChemicalMaxVolume;
|
|
|
|
|
bloodSolution.MaxVolume = entity.Comp.BloodMaxVolume;
|
|
|
|
|
tempSolution.MaxVolume = entity.Comp.BleedPuddleThreshold * 4; // give some leeway, for chemstream as well
|
2022-02-17 15:00:41 -07:00
|
|
|
|
|
|
|
|
// Fill blood solution with BLOOD
|
2023-12-29 04:47:43 -08:00
|
|
|
bloodSolution.AddReagent(entity.Comp.BloodReagent, entity.Comp.BloodMaxVolume - bloodSolution.Volume);
|
2022-02-17 15:00:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-29 04:47:43 -08:00
|
|
|
private void OnRejuvenate(Entity<BloodstreamComponent> entity, ref RejuvenateEvent args)
|
2022-09-14 19:30:56 +02:00
|
|
|
{
|
2023-12-29 04:47:43 -08:00
|
|
|
TryModifyBleedAmount(entity.Owner, -entity.Comp.BleedAmount, entity.Comp);
|
|
|
|
|
|
|
|
|
|
if (_solutionContainerSystem.ResolveSolution(entity.Owner, entity.Comp.BloodSolutionName, ref entity.Comp.BloodSolution, out var bloodSolution))
|
|
|
|
|
TryModifyBloodLevel(entity.Owner, bloodSolution.AvailableVolume, entity.Comp);
|
|
|
|
|
|
|
|
|
|
if (_solutionContainerSystem.ResolveSolution(entity.Owner, entity.Comp.ChemicalSolutionName, ref entity.Comp.ChemicalSolution))
|
|
|
|
|
_solutionContainerSystem.RemoveAllSolution(entity.Comp.ChemicalSolution.Value);
|
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>
|
2023-12-29 04:47:43 -08:00
|
|
|
public bool TryAddToChemicals(EntityUid uid, Solution solution, BloodstreamComponent? component = null)
|
2022-02-17 15:00:41 -07:00
|
|
|
{
|
|
|
|
|
if (!Resolve(uid, ref component, false))
|
|
|
|
|
return false;
|
|
|
|
|
|
2023-12-29 04:47:43 -08:00
|
|
|
if (!_solutionContainerSystem.ResolveSolution(uid, component.ChemicalSolutionName, ref component.ChemicalSolution))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return _solutionContainerSystem.TryAddSolution(component.ChemicalSolution.Value, solution);
|
2022-02-17 15:00:41 -07:00
|
|
|
}
|
|
|
|
|
|
2023-12-29 04:47:43 -08:00
|
|
|
public bool FlushChemicals(EntityUid uid, string excludedReagentID, FixedPoint2 quantity, BloodstreamComponent? component = null)
|
|
|
|
|
{
|
2022-09-11 00:20:44 +01:00
|
|
|
if (!Resolve(uid, ref component, false))
|
|
|
|
|
return false;
|
|
|
|
|
|
2023-12-29 04:47:43 -08:00
|
|
|
if (!_solutionContainerSystem.ResolveSolution(uid, component.ChemicalSolutionName, ref component.ChemicalSolution, out var chemSolution))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
for (var i = chemSolution.Contents.Count - 1; i >= 0; i--)
|
2022-09-11 00:20:44 +01:00
|
|
|
{
|
2023-12-29 04:47:43 -08:00
|
|
|
var (reagentId, _) = chemSolution.Contents[i];
|
2023-09-05 09:55:10 +12:00
|
|
|
if (reagentId.Prototype != excludedReagentID)
|
2022-09-11 00:20:44 +01:00
|
|
|
{
|
2023-12-29 04:47:43 -08:00
|
|
|
_solutionContainerSystem.RemoveReagent(component.ChemicalSolution.Value, reagentId, quantity);
|
2022-09-11 00:20:44 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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-12-29 04:47:43 -08:00
|
|
|
if (!_solutionContainerSystem.ResolveSolution(uid, component.BloodSolutionName, ref component.BloodSolution, out var bloodSolution))
|
|
|
|
|
return 0.0f;
|
|
|
|
|
|
|
|
|
|
return 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;
|
|
|
|
|
|
2023-12-29 04:47:43 -08:00
|
|
|
if (!_solutionContainerSystem.ResolveSolution(uid, component.BloodSolutionName, ref component.BloodSolution))
|
|
|
|
|
return false;
|
|
|
|
|
|
2022-02-17 15:00:41 -07:00
|
|
|
if (amount >= 0)
|
2023-12-29 04:47:43 -08:00
|
|
|
return _solutionContainerSystem.TryAddReagent(component.BloodSolution.Value, component.BloodReagent, amount, out _);
|
2022-02-17 15:00:41 -07:00
|
|
|
|
|
|
|
|
// Removal is more involved,
|
|
|
|
|
// since we also wanna handle moving it to the temporary solution
|
|
|
|
|
// and then spilling it if necessary.
|
2023-12-29 04:47:43 -08:00
|
|
|
var newSol = _solutionContainerSystem.SplitSolution(component.BloodSolution.Value, -amount);
|
|
|
|
|
|
|
|
|
|
if (!_solutionContainerSystem.ResolveSolution(uid, component.BloodTemporarySolutionName, ref component.TemporarySolution, out var tempSolution))
|
|
|
|
|
return true;
|
2022-02-17 15:00:41 -07:00
|
|
|
|
2023-12-29 04:47:43 -08:00
|
|
|
tempSolution.AddSolution(newSol, _prototypeManager);
|
|
|
|
|
|
|
|
|
|
if (tempSolution.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-12-29 04:47:43 -08:00
|
|
|
if (_solutionContainerSystem.ResolveSolution(uid, component.ChemicalSolutionName, ref component.ChemicalSolution))
|
|
|
|
|
{
|
|
|
|
|
var temp = _solutionContainerSystem.SplitSolution(component.ChemicalSolution.Value, tempSolution.Volume / 10);
|
|
|
|
|
tempSolution.AddSolution(temp, _prototypeManager);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (_puddleSystem.TrySpillAt(uid, tempSolution, out var puddleUid, false))
|
2023-03-31 07:49:25 +03:00
|
|
|
{
|
2023-12-15 04:52:55 -05:00
|
|
|
_forensicsSystem.TransferDna(puddleUid, uid, false);
|
2023-03-31 07:49:25 +03:00
|
|
|
}
|
|
|
|
|
|
2023-12-29 04:47:43 -08:00
|
|
|
tempSolution.RemoveAllSolution();
|
2022-02-17 15:00:41 -07:00
|
|
|
}
|
|
|
|
|
|
2023-12-29 04:47:43 -08:00
|
|
|
_solutionContainerSystem.UpdateChemicals(component.TemporarySolution.Value);
|
|
|
|
|
|
2022-02-17 15:00:41 -07:00
|
|
|
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
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
2023-12-29 04:47:43 -08:00
|
|
|
var tempSol = new Solution();
|
2022-02-18 15:57:42 -07:00
|
|
|
|
2023-12-29 04:47:43 -08:00
|
|
|
if (_solutionContainerSystem.ResolveSolution(uid, component.BloodSolutionName, ref component.BloodSolution, out var bloodSolution))
|
|
|
|
|
{
|
|
|
|
|
tempSol.MaxVolume += bloodSolution.MaxVolume;
|
|
|
|
|
tempSol.AddSolution(bloodSolution, _prototypeManager);
|
|
|
|
|
_solutionContainerSystem.RemoveAllSolution(component.BloodSolution.Value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (_solutionContainerSystem.ResolveSolution(uid, component.ChemicalSolutionName, ref component.ChemicalSolution, out var chemSolution))
|
|
|
|
|
{
|
|
|
|
|
tempSol.MaxVolume += chemSolution.MaxVolume;
|
|
|
|
|
tempSol.AddSolution(chemSolution, _prototypeManager);
|
|
|
|
|
_solutionContainerSystem.RemoveAllSolution(component.ChemicalSolution.Value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (_solutionContainerSystem.ResolveSolution(uid, component.BloodTemporarySolutionName, ref component.TemporarySolution, out var tempSolution))
|
|
|
|
|
{
|
|
|
|
|
tempSol.MaxVolume += tempSolution.MaxVolume;
|
|
|
|
|
tempSol.AddSolution(tempSolution, _prototypeManager);
|
|
|
|
|
_solutionContainerSystem.RemoveAllSolution(component.TemporarySolution.Value);
|
|
|
|
|
}
|
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
|
|
|
{
|
2023-12-15 04:52:55 -05:00
|
|
|
_forensicsSystem.TransferDna(puddleUid, uid, false);
|
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;
|
|
|
|
|
|
2023-12-29 04:47:43 -08:00
|
|
|
if (reagent == component.BloodReagent)
|
2023-07-09 15:01:35 -07:00
|
|
|
return;
|
|
|
|
|
|
2023-12-29 04:47:43 -08:00
|
|
|
if (!_solutionContainerSystem.ResolveSolution(uid, component.BloodSolutionName, ref component.BloodSolution, out var bloodSolution))
|
|
|
|
|
{
|
|
|
|
|
component.BloodReagent = reagent;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var currentVolume = bloodSolution.RemoveReagent(component.BloodReagent, bloodSolution.Volume);
|
2023-07-09 15:01:35 -07:00
|
|
|
|
|
|
|
|
component.BloodReagent = reagent;
|
2023-12-29 04:47:43 -08:00
|
|
|
|
|
|
|
|
if (currentVolume > 0)
|
|
|
|
|
_solutionContainerSystem.TryAddReagent(component.BloodSolution.Value, component.BloodReagent, currentVolume, out _);
|
2023-07-09 15:01:35 -07:00
|
|
|
}
|
2021-11-30 16:47:21 -07:00
|
|
|
}
|