Metabolism fixes (#20402)
* In-progress commit for fixing metabolism system * Commit with all debugging in there In case I have to revert or something * Cleanup debug commands
This commit is contained in:
@@ -14,6 +14,7 @@ public sealed class DrunkOverlay : Overlay
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||
[Dependency] private readonly IEntitySystemManager _sysMan = default!;
|
||||
[Dependency] private readonly IGameTiming _timing = default!;
|
||||
|
||||
public override OverlaySpace Space => OverlaySpace.WorldSpace;
|
||||
public override bool RequestScreenTexture => true;
|
||||
@@ -34,6 +35,7 @@ public sealed class DrunkOverlay : Overlay
|
||||
|
||||
protected override void FrameUpdate(FrameEventArgs args)
|
||||
{
|
||||
|
||||
var playerEntity = _playerManager.LocalPlayer?.ControlledEntity;
|
||||
|
||||
if (playerEntity == null)
|
||||
@@ -47,8 +49,11 @@ public sealed class DrunkOverlay : Overlay
|
||||
if (!statusSys.TryGetTime(playerEntity.Value, SharedDrunkSystem.DrunkKey, out var time, status))
|
||||
return;
|
||||
|
||||
var timeLeft = (float) (time.Value.Item2 - time.Value.Item1).TotalSeconds;
|
||||
CurrentBoozePower += (timeLeft - CurrentBoozePower) * args.DeltaSeconds / 16f;
|
||||
var curTime = _timing.CurTime;
|
||||
var timeLeft = (float) (time.Value.Item2 - curTime).TotalSeconds;
|
||||
|
||||
|
||||
CurrentBoozePower += 8f * (0.5f*timeLeft - CurrentBoozePower) * args.DeltaSeconds / (timeLeft+1);
|
||||
}
|
||||
|
||||
protected override bool BeforeDraw(in OverlayDrawArgs args)
|
||||
@@ -83,6 +88,14 @@ public sealed class DrunkOverlay : Overlay
|
||||
/// <param name="boozePower"></param>
|
||||
private float BoozePowerToVisual(float boozePower)
|
||||
{
|
||||
return Math.Clamp((boozePower - VisualThreshold) / PowerDivisor, 0.0f, 1.0f);
|
||||
// Clamp booze power when it's low, to prevent really jittery effects
|
||||
if (boozePower < 50f)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Math.Clamp((boozePower - VisualThreshold) / PowerDivisor, 0.0f, 1.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,7 +149,6 @@ namespace Content.Server.Body.Systems
|
||||
if (reagents >= meta.MaxReagentsProcessable)
|
||||
return;
|
||||
|
||||
reagents += 1;
|
||||
|
||||
// loop over all our groups and see which ones apply
|
||||
if (meta.MetabolismGroups == null)
|
||||
@@ -161,16 +160,12 @@ namespace Content.Server.Body.Systems
|
||||
continue;
|
||||
|
||||
var entry = proto.Metabolisms[group.Id];
|
||||
var rate = entry.MetabolismRate * group.MetabolismRateModifier;
|
||||
|
||||
// we don't remove reagent for every group, just whichever had the biggest rate
|
||||
if (entry.MetabolismRate > mostToRemove)
|
||||
mostToRemove = entry.MetabolismRate;
|
||||
// Remove $rate, as long as there's enough reagent there to actually remove that much
|
||||
mostToRemove = FixedPoint2.Clamp(rate, 0, quantity);
|
||||
|
||||
mostToRemove *= group.MetabolismRateModifier;
|
||||
|
||||
mostToRemove = FixedPoint2.Clamp(mostToRemove, 0, quantity);
|
||||
|
||||
float scale = (float) mostToRemove / (float) entry.MetabolismRate;
|
||||
float scale = (float) mostToRemove / (float) rate;
|
||||
|
||||
// if it's possible for them to be dead, and they are,
|
||||
// then we shouldn't process any effects, but should probably
|
||||
@@ -205,6 +200,9 @@ namespace Content.Server.Body.Systems
|
||||
if (mostToRemove > FixedPoint2.Zero)
|
||||
{
|
||||
_solutionContainerSystem.RemoveReagent(solutionEntityUid.Value, solution, reagent, mostToRemove);
|
||||
|
||||
// We have processed a reagant, so count it towards the cap
|
||||
reagents += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ using Content.Shared.Drunk;
|
||||
using Content.Shared.Speech.EntitySystems;
|
||||
using Content.Shared.StatusEffect;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Server.Speech.EntitySystems;
|
||||
|
||||
@@ -11,6 +12,9 @@ public sealed class SlurredSystem : SharedSlurredSystem
|
||||
{
|
||||
[Dependency] private readonly StatusEffectsSystem _statusEffectsSystem = default!;
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly IGameTiming _timing = default!;
|
||||
|
||||
|
||||
|
||||
[ValidatePrototypeId<StatusEffectPrototype>]
|
||||
private const string SlurKey = "SlurredSpeech";
|
||||
@@ -39,8 +43,9 @@ public sealed class SlurredSystem : SharedSlurredSystem
|
||||
if (!_statusEffectsSystem.TryGetTime(uid, SharedDrunkSystem.DrunkKey, out var time))
|
||||
return 0;
|
||||
|
||||
var timeLeft = (float) (time.Value.Item2 - time.Value.Item1).TotalSeconds;
|
||||
return Math.Clamp(timeLeft / 200, 0f, 1f);
|
||||
var curTime = _timing.CurTime;
|
||||
var timeLeft = (float) (time.Value.Item2 - curTime).TotalSeconds;
|
||||
return Math.Clamp((timeLeft - 80) / 1100, 0f, 1f);
|
||||
}
|
||||
|
||||
private void OnAccent(EntityUid uid, SlurredAccentComponent component, AccentGetEvent args)
|
||||
|
||||
@@ -120,12 +120,12 @@
|
||||
boilingPoint: 78.2
|
||||
meltingPoint: -114.1
|
||||
metabolisms:
|
||||
Poison:
|
||||
Alcohol:
|
||||
effects:
|
||||
- !type:HealthChange
|
||||
conditions:
|
||||
- !type:ReagentThreshold
|
||||
min: 5
|
||||
min: 15
|
||||
- !type:OrganType
|
||||
type: Dwarf
|
||||
shouldHave: false
|
||||
@@ -136,7 +136,7 @@
|
||||
- !type:HealthChange
|
||||
conditions:
|
||||
- !type:ReagentThreshold
|
||||
min: 5
|
||||
min: 15
|
||||
- !type:OrganType
|
||||
type: Dwarf
|
||||
damage:
|
||||
@@ -145,7 +145,7 @@
|
||||
- !type:HealthChange
|
||||
conditions:
|
||||
- !type:ReagentThreshold
|
||||
min: 5
|
||||
min: 15
|
||||
- !type:OrganType
|
||||
type: Dwarf
|
||||
damage:
|
||||
@@ -156,15 +156,13 @@
|
||||
conditions:
|
||||
- !type:ReagentThreshold
|
||||
reagent: Ethanol
|
||||
min: 3
|
||||
min: 12
|
||||
# dwarves immune to vomiting from alcohol
|
||||
- !type:OrganType
|
||||
type: Dwarf
|
||||
shouldHave: false
|
||||
Alcohol:
|
||||
effects:
|
||||
- !type:Drunk
|
||||
boozePower: 20
|
||||
boozePower: 2
|
||||
|
||||
- type: reagent
|
||||
id: Gin
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
- type: reagent
|
||||
- type: reagent
|
||||
id: BaseDrink
|
||||
group: Drinks
|
||||
abstract: true
|
||||
@@ -48,7 +48,7 @@
|
||||
factor: 2
|
||||
- !type:AdjustReagent
|
||||
reagent: Ethanol
|
||||
amount: 0.05
|
||||
amount: 0.06
|
||||
reactiveEffects:
|
||||
Flammable:
|
||||
methods: [ Touch ]
|
||||
|
||||
Reference in New Issue
Block a user