From bf30f82ff5db30c3fc0bb09c0a77cbac555b3058 Mon Sep 17 00:00:00 2001 From: mirrorcult Date: Sat, 27 Nov 2021 00:31:49 -0700 Subject: [PATCH] Acid effects (#5466) * acid * balance * nerf area effects --- .../SolutionAreaEffectInceptionComponent.cs | 2 +- .../Chemistry/ReagentEffects/DoAction.cs | 36 ++++++++++++++++ .../Chemistry/ReagentEffects/HealthChange.cs | 14 ++++++- .../Prototypes/Chemistry/reactive_groups.yml | 3 ++ .../Entities/Mobs/NPCs/simplemob.yml | 1 + .../Entities/Mobs/Species/human.yml | 1 + Resources/Prototypes/Reagents/toxins.yml | 41 ++++++++++++++++++- 7 files changed, 94 insertions(+), 4 deletions(-) create mode 100644 Content.Server/Chemistry/ReagentEffects/DoAction.cs diff --git a/Content.Server/Chemistry/Components/SolutionAreaEffectInceptionComponent.cs b/Content.Server/Chemistry/Components/SolutionAreaEffectInceptionComponent.cs index ff38721a16..85d5b7d7e1 100644 --- a/Content.Server/Chemistry/Components/SolutionAreaEffectInceptionComponent.cs +++ b/Content.Server/Chemistry/Components/SolutionAreaEffectInceptionComponent.cs @@ -15,7 +15,7 @@ namespace Content.Server.Chemistry.Components { public override string Name => "AreaEffectInception"; - private const float ReactionDelay = 0.5f; + private const float ReactionDelay = 1.5f; private readonly HashSet _group = new(); diff --git a/Content.Server/Chemistry/ReagentEffects/DoAction.cs b/Content.Server/Chemistry/ReagentEffects/DoAction.cs new file mode 100644 index 0000000000..ed2acff393 --- /dev/null +++ b/Content.Server/Chemistry/ReagentEffects/DoAction.cs @@ -0,0 +1,36 @@ +using Content.Shared.Actions; +using Content.Shared.Actions.Components; +using Content.Shared.Actions.Prototypes; +using Content.Shared.Chemistry.Reagent; +using Content.Shared.Construction.Steps; +using Robust.Shared.GameObjects; +using Robust.Shared.IoC; +using Robust.Shared.Prototypes; +using Robust.Shared.Serialization.Manager.Attributes; +using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; + +namespace Content.Server.Chemistry.ReagentEffects; + +/// +/// Forces someone to do a certain action, if they have it. +/// +public class DoAction : ReagentEffect +{ + [DataField("action", required: true, customTypeSerializer:typeof(PrototypeIdSerializer))] + public string Action = default!; + + public override void Effect(ReagentEffectArgs args) + { + if (args.EntityManager.TryGetComponent(args.SolutionEntity, out SharedActionsComponent? actions)) + { + if (!IoCManager.Resolve().TryIndex(Action, out var proto)) + return; + + if (actions.IsGranted(proto.ActionType)) + { + var attempt = new ActionAttempt(proto); + attempt.DoInstantAction(args.EntityManager.GetEntity(args.SolutionEntity)); + } + } + } +} diff --git a/Content.Server/Chemistry/ReagentEffects/HealthChange.cs b/Content.Server/Chemistry/ReagentEffects/HealthChange.cs index 6d4c57077e..d8ea396740 100644 --- a/Content.Server/Chemistry/ReagentEffects/HealthChange.cs +++ b/Content.Server/Chemistry/ReagentEffects/HealthChange.cs @@ -2,6 +2,7 @@ using Content.Shared.Chemistry.Reagent; using Robust.Shared.GameObjects; using Robust.Shared.Serialization.Manager.Attributes; using Content.Shared.Damage; +using Content.Shared.FixedPoint; using JetBrains.Annotations; namespace Content.Server.Chemistry.ReagentEffects @@ -18,9 +19,20 @@ namespace Content.Server.Chemistry.ReagentEffects [DataField("damage", required: true)] public DamageSpecifier Damage = default!; + /// + /// Should this effect scale the damage by the amount of chemical in the solution? + /// Useful for touch reactions, like styptic powder or acid. + /// + [DataField("scaleByQuantity")] + public bool ScaleByQuantity = false; + + [DataField("ignoreResistances")] + public bool IgnoreResistances = true; + public override void Effect(ReagentEffectArgs args) { - EntitySystem.Get().TryChangeDamage(args.SolutionEntity, Damage, true); + var scale = ScaleByQuantity ? args.Quantity : FixedPoint2.New(1); + EntitySystem.Get().TryChangeDamage(args.SolutionEntity, Damage * scale, IgnoreResistances); } } } diff --git a/Resources/Prototypes/Chemistry/reactive_groups.yml b/Resources/Prototypes/Chemistry/reactive_groups.yml index 264df6e394..fa001f3083 100644 --- a/Resources/Prototypes/Chemistry/reactive_groups.yml +++ b/Resources/Prototypes/Chemistry/reactive_groups.yml @@ -3,3 +3,6 @@ - type: reactiveGroup id: Extinguish + +- type: reactiveGroup + id: Acidic diff --git a/Resources/Prototypes/Entities/Mobs/NPCs/simplemob.yml b/Resources/Prototypes/Entities/Mobs/NPCs/simplemob.yml index 08d033583c..47907853cb 100644 --- a/Resources/Prototypes/Entities/Mobs/NPCs/simplemob.yml +++ b/Resources/Prototypes/Entities/Mobs/NPCs/simplemob.yml @@ -8,6 +8,7 @@ groups: Flammable: [Touch] Extinguish: [Touch] + Acidic: [Touch, Ingestion] - type: UtilityAI behaviorSets: # - Clothing diff --git a/Resources/Prototypes/Entities/Mobs/Species/human.yml b/Resources/Prototypes/Entities/Mobs/Species/human.yml index c1dee05a76..4a01685717 100644 --- a/Resources/Prototypes/Entities/Mobs/Species/human.yml +++ b/Resources/Prototypes/Entities/Mobs/Species/human.yml @@ -14,6 +14,7 @@ groups: Flammable: [ Touch ] Extinguish: [ Touch ] + Acidic: [Touch, Ingestion] reactions: - reagents: [Water, SpaceCleaner] methods: [Touch] diff --git a/Resources/Prototypes/Reagents/toxins.yml b/Resources/Prototypes/Reagents/toxins.yml index 765b30d5b1..4f2668a033 100644 --- a/Resources/Prototypes/Reagents/toxins.yml +++ b/Resources/Prototypes/Reagents/toxins.yml @@ -32,7 +32,19 @@ amount: -4 - !type:PlantAdjustHealth amount: -8 - # TODO MIRROR acid! hurt people on contact + reactiveEffects: + Acidic: + methods: [ Touch ] + effects: + - !type:HealthChange + scaleByQuantity: true + ignoreResistances: false + damage: + groups: + Caustic: 0.5 + - !type:DoAction + probability: 0.3 + action: HumanScream metabolisms: Poison: effects: @@ -53,7 +65,19 @@ color: "#5050ff" boilingPoint: 165 meltingPoint: -87 - # TODO MIRROR acid! hurt people on contact + reactiveEffects: + Acidic: + methods: [ Touch ] + effects: + - !type:HealthChange + scaleByQuantity: true + ignoreResistances: false + damage: + groups: + Caustic: 0.3 + - !type:DoAction + probability: 0.2 + action: HumanScream metabolisms: Poison: effects: @@ -81,6 +105,19 @@ amount: -2 - !type:PlantAdjustHealth amount: -5 + reactiveEffects: + Acidic: + methods: [ Touch ] + effects: + - !type:HealthChange + scaleByQuantity: true + ignoreResistances: false + damage: + groups: + Caustic: 0.1 + - !type:DoAction + probability: 0.1 + action: HumanScream metabolisms: Poison: effects: