From 2a4f36422b10c973f9eac25d9db89f7b049560db Mon Sep 17 00:00:00 2001 From: Perry Fraser Date: Tue, 5 Aug 2025 20:02:52 -0400 Subject: [PATCH] fix: properly respect AllowRepeatedMorphs (#39411) * fix: properly respect AllowRepeatedMorphs * feat: add IgnoreAllowRepeatedMorphs --- Content.Server/Polymorph/Systems/PolymorphSystem.cs | 13 ++++++++----- Content.Shared/Polymorph/PolymorphPrototype.cs | 12 +++++++++++- Resources/Prototypes/Polymorphs/admin.yml | 12 ++++++------ 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/Content.Server/Polymorph/Systems/PolymorphSystem.cs b/Content.Server/Polymorph/Systems/PolymorphSystem.cs index d411eb7722..6b6284b18e 100644 --- a/Content.Server/Polymorph/Systems/PolymorphSystem.cs +++ b/Content.Server/Polymorph/Systems/PolymorphSystem.cs @@ -170,15 +170,18 @@ public sealed partial class PolymorphSystem : EntitySystem } /// - /// Polymorphs the target entity into another + /// Polymorphs the target entity into another. /// /// The entity that will be transformed - /// Polymorph data - /// + /// The new polymorph configuration + /// The new entity, or null if the polymorph failed. public EntityUid? PolymorphEntity(EntityUid uid, PolymorphConfiguration configuration) { - // if it's already morphed, don't allow it again with this condition active. - if (!configuration.AllowRepeatedMorphs && HasComp(uid)) + // If they're morphed, check their current config to see if they can be + // morphed again + if (!configuration.IgnoreAllowRepeatedMorphs + && TryComp(uid, out var currentPoly) + && !currentPoly.Configuration.AllowRepeatedMorphs) return null; // If this polymorph has a cooldown, check if that amount of time has passed since the diff --git a/Content.Shared/Polymorph/PolymorphPrototype.cs b/Content.Shared/Polymorph/PolymorphPrototype.cs index d731c4bfc5..0978d7119a 100644 --- a/Content.Shared/Polymorph/PolymorphPrototype.cs +++ b/Content.Shared/Polymorph/PolymorphPrototype.cs @@ -112,11 +112,21 @@ public sealed partial record PolymorphConfiguration public bool RevertOnEat; /// - /// Whether or not an already polymorphed entity is able to be polymorphed again + /// If true, attempts to polymorph this polymorph will fail, unless + /// is true on the /new/ morph. /// [DataField(serverOnly: true)] public bool AllowRepeatedMorphs; + /// + /// If true, this morph will succeed even when used on an entity + /// that is already polymorphed with a configuration that has + /// set to false. Helpful for + /// smite polymorphs which should always succeed. + /// + [DataField(serverOnly: true)] + public bool IgnoreAllowRepeatedMorphs; + /// /// The amount of time that should pass after this polymorph has ended, before a new one /// can occur. diff --git a/Resources/Prototypes/Polymorphs/admin.yml b/Resources/Prototypes/Polymorphs/admin.yml index cb274ec7d4..3739175c8a 100644 --- a/Resources/Prototypes/Polymorphs/admin.yml +++ b/Resources/Prototypes/Polymorphs/admin.yml @@ -6,7 +6,7 @@ transferName: true transferHumanoidAppearance: true inventory: Transfer - allowRepeatedMorphs: true + ignoreAllowRepeatedMorphs: true - type: polymorph id: AdminMonkeySmite @@ -14,7 +14,7 @@ entity: MobMonkey forced: true inventory: Drop - allowRepeatedMorphs: true + ignoreAllowRepeatedMorphs: true - type: polymorph id: AdminBreadSmite @@ -22,7 +22,7 @@ entity: FoodBreadPlain forced: true inventory: Drop - allowRepeatedMorphs: true + ignoreAllowRepeatedMorphs: true - type: polymorph id: AdminInstrumentSmite @@ -30,7 +30,7 @@ entity: SuperSynthesizerInstrument forced: true inventory: Drop - allowRepeatedMorphs: true + ignoreAllowRepeatedMorphs: true - type: polymorph id: AdminMouseSmite @@ -38,7 +38,7 @@ entity: MobMouse forced: true inventory: Drop - allowRepeatedMorphs: true + ignoreAllowRepeatedMorphs: true - type: polymorph id: AdminDisposalsSmite @@ -46,4 +46,4 @@ entity: DisposalUnit forced: true inventory: Drop - allowRepeatedMorphs: true + ignoreAllowRepeatedMorphs: true