Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds Psionic-related Antag Objectives. #345

Merged
merged 2 commits into from
Oct 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Content.Server.Objectives.Systems;
using Content.Shared.Roles;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;

/// <summary>
/// Requires that the player not have a certain job to have this objective.
/// </summary>
[RegisterComponent, Access(typeof(NotJobsRequirementSystem))]
public sealed partial class NotJobsRequirementComponent : Component
{
/// <summary>
/// ID of the job to ban from having this objective.
/// </summary>
[DataField(required: true, customTypeSerializer: typeof(PrototypeIdListSerializer<JobPrototype>))]
public List<string> Jobs = new();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using Content.Server.Objectives.Components;
using Content.Shared.Objectives.Components;
using Content.Shared.Roles.Jobs;

namespace Content.Server.Objectives.Systems;

/// <summary>
/// Handles checking the job blacklist for this objective.
/// </summary>
public sealed class NotJobsRequirementSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<NotJobsRequirementComponent, RequirementCheckEvent>(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<JobComponent>(args.MindId, out var job))
return;
foreach (string forbidJob in comp.Jobs)
if (job.PrototypeId == forbidJob)
args.Cancelled = true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Content.Server.Objectives.Systems;

namespace Content.Server.Objectives.Components;

/// <summary>
/// Requires that the player dies to be complete.
/// </summary>
[RegisterComponent, Access(typeof(BecomeGolemConditionSystem))]
public sealed partial class BecomeGolemConditionComponent : Component
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Content.Server.Objectives.Systems;

namespace Content.Server.Objectives.Components;

/// <summary>
/// Requires that the player dies to be complete.
/// </summary>
[RegisterComponent, Access(typeof(BecomePsionicConditionSystem))]
public sealed partial class BecomePsionicConditionComponent : Component
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Content.Server.Objectives.Systems;

namespace Content.Server.Objectives.Components;

/// <summary>
/// Requires that the player dies to be complete.
/// </summary>
[RegisterComponent, Access(typeof(RaiseGlimmerConditionSystem))]
public sealed partial class RaiseGlimmerConditionComponent : Component
{
[DataField("target"), ViewVariables(VVAccess.ReadWrite)]
public int Target;
}
Original file line number Diff line number Diff line change
@@ -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<MetaDataComponent> _metaQuery;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<BecomeGolemConditionComponent, ObjectiveGetProgressEvent>(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<IEntityManager>();
if (!_metaQuery.TryGetComponent(mind.OwnedEntity, out var meta))
return 0;
/*EntityManager.TryGetComponent<GolemComponent>(mind.CurrentEntity, out var GolemComp);
if(GolemComp)
return 1; TODO: Add this code back once Golems are implemented. */
return 0;
}
}
}
Original file line number Diff line number Diff line change
@@ -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<MetaDataComponent> _metaQuery;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<BecomePsionicConditionComponent, ObjectiveGetProgressEvent>(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<IEntityManager>();
if (HasComp<PsionicComponent>(mind.CurrentEntity))
return 1;
return 0;
}
}
}
Original file line number Diff line number Diff line change
@@ -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<RaiseGlimmerConditionComponent, ObjectiveGetProgressEvent>(OnGetProgress);
SubscribeLocalEvent<RaiseGlimmerConditionComponent, ObjectiveAfterAssignEvent>(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<GlimmerSystem>().Glimmer;
var progress = Math.Min((float) glimmer / (float) target, 1f);
return progress;
}
}
}
Original file line number Diff line number Diff line change
@@ -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.
60 changes: 60 additions & 0 deletions Resources/Prototypes/Nyanotrasen/Objectives/traitor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions Resources/Prototypes/Objectives/objectiveGroups.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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...
Loading