Apply Entity Effects On Melee (#44882)

* stub

* Revert "stub"

This reverts commit c1204b88d3ae1bbdca2deeb075a9dd0d6c529326.

* turtoise

* e

* e

* r

* Update SharedMeleeWeaponSystem.cs

* Update Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs

Co-authored-by: Connor Huffine <chuffine@gmail.com>

---------

Co-authored-by: nomdéraisonnablementlong <you@example.com>
Co-authored-by: Connor Huffine <chuffine@gmail.com>
This commit is contained in:
KeTuFaisPiKiNut 2026-07-29 00:31:15 -04:00 • committed by GitHub
parent 97176cc41a
commit 457378ff83
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 55 additions and 1 deletions

View file

@ -0,0 +1,17 @@
using Content.Shared.EntityEffects;
using Robust.Shared.GameStates;
namespace Content.Shared.Weapons.Melee;
/// <summary>
/// Applies an entity effect on hit entities
/// </summary>
[RegisterComponent, NetworkedComponent, Access(typeof(SharedMeleeWeaponSystem))]
public sealed partial class EntityEffectMeleeComponent : Component
{
/// <summary>
/// List of entity effects to apply to hit entities.
/// </summary>
[DataField(required: true)]
public EntityEffect[] Effects;
}

View file

@ -1,3 +1,4 @@
using System.Collections.Immutable;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Numerics;
@ -11,6 +12,7 @@ using Content.Shared.Damage.Components;
using Content.Shared.Damage.Events;
using Content.Shared.Damage.Systems;
using Content.Shared.Database;
using Content.Shared.EntityEffects;
using Content.Shared.FixedPoint;
using Content.Shared.Hands;
using Content.Shared.Hands.Components;
@ -65,6 +67,7 @@ public abstract partial class SharedMeleeWeaponSystem : EntitySystem
[Dependency] protected SharedTransformSystem TransformSystem = default!;
[Dependency] private SharedStaminaSystem _stamina = default!;
[Dependency] private DamageExamineSystem _damageExamine = default!;
[Dependency] private SharedEntityEffectsSystem _effects = default!;
[Dependency] private EntityQuery<DamageableComponent> _damageQuery = default!;
@ -91,7 +94,6 @@ public abstract partial class SharedMeleeWeaponSystem : EntitySystem
SubscribeLocalEvent<BonusMeleeDamageComponent, GetMeleeDamageEvent>(OnGetBonusMeleeDamage);
SubscribeLocalEvent<BonusMeleeDamageComponent, GetHeavyDamageModifierEvent>(OnGetBonusHeavyDamageModifier);
SubscribeLocalEvent<BonusMeleeAttackRateComponent, GetMeleeAttackRateEvent>(OnGetBonusMeleeAttackRate);
SubscribeLocalEvent<ItemToggleMeleeWeaponComponent, ItemToggledEvent>(OnItemToggle);
SubscribeAllEvent<HeavyAttackEvent>(OnHeavyAttack);
@ -110,6 +112,15 @@ public abstract partial class SharedMeleeWeaponSystem : EntitySystem
#endif
}
[SubscribeLocalEvent]
private void EntityEffectMeleeHit(Entity<EntityEffectMeleeComponent> ent, ref MeleeHitEvent args)
{
foreach (var entity in args.HitEntities)
{
_effects.ApplyEffects(entity, ent.Comp.Effects, 1f, args.User);
}
}
private void OnMeleeShotAttempted(EntityUid uid, MeleeWeaponComponent comp, ref ShotAttemptedEvent args)
{
if (comp.NextAttack > Timing.CurTime)

View file

@ -145,3 +145,29 @@
damage:
types:
Blunt: 200
- type: entity
name: unbang stick
parent: BaseItem
id: MeleeDebugUnbang
description: hit soft ye
suffix: DEBUG
components:
- type: Sprite
sprite: Objects/Weapons/Melee/debug.rsi
state: icon
- type: MeleeWeapon
damage:
types:
Blunt: 0
- type: Item
size: Tiny
sprite: Objects/Weapons/Melee/debug.rsi
- type: EntityEffectMelee
effects:
- !type:EvenHealthChange
damage:
Burn: -200
Toxin: -200
Airloss: -200
Brute: -200