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