diff --git a/Content.Server/Damage/Systems/DamageOtherOnHitSystem.cs b/Content.Server/Damage/Systems/DamageOtherOnHitSystem.cs index 248562a44f..0dc9808dc1 100644 --- a/Content.Server/Damage/Systems/DamageOtherOnHitSystem.cs +++ b/Content.Server/Damage/Systems/DamageOtherOnHitSystem.cs @@ -1,4 +1,5 @@ using Content.Shared.Camera; +using Content.Shared.CombatMode.Pacification; using Content.Shared.Damage; using Content.Shared.Damage.Components; using Content.Shared.Damage.Events; @@ -31,13 +32,13 @@ namespace Content.Server.Damage.Systems { base.Initialize(); - SubscribeLocalEvent(OnBeforeThrow); + SubscribeLocalEvent(OnBeforeThrow, after: [typeof(PacificationSystem)]); SubscribeLocalEvent(OnDamageExamine, after: [typeof(MeleeWeaponSystem)]); } private void OnBeforeThrow(EntityUid uid, StaminaComponent component, ref BeforeThrowEvent args) { - if (!TryComp(args.ItemUid, out var damage)) + if (args.Cancelled || !TryComp(args.ItemUid, out var damage)) return; if (component.CritThreshold - component.StaminaDamage <= damage.StaminaCost) diff --git a/Content.Shared/Damage/Systems/SharedDamageOtherOnHitSystem.cs b/Content.Shared/Damage/Systems/SharedDamageOtherOnHitSystem.cs index 1ea4c3ef0c..e9e786a817 100644 --- a/Content.Shared/Damage/Systems/SharedDamageOtherOnHitSystem.cs +++ b/Content.Shared/Damage/Systems/SharedDamageOtherOnHitSystem.cs @@ -1,5 +1,6 @@ using Content.Shared.Administration.Logs; using Content.Shared.Camera; +using Content.Shared.CombatMode.Pacification; using Content.Shared.Contests; using Content.Shared.Damage; using Content.Shared.Damage.Components; @@ -39,6 +40,7 @@ namespace Content.Shared.Damage.Systems SubscribeLocalEvent(OnMapInit); SubscribeLocalEvent(OnDoHit); SubscribeLocalEvent(OnThrown); + SubscribeLocalEvent(OnAttemptPacifiedThrow); SubscribeLocalEvent(OnItemToggleMapInit); SubscribeLocalEvent(OnItemToggle); @@ -181,6 +183,16 @@ namespace Content.Shared.Damage.Systems component.HitQuantity = 0; } + /// + /// Prevent Pacified entities from throwing damaging items. + /// + private void OnAttemptPacifiedThrow(EntityUid uid, DamageOtherOnHitComponent comp, ref AttemptPacifiedThrowEvent args) + { + // Allow healing projectiles, forbid any that do damage + if (comp.Damage.AnyPositive()) + args.Cancel("pacified-cannot-throw"); + } + /// /// Gets the total damage a throwing weapon does. /// diff --git a/Content.Shared/Projectiles/EmbedPassiveDamageSystem.cs b/Content.Shared/Projectiles/EmbedPassiveDamageSystem.cs index 55733ac5bb..589abf305c 100644 --- a/Content.Shared/Projectiles/EmbedPassiveDamageSystem.cs +++ b/Content.Shared/Projectiles/EmbedPassiveDamageSystem.cs @@ -1,3 +1,4 @@ +using Content.Shared.CombatMode.Pacification; using Content.Shared.Damage; using Content.Shared.Damage.Components; using Content.Shared.Damage.Events; @@ -24,6 +25,7 @@ public sealed class EmbedPassiveDamageSystem : EntitySystem SubscribeLocalEvent(OnEmbed); SubscribeLocalEvent(OnRemoveEmbed); SubscribeLocalEvent(OnItemToggle); + SubscribeLocalEvent(OnAttemptPacifiedThrow); } /// @@ -92,6 +94,16 @@ public sealed class EmbedPassiveDamageSystem : EntitySystem component.Damage = deactivatedDamage; } + /// + /// Prevent Pacified entities from throwing items that deal passive damage when embedded. + /// + private void OnAttemptPacifiedThrow(EntityUid uid, EmbedPassiveDamageComponent comp, ref AttemptPacifiedThrowEvent args) + { + // Allow healing projectiles, forbid any that do damage + if (comp.Damage.AnyPositive()) + args.Cancel("pacified-cannot-throw"); + } + public override void Update(float frameTime) { base.Update(frameTime); diff --git a/Content.Shared/Projectiles/SharedProjectileSystem.cs b/Content.Shared/Projectiles/SharedProjectileSystem.cs index 01b8e50347..72665383c6 100644 --- a/Content.Shared/Projectiles/SharedProjectileSystem.cs +++ b/Content.Shared/Projectiles/SharedProjectileSystem.cs @@ -3,7 +3,6 @@ using System.Numerics; using Content.Shared._White.Penetrated; using Content.Shared._White.Projectile; using Content.Shared.Body.Systems; -using Content.Shared.CombatMode.Pacification; using Content.Shared.Damage; using Content.Shared.DoAfter; using Content.Shared.Examine; @@ -52,7 +51,6 @@ public abstract partial class SharedProjectileSystem : EntitySystem SubscribeLocalEvent(OnEmbedThrowDoHit); SubscribeLocalEvent(OnEmbedActivate, before: new[] {typeof(ActivatableUISystem)}); // WD EDIT SubscribeLocalEvent(OnEmbedRemove); - SubscribeLocalEvent(OnAttemptPacifiedThrow); SubscribeLocalEvent(OnExamined); SubscribeLocalEvent(OnPreventCollision); // WD EDIT } @@ -217,14 +215,6 @@ public abstract partial class SharedProjectileSystem : EntitySystem Dirty(id, component); } - /// - /// Prevent players with the Pacified status effect from throwing embeddable projectiles. - /// - private void OnAttemptPacifiedThrow(Entity ent, ref AttemptPacifiedThrowEvent args) - { - args.Cancel("pacified-cannot-throw-embed"); - } - private void OnExamined(EntityUid uid, EmbeddableProjectileComponent component, ExaminedEvent args) { if (!(component.Target is {} target))