* removing drunk scaling with missing blood, drunk will apply until blood restored * added new drunk function to go with new bloodloss drunk code * initial tryremovetime code for drunk system. Still need to code it into bloodloss and test. * initial tryremovetime code for drunk system. Still need to code it into bloodloss and test. * Drunk status added by low blood level should be removed when healthy * Everything is working in the dev enviroment. Cleaning up code. * Dead bodies bleed, do not recover blood, and do not take further bloodloss damage to missing blood * Last commit
46 lines
1.5 KiB
C#
46 lines
1.5 KiB
C#
using Content.Shared.Speech.EntitySystems;
|
|
using Content.Shared.StatusEffect;
|
|
using Content.Shared.Traits.Assorted;
|
|
|
|
namespace Content.Shared.Drunk;
|
|
|
|
public abstract class SharedDrunkSystem : EntitySystem
|
|
{
|
|
public const string DrunkKey = "Drunk";
|
|
|
|
[Dependency] private readonly StatusEffectsSystem _statusEffectsSystem = default!;
|
|
[Dependency] private readonly SharedSlurredSystem _slurredSystem = default!;
|
|
|
|
public void TryApplyDrunkenness(EntityUid uid, float boozePower, bool applySlur = true,
|
|
StatusEffectsComponent? status = null)
|
|
{
|
|
if (!Resolve(uid, ref status, false))
|
|
return;
|
|
|
|
if (applySlur)
|
|
_slurredSystem.DoSlur(uid, TimeSpan.FromSeconds(boozePower), status);
|
|
|
|
if (TryComp<LightweightDrunkComponent>(uid, out var trait))
|
|
boozePower *= trait.BoozeStrengthMultiplier;
|
|
|
|
if (!_statusEffectsSystem.HasStatusEffect(uid, DrunkKey, status))
|
|
{
|
|
_statusEffectsSystem.TryAddStatusEffect<DrunkComponent>(uid, DrunkKey, TimeSpan.FromSeconds(boozePower), true, status);
|
|
}
|
|
else
|
|
{
|
|
_statusEffectsSystem.TryAddTime(uid, DrunkKey, TimeSpan.FromSeconds(boozePower), status);
|
|
}
|
|
}
|
|
|
|
public void TryRemoveDrunkenness(EntityUid uid)
|
|
{
|
|
_statusEffectsSystem.TryRemoveStatusEffect(uid, DrunkKey);
|
|
}
|
|
public void TryRemoveDrunkenessTime(EntityUid uid, double timeRemoved)
|
|
{
|
|
_statusEffectsSystem.TryRemoveTime(uid, DrunkKey, TimeSpan.FromSeconds(timeRemoved));
|
|
}
|
|
|
|
}
|