From 4996db833f21d1994aa1e6126646d62a4781ec43 Mon Sep 17 00:00:00 2001
From: JJ <47927305+PHCodes@users.noreply.github.com>
Date: Sat, 28 Oct 2023 15:06:51 -0400
Subject: [PATCH] Adds Psionic-related Antag Objectives. (#345)
* Adds Psionic-related Antag Objectives.
Look at them.
* Adds NotJobsRequirement, which should probably replace NotJob
---
.../Components/NotJobsRequirementComponent.cs | 16 +++++
.../Systems/NotJobsRequirementSystem.cs | 31 ++++++++++
.../BecomeGolemConditionComponent.cs | 11 ++++
.../BecomePsionicConditionComponent.cs | 11 ++++
.../RaiseGlimmerConditionComponent.cs | 13 ++++
.../Systems/BecomeGolemConditionSystem.cs | 34 +++++++++++
.../Systems/BecomePsionicConditionSystem.cs | 32 ++++++++++
.../Systems/RaiseGlimmerConditionSystem.cs | 40 +++++++++++++
.../objectives/conditions/conditions.ftl | 6 ++
.../Nyanotrasen/Objectives/traitor.yml | 60 +++++++++++++++++++
.../Prototypes/Objectives/objectiveGroups.yml | 4 ++
11 files changed, 258 insertions(+)
create mode 100644 Content.Server/DeltaV/Objectives/Components/NotJobsRequirementComponent.cs
create mode 100644 Content.Server/DeltaV/Objectives/Systems/NotJobsRequirementSystem.cs
create mode 100644 Content.Server/Nyanotrasen/Objectives/Components/BecomeGolemConditionComponent.cs
create mode 100644 Content.Server/Nyanotrasen/Objectives/Components/BecomePsionicConditionComponent.cs
create mode 100644 Content.Server/Nyanotrasen/Objectives/Components/RaiseGlimmerConditionComponent.cs
create mode 100644 Content.Server/Nyanotrasen/Objectives/Systems/BecomeGolemConditionSystem.cs
create mode 100644 Content.Server/Nyanotrasen/Objectives/Systems/BecomePsionicConditionSystem.cs
create mode 100644 Content.Server/Nyanotrasen/Objectives/Systems/RaiseGlimmerConditionSystem.cs
create mode 100644 Resources/Locale/en-US/nyanotrasen/objectives/conditions/conditions.ftl
diff --git a/Content.Server/DeltaV/Objectives/Components/NotJobsRequirementComponent.cs b/Content.Server/DeltaV/Objectives/Components/NotJobsRequirementComponent.cs
new file mode 100644
index 00000000000..9a0a3f17663
--- /dev/null
+++ b/Content.Server/DeltaV/Objectives/Components/NotJobsRequirementComponent.cs
@@ -0,0 +1,16 @@
+using Content.Server.Objectives.Systems;
+using Content.Shared.Roles;
+using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
+
+///
+/// Requires that the player not have a certain job to have this objective.
+///
+[RegisterComponent, Access(typeof(NotJobsRequirementSystem))]
+public sealed partial class NotJobsRequirementComponent : Component
+{
+ ///
+ /// ID of the job to ban from having this objective.
+ ///
+ [DataField(required: true, customTypeSerializer: typeof(PrototypeIdListSerializer))]
+ public List Jobs = new();
+}
diff --git a/Content.Server/DeltaV/Objectives/Systems/NotJobsRequirementSystem.cs b/Content.Server/DeltaV/Objectives/Systems/NotJobsRequirementSystem.cs
new file mode 100644
index 00000000000..e0112ddc794
--- /dev/null
+++ b/Content.Server/DeltaV/Objectives/Systems/NotJobsRequirementSystem.cs
@@ -0,0 +1,31 @@
+using Content.Server.Objectives.Components;
+using Content.Shared.Objectives.Components;
+using Content.Shared.Roles.Jobs;
+
+namespace Content.Server.Objectives.Systems;
+
+///
+/// Handles checking the job blacklist for this objective.
+///
+public sealed class NotJobsRequirementSystem : EntitySystem
+{
+ public override void Initialize()
+ {
+ base.Initialize();
+
+ SubscribeLocalEvent(OnCheck);
+ }
+
+ private void OnCheck(EntityUid uid, NotJobsRequirementComponent comp, ref RequirementCheckEvent args)
+ {
+ if (args.Cancelled)
+ return;
+
+ // if player has no job then don't care
+ if (!TryComp(args.MindId, out var job))
+ return;
+ foreach (string forbidJob in comp.Jobs)
+ if (job.PrototypeId == forbidJob)
+ args.Cancelled = true;
+ }
+}
diff --git a/Content.Server/Nyanotrasen/Objectives/Components/BecomeGolemConditionComponent.cs b/Content.Server/Nyanotrasen/Objectives/Components/BecomeGolemConditionComponent.cs
new file mode 100644
index 00000000000..2dbbd12ab49
--- /dev/null
+++ b/Content.Server/Nyanotrasen/Objectives/Components/BecomeGolemConditionComponent.cs
@@ -0,0 +1,11 @@
+using Content.Server.Objectives.Systems;
+
+namespace Content.Server.Objectives.Components;
+
+///
+/// Requires that the player dies to be complete.
+///
+[RegisterComponent, Access(typeof(BecomeGolemConditionSystem))]
+public sealed partial class BecomeGolemConditionComponent : Component
+{
+}
\ No newline at end of file
diff --git a/Content.Server/Nyanotrasen/Objectives/Components/BecomePsionicConditionComponent.cs b/Content.Server/Nyanotrasen/Objectives/Components/BecomePsionicConditionComponent.cs
new file mode 100644
index 00000000000..3b677bab2d4
--- /dev/null
+++ b/Content.Server/Nyanotrasen/Objectives/Components/BecomePsionicConditionComponent.cs
@@ -0,0 +1,11 @@
+using Content.Server.Objectives.Systems;
+
+namespace Content.Server.Objectives.Components;
+
+///
+/// Requires that the player dies to be complete.
+///
+[RegisterComponent, Access(typeof(BecomePsionicConditionSystem))]
+public sealed partial class BecomePsionicConditionComponent : Component
+{
+}
\ No newline at end of file
diff --git a/Content.Server/Nyanotrasen/Objectives/Components/RaiseGlimmerConditionComponent.cs b/Content.Server/Nyanotrasen/Objectives/Components/RaiseGlimmerConditionComponent.cs
new file mode 100644
index 00000000000..387067a626e
--- /dev/null
+++ b/Content.Server/Nyanotrasen/Objectives/Components/RaiseGlimmerConditionComponent.cs
@@ -0,0 +1,13 @@
+using Content.Server.Objectives.Systems;
+
+namespace Content.Server.Objectives.Components;
+
+///
+/// Requires that the player dies to be complete.
+///
+[RegisterComponent, Access(typeof(RaiseGlimmerConditionSystem))]
+public sealed partial class RaiseGlimmerConditionComponent : Component
+{
+ [DataField("target"), ViewVariables(VVAccess.ReadWrite)]
+ public int Target;
+}
\ No newline at end of file
diff --git a/Content.Server/Nyanotrasen/Objectives/Systems/BecomeGolemConditionSystem.cs b/Content.Server/Nyanotrasen/Objectives/Systems/BecomeGolemConditionSystem.cs
new file mode 100644
index 00000000000..0260d6f28f6
--- /dev/null
+++ b/Content.Server/Nyanotrasen/Objectives/Systems/BecomeGolemConditionSystem.cs
@@ -0,0 +1,34 @@
+using Content.Server.Objectives.Components;
+using Content.Shared.Mind;
+using Content.Shared.Objectives.Components;
+
+namespace Content.Server.Objectives.Systems
+{
+ public sealed class BecomeGolemConditionSystem : EntitySystem
+ {
+ private EntityQuery _metaQuery;
+
+ public override void Initialize()
+ {
+ base.Initialize();
+
+ SubscribeLocalEvent(OnGetProgress);
+ }
+
+ private void OnGetProgress(EntityUid uid, BecomeGolemConditionComponent comp, ref ObjectiveGetProgressEvent args)
+ {
+ args.Progress = GetProgress(args.Mind);
+ }
+
+ private float GetProgress(MindComponent mind)
+ {
+ var entMan = IoCManager.Resolve();
+ if (!_metaQuery.TryGetComponent(mind.OwnedEntity, out var meta))
+ return 0;
+ /*EntityManager.TryGetComponent(mind.CurrentEntity, out var GolemComp);
+ if(GolemComp)
+ return 1; TODO: Add this code back once Golems are implemented. */
+ return 0;
+ }
+ }
+}
diff --git a/Content.Server/Nyanotrasen/Objectives/Systems/BecomePsionicConditionSystem.cs b/Content.Server/Nyanotrasen/Objectives/Systems/BecomePsionicConditionSystem.cs
new file mode 100644
index 00000000000..d090c320a41
--- /dev/null
+++ b/Content.Server/Nyanotrasen/Objectives/Systems/BecomePsionicConditionSystem.cs
@@ -0,0 +1,32 @@
+using Content.Shared.Abilities.Psionics;
+using Content.Server.Objectives.Components;
+using Content.Shared.Mind;
+using Content.Shared.Objectives.Components;
+
+namespace Content.Server.Objectives.Systems
+{
+ public sealed class BecomePsionicConditionSystem : EntitySystem
+ {
+ private EntityQuery _metaQuery;
+
+ public override void Initialize()
+ {
+ base.Initialize();
+
+ SubscribeLocalEvent(OnGetProgress);
+ }
+
+ private void OnGetProgress(EntityUid uid, BecomePsionicConditionComponent comp, ref ObjectiveGetProgressEvent args)
+ {
+ args.Progress = GetProgress(args.Mind);
+ }
+
+ private float GetProgress(MindComponent mind)
+ {
+ var entMan = IoCManager.Resolve();
+ if (HasComp(mind.CurrentEntity))
+ return 1;
+ return 0;
+ }
+ }
+}
diff --git a/Content.Server/Nyanotrasen/Objectives/Systems/RaiseGlimmerConditionSystem.cs b/Content.Server/Nyanotrasen/Objectives/Systems/RaiseGlimmerConditionSystem.cs
new file mode 100644
index 00000000000..d7aae44afa7
--- /dev/null
+++ b/Content.Server/Nyanotrasen/Objectives/Systems/RaiseGlimmerConditionSystem.cs
@@ -0,0 +1,40 @@
+using Content.Shared.Psionics.Glimmer;
+using Content.Server.Objectives.Components;
+using Content.Shared.Objectives.Components;
+
+namespace Content.Server.Objectives.Systems
+{
+ public sealed class RaiseGlimmerConditionSystem : EntitySystem
+ {
+ [Dependency] private readonly IEntitySystemManager _sysMan = default!;
+ [Dependency] private readonly MetaDataSystem _metaData = default!;
+ public override void Initialize()
+ {
+ base.Initialize();
+
+ SubscribeLocalEvent(OnGetProgress);
+ SubscribeLocalEvent(OnAfterAssign);
+ }
+
+ private void OnAfterAssign(EntityUid uid, RaiseGlimmerConditionComponent comp, ref ObjectiveAfterAssignEvent args)
+ {
+ var title = Loc.GetString("objective-condition-raise-glimmer-title", ("target", comp.Target));
+ var description = Loc.GetString("objective-condition-raise-glimmer-description", ("target", comp.Target));
+
+ _metaData.SetEntityName(uid, title, args.Meta);
+ _metaData.SetEntityDescription(uid, description, args.Meta);
+ }
+
+ private void OnGetProgress(EntityUid uid, RaiseGlimmerConditionComponent comp, ref ObjectiveGetProgressEvent args)
+ {
+ args.Progress = GetProgress(comp.Target);
+ }
+
+ private float GetProgress(int target)
+ {
+ var glimmer = _sysMan.GetEntitySystem().Glimmer;
+ var progress = Math.Min((float) glimmer / (float) target, 1f);
+ return progress;
+ }
+ }
+}
diff --git a/Resources/Locale/en-US/nyanotrasen/objectives/conditions/conditions.ftl b/Resources/Locale/en-US/nyanotrasen/objectives/conditions/conditions.ftl
new file mode 100644
index 00000000000..076260f7e43
--- /dev/null
+++ b/Resources/Locale/en-US/nyanotrasen/objectives/conditions/conditions.ftl
@@ -0,0 +1,6 @@
+objective-condition-raise-glimmer-title = Ensure glimmer reaches {$target}Ψ.
+objective-condition-raise-glimmer-description = We need you to pump the noösphere surrounding the station to at least {$target}Ψ and keep it that way.
+objective-condition-become-psionic-title = Become psionic
+objective-condition-become-psionic-description = We need you to acquire psionics and keep them until your mission is complete.
+objective-condition-become-golem-title = Get golemized
+objective-condition-become-golem-description = We'd like to understand more of the golemization process. Become a golem, survive, and we'll debrief you.
diff --git a/Resources/Prototypes/Nyanotrasen/Objectives/traitor.yml b/Resources/Prototypes/Nyanotrasen/Objectives/traitor.yml
index debf04a9013..f66db77b5ce 100644
--- a/Resources/Prototypes/Nyanotrasen/Objectives/traitor.yml
+++ b/Resources/Prototypes/Nyanotrasen/Objectives/traitor.yml
@@ -8,3 +8,63 @@
- type: StealCondition
prototype: AntiPsychicKnife
owner: job-name-mantis
+
+- type: entity
+ id: BecomePsionicObjective
+ parent: BaseTraitorObjective
+ name: Become psionic
+ description: We need you to acquire psionics and keep them until your mission is complete.
+ noSpawn: true
+ components:
+ - type: NotJobsRequirement
+ jobs:
+ - Mime
+ - ForensicMantis
+ - type: Objective
+ difficulty: 2.5
+ #unique: false
+ icon:
+ sprite: Nyanotrasen/Icons/psi.rsi
+ state: psi
+ - type: ObjectiveBlacklistRequirement
+ blacklist:
+ components:
+ - BecomeGolemCondition
+ - type: BecomePsionicCondition
+
+#- type: entity
+# id: BecomeGolemObjective
+# parent: BaseTraitorObjective
+# name: objective-condition-become-golem-title
+# description: objective-condition-become-golem-description.
+# noSpawn: true
+# components:
+# - type: NotJobRequirement
+# job: Chaplain
+# - type: Objective
+# difficulty: 3.5
+# #unique: false
+# icon:
+# sprite: Nyanotrasen/Mobs/Species/Golem/cult.rsi
+# state: full
+# - type: ObjectiveBlacklistRequirement
+# blacklist:
+# components:
+# - BecomePsionicCondition
+# - type: BecomeGolemCondition
+
+- type: entity
+ id: RaiseGlimmerObjective
+ parent: BaseTraitorObjective
+ noSpawn: true
+ name: Raise Glimmer.
+ description: Get the glimmer above the specified amount.
+ components:
+ - type: Objective
+ difficulty: 2.5
+ #unique: false
+ icon:
+ sprite: Nyanotrasen/Icons/psi.rsi
+ state: psi
+ - type: RaiseGlimmerCondition
+ target: 500
\ No newline at end of file
diff --git a/Resources/Prototypes/Objectives/objectiveGroups.yml b/Resources/Prototypes/Objectives/objectiveGroups.yml
index 4a4d0ea3439..f9536ed2a73 100644
--- a/Resources/Prototypes/Objectives/objectiveGroups.yml
+++ b/Resources/Prototypes/Objectives/objectiveGroups.yml
@@ -37,11 +37,15 @@
EscapeShuttleObjective: 1
# DieObjective: 0.05 # DeltaV - Disable the lrp objective aka murderbone justification
HijackShuttleObjective: 0.02
+ BecomePsionicObjective: 1 # Nyanotrasen - Become Psionic objective, see Resources/Prototypes/Nyanotrasen/Objectives/traitor.yml
+ #BecomeGolemObjective: 0.5 # Nyanotrasen - Become a golem objective, see Resources/Prototypes/Nyanotrasen/Objectives/traitor.yml
- type: weightedRandom
id: TraitorObjectiveGroupSocial
weights:
RandomTraitorAliveObjective: 1
RandomTraitorProgressObjective: 1
+ RaiseGlimmerObjective: 0.5 # Nyanotrasen - Raise glimmer to a target amount, see Resources/Prototypes/Nyanotrasen/Objectives/traitor.yml
+
#Changeling, crew, wizard, when you code it...