Skip to content

Commit

Permalink
basics done
Browse files Browse the repository at this point in the history
  • Loading branch information
taydeo committed Aug 25, 2024
1 parent b0d0cd6 commit 50f3910
Show file tree
Hide file tree
Showing 18 changed files with 269 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Content.Server/Administration/Systems/AdminVerbSystem.Antags.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,5 +166,20 @@ private void AddAntagVerbs(GetVerbsEvent<Verb> args)
Message = Loc.GetString("admin-verb-make-changeling"),
};
args.Verbs.Add(ling);

// funkystation - obsessed
Verb obsessed = new()
{
Text = Loc.GetString("Make Obsessed"),
Category = VerbCategory.Antag,
Icon = new SpriteSpecifier.Rsi(new ResPath("/Textures/Goobstation/Changeling/changeling_abilities.rsi"), "transform"),
Act = () =>
{
_antag.ForceMakeAntag<ObsessedRuleComponent>(targetPlayer, "Obsessed");
},
Impact = LogImpact.High,
Message = Loc.GetString("Turn the player into an obsessed."),
};
args.Verbs.Add(obsessed);
}
}
9 changes: 9 additions & 0 deletions Content.Server/Content.Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,16 @@
<ProjectReference Include="..\Content.Shared\Content.Shared.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Funkystation\Objectives\Systems\" />
<Folder Include="Objectives\Interfaces\" />
</ItemGroup>
<ItemGroup>
<Compile Remove="Funkystation\Roles\ObsessedRoleComponent.cs" />
<Compile Remove="Funkystation\Obsessed\ObsessedSystem.cs" />
<Compile Remove="Funkystation\Obsessed\GameTicking\Rules\ObsessedRuleSystem.cs" />
<Compile Remove="Funkystation\Objectives\Components\ObsessedTimeComponent.cs" />
<Compile Remove="Funkystation\Objectives\Components\ObsessedTargetComponent.cs" />
<Compile Remove="Funkystation\Objectives\Components\ObsessedPhotoObjective.cs" />
</ItemGroup>
<Import Project="..\RobustToolbox\MSBuild\Robust.Properties.targets" />
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using Content.Server.Objectives.Components;

namespace Content.Server.Funkystation.Components;

[RegisterComponent]
public sealed partial class RandomPersistentTargetComponent : Component
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Content.Server.Objectives.Systems;

namespace Content.Server.Funkystation.Objectives.Components;

