Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Heavyweight Drunk Trait + Drunk Traits Rework #512

Merged
merged 6 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Content.Server/Body/Systems/MetabolizerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,11 @@ private void TryMetabolize(Entity<MetabolizerComponent, OrganComponent?, Solutio
}

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)
Expand Down Expand Up @@ -251,3 +254,6 @@ public readonly record struct ApplyMetabolicMultiplierEvent(
public readonly bool Apply = Apply;
}
}

[ByRefEvent]
public record struct TryMetabolizeReagent(ReagentId Reagent, ReagentPrototype Prototype, FixedPoint2 Quantity, float Scale = 1f, float QuantityMultiplier = 1f);
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Chemistry/ReagentEffects/Drunk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<SharedDrunkSystem>();
drunkSys.TryApplyDrunkenness(args.SolutionEntity, boozePower, SlurSpeech);
Expand Down
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
23 changes: 23 additions & 0 deletions Content.Server/Traits/Assorted/LightweightDrunkSystem.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}
3 changes: 2 additions & 1 deletion Content.Shared/Chemistry/Reagent/ReagentEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ public readonly record struct ReagentEffectArgs(
FixedPoint2 Quantity,
IEntityManager EntityManager,
ReactionMethod? Method,
float Scale
float Scale = 1f,
float QuantityMultiplier = 1f
);
}
3 changes: 0 additions & 3 deletions Content.Shared/Drunk/DrunkSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ public void TryApplyDrunkenness(EntityUid uid, float boozePower, bool applySlur
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);
Expand Down
3 changes: 3 additions & 0 deletions Resources/Locale/en-US/traits/traits.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions Resources/Prototypes/Traits/inconveniences.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
jobs:
- Borg
- MedicalBorg
- !type:CharacterTraitRequirement
inverted: true
traits:
- HeavyweightDrunk
components:
- type: LightweightDrunk
boozeStrengthMultiplier: 2
Expand Down
18 changes: 18 additions & 0 deletions Resources/Prototypes/Traits/skills.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Loading