mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-17 13:37:47 +03:00
Pacification Prevents Throwing Weapons (#1433)
# Description Prevents entities who are Pacified (through the Pacifist trait or being a thief) from throwing items that deal damage on hit or embed. ## Technical Details Two components will prevent throwing if they deal any damage: `DamageOtherOnHitComponent` and `EmbedPassiveComponent`. The pacifist check on `EmbeddableProjectileComponent` has been removed, because just because an item is embeddable does not mean they deal damage. ## Media **Throw attempt with the Pacifist trait**  # Changelog 🆑 Skubman - fix: Pacified characters (Pacifist trait and thieves) can no longer throw items that deal throwing damage. --------- Signed-off-by: VMSolidus <evilexecutive@gmail.com> Co-authored-by: VMSolidus <evilexecutive@gmail.com> (cherry picked from commit 71e3c031750db523f8fcccc4a36a61200b1028f2)
This commit is contained in:
@@ -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<StaminaComponent, BeforeThrowEvent>(OnBeforeThrow);
|
||||
SubscribeLocalEvent<StaminaComponent, BeforeThrowEvent>(OnBeforeThrow, after: [typeof(PacificationSystem)]);
|
||||
SubscribeLocalEvent<DamageOtherOnHitComponent, DamageExamineEvent>(OnDamageExamine, after: [typeof(MeleeWeaponSystem)]);
|
||||
}
|
||||
|
||||
private void OnBeforeThrow(EntityUid uid, StaminaComponent component, ref BeforeThrowEvent args)
|
||||
{
|
||||
if (!TryComp<DamageOtherOnHitComponent>(args.ItemUid, out var damage))
|
||||
if (args.Cancelled || !TryComp<DamageOtherOnHitComponent>(args.ItemUid, out var damage))
|
||||
return;
|
||||
|
||||
if (component.CritThreshold - component.StaminaDamage <= damage.StaminaCost)
|
||||
|
||||
@@ -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<DamageOtherOnHitComponent, MapInitEvent>(OnMapInit);
|
||||
SubscribeLocalEvent<DamageOtherOnHitComponent, ThrowDoHitEvent>(OnDoHit);
|
||||
SubscribeLocalEvent<DamageOtherOnHitComponent, ThrownEvent>(OnThrown);
|
||||
SubscribeLocalEvent<DamageOtherOnHitComponent, AttemptPacifiedThrowEvent>(OnAttemptPacifiedThrow);
|
||||
|
||||
SubscribeLocalEvent<ItemToggleDamageOtherOnHitComponent, MapInitEvent>(OnItemToggleMapInit);
|
||||
SubscribeLocalEvent<DamageOtherOnHitComponent, ItemToggledEvent>(OnItemToggle);
|
||||
@@ -181,6 +183,16 @@ namespace Content.Shared.Damage.Systems
|
||||
component.HitQuantity = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Prevent Pacified entities from throwing damaging items.
|
||||
/// </summary>
|
||||
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");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the total damage a throwing weapon does.
|
||||
/// </summary>
|
||||
|
||||
@@ -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<EmbedPassiveDamageComponent, EmbedEvent>(OnEmbed);
|
||||
SubscribeLocalEvent<EmbedPassiveDamageComponent, RemoveEmbedEvent>(OnRemoveEmbed);
|
||||
SubscribeLocalEvent<EmbedPassiveDamageComponent, ItemToggledEvent>(OnItemToggle);
|
||||
SubscribeLocalEvent<EmbedPassiveDamageComponent, AttemptPacifiedThrowEvent>(OnAttemptPacifiedThrow);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -92,6 +94,16 @@ public sealed class EmbedPassiveDamageSystem : EntitySystem
|
||||
component.Damage = deactivatedDamage;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Prevent Pacified entities from throwing items that deal passive damage when embedded.
|
||||
/// </summary>
|
||||
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);
|
||||
|
||||
@@ -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<EmbeddableProjectileComponent, ThrowDoHitEvent>(OnEmbedThrowDoHit);
|
||||
SubscribeLocalEvent<EmbeddableProjectileComponent, ActivateInWorldEvent>(OnEmbedActivate, before: new[] {typeof(ActivatableUISystem)}); // WD EDIT
|
||||
SubscribeLocalEvent<EmbeddableProjectileComponent, RemoveEmbeddedProjectileEvent>(OnEmbedRemove);
|
||||
SubscribeLocalEvent<EmbeddableProjectileComponent, AttemptPacifiedThrowEvent>(OnAttemptPacifiedThrow);
|
||||
SubscribeLocalEvent<EmbeddableProjectileComponent, ExaminedEvent>(OnExamined);
|
||||
SubscribeLocalEvent<EmbeddableProjectileComponent, PreventCollideEvent>(OnPreventCollision); // WD EDIT
|
||||
}
|
||||
@@ -217,14 +215,6 @@ public abstract partial class SharedProjectileSystem : EntitySystem
|
||||
Dirty(id, component);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Prevent players with the Pacified status effect from throwing embeddable projectiles.
|
||||
/// </summary>
|
||||
private void OnAttemptPacifiedThrow(Entity<EmbeddableProjectileComponent> ent, ref AttemptPacifiedThrowEvent args)
|
||||
{
|
||||
args.Cancel("pacified-cannot-throw-embed");
|
||||
}
|
||||
|
||||
private void OnExamined(EntityUid uid, EmbeddableProjectileComponent component, ExaminedEvent args)
|
||||
{
|
||||
if (!(component.Target is {} target))
|
||||
|
||||
Reference in New Issue
Block a user