[RegisterComponent, Access(typeof(KeepAliveConditionSystem))]
public sealed partial class ObsessedPersistentTargetComponent : Component
{
public EntityUid EntityUid = EntityUid.Invalid;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
using Content.Server.Antag;
using Content.Server.GameTicking.Rules.Components;
using Content.Server.Mind;
using Content.Server.Objectives;
using Content.Server.Roles;
using Content.Shared.Changeling;
using Content.Shared.NPC.Prototypes;
using Content.Shared.NPC.Systems;
using Content.Shared.Roles;
using Content.Shared.Store;
using Content.Shared.Store.Components;
using Robust.Shared.Audio;
using Robust.Shared.Prototypes;
using System.Text;
using Content.Shared.Obsessed;

namespace Content.Server.GameTicking.Rules;

public sealed partial class ObsessedRuleSystem : GameRuleSystem<ObsessedRuleComponent>
{
[Dependency] private readonly MindSystem _mind = default!;
[Dependency] private readonly AntagSelectionSystem _antag = default!;
[Dependency] private readonly SharedRoleSystem _role = default!;
[Dependency] private readonly ObjectivesSystem _objective = default!;

public readonly ProtoId<AntagPrototype> ObsessedPrototypeId = "Obsessed";

public readonly SoundSpecifier BriefingSound = new SoundPathSpecifier("/Audio/Funkystation/Ambience/angels_harp_sound.ogg");

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

SubscribeLocalEvent<ObsessedRuleComponent, AfterAntagEntitySelectedEvent>(OnSelectAntag);
SubscribeLocalEvent<ObsessedRuleComponent, ObjectivesTextPrependEvent>(OnTextPrepend);
}

private void OnSelectAntag(EntityUid uid, ObsessedRuleComponent comp, ref AfterAntagEntitySelectedEvent args)
{
MakeObsessed(args.EntityUid, comp);
}
public bool MakeObsessed(EntityUid target, ObsessedRuleComponent rule)
{
if (!_mind.TryGetMind(target, out var mindId, out var mind))
return false;

var briefing = Loc.GetString("obsessed-role-greeting");
var briefingShort = Loc.GetString("obsessed-role-greeting-short");

EnsureComp<ObsessedComponent>(target);

_antag.SendBriefing(target, briefing, Color.Pink, BriefingSound);
_role.MindAddRole(mindId, new RoleBriefingComponent { Briefing = briefingShort }, mind, true);

foreach (var objective in rule.Objectives)
{
_mind.TryAddObjective(mindId, mind, objective);
}

return true;
}

private void OnTextPrepend(EntityUid uid, ObsessedRuleComponent comp, ref ObjectivesTextPrependEvent args)
{
var mostAbsorbedName = string.Empty;
var mostStolenName = string.Empty;
var mostAbsorbed = 0f;
var mostStolen = 0f;

foreach (var ling in EntityQuery<ChangelingComponent>())
{
if (!_mind.TryGetMind(ling.Owner, out var mindId, out var mind))
continue;

if (!TryComp<MetaDataComponent>(ling.Owner, out var metaData))
continue;

if (ling.TotalAbsorbedEntities > mostAbsorbed)
{
mostAbsorbed = ling.TotalAbsorbedEntities;
mostAbsorbedName = _objective.GetTitle((mindId, mind), metaData.EntityName);
}
if (ling.TotalStolenDNA > mostStolen)
{
mostStolen = ling.TotalStolenDNA;
mostStolenName = _objective.GetTitle((mindId, mind), metaData.EntityName);
}
}

var sb = new StringBuilder();
sb.AppendLine(Loc.GetString($"roundend-prepend-changeling-absorbed{(!string.IsNullOrWhiteSpace(mostAbsorbedName) ? "-named" : "")}", ("name", mostAbsorbedName), ("number", mostAbsorbed)));
sb.AppendLine(Loc.GetString($"roundend-prepend-changeling-stolen{(!string.IsNullOrWhiteSpace(mostStolenName) ? "-named" : "")}", ("name", mostStolenName), ("number", mostStolen)));

args.Text = sb.ToString();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Robust.Shared.Prototypes;

namespace Content.Server.GameTicking.Rules.Components;

[RegisterComponent, Access(typeof(ObsessedRuleSystem))]
public sealed partial class ObsessedRuleComponent : Component
{
public readonly List<ProtoId<EntityPrototype>> Objectives =
[
"ObsessedKeepAliveObjective",
"ObsessedHugObjective",
];
}
8 changes: 8 additions & 0 deletions Content.Server/Funkystation/Roles/ObsessedRole.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using Content.Shared.Roles;

namespace Content.Server.Roles;

[RegisterComponent, ExclusiveAntagonist]
public sealed partial class ObsessedRoleComponent : AntagonistRoleComponent
{
}
29 changes: 29 additions & 0 deletions Content.Server/Objectives/Systems/KeepAliveCondition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using Content.Shared.Roles.Jobs;
using Robust.Shared.Random;
using System.Linq;
using Content.Server.Funkystation.Components;
using Content.Server.Funkystation.Objectives.Components;
using Content.Server.Goobstation.Objectives.Components;

namespace Content.Server.Objectives.Systems;
Expand All @@ -29,6 +31,8 @@ public override void Initialize()
SubscribeLocalEvent<RandomTraitorAliveComponent, ObjectiveAssignedEvent>(OnAssigned);

SubscribeLocalEvent<RandomTraitorTargetComponent, ObjectiveAssignedEvent>(OnTraitorTargetAssigned);

SubscribeLocalEvent<RandomPersistentTargetComponent, ObjectiveAssignedEvent>(OnPersistentAssigned);
}

private void OnGetProgress(EntityUid uid, KeepAliveConditionComponent comp, ref ObjectiveGetProgressEvent args)
Expand Down Expand Up @@ -108,6 +112,31 @@ private void OnTraitorTargetAssigned(EntityUid uid,
_target.SetTarget(uid, _random.Pick(killTargets), target);
}

// funkystation - persistent target for an antag
// TODO: make more generic but idgaf
private void OnPersistentAssigned(EntityUid uid, RandomPersistentTargetComponent comp, ref ObjectiveAssignedEvent args)
{
if (!TryComp<TargetObjectiveComponent>(uid, out var target))
{
args.Cancelled = true;
return;
}

EnsureComp<ObsessedPersistentTargetComponent>(uid, out var obsessedTarget);

if (obsessedTarget.EntityUid != EntityUid.Invalid)
{
_target.SetTarget(uid, obsessedTarget.EntityUid, target);
return;
}

var allAlive = _mind.GetAliveHumansExcept(uid);
var luckyOne = _random.Pick(allAlive);

obsessedTarget.EntityUid = luckyOne;
_target.SetTarget(uid, obsessedTarget.EntityUid, target);
}

private float GetProgress(EntityUid target)
{
if (!TryComp<MindComponent>(target, out var mind))
Expand Down
8 changes: 8 additions & 0 deletions Content.Shared/Funkystation/Obsessed/ObsessedComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using Robust.Shared.GameStates;

namespace Content.Shared.Obsessed;

[RegisterComponent, NetworkedComponent]
public sealed partial class ObsessedComponent : Component
{
}
Binary file not shown.
4 changes: 4 additions & 0 deletions Resources/Audio/Funkystation/Ambience/attributions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- files: ["angels_harp_sound.wav"]
license: "CC-BY-3.0"
copyright: "Created by Brand Name Audio"
source: "https://www.youtube.com/watch?v=eTebYPZ1yMI"
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
admin-verb-make-obsessed = Make the target into an obsessed.
admin-verb-text-make-obsessed = Make Obsessed
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
obsessed-roundend-name = obsessed
objective-issuer-obsessed = [color=pink]Obsessed[/color]
obsessed-gamemode-title = Obsessed
obsessed-gamemode-description =
There's love (lead) in the air! Figure out who's obsessed over who before it turns into a bloody Valentine's.
obsessed-role-greeting =
You suddenly come down with a severe case of heartache.
Your objectives are listed in the character menu.
Note, you ARE NOT a traditional antagonist!
obsessed-role-greeting-short =
You're infatuated with a crew member on the station.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
objective-condition-obsessed-keep-safe-title = Keep {$targetName}, {CAPITALIZE($job)} safe.
objective-condition-obsessed-keep-safe = I can't let anyone hurt them!
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
roles-antag-obsessed-name = Obsessed
roles-antag-obsessed-description = Use whatever means are available to you to protect your obsession.
20 changes: 20 additions & 0 deletions Resources/Prototypes/Funkystation/Obsessed/GameRules/obsessed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
- type: entity
parent: BaseGameRule
id: Obsessed
components:
- type: ObsessedRule
- type: GameRule
minPlayers: 10
delay:
min: 10
max: 20
- type: AntagSelection
agentName: obsessed
definitions:
- prefRoles: [ Obsessed ]
max: 8
playerRatio: 10
lateJoinAdditional: true
mindComponents:
- type: ObsessedRole
prototype: Obsessed
25 changes: 25 additions & 0 deletions Resources/Prototypes/Funkystation/Obsessed/Objectives/obsessed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
- type: entity
abstract: true
parent: BaseObjective
id: BaseObsessedObjective
components:
- type: Objective
difficulty: 1.5 # unused but necessary I guess
issuer: objective-issuer-obsessed
- type: RoleRequirement
roles:
components:
- ObsessedRole

- type: entity
parent: [BaseObsessedObjective, BaseKeepAliveObjective]
id: ObsessedKeepAliveObjective
description: No matter what, I can't let anyone hurt them!
components:
- type: Objective
icon:
sprite: Mobs/Demons/abomination.rsi
state: dead
- type: TargetObjective
title: objective-condition-obsessed-keep-safe-title
- type: RandomPersistentTarget
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- type: antag
id: Obsessed
name: Obsessed
antagonist: true
setPreference: true
objective: Do anything in your power to protect your obsession.
guides: [ Changelings ]

0 comments on commit 50f3910

Please sign in to comment.