From 237a90cd48ff97d2a8eeafe619d364fae6e5fcc0 Mon Sep 17 00:00:00 2001 From: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> Date: Sun, 12 Dec 2021 12:12:48 +1300 Subject: [PATCH] Make welders only deal burn damage when lit. (#5695) --- .../Tools/Components/WelderComponent.cs | 11 +++++++ Content.Server/Tools/ToolSystem.Welder.cs | 11 ++++++- .../Weapon/Melee/MeleeWeaponSystem.cs | 30 +++++++++++-------- .../Entities/Objects/Tools/cowtools.yml | 5 ++++ .../Entities/Objects/Tools/welders.yml | 5 +++- 5 files changed, 47 insertions(+), 15 deletions(-) diff --git a/Content.Server/Tools/Components/WelderComponent.cs b/Content.Server/Tools/Components/WelderComponent.cs index 9ffb0b5250..048ee3816d 100644 --- a/Content.Server/Tools/Components/WelderComponent.cs +++ b/Content.Server/Tools/Components/WelderComponent.cs @@ -1,4 +1,5 @@ using Content.Shared.Chemistry.Reagent; +using Content.Shared.Damage; using Content.Shared.FixedPoint; using Content.Shared.Sound; using Content.Shared.Tools.Components; @@ -49,5 +50,15 @@ namespace Content.Server.Tools.Components [DataField("welderRefill")] public SoundSpecifier WelderRefill { get; } = new SoundPathSpecifier("/Audio/Effects/refill.ogg"); + + /// + /// When the welder is lit, this damage is added to the base melee weapon damage. + /// + /// + /// If this is a standard welder, this damage bonus should probably subtract the entity's standard melee weapon damage + /// and replace it all with heat damage. + /// + [DataField("litMeleeDamageBonus")] + public DamageSpecifier LitMeleeDamageBonus = new(); } } diff --git a/Content.Server/Tools/ToolSystem.Welder.cs b/Content.Server/Tools/ToolSystem.Welder.cs index b937389bbf..3e0a3f1365 100644 --- a/Content.Server/Tools/ToolSystem.Welder.cs +++ b/Content.Server/Tools/ToolSystem.Welder.cs @@ -1,10 +1,12 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; using Content.Server.Chemistry.Components; using Content.Server.Chemistry.Components.SolutionManager; using Content.Server.Chemistry.EntitySystems; using Content.Server.Items; using Content.Server.Tools.Components; +using Content.Server.Weapon.Melee; using Content.Shared.Audio; using Content.Shared.Examine; using Content.Shared.FixedPoint; @@ -41,6 +43,13 @@ namespace Content.Server.Tools SubscribeLocalEvent(OnWelderToolUseFinishAttempt); SubscribeLocalEvent(OnWelderShutdown); SubscribeLocalEvent(OnWelderGetState); + SubscribeLocalEvent(OnMeleeHit); + } + + private void OnMeleeHit(EntityUid uid, WelderComponent component, MeleeHitEvent args) + { + if (!args.Handled && component.Lit) + args.BonusDamage += component.LitMeleeDamageBonus; } public (FixedPoint2 fuel, FixedPoint2 capacity) GetWelderFuelAndCapacity(EntityUid uid, WelderComponent? welder = null, SolutionContainerManagerComponent? solutionContainer = null) diff --git a/Content.Server/Weapon/Melee/MeleeWeaponSystem.cs b/Content.Server/Weapon/Melee/MeleeWeaponSystem.cs index c4e8c8d996..4581cdee6d 100644 --- a/Content.Server/Weapon/Melee/MeleeWeaponSystem.cs +++ b/Content.Server/Weapon/Melee/MeleeWeaponSystem.cs @@ -94,17 +94,17 @@ namespace Content.Server.Weapon.Melee RaiseLocalEvent(target, new AttackedEvent(args.Used, args.User, args.ClickLocation)); - var damage = _damageableSystem.TryChangeDamage(target, - DamageSpecifier.ApplyModifierSets(comp.Damage, hitEvent.ModifiersList)); + var modifiedDamage = DamageSpecifier.ApplyModifierSets(comp.Damage + hitEvent.BonusDamage, hitEvent.ModifiersList); + var damageResult = _damageableSystem.TryChangeDamage(target, modifiedDamage); - if (damage != null) + if (damageResult != null) { if (args.Used == args.User) _logSystem.Add(LogType.MeleeHit, - $"{args.User} melee attacked {args.TargetEntity} using their hands and dealt {damage.Total} damage"); + $"{args.User} melee attacked {args.TargetEntity} using their hands and dealt {damageResult.Total} damage"); else _logSystem.Add(LogType.MeleeHit, - $"{args.User} melee attacked {args.TargetEntity} using {args.Used} and dealt {damage.Total} damage"); + $"{args.User} melee attacked {args.TargetEntity} using {args.Used} and dealt {damageResult.Total} damage"); } SoundSystem.Play(Filter.Pvs(owner), comp.HitSound.GetSound(), target); @@ -167,21 +167,22 @@ namespace Content.Server.Weapon.Melee SoundSystem.Play(Filter.Pvs(owner), comp.MissSound.GetSound(), EntityManager.GetComponent(args.User).Coordinates); } + var modifiedDamage = DamageSpecifier.ApplyModifierSets(comp.Damage + hitEvent.BonusDamage, hitEvent.ModifiersList); + foreach (var entity in hitEntities) { RaiseLocalEvent(entity, new AttackedEvent(args.Used, args.User, args.ClickLocation)); - var damage = _damageableSystem.TryChangeDamage(entity, - DamageSpecifier.ApplyModifierSets(comp.Damage, hitEvent.ModifiersList)); + var damageResult = _damageableSystem.TryChangeDamage(entity, modifiedDamage); - if (damage != null) + if (damageResult != null) { if (args.Used == args.User) _logSystem.Add(LogType.MeleeHit, - $"{args.User} melee attacked {entity} using their hands and dealt {damage.Total} damage"); + $"{args.User} melee attacked {entity} using their hands and dealt {damageResult.Total} damage"); else _logSystem.Add(LogType.MeleeHit, - $"{args.User} melee attacked {entity} using {args.Used} and dealt {damage.Total} damage"); + $"{args.User} melee attacked {entity} using {args.Used} and dealt {damageResult.Total} damage"); } } } @@ -307,9 +308,12 @@ namespace Content.Server.Weapon.Melee public List ModifiersList = new(); /// - /// A flat amount of damage to add. Same reason as above with Multiplier. + /// Damage to add to the default melee weapon damage. Applied before modifiers. /// - public int FlatDamage = 0; + /// + /// This might be required as damage modifier sets cannot add a new damage type to a DamageSpecifier. + /// + public DamageSpecifier BonusDamage = new(); /// /// A list containing every hit entity. Can be zero. @@ -317,7 +321,7 @@ namespace Content.Server.Weapon.Melee public IEnumerable HitEntities { get; } /// - /// The user who attacked with the melee wepaon. + /// The user who attacked with the melee weapon. /// public EntityUid User { get; } diff --git a/Resources/Prototypes/Entities/Objects/Tools/cowtools.yml b/Resources/Prototypes/Entities/Objects/Tools/cowtools.yml index 7ccc7f2da0..0f6dbe7e5e 100644 --- a/Resources/Prototypes/Entities/Objects/Tools/cowtools.yml +++ b/Resources/Prototypes/Entities/Objects/Tools/cowtools.yml @@ -128,6 +128,11 @@ HeldPrefix: off - type: Tool speed: 0.05 + - type: Welder + litMeleeDamageBonus: + types: # When lit, negate standard melee damage and replace with heat + Heat: 0.5 + Blunt: -10 - type: entity name: milkalyzer diff --git a/Resources/Prototypes/Entities/Objects/Tools/welders.yml b/Resources/Prototypes/Entities/Objects/Tools/welders.yml index 716d781635..089090b418 100644 --- a/Resources/Prototypes/Entities/Objects/Tools/welders.yml +++ b/Resources/Prototypes/Entities/Objects/Tools/welders.yml @@ -23,7 +23,6 @@ damage: types: Blunt: 10 - Heat: 10 # Hotfix to make kudzu die. - type: ItemStatus - type: RefillableSolution solution: Welder @@ -39,6 +38,10 @@ collection: Welder qualities: Welding - type: Welder + litMeleeDamageBonus: + types: # When lit, negate standard melee damage and replace with heat + Heat: 10 + Blunt: -10 - type: PointLight enabled: false radius: 1.5