From da4da16c6ace27bca77a266f10a9ab15043799e3 Mon Sep 17 00:00:00 2001 From: WarMechanic <69510347+WarMechanic@users.noreply.github.com> Date: Sat, 6 Jul 2024 00:16:09 +1000 Subject: [PATCH 1/4] make changes --- .../Body/Systems/MetabolizerSystem.cs | 8 ++++++- .../ReagentThreshold.cs | 2 +- .../Chemistry/ReagentEffects/Drunk.cs | 2 +- .../Traits/Assorted/LightweightDrunkSystem.cs | 23 +++++++++++++++++++ .../Chemistry/Reagent/ReagentEffect.cs | 3 ++- Content.Shared/Drunk/DrunkSystem.cs | 3 --- .../customization/character-requirements.ftl | 2 +- Resources/Locale/en-US/traits/traits.ftl | 3 +++ .../Prototypes/Traits/inconveniences.yml | 4 ++++ Resources/Prototypes/Traits/skills.yml | 17 ++++++++++++++ 10 files changed, 59 insertions(+), 8 deletions(-) create mode 100644 Content.Server/Traits/Assorted/LightweightDrunkSystem.cs create mode 100644 Resources/Prototypes/Traits/skills.yml diff --git a/Content.Server/Body/Systems/MetabolizerSystem.cs b/Content.Server/Body/Systems/MetabolizerSystem.cs index e5f604f70df..1ada6d35150 100644 --- a/Content.Server/Body/Systems/MetabolizerSystem.cs +++ b/Content.Server/Body/Systems/MetabolizerSystem.cs @@ -176,8 +176,11 @@ private void TryMetabolize(EntityUid uid, MetabolizerComponent meta, OrganCompon } var actualEntity = organ?.Body ?? solutionEntityUid.Value; + var ev = new TryMetabolizeReagent(reagent, proto, quantity); + RaiseLocalEvent(actualEntity, ref ev); + var args = new ReagentEffectArgs(actualEntity, uid, solution, proto, mostToRemove, - EntityManager, null, scale); + EntityManager, null, scale * ev.Scale, ev.QuantityMultiplier); // do all effects, if conditions apply foreach (var effect in entry.Effects) @@ -221,3 +224,6 @@ public sealed class ApplyMetabolicMultiplierEvent : EntityEventArgs public bool Apply; } } + +[ByRefEvent] +public record struct TryMetabolizeReagent(ReagentId Reagent, ReagentPrototype Prototype, FixedPoint2 Quantity, float Scale = 1f, float QuantityMultiplier = 1f); \ No newline at end of file diff --git a/Content.Server/Chemistry/ReagentEffectConditions/ReagentThreshold.cs b/Content.Server/Chemistry/ReagentEffectConditions/ReagentThreshold.cs index 664569d7be4..50be89581fb 100644 --- a/Content.Server/Chemistry/ReagentEffectConditions/ReagentThreshold.cs +++ b/Content.Server/Chemistry/ReagentEffectConditions/ReagentThreshold.cs @@ -31,7 +31,7 @@ public override bool Condition(ReagentEffectArgs args) var quant = FixedPoint2.Zero; if (args.Source != null) - quant = args.Source.GetTotalPrototypeQuantity(reagent); + quant = args.Source.GetTotalPrototypeQuantity(reagent) * args.QuantityMultiplier; return quant >= 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.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/customization/character-requirements.ftl b/Resources/Locale/en-US/customization/character-requirements.ftl index b073bdb773f..e7bcf0669f7 100644 --- a/Resources/Locale/en-US/customization/character-requirements.ftl +++ b/Resources/Locale/en-US/customization/character-requirements.ftl @@ -9,7 +9,7 @@ character-species-requirement = You must {$inverted -> character-trait-requirement = You must {$inverted -> [true] not have *[other] have -} the trait [color=lightblue]{$trait}[/color] +} the trait [color=lightblue]{$traits}[/color] character-backpack-type-requirement = You must {$inverted -> [true] not use *[other] use diff --git a/Resources/Locale/en-US/traits/traits.ftl b/Resources/Locale/en-US/traits/traits.ftl index e9163bdb548..cfab2e1fc89 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 dcf53d9ab7f..34526483a81 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 new file mode 100644 index 00000000000..892d61bfdfb --- /dev/null +++ b/Resources/Prototypes/Traits/skills.yml @@ -0,0 +1,17 @@ +- 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 \ No newline at end of file From 2bcd209719bae703b25fbf965940fff32cb322ea Mon Sep 17 00:00:00 2001 From: WarMechanic <69510347+WarMechanic@users.noreply.github.com> Date: Sat, 6 Jul 2024 12:24:19 +1000 Subject: [PATCH 2/4] move LightweightDrunkComponent to server --- .../Traits/Assorted}/LightweightDrunkComponent.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) rename {Content.Shared/Traits/Assorted/Components => Content.Server/Traits/Assorted}/LightweightDrunkComponent.cs (50%) 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)] From f7ab447fb2ec2c05b04526e3a5d1ecdfb7df93da Mon Sep 17 00:00:00 2001 From: WarMechanic <69510347+WarMechanic@users.noreply.github.com> Date: Sat, 6 Jul 2024 12:44:39 +1000 Subject: [PATCH 3/4] minor spelling mistake --- Resources/Prototypes/Traits/skills.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/Prototypes/Traits/skills.yml b/Resources/Prototypes/Traits/skills.yml index 1e467dfcf5f..988307f58e4 100644 --- a/Resources/Prototypes/Traits/skills.yml +++ b/Resources/Prototypes/Traits/skills.yml @@ -16,7 +16,7 @@ - type: LightweightDrunk boozeStrengthMultiplier: 0.5 -- type: trair +- type: trait id: Thieving category: Physical points: -4 From 82fad3e7fdd9caeaf1cfe12b7c5d76ff53581f91 Mon Sep 17 00:00:00 2001 From: VMSolidus Date: Fri, 12 Jul 2024 14:50:52 -0400 Subject: [PATCH 4/4] Update MetabolizerSystem.cs --- Content.Server/Body/Systems/MetabolizerSystem.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Content.Server/Body/Systems/MetabolizerSystem.cs b/Content.Server/Body/Systems/MetabolizerSystem.cs index 271c2e1028c..066bf0a1c5b 100644 --- a/Content.Server/Body/Systems/MetabolizerSystem.cs +++ b/Content.Server/Body/Systems/MetabolizerSystem.cs @@ -193,7 +193,7 @@ private void TryMetabolize(Entity