From 7916f07ddd41bb974fb4e8399c5e8132f7e274cc Mon Sep 17 00:00:00 2001
From: WarMechanic <69510347+WarMechanic@users.noreply.github.com>
Date: Sat, 13 Jul 2024 05:02:15 +1000
Subject: [PATCH] Heavyweight Drunk Trait + Drunk Traits Rework (#512)
# Description
Adds the inverse of lightweight drunk, which makes you less susceptible
to the effects of ethanol.
(more specifically, it halves the damage of alcohol and you need to
drink twice as much to feel the effects in the first place)
To make the change happen, `LightweightDrunk` component was reworked to:
- A) no longer change any drunk effects (including non-alcohol related
drunkness like bloodloss)
- B) instead multiply the effects of ethanol in your bloodstream
I chose this route in particular, because the other option of
multiplying the amount of ethanol gained from alcohols is nonsense.
---
# TODO
- [X] Add a `TryMetabolizeReagent` event to `MetabolizerSystem.cs` so a
`LightweightDrunkSystem.cs` can listen to the event and multiply the
effects of "Ethanol" specifically.
- [X] Add the Heavyweight Drunk trait
- ~~Fix a minor spelling mistake that caused the trait condition to not
show up~~
- [ ] Would we be able to name trait files after categories? I don't
want to put every positive trait in a file named 'skills.yml'
---
Media
![Example Media Embed](https://example.com/thisimageisntreal.png)
---
# Changelog
:cl:
- add: Added the Heavyweight Drunk trait, which doubles your alcoholism
potential.
---------
Signed-off-by: VMSolidus
Co-authored-by: VMSolidus
---
.../Body/Systems/MetabolizerSystem.cs | 8 ++++++-
.../ReagentThreshold.cs | 2 +-
.../Chemistry/ReagentEffects/Drunk.cs | 2 +-
.../Assorted}/LightweightDrunkComponent.cs | 8 ++-----
.../Traits/Assorted/LightweightDrunkSystem.cs | 23 +++++++++++++++++++
.../Chemistry/Reagent/ReagentEffect.cs | 3 ++-
Content.Shared/Drunk/DrunkSystem.cs | 3 ---
Resources/Locale/en-US/traits/traits.ftl | 3 +++
.../Prototypes/Traits/inconveniences.yml | 4 ++++
Resources/Prototypes/Traits/skills.yml | 18 +++++++++++++++
10 files changed, 61 insertions(+), 13 deletions(-)
rename {Content.Shared/Traits/Assorted/Components => Content.Server/Traits/Assorted}/LightweightDrunkComponent.cs (50%)
create mode 100644 Content.Server/Traits/Assorted/LightweightDrunkSystem.cs
diff --git a/Content.Server/Body/Systems/MetabolizerSystem.cs b/Content.Server/Body/Systems/MetabolizerSystem.cs
index 45cba5a195f..066bf0a1c5b 100644
--- a/Content.Server/Body/Systems/MetabolizerSystem.cs
+++ b/Content.Server/Body/Systems/MetabolizerSystem.cs
@@ -190,8 +190,11 @@ private void TryMetabolize(Entity= Min && quant <= Max;
}
diff --git a/Content.Server/Chemistry/ReagentEffects/Drunk.cs b/Content.Server/Chemistry/ReagentEffects/Drunk.cs
index dbce995ca2e..6088db5787c 100644
--- a/Content.Server/Chemistry/ReagentEffects/Drunk.cs
+++ b/Content.Server/Chemistry/ReagentEffects/Drunk.cs
@@ -25,7 +25,7 @@ public override void Effect(ReagentEffectArgs args)
{
var boozePower = BoozePower;
- boozePower *= args.Scale;
+ boozePower *= Math.Max(args.Scale, 1);
var drunkSys = args.EntityManager.EntitySysManager.GetEntitySystem();
drunkSys.TryApplyDrunkenness(args.SolutionEntity, boozePower, SlurSpeech);
diff --git a/Content.Shared/Traits/Assorted/Components/LightweightDrunkComponent.cs b/Content.Server/Traits/Assorted/LightweightDrunkComponent.cs
similarity index 50%
rename from Content.Shared/Traits/Assorted/Components/LightweightDrunkComponent.cs
rename to Content.Server/Traits/Assorted/LightweightDrunkComponent.cs
index 62d2f5899a4..4daff2e1338 100644
--- a/Content.Shared/Traits/Assorted/Components/LightweightDrunkComponent.cs
+++ b/Content.Server/Traits/Assorted/LightweightDrunkComponent.cs
@@ -1,13 +1,9 @@
-using Content.Shared.Drunk;
-using Robust.Shared.GameStates;
-
namespace Content.Shared.Traits.Assorted.Components;
///
-/// Used for the lightweight trait. DrunkSystem will check for this component and modify the boozePower accordingly if it finds it.
+/// Used for the lightweight trait. LightweightDrunkSystem will multiply the effects of ethanol being metabolized
///
-[RegisterComponent, NetworkedComponent]
-[Access(typeof(SharedDrunkSystem))]
+[RegisterComponent]
public sealed partial class LightweightDrunkComponent : Component
{
[DataField("boozeStrengthMultiplier"), ViewVariables(VVAccess.ReadWrite)]
diff --git a/Content.Server/Traits/Assorted/LightweightDrunkSystem.cs b/Content.Server/Traits/Assorted/LightweightDrunkSystem.cs
new file mode 100644
index 00000000000..b5e9b877764
--- /dev/null
+++ b/Content.Server/Traits/Assorted/LightweightDrunkSystem.cs
@@ -0,0 +1,23 @@
+using Content.Server.Body.Components;
+using Content.Server.Body.Systems;
+using Content.Shared.Chemistry.Reagent;
+using Content.Shared.Traits.Assorted.Components;
+
+namespace Content.Shared.Traits.Assorted.Systems;
+public sealed class LightweightDrunkSystem : EntitySystem
+{
+ public override void Initialize()
+ {
+ SubscribeLocalEvent(OnTryMetabolizeReagent);
+ }
+
+ private void OnTryMetabolizeReagent(EntityUid uid, LightweightDrunkComponent comp, ref TryMetabolizeReagent args)
+ {
+ Log.Debug(args.Prototype.ID);
+ if (args.Prototype.ID != "Ethanol")
+ return;
+
+ args.Scale *= comp.BoozeStrengthMultiplier;
+ args.QuantityMultiplier *= comp.BoozeStrengthMultiplier;
+ }
+}
\ No newline at end of file
diff --git a/Content.Shared/Chemistry/Reagent/ReagentEffect.cs b/Content.Shared/Chemistry/Reagent/ReagentEffect.cs
index 5bcb21fedb3..41eea55cca4 100644
--- a/Content.Shared/Chemistry/Reagent/ReagentEffect.cs
+++ b/Content.Shared/Chemistry/Reagent/ReagentEffect.cs
@@ -107,6 +107,7 @@ public readonly record struct ReagentEffectArgs(
FixedPoint2 Quantity,
IEntityManager EntityManager,
ReactionMethod? Method,
- float Scale
+ float Scale = 1f,
+ float QuantityMultiplier = 1f
);
}
diff --git a/Content.Shared/Drunk/DrunkSystem.cs b/Content.Shared/Drunk/DrunkSystem.cs
index 161d4729ede..ed022cae31b 100644
--- a/Content.Shared/Drunk/DrunkSystem.cs
+++ b/Content.Shared/Drunk/DrunkSystem.cs
@@ -18,9 +18,6 @@ public void TryApplyDrunkenness(EntityUid uid, float boozePower, bool applySlur
if (!Resolve(uid, ref status, false))
return;
- if (TryComp(uid, out var trait))
- boozePower *= trait.BoozeStrengthMultiplier;
-
if (applySlur)
{
_slurredSystem.DoSlur(uid, TimeSpan.FromSeconds(boozePower), status);
diff --git a/Resources/Locale/en-US/traits/traits.ftl b/Resources/Locale/en-US/traits/traits.ftl
index f6e3e0b1fc1..f8cef13ecd3 100644
--- a/Resources/Locale/en-US/traits/traits.ftl
+++ b/Resources/Locale/en-US/traits/traits.ftl
@@ -11,6 +11,9 @@ trait-description-Pacifist = You cannot attack or hurt any living beings.
trait-name-LightweightDrunk = Lightweight Drunk
trait-description-LightweightDrunk = Alcohol has a stronger effect on you
+trait-name-HeavyweightDrunk = Heavyweight Drunk
+trait-description-HeavyweightDrunk = Alcohols are afraid of you
+
trait-name-Muted = Muted
trait-description-Muted = You can't speak
diff --git a/Resources/Prototypes/Traits/inconveniences.yml b/Resources/Prototypes/Traits/inconveniences.yml
index 8dc0264ffea..fee312593da 100644
--- a/Resources/Prototypes/Traits/inconveniences.yml
+++ b/Resources/Prototypes/Traits/inconveniences.yml
@@ -7,6 +7,10 @@
jobs:
- Borg
- MedicalBorg
+ - !type:CharacterTraitRequirement
+ inverted: true
+ traits:
+ - HeavyweightDrunk
components:
- type: LightweightDrunk
boozeStrengthMultiplier: 2
diff --git a/Resources/Prototypes/Traits/skills.yml b/Resources/Prototypes/Traits/skills.yml
index 6175834c1fc..988307f58e4 100644
--- a/Resources/Prototypes/Traits/skills.yml
+++ b/Resources/Prototypes/Traits/skills.yml
@@ -1,3 +1,21 @@
+- type: trait
+ id: HeavyweightDrunk
+ category: Physical
+ points: -2
+ requirements:
+ - !type:CharacterJobRequirement
+ inverted: true
+ jobs:
+ - Borg
+ - MedicalBorg
+ - !type:CharacterTraitRequirement
+ inverted: true
+ traits:
+ - LightweightDrunk
+ components:
+ - type: LightweightDrunk
+ boozeStrengthMultiplier: 0.5
+
- type: trait
id: Thieving
category: Physical