diff --git a/Content.Client/Drunk/DrunkOverlay.cs b/Content.Client/Drunk/DrunkOverlay.cs index c806cdad66..692232776a 100644 --- a/Content.Client/Drunk/DrunkOverlay.cs +++ b/Content.Client/Drunk/DrunkOverlay.cs @@ -27,6 +27,15 @@ public sealed class DrunkOverlay : Overlay private const float VisualThreshold = 10.0f; private const float PowerDivisor = 250.0f; + /// + /// This is a magic number based on my person preference of how quickly the bloodloss effect should kick in. + /// It is entirely arbitrary, and you should change it if it sucks. + /// Honestly should be refactored to be based on amount of blood lost but that's out of scope for what I'm doing atm. + /// Also caps all booze visual effects to a max intensity of 100 seconds or 100 booze power. + /// + private const float MaxBoozePower = 100f; + + private const float BoozePowerScale = 8f; private float _visualScale = 0; @@ -50,15 +59,9 @@ public sealed class DrunkOverlay : Overlay var time = status.Item2; - var power = SharedDrunkSystem.MagicNumber; + var power = time == null ? MaxBoozePower : (float) Math.Min((time - _timing.CurTime).Value.TotalSeconds, MaxBoozePower); - if (time != null) - { - var curTime = _timing.CurTime; - power = (float) (time - curTime).Value.TotalSeconds; - } - - CurrentBoozePower += 8f * (power * 0.5f - CurrentBoozePower) * args.DeltaSeconds / (power+1); + CurrentBoozePower += BoozePowerScale * (power - CurrentBoozePower) * args.DeltaSeconds / (power+1); } protected override bool BeforeDraw(in OverlayDrawArgs args) diff --git a/Content.Server/Body/Systems/MetabolizerSystem.cs b/Content.Server/Body/Systems/MetabolizerSystem.cs index 6679bfea54..b5b30ae74c 100644 --- a/Content.Server/Body/Systems/MetabolizerSystem.cs +++ b/Content.Server/Body/Systems/MetabolizerSystem.cs @@ -16,6 +16,7 @@ using Content.Shared.EntityEffects.Effects.Solution; using Content.Shared.FixedPoint; using Content.Shared.Mobs.Components; using Content.Shared.Mobs.Systems; +using Content.Shared.Random.Helpers; using Robust.Shared.Collections; using Robust.Shared.Prototypes; using Robust.Shared.Random; @@ -199,6 +200,9 @@ public sealed class MetabolizerSystem : SharedMetabolizerSystem if (scale < effect.MinScale) continue; + if (effect.Probability < 1.0f && !_random.Prob(effect.Probability)) + continue; + // See if conditions apply if (effect.Conditions != null && !CanMetabolizeEffect(actualEntity, ent, soln.Value, effect.Conditions)) continue; diff --git a/Content.Server/Speech/EntitySystems/SlurredSystem.cs b/Content.Server/Speech/EntitySystems/SlurredSystem.cs index c4db77c14b..34cd050439 100644 --- a/Content.Server/Speech/EntitySystems/SlurredSystem.cs +++ b/Content.Server/Speech/EntitySystems/SlurredSystem.cs @@ -15,6 +15,16 @@ public sealed class SlurredSystem : SharedSlurredSystem [Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly IGameTiming _timing = default!; + /// + /// Divisor applied to total seconds used to get the odds of slurred speech occuring. + /// + private const float SlurredModifier = 1100f; + + /// + /// Minimum amount of time on the slurred accent for it to start taking effect. + /// + private const float SlurredThreshold = 80f; + public override void Initialize() { SubscribeLocalEvent(OnAccent); @@ -32,15 +42,9 @@ public sealed class SlurredSystem : SharedSlurredSystem return 0; // This is a magic number. Why this value? No clue it was made 3 years before I refactored this. - var magic = SharedDrunkSystem.MagicNumber; + var magic = time.Item2 == null ? SlurredModifier : (float) (time.Item2 - _timing.CurTime).Value.TotalSeconds - SlurredThreshold; - if (time.Item2 != null) - { - var curTime = _timing.CurTime; - magic = (float) (time.Item2 - curTime).Value.TotalSeconds - 80f; - } - - return Math.Clamp(magic / SharedDrunkSystem.MagicNumber, 0f, 1f); + return Math.Clamp(magic / SlurredModifier, 0f, 1f); } private void OnAccent(Entity entity, ref AccentGetEvent args) diff --git a/Content.Shared/Drunk/SharedDrunkSystem.cs b/Content.Shared/Drunk/SharedDrunkSystem.cs index 96aff82fa0..9faeb9419d 100644 --- a/Content.Shared/Drunk/SharedDrunkSystem.cs +++ b/Content.Shared/Drunk/SharedDrunkSystem.cs @@ -1,4 +1,3 @@ -using Content.Shared.Speech.EntitySystems; using Content.Shared.StatusEffectNew; using Content.Shared.Traits.Assorted; using Robust.Shared.Prototypes; @@ -8,12 +7,6 @@ namespace Content.Shared.Drunk; public abstract class SharedDrunkSystem : EntitySystem { public static EntProtoId Drunk = "StatusEffectDrunk"; - public static EntProtoId Woozy = "StatusEffectWoozy"; - - /* I have no clue why this magic number was chosen, I copied it from slur system and needed it for the overlay - If you have a more intelligent magic number be my guest to completely explode this value. - There were no comments as to why this value was chosen three years ago. */ - public static float MagicNumber = 1100f; [Dependency] protected readonly StatusEffectsSystem Status = default!; diff --git a/Content.Shared/EntityEffects/Effects/StatusEffects/ModifyParalysisEntityEffectSystem.cs b/Content.Shared/EntityEffects/Effects/StatusEffects/ModifyParalysisEntityEffectSystem.cs index 318c8ad30b..c6260eb71d 100644 --- a/Content.Shared/EntityEffects/Effects/StatusEffects/ModifyParalysisEntityEffectSystem.cs +++ b/Content.Shared/EntityEffects/Effects/StatusEffects/ModifyParalysisEntityEffectSystem.cs @@ -1,5 +1,4 @@ using Content.Shared.StatusEffectNew; -using Content.Shared.StatusEffectNew.Components; using Content.Shared.Stunnable; using Robust.Shared.Prototypes; @@ -10,12 +9,12 @@ namespace Content.Shared.EntityEffects.Effects.StatusEffects; /// Duration is modified by scale. /// /// -public sealed partial class ModifyParalysisEntityEffectSystem : EntityEffectSystem +public sealed partial class ModifyParalysisEntityEffectSystem : EntityEffectSystem { [Dependency] private readonly StatusEffectsSystem _status = default!; [Dependency] private readonly SharedStunSystem _stun = default!; - protected override void Effect(Entity entity, ref EntityEffectEvent args) + protected override void Effect(Entity entity, ref EntityEffectEvent args) { var time = args.Effect.Time * args.Scale; diff --git a/Content.Shared/EntityEffects/Effects/StatusEffects/ModifyStatusEffectEntityEffectSystem.cs b/Content.Shared/EntityEffects/Effects/StatusEffects/ModifyStatusEffectEntityEffectSystem.cs index d7e4b634f3..b42c3f2950 100644 --- a/Content.Shared/EntityEffects/Effects/StatusEffects/ModifyStatusEffectEntityEffectSystem.cs +++ b/Content.Shared/EntityEffects/Effects/StatusEffects/ModifyStatusEffectEntityEffectSystem.cs @@ -1,5 +1,4 @@ using Content.Shared.StatusEffectNew; -using Content.Shared.StatusEffectNew.Components; using Robust.Shared.Prototypes; namespace Content.Shared.EntityEffects.Effects.StatusEffects; @@ -9,11 +8,11 @@ namespace Content.Shared.EntityEffects.Effects.StatusEffects; /// Duration is modified by scale. /// /// -public sealed partial class ModifyStatusEffectEntityEffectSystem : EntityEffectSystem +public sealed partial class ModifyStatusEffectEntityEffectSystem : EntityEffectSystem { [Dependency] private readonly StatusEffectsSystem _status = default!; - protected override void Effect(Entity entity, ref EntityEffectEvent args) + protected override void Effect(Entity entity, ref EntityEffectEvent args) { var time = args.Effect.Time * args.Scale; var delay = args.Effect.Delay; diff --git a/Content.Shared/StatusEffectNew/Components/StatusEffectComponent.cs b/Content.Shared/StatusEffectNew/Components/StatusEffectComponent.cs index 27764b3aee..a7c772434c 100644 --- a/Content.Shared/StatusEffectNew/Components/StatusEffectComponent.cs +++ b/Content.Shared/StatusEffectNew/Components/StatusEffectComponent.cs @@ -35,7 +35,8 @@ public sealed partial class StatusEffectComponent : Component /// /// If true, this status effect has been applied. Used to ensure that only fires once. /// - [DataField, AutoNetworkedField] + /// We actually don't want to network this, that way client can apply an effect it's receiving properly! + [DataField] public bool Applied; /// diff --git a/Content.Shared/StatusEffectNew/StatusEffectsSystem.cs b/Content.Shared/StatusEffectNew/StatusEffectsSystem.cs index 966878b4e3..82915b002a 100644 --- a/Content.Shared/StatusEffectNew/StatusEffectsSystem.cs +++ b/Content.Shared/StatusEffectNew/StatusEffectsSystem.cs @@ -51,7 +51,7 @@ public sealed partial class StatusEffectsSystem : EntitySystem if (effect.EndEffectTime is null) continue; - if (!(_timing.CurTime >= effect.EndEffectTime)) + if (_timing.CurTime < effect.EndEffectTime) continue; if (effect.AppliedTo is null) @@ -81,14 +81,14 @@ public sealed partial class StatusEffectsSystem : EntitySystem if (args.Container.ID != StatusEffectContainerComponent.ContainerId) return; - if (!TryComp(args.Entity, out var statusComp)) + if (!_effectQuery.TryComp(args.Entity, out var statusComp)) return; // Make sure AppliedTo is set correctly so events can rely on it if (statusComp.AppliedTo != ent) { statusComp.AppliedTo = ent; - Dirty(args.Entity, statusComp); + DirtyField(args.Entity, statusComp, nameof(StatusEffectComponent.AppliedTo)); } } @@ -97,7 +97,7 @@ public sealed partial class StatusEffectsSystem : EntitySystem if (args.Container.ID != StatusEffectContainerComponent.ContainerId) return; - if (!TryComp(args.Entity, out var statusComp)) + if (!_effectQuery.TryComp(args.Entity, out var statusComp)) return; var ev = new StatusEffectRemovedEvent(ent); @@ -127,20 +127,17 @@ public sealed partial class StatusEffectsSystem : EntitySystem /// Returns true if the effect is applied. private bool TryApplyStatusEffect(Entity statusEffectEnt) { - if (!statusEffectEnt.Comp.Applied && - statusEffectEnt.Comp.AppliedTo != null && - _timing.CurTime >= statusEffectEnt.Comp.StartEffectTime) - { - var ev = new StatusEffectAppliedEvent(statusEffectEnt.Comp.AppliedTo.Value); - RaiseLocalEvent(statusEffectEnt, ref ev); + if (statusEffectEnt.Comp.Applied || + statusEffectEnt.Comp.AppliedTo == null || + _timing.CurTime < statusEffectEnt.Comp.StartEffectTime) + return false; - statusEffectEnt.Comp.Applied = true; + var ev = new StatusEffectAppliedEvent(statusEffectEnt.Comp.AppliedTo.Value); + RaiseLocalEvent(statusEffectEnt, ref ev); - DirtyField(statusEffectEnt, statusEffectEnt.Comp, nameof(StatusEffectComponent.StartEffectTime)); - return true; - } + statusEffectEnt.Comp.Applied = true; - return false; + return true; } public bool CanAddStatusEffect(EntityUid uid, EntProtoId effectProto) @@ -207,7 +204,7 @@ public sealed partial class StatusEffectsSystem : EntitySystem var startTime = delay == null ? TimeSpan.Zero : _timing.CurTime + delay.Value; SetStatusEffectStartTime(effect.Value, startTime); - TryApplyStatusEffect((effect.Value, effectComp)); + TryApplyStatusEffect((statusEffect.Value, effectComp)); return true; } diff --git a/Resources/Prototypes/Reagents/Consumable/Drink/alcohol.yml b/Resources/Prototypes/Reagents/Consumable/Drink/alcohol.yml index f294b5438b..3e35837dda 100644 --- a/Resources/Prototypes/Reagents/Consumable/Drink/alcohol.yml +++ b/Resources/Prototypes/Reagents/Consumable/Drink/alcohol.yml @@ -206,7 +206,7 @@ type: [ Dwarf ] inverted: true - !type:Drunk - boozePower: 2 + boozePower: 20 - type: reagent id: Gin