From f9922d91609ed3de65c2bcc27e984b62d79e8c7c Mon Sep 17 00:00:00 2001 From: Flipp Syder <76629141+vulppine@users.noreply.github.com> Date: Tue, 13 Sep 2022 20:46:49 -0700 Subject: [PATCH] Restrict ghost role speech/movement to component flags (#11183) --- .../Roles/Components/GhostRoleComponent.cs | 8 +++++++ .../GhostRoleMobSpawnerComponent.cs | 2 +- .../GhostTakeoverAvailableComponent.cs | 2 +- .../Mind/Commands/MakeSentientCommand.cs | 22 +++++++++++++------ .../StationEvents/Events/RandomSentience.cs | 1 - .../Prototypes/Entities/Mobs/NPCs/animals.yml | 2 ++ .../Prototypes/Entities/Mobs/NPCs/carp.yml | 4 ++++ .../Prototypes/Entities/Mobs/NPCs/xeno.yml | 2 ++ .../Entities/Mobs/Player/dragon.yml | 2 ++ .../Entities/Mobs/Player/familiars.yml | 4 ++++ .../Entities/Mobs/Player/guardian.yml | 6 +++++ 11 files changed, 45 insertions(+), 10 deletions(-) diff --git a/Content.Server/Ghost/Roles/Components/GhostRoleComponent.cs b/Content.Server/Ghost/Roles/Components/GhostRoleComponent.cs index 0ae16f1c69..558366e786 100644 --- a/Content.Server/Ghost/Roles/Components/GhostRoleComponent.cs +++ b/Content.Server/Ghost/Roles/Components/GhostRoleComponent.cs @@ -63,6 +63,14 @@ namespace Content.Server.Ghost.Roles.Components } } + [DataField("allowSpeech")] + [ViewVariables(VVAccess.ReadWrite)] + public bool AllowSpeech { get; set; } = true; + + [DataField("allowMovement")] + [ViewVariables(VVAccess.ReadWrite)] + public bool AllowMovement { get; set; } + [ViewVariables(VVAccess.ReadOnly)] public bool Taken { get; set; } diff --git a/Content.Server/Ghost/Roles/Components/GhostRoleMobSpawnerComponent.cs b/Content.Server/Ghost/Roles/Components/GhostRoleMobSpawnerComponent.cs index 43c317fd34..720bd5387e 100644 --- a/Content.Server/Ghost/Roles/Components/GhostRoleMobSpawnerComponent.cs +++ b/Content.Server/Ghost/Roles/Components/GhostRoleMobSpawnerComponent.cs @@ -46,7 +46,7 @@ namespace Content.Server.Ghost.Roles.Components _entMan.EventBus.RaiseLocalEvent(mob, spawnedEvent, false); if (MakeSentient) - MakeSentientCommand.MakeSentient(mob, _entMan); + MakeSentientCommand.MakeSentient(mob, _entMan, AllowMovement, AllowSpeech); mob.EnsureComponent(); diff --git a/Content.Server/Ghost/Roles/Components/GhostTakeoverAvailableComponent.cs b/Content.Server/Ghost/Roles/Components/GhostTakeoverAvailableComponent.cs index fc1c1b4b00..0a9a9435f9 100644 --- a/Content.Server/Ghost/Roles/Components/GhostTakeoverAvailableComponent.cs +++ b/Content.Server/Ghost/Roles/Components/GhostTakeoverAvailableComponent.cs @@ -23,7 +23,7 @@ namespace Content.Server.Ghost.Roles.Components return false; if (MakeSentient) - MakeSentientCommand.MakeSentient(Owner, IoCManager.Resolve()); + MakeSentientCommand.MakeSentient(Owner, IoCManager.Resolve(), AllowMovement, AllowSpeech); var ghostRoleSystem = EntitySystem.Get(); ghostRoleSystem.GhostRoleInternalCreateMindAndTransfer(session, Owner, Owner, this); diff --git a/Content.Server/Mind/Commands/MakeSentientCommand.cs b/Content.Server/Mind/Commands/MakeSentientCommand.cs index 8da2df3645..9b8cef2e34 100644 --- a/Content.Server/Mind/Commands/MakeSentientCommand.cs +++ b/Content.Server/Mind/Commands/MakeSentientCommand.cs @@ -39,19 +39,27 @@ namespace Content.Server.Mind.Commands return; } - MakeSentient(entId, entityManager); + MakeSentient(entId, entityManager, true, true); } - public static void MakeSentient(EntityUid uid, IEntityManager entityManager) + public static void MakeSentient(EntityUid uid, IEntityManager entityManager, bool allowMovement = true, bool allowSpeech = true) { entityManager.RemoveComponent(uid); entityManager.EnsureComponent(uid); - entityManager.EnsureComponent(uid); - entityManager.EnsureComponent(uid); - entityManager.EnsureComponent(uid); - entityManager.EnsureComponent(uid); - entityManager.EnsureComponent(uid); + if (allowMovement) + { + entityManager.EnsureComponent(uid); + entityManager.EnsureComponent(uid); + entityManager.EnsureComponent(uid); + } + + if (allowSpeech) + { + entityManager.EnsureComponent(uid); + entityManager.EnsureComponent(uid); + } + entityManager.EnsureComponent(uid); } } diff --git a/Content.Server/StationEvents/Events/RandomSentience.cs b/Content.Server/StationEvents/Events/RandomSentience.cs index 3e955bc5f7..e2c30a5933 100644 --- a/Content.Server/StationEvents/Events/RandomSentience.cs +++ b/Content.Server/StationEvents/Events/RandomSentience.cs @@ -29,7 +29,6 @@ public sealed class RandomSentience : StationEventSystem if (toMakeSentient-- == 0) break; - MakeSentientCommand.MakeSentient(target.Owner, EntityManager); EntityManager.RemoveComponent(target.Owner); var comp = EntityManager.AddComponent(target.Owner); comp.RoleName = EntityManager.GetComponent(target.Owner).EntityName; diff --git a/Resources/Prototypes/Entities/Mobs/NPCs/animals.yml b/Resources/Prototypes/Entities/Mobs/NPCs/animals.yml index c74cb6bee1..4117ad9895 100644 --- a/Resources/Prototypes/Entities/Mobs/NPCs/animals.yml +++ b/Resources/Prototypes/Entities/Mobs/NPCs/animals.yml @@ -738,6 +738,8 @@ components: - type: GhostTakeoverAvailable makeSentient: true + allowSpeech: true + allowMovement: true name: ghost-role-information-mouse-name description: ghost-role-information-mouse-description - type: Speech diff --git a/Resources/Prototypes/Entities/Mobs/NPCs/carp.yml b/Resources/Prototypes/Entities/Mobs/NPCs/carp.yml index cc8fe851e4..74dd5bf9d1 100644 --- a/Resources/Prototypes/Entities/Mobs/NPCs/carp.yml +++ b/Resources/Prototypes/Entities/Mobs/NPCs/carp.yml @@ -138,6 +138,8 @@ - type: GhostTakeoverAvailable prob: 0.33 name: space carp on salvage wreck + allowMovement: true + allowSpeech: true description: | Defend the loot inside the salvage wreck! - type: SalvageMobRestrictions @@ -149,6 +151,8 @@ parent: BaseMobCarp components: - type: GhostTakeoverAvailable + allowMovement: true + allowSpeech: true makeSentient: true name: Sentient Carp description: Help the dragon flood the station with carps! diff --git a/Resources/Prototypes/Entities/Mobs/NPCs/xeno.yml b/Resources/Prototypes/Entities/Mobs/NPCs/xeno.yml index d3208bc570..4285b557c1 100644 --- a/Resources/Prototypes/Entities/Mobs/NPCs/xeno.yml +++ b/Resources/Prototypes/Entities/Mobs/NPCs/xeno.yml @@ -86,6 +86,8 @@ - id: FoodMeatXeno amount: 5 - type: GhostTakeoverAvailable + allowMovement: true + allowSpeech: true makeSentient: true name: xeno description: You are a xeno, co-operate with your hive to kill all crewmembers! diff --git a/Resources/Prototypes/Entities/Mobs/Player/dragon.yml b/Resources/Prototypes/Entities/Mobs/Player/dragon.yml index 734298c4b5..0508f4f6c0 100644 --- a/Resources/Prototypes/Entities/Mobs/Player/dragon.yml +++ b/Resources/Prototypes/Entities/Mobs/Player/dragon.yml @@ -6,6 +6,8 @@ description: A flying leviathan, loosely related to space carps. components: - type: GhostTakeoverAvailable + allowMovement: true + allowSpeech: true makeSentient: true name: Space dragon description: Call in 3 carp rifts and take over this quadrant! You have only 5 minutes in between each rift before you will disappear. diff --git a/Resources/Prototypes/Entities/Mobs/Player/familiars.yml b/Resources/Prototypes/Entities/Mobs/Player/familiars.yml index f57b1ef57f..2ec1a0e36e 100644 --- a/Resources/Prototypes/Entities/Mobs/Player/familiars.yml +++ b/Resources/Prototypes/Entities/Mobs/Player/familiars.yml @@ -6,6 +6,8 @@ components: - type: GhostTakeoverAvailable makeSentient: true + allowMovement: true + allowSpeech: true name: Remilia, the chaplain's familiar description: Obey your master. Eat fruit. rules: You are an intelligent fruit bat. Follow the chaplain around. Don't cause any trouble unless the chaplain tells you to. @@ -32,6 +34,8 @@ components: - type: GhostTakeoverAvailable makeSentient: true + allowMovement: true + allowSpeech: true name: Cerberus, Evil Familiar description: Obey your master. Spread chaos. rules: You are an intelligent, demonic dog. Try to help the chaplain and any of his flock. As an antagonist, you're otherwise unrestrained. diff --git a/Resources/Prototypes/Entities/Mobs/Player/guardian.yml b/Resources/Prototypes/Entities/Mobs/Player/guardian.yml index 5ef64f67cb..8ecf4363e5 100644 --- a/Resources/Prototypes/Entities/Mobs/Player/guardian.yml +++ b/Resources/Prototypes/Entities/Mobs/Player/guardian.yml @@ -7,6 +7,8 @@ save: false components: - type: GhostTakeoverAvailable + allowMovement: true + allowSpeech: true makeSentient: true name: Guardian description: Listen to your owner. Don't tank damage. Punch people hard. @@ -103,6 +105,8 @@ description: A mesmerising whirl of hard-light patterns weaves a marvelous, yet oddly familiar visage. It stands proud, tuning into its owner's life to sustain itself. components: - type: GhostTakeoverAvailable + allowMovement: true + allowSpeech: true makeSentient: true name: Holoparasite description: Listen to your owner. Don't tank damage. Punch people hard. @@ -127,6 +131,8 @@ description: A corrupted jinn, ripped from fitra to serve the wizard's petty needs. It stands wicked, tuning into it's owner's life to sustain itself. components: - type: GhostTakeoverAvailable + allowMovement: true + allowSpeech: true makeSentient: true name: Ifrit description: Listen to your owner. Don't tank damage. Punch people hard.