Add dizziness as a symptom of bloodloss (#10172)

This commit is contained in:
Rane
2022-07-30 22:24:24 -04:00
committed by GitHub
parent 68a5fcb7f8
commit 95bf54af7a
3 changed files with 19 additions and 3 deletions

View File

@@ -12,6 +12,7 @@ using Content.Shared.FixedPoint;
using Content.Shared.IdentityManagement; using Content.Shared.IdentityManagement;
using Content.Shared.MobState.Components; using Content.Shared.MobState.Components;
using Content.Shared.Popups; using Content.Shared.Popups;
using Content.Shared.Drunk;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.Player; using Robust.Shared.Player;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
@@ -28,6 +29,8 @@ public sealed class BloodstreamSystem : EntitySystem
[Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IRobustRandom _robustRandom = default!; [Dependency] private readonly IRobustRandom _robustRandom = default!;
[Dependency] private readonly SharedDrunkSystem _drunkSystem = default!;
// TODO here // TODO here
// Update over time. Modify bloodloss damage in accordance with (amount of blood / max blood level), and reduce bleeding over time // Update over time. Modify bloodloss damage in accordance with (amount of blood / max blood level), and reduce bleeding over time
// Sub to damage changed event and modify bloodloss if incurring large hits of slashing/piercing // Sub to damage changed event and modify bloodloss if incurring large hits of slashing/piercing
@@ -108,6 +111,11 @@ public sealed class BloodstreamSystem : EntitySystem
var amt = bloodstream.BloodlossDamage / (0.1f + bloodPercentage); var amt = bloodstream.BloodlossDamage / (0.1f + bloodPercentage);
_damageableSystem.TryChangeDamage(uid, amt, true, false); _damageableSystem.TryChangeDamage(uid, amt, true, false);
// Apply dizziness as a symptom of bloodloss.
// So, threshold is 0.9, you have 0.85 percent blood, it adds (5 * 1.05) or 5.25 seconds of drunkenness.
// So, it'd max at 1.9 by default with 0% blood.
_drunkSystem.TryApplyDrunkenness(uid, bloodstream.UpdateInterval * (1 + (bloodstream.BloodlossThreshold - bloodPercentage)), false);
} }
else else
{ {

View File

@@ -11,9 +11,15 @@ public sealed class Drunk : ReagentEffect
[DataField("boozePower")] [DataField("boozePower")]
public float BoozePower = 2f; public float BoozePower = 2f;
/// <summary>
/// Whether speech should be slurred.
/// </summary>
[DataField("slurSpeech")]
public bool SlurSpeech = true;
public override void Effect(ReagentEffectArgs args) public override void Effect(ReagentEffectArgs args)
{ {
var drunkSys = args.EntityManager.EntitySysManager.GetEntitySystem<SharedDrunkSystem>(); var drunkSys = args.EntityManager.EntitySysManager.GetEntitySystem<SharedDrunkSystem>();
drunkSys.TryApplyDrunkenness(args.SolutionEntity, BoozePower); drunkSys.TryApplyDrunkenness(args.SolutionEntity, BoozePower, SlurSpeech);
} }
} }

View File

@@ -10,13 +10,15 @@ public abstract class SharedDrunkSystem : EntitySystem
[Dependency] private readonly StatusEffectsSystem _statusEffectsSystem = default!; [Dependency] private readonly StatusEffectsSystem _statusEffectsSystem = default!;
[Dependency] private readonly SharedSlurredSystem _slurredSystem = default!; [Dependency] private readonly SharedSlurredSystem _slurredSystem = default!;
public void TryApplyDrunkenness(EntityUid uid, float boozePower, public void TryApplyDrunkenness(EntityUid uid, float boozePower, bool applySlur = true,
StatusEffectsComponent? status = null) StatusEffectsComponent? status = null)
{ {
if (!Resolve(uid, ref status, false)) if (!Resolve(uid, ref status, false))
return; return;
if (applySlur)
_slurredSystem.DoSlur(uid, TimeSpan.FromSeconds(boozePower), status); _slurredSystem.DoSlur(uid, TimeSpan.FromSeconds(boozePower), status);
if (!_statusEffectsSystem.HasStatusEffect(uid, DrunkKey, status)) if (!_statusEffectsSystem.HasStatusEffect(uid, DrunkKey, status))
{ {
_statusEffectsSystem.TryAddStatusEffect<DrunkComponent>(uid, DrunkKey, TimeSpan.FromSeconds(boozePower), true, status); _statusEffectsSystem.TryAddStatusEffect<DrunkComponent>(uid, DrunkKey, TimeSpan.FromSeconds(boozePower), true, status);