DamageOnHit only damages on successful hits. (#17758)

This commit is contained in:
LankLTE
2023-07-01 12:01:50 -07:00
committed by GitHub
parent e73e5ccf84
commit 82b33bc12a

View File

@@ -2,6 +2,7 @@ using Content.Server.Damage.Components;
using Content.Shared.Damage; using Content.Shared.Damage;
using Robust.Shared.Player; using Robust.Shared.Player;
using Content.Shared.Weapons.Melee.Events; using Content.Shared.Weapons.Melee.Events;
using System.Linq;
namespace Content.Server.Damage.Systems; namespace Content.Server.Damage.Systems;
@@ -17,6 +18,8 @@ public sealed class DamageOnHitSystem : EntitySystem
// Looks for a hit, then damages the held item an appropriate amount. // Looks for a hit, then damages the held item an appropriate amount.
private void DamageItem(EntityUid uid, DamageOnHitComponent component, MeleeHitEvent args) private void DamageItem(EntityUid uid, DamageOnHitComponent component, MeleeHitEvent args)
{ {
_damageableSystem.TryChangeDamage(uid, component.Damage, component.IgnoreResistances); if (args.HitEntities.Any()) {
_damageableSystem.TryChangeDamage(uid, component.Damage, component.IgnoreResistances);
}
} }
} }