From e82064916a891f835bc09269c721c1e22112ef8c Mon Sep 17 00:00:00 2001 From: Velken <8467292+Velken@users.noreply.github.com> Date: Fri, 4 Jul 2025 02:08:45 -0300 Subject: [PATCH] [BUGFIX] Fixed revenant malfunction ability not working properly only MediBots and Stasis bed (#38664) * fixed * clean up * orks fix smart * review fix 1 * more requested changes * less cursed * more descriptive description * better wording --- .../EntitySystems/RevenantSystem.Abilities.cs | 4 ++-- Content.Shared/Emag/Systems/EmagSystem.cs | 15 +++++++++------ .../Prototypes/Entities/Mobs/NPCs/revenant.yml | 2 ++ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Content.Server/Revenant/EntitySystems/RevenantSystem.Abilities.cs b/Content.Server/Revenant/EntitySystems/RevenantSystem.Abilities.cs index 51cbb6d4d5..0ef7b8f533 100644 --- a/Content.Server/Revenant/EntitySystems/RevenantSystem.Abilities.cs +++ b/Content.Server/Revenant/EntitySystems/RevenantSystem.Abilities.cs @@ -35,6 +35,7 @@ namespace Content.Server.Revenant.EntitySystems; public sealed partial class RevenantSystem { + [Dependency] private readonly EmagSystem _emagSystem = default!; [Dependency] private readonly ThrowingSystem _throwing = default!; [Dependency] private readonly EntityStorageSystem _entityStorage = default!; [Dependency] private readonly SharedAppearanceSystem _appearance = default!; @@ -345,8 +346,7 @@ public sealed partial class RevenantSystem _whitelistSystem.IsBlacklistPass(component.MalfunctionBlacklist, ent)) continue; - var ev = new GotEmaggedEvent(uid, EmagType.Interaction | EmagType.Access); - RaiseLocalEvent(ent, ref ev); + _emagSystem.TryEmagEffect(uid, uid, ent); } } } diff --git a/Content.Shared/Emag/Systems/EmagSystem.cs b/Content.Shared/Emag/Systems/EmagSystem.cs index 7aa4303471..912c4bdaea 100644 --- a/Content.Shared/Emag/Systems/EmagSystem.cs +++ b/Content.Shared/Emag/Systems/EmagSystem.cs @@ -51,9 +51,9 @@ public sealed class EmagSystem : EntitySystem } /// - /// Does the emag effect on a specified entity + /// Does the emag effect on a specified entity with a specified EmagType. The optional field customEmagType can be used to override the emag type defined in the component. /// - public bool TryEmagEffect(Entity ent, EntityUid user, EntityUid target) + public bool TryEmagEffect(Entity ent, EntityUid user, EntityUid target, EmagType? customEmagType = null) { if (!Resolve(ent, ref ent.Comp, false)) return false; @@ -68,7 +68,9 @@ public sealed class EmagSystem : EntitySystem return false; } - var emaggedEvent = new GotEmaggedEvent(user, ent.Comp.EmagType); + var typeToUse = customEmagType ?? ent.Comp.EmagType; + + var emaggedEvent = new GotEmaggedEvent(user, typeToUse); RaiseLocalEvent(target, ref emaggedEvent); if (!emaggedEvent.Handled) @@ -78,7 +80,7 @@ public sealed class EmagSystem : EntitySystem _audio.PlayPredicted(ent.Comp.EmagSound, ent, ent); - _adminLogger.Add(LogType.Emag, LogImpact.High, $"{ToPrettyString(user):player} emagged {ToPrettyString(target):target} with flag(s): {ent.Comp.EmagType}"); + _adminLogger.Add(LogType.Emag, LogImpact.High, $"{ToPrettyString(user):player} emagged {ToPrettyString(target):target} with flag(s): {typeToUse}"); if (emaggedEvent.Handled) _sharedCharges.TryUseCharge(chargesEnt); @@ -87,7 +89,7 @@ public sealed class EmagSystem : EntitySystem { EnsureComp(target, out var emaggedComp); - emaggedComp.EmagType |= ent.Comp.EmagType; + emaggedComp.EmagType |= typeToUse; Dirty(target, emaggedComp); } @@ -129,9 +131,10 @@ public sealed class EmagSystem : EntitySystem [Flags] [Serializable, NetSerializable] -public enum EmagType : byte +public enum EmagType { None = 0, + All = ~None, Interaction = 1 << 1, Access = 1 << 2 } diff --git a/Resources/Prototypes/Entities/Mobs/NPCs/revenant.yml b/Resources/Prototypes/Entities/Mobs/NPCs/revenant.yml index 1c70e55d66..13bce86b06 100644 --- a/Resources/Prototypes/Entities/Mobs/NPCs/revenant.yml +++ b/Resources/Prototypes/Entities/Mobs/NPCs/revenant.yml @@ -6,6 +6,8 @@ name: revenant description: A spooky ghostie. components: + - type: Emag + emagType: All - type: Input context: "ghost" - type: Spectral