Heavyweight Drunk Trait + Drunk Traits Rework (#512)

<!--
This is a semi-strict format, you can add/remove sections as needed but
the order/format should be kept the same
Remove these comments before submitting
-->

# Description
<!--
Explain this PR in as much detail as applicable

Some example prompts to consider:
How might this affect the game? The codebase?
What might be some alternatives to this?
How/Who does this benefit/hurt [the game/codebase]?
-->

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

<!--
A list of everything you have to do before this PR is "complete"
You probably won't have to complete everything before merging but it's
good to leave future references
-->

- [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'

---

<!--
This is default collapsed, readers click to expand it and see all your
media
The PR media section can get very large at times, so this is a good way
to keep it clean
The title is written using HTML tags
The title must be within the <summary> tags or you won't see it
-->

<details><summary><h1>Media</h1></summary>
<p>

![Example Media Embed](https://example.com/thisimageisntreal.png)

</p>
</details>

---

# Changelog

<!--
You can add an author after the `🆑` to change the name that appears
in the changelog (ex: `🆑 Death`)
Leaving it blank will default to your GitHub display name
This includes all available types for the changelog
-->

🆑
- add: Added the Heavyweight Drunk trait, which doubles your alcoholism
potential.

---------

Signed-off-by: VMSolidus <evilexecutive@gmail.com>
Co-authored-by: VMSolidus <evilexecutive@gmail.com>
This commit is contained in:
WarMechanic
2024-07-13 05:02:15 +10:00
committed by GitHub
parent c55afe59ef
commit 7916f07ddd
10 changed files with 61 additions and 13 deletions

View File

@@ -190,8 +190,11 @@ namespace Content.Server.Body.Systems
}
var actualEntity = ent.Comp2?.Body ?? solutionEntityUid.Value;
var ev = new TryMetabolizeReagent(reagent, proto, quantity);
RaiseLocalEvent(actualEntity, ref ev);
var args = new ReagentEffectArgs(actualEntity, ent, 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)
@@ -251,3 +254,6 @@ namespace Content.Server.Body.Systems
public readonly bool Apply = Apply;
}
}
[ByRefEvent]
public record struct TryMetabolizeReagent(ReagentId Reagent, ReagentPrototype Prototype, FixedPoint2 Quantity, float Scale = 1f, float QuantityMultiplier = 1f);

View File

@@ -31,7 +31,7 @@ namespace Content.Server.Chemistry.ReagentEffectConditions
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;
}

View File

@@ -25,7 +25,7 @@ public sealed partial class Drunk : ReagentEffect
{
var boozePower = BoozePower;
boozePower *= args.Scale;
boozePower *= Math.Max(args.Scale, 1);
var drunkSys = args.EntityManager.EntitySysManager.GetEntitySystem<SharedDrunkSystem>();
drunkSys.TryApplyDrunkenness(args.SolutionEntity, boozePower, SlurSpeech);

View File

@@ -1,13 +1,9 @@
using Content.Shared.Drunk;
using Robust.Shared.GameStates;
namespace Content.Shared.Traits.Assorted.Components;
/// <summary>
/// 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
/// </summary>
[RegisterComponent, NetworkedComponent]
[Access(typeof(SharedDrunkSystem))]
[RegisterComponent]
public sealed partial class LightweightDrunkComponent : Component
{
[DataField("boozeStrengthMultiplier"), ViewVariables(VVAccess.ReadWrite)]

View File

@@ -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<LightweightDrunkComponent, TryMetabolizeReagent>(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;
}
}

View File

@@ -107,6 +107,7 @@ namespace Content.Shared.Chemistry.Reagent
FixedPoint2 Quantity,
IEntityManager EntityManager,
ReactionMethod? Method,
float Scale
float Scale = 1f,
float QuantityMultiplier = 1f
);
}

View File

@@ -18,9 +18,6 @@ public abstract class SharedDrunkSystem : EntitySystem
if (!Resolve(uid, ref status, false))
return;
if (TryComp<LightweightDrunkComponent>(uid, out var trait))
boozePower *= trait.BoozeStrengthMultiplier;
if (applySlur)
{
_slurredSystem.DoSlur(uid, TimeSpan.FromSeconds(boozePower), status);

View File

@@ -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

View File

@@ -7,6 +7,10 @@
jobs:
- Borg
- MedicalBorg
- !type:CharacterTraitRequirement
inverted: true
traits:
- HeavyweightDrunk
components:
- type: LightweightDrunk
boozeStrengthMultiplier: 2

View File

@@ -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