Skip to content

Commit

Permalink
Change Thief Syndie & Chameleon kit contents, add Syndie codeword pap…
Browse files Browse the repository at this point in the history
…er (#30446)

* Initial commit

* more like bYE

* Fix exception during test
  • Loading branch information
SlamBamActionman authored Aug 5, 2024
1 parent 8197382 commit bf06d0e
Show file tree
Hide file tree
Showing 7 changed files with 161 additions and 9 deletions.
14 changes: 10 additions & 4 deletions Content.Server/GameTicking/Rules/TraitorRuleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,25 +42,31 @@ public override void Initialize()
protected override void Added(EntityUid uid, TraitorRuleComponent component, GameRuleComponent gameRule, GameRuleAddedEvent args)
{
base.Added(uid, component, gameRule, args);
MakeCodewords(component);
SetCodewords(component);
}

private void AfterEntitySelected(Entity<TraitorRuleComponent> ent, ref AfterAntagEntitySelectedEvent args)
{
MakeTraitor(args.EntityUid, ent);
}

private void MakeCodewords(TraitorRuleComponent component)
private void SetCodewords(TraitorRuleComponent component)
{
component.Codewords = GenerateTraitorCodewords(component);
}

public string[] GenerateTraitorCodewords(TraitorRuleComponent component)
{
var adjectives = _prototypeManager.Index(component.CodewordAdjectives).Values;
var verbs = _prototypeManager.Index(component.CodewordVerbs).Values;
var codewordPool = adjectives.Concat(verbs).ToList();
var finalCodewordCount = Math.Min(component.CodewordCount, codewordPool.Count);
component.Codewords = new string[finalCodewordCount];
string[] codewords = new string[finalCodewordCount];
for (var i = 0; i < finalCodewordCount; i++)
{
component.Codewords[i] = _random.PickAndTake(codewordPool);
codewords[i] = _random.PickAndTake(codewordPool);
}
return codewords;
}

public bool MakeTraitor(EntityUid traitor, TraitorRuleComponent component, bool giveUplink = true)
Expand Down
27 changes: 27 additions & 0 deletions Content.Server/Traitor/Components/TraitorCodePaperComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
namespace Content.Server.Traitor.Components;

/// <summary>
/// Paper with written traitor codewords on it.
/// </summary>
[RegisterComponent]
public sealed partial class TraitorCodePaperComponent : Component
{
/// <summary>
/// The number of codewords that should be generated on this paper.
/// Will not extend past the max number of available codewords.
/// </summary>
[DataField]
public int CodewordAmount = 1;

/// <summary>
/// Whether the codewords should be faked if there is no traitor gamerule set.
/// </summary>
[DataField]
public bool FakeCodewords = true;

/// <summary>
/// Whether all codewords added to the round should be used. Overrides CodewordAmount if true.
/// </summary>
[DataField]
public bool CodewordShowAll = false;
}
93 changes: 93 additions & 0 deletions Content.Server/Traitor/Systems/TraitorCodePaperSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
using System.Diagnostics.CodeAnalysis;
using Content.Server.GameTicking;
using Content.Server.GameTicking.Rules;
using Content.Server.GameTicking.Rules.Components;
using Content.Server.Paper;
using Content.Server.Traitor.Components;
using Robust.Shared.Random;
using Robust.Shared.Utility;
using System.Linq;

namespace Content.Server.Traitor.Systems;

public sealed class TraitorCodePaperSystem : EntitySystem
{
[Dependency] private readonly GameTicker _gameTicker = default!;
[Dependency] private readonly TraitorRuleSystem _traitorRuleSystem = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly PaperSystem _paper = default!;

Check failure on line 18 in Content.Server/Traitor/Systems/TraitorCodePaperSystem.cs

View workflow job for this annotation

GitHub Actions / Test Packaging

The type or namespace name 'PaperSystem' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 18 in Content.Server/Traitor/Systems/TraitorCodePaperSystem.cs

View workflow job for this annotation

GitHub Actions / Test Packaging

The type or namespace name 'PaperSystem' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 18 in Content.Server/Traitor/Systems/TraitorCodePaperSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'PaperSystem' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 18 in Content.Server/Traitor/Systems/TraitorCodePaperSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'PaperSystem' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 18 in Content.Server/Traitor/Systems/TraitorCodePaperSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'PaperSystem' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 18 in Content.Server/Traitor/Systems/TraitorCodePaperSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'PaperSystem' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 18 in Content.Server/Traitor/Systems/TraitorCodePaperSystem.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

The type or namespace name 'PaperSystem' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 18 in Content.Server/Traitor/Systems/TraitorCodePaperSystem.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

The type or namespace name 'PaperSystem' could not be found (are you missing a using directive or an assembly reference?)

public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<TraitorCodePaperComponent, MapInitEvent>(OnMapInit);
}

private void OnMapInit(EntityUid uid, TraitorCodePaperComponent component, MapInitEvent args)
{
SetupPaper(uid, component);
}

private void SetupPaper(EntityUid uid, TraitorCodePaperComponent? component = null)
{
if (!Resolve(uid, ref component))
return;

if (HasComp<PaperComponent>(uid))
{
if (TryGetTraitorCode(out var paperContent, component))
{
_paper.SetContent(uid, paperContent);
}
}
}

private bool TryGetTraitorCode([NotNullWhen(true)] out string? traitorCode, TraitorCodePaperComponent component)
{
traitorCode = null;

var codesMessage = new FormattedMessage();
List<string> codeList = new();
// Find the first nuke that matches the passed location.
if (_gameTicker.IsGameRuleAdded<TraitorRuleComponent>())
{
var ruleEnts = _gameTicker.GetAddedGameRules();
foreach (var ruleEnt in ruleEnts)
{
if (TryComp(ruleEnt, out TraitorRuleComponent? traitorComp))
{
codeList.AddRange(traitorComp.Codewords.ToList());
}
}
}
if (codeList.Count == 0)
{
if (component.FakeCodewords)
codeList = _traitorRuleSystem.GenerateTraitorCodewords(new TraitorRuleComponent()).ToList();
else
codeList = [Loc.GetString("traitor-codes-none")];
}

_random.Shuffle(codeList);

int i = 0;
foreach (var code in codeList)
{
i++;
if (i > component.CodewordAmount && !component.CodewordShowAll)
break;

codesMessage.PushNewline();
codesMessage.AddMarkup(code);
}

if (!codesMessage.IsEmpty)
{
if (i == 1)
traitorCode = Loc.GetString("traitor-codes-message-singular") + codesMessage;
else
traitorCode = Loc.GetString("traitor-codes-message-plural") + codesMessage;
}
return !codesMessage.IsEmpty;
}
}
7 changes: 4 additions & 3 deletions Resources/Locale/en-US/thief/backpack.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ thief-backpack-button-deselect = Select [X]
thief-backpack-category-chameleon-name = chameleon kit
thief-backpack-category-chameleon-description =
You are everyone and no one; you are a master of disguise.
Includes: Set of chameleon clothing, a chameleon projector.
Includes: A full set of chameleon clothing,
a chameleon projector, and an Agent ID.
Disguise as anyone and anything.
thief-backpack-category-tools-name = breacher kit
Expand All @@ -38,8 +39,8 @@ thief-backpack-category-syndie-name = syndie kit
thief-backpack-category-syndie-description =
Trinkets from a disavowed past, or stolen from a careless agent?
You've made some connections. Whiskey, echo...
Includes: Agent ID card, Emag, syndicate pAI, Interdyne cigs,
and some strange red crystals.
Includes: An Emag, Interdyne cigs, a Syndicate codeword,
a Radio Jammer, a lighter and some strange red crystals.
thief-backpack-category-sleeper-name = sleeper kit
thief-backpack-category-sleeper-description =
Expand Down
3 changes: 3 additions & 0 deletions Resources/Locale/en-US/traitor/traitor-codes-component.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
traitor-codes-message-singular = syndicate codeword:
traitor-codes-message-plural = syndicate codewords:
traitor-codes-none = no known codewords
6 changes: 4 additions & 2 deletions Resources/Prototypes/Catalog/thief_toolbox_sets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- ClothingShoesChameleon
- BarberScissors
- ChameleonProjector
- AgentIDCard

- type: thiefBackpackSet
id: ToolsSet
Expand Down Expand Up @@ -57,9 +58,10 @@
sprite: Objects/Specific/Syndicate/telecrystal.rsi
state: telecrystal
content:
- AgentIDCard
- RadioJammer
- TraitorCodePaper
- Emag
- SyndicatePersonalAI
- Lighter
- CigPackSyndicate
- Telecrystal10 #The thief cannot use them, but it may induce communication with traitors

Expand Down
20 changes: 20 additions & 0 deletions Resources/Prototypes/Entities/Objects/Misc/paper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,26 @@
- type: StealTarget
stealGroup: BoxFolderQmClipboard

- type: entity
parent: Paper
id: TraitorCodePaper
name: syndicate codeword
description: A leaked codeword to possibly get in touch with the Syndicate.
suffix: DO NOT MAP
components:
- type: TraitorCodePaper

- type: entity
parent: Paper
id: AllTraitorCodesPaper
name: syndicate codewords registry
description: A registry of all active Syndicate codewords.
suffix: Admeme
components:
- type: TraitorCodePaper
fakeCodewords: false
codewordShowAll: true

- type: entity
name: envelope
parent: BaseItem
Expand Down

0 comments on commit bf06d0e

Please sign in to comment.