Skip to content

Commit

Permalink
New Thief minor antagonist (space-wizards#21520)
Browse files Browse the repository at this point in the history
* start working

* add right-click thief antagins
some architecture restruct

* add meh thief greeting audio

* add thief subgamemode to Traitors gamemode

* add late join thief (not tested yet)
add briefing

* add pacifism

* add Steal tasks to thief

* fix crash thief+traitor on person

* add new condition: collection steal

* add tracking of succes collection objective

* add stamp collection target
remove some boring steal target
add check pulling entity to collection target

* finalize first 2 group objective

* start merging stealing objective systems

* merging

* finish merging. Now traitor steal objective work better

* we don't check the items of pullable sentient entity

* clear naming, enable thief signle item objective start

* objective pack add

* finish with steal item objectives

* convert string to ProtoId<>

* some clean up

* add thieves to revolution game mode

* Update Resources/Locale/en-US/game-ticking/game-presets/preset-thief.ftl

Co-authored-by: Flareguy <[email protected]>

* Update Resources/Locale/en-US/game-ticking/game-presets/preset-thief.ftl

Co-authored-by: Flareguy <[email protected]>

* update pacifism: fix crashing, monkey-thief without pacified

* adaptive animal briefing, cleaning locales

* add structure steal objectives

* remove RCD target

* add thiefs to manifest, but bug with traitor duplications

* add escape objective

* add chat briefing

* setup animal objective group system

* add animal steal objectives

* add animal objectives notroleconditions

* add morty

* now thief mode has a chance of not launching Now there are a random number of thieves per round from 1 to 3

* 6 hours of trying to fix duplicate tasks. Failure

* added thief pinpointer (buggy)

* start thief backpack UI work

* revert pinpointer for scope reason

* UI continue work

* add thief starter kits content

* remove ERP kit :trollface:

* finally! giving starting items to thief. Now it playable, but still need more work

* clean up

* fix

* fox

* add merged items into thief
new Starting Kit (buggy)

* fix YES antag menu

* objection tweaks

* remove hearts objective, working on spawning things from toolbox

* smug

* fixes

* add race specifier objective condition LAMPS

* meh

* fix fix fix

* the alive

* Adding stamps

* Update backpack.ftl

* Revert1

* Revert ftl

* add voice mask to communicator kit

* Update Resources/Locale/en-US/administration/antag.ftl

Co-authored-by: Colin-Tel <[email protected]>

* Update Resources/Locale/en-US/game-ticking/game-presets/preset-thief.ftl

Co-authored-by: Colin-Tel <[email protected]>

* Update Resources/Locale/en-US/thief/backpack.ftl

Co-authored-by: Colin-Tel <[email protected]>

* Update Resources/Locale/en-US/objectives/conditions/steal.ftl

Co-authored-by: Colin-Tel <[email protected]>

* Update Resources/Locale/en-US/thief/backpack.ftl

Co-authored-by: Colin-Tel <[email protected]>

* Update Resources/Locale/en-US/thief/backpack.ftl

Co-authored-by: Colin-Tel <[email protected]>

* Update Resources/Locale/en-US/thief/backpack.ftl

Co-authored-by: Colin-Tel <[email protected]>

* Update Resources/Locale/en-US/thief/backpack.ftl

Co-authored-by: Colin-Tel <[email protected]>

* Update Resources/Locale/en-US/prototypes/roles/antags.ftl

Co-authored-by: Colin-Tel <[email protected]>

* Update Resources/Locale/en-US/thief/backpack.ftl

Co-authored-by: Colin-Tel <[email protected]>

* update

* fix

* more reusable function, add documentation

* fix doc

* faint fixes

---------

Co-authored-by: Flareguy <[email protected]>
Co-authored-by: Colin-Tel <[email protected]>
  • Loading branch information
3 people authored and qwerltaz committed Dec 26, 2023
1 parent 1c6ac37 commit d340269
Show file tree
Hide file tree
Showing 94 changed files with 2,544 additions and 128 deletions.
52 changes: 52 additions & 0 deletions Content.Client/Thief/ThiefBackpackBoundUserInterface.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using Content.Shared.Thief;
using JetBrains.Annotations;
using Robust.Client.GameObjects;

namespace Content.Client.Thief;

[UsedImplicitly]
public sealed class ThiefBackpackBoundUserInterface : BoundUserInterface
{
private ThiefBackpackMenu? _window;

public ThiefBackpackBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) { }

protected override void Open()
{
base.Open();

_window = new ThiefBackpackMenu(this);
_window.OnClose += Close;
_window.OpenCentered();
}

protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (!disposing)
return;

_window?.Dispose();
_window = null;
}

protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);

if (state is not ThiefBackpackBoundUserInterfaceState current)
return;

_window?.UpdateState(current);
}

public void SendChangeSelected(int setNumber)
{
SendMessage(new ThiefBackpackChangeSetMessage(setNumber));
}

public void SendApprove()
{
SendMessage(new ThiefBackpackApproveMessage());
}
}
39 changes: 39 additions & 0 deletions Content.Client/Thief/ThiefBackpackMenu.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<controls:FancyWindow xmlns="https://spacestation14.io"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
Title="{Loc 'thief-backpack-window-title'}"
MinSize="700 700">
<BoxContainer Orientation="Vertical" HorizontalExpand="True" VerticalExpand="True">
<!-- First Informational panel -->
<Label Text="{Loc 'thief-backpack-window-description'}" Margin="5 5"/>
<controls:HLine Color="#404040" Thickness="2" Margin="0 5"/>
<Label Name="SelectedSets" Text="{Loc 'thief-backpack-window-selected'}" Margin="5 5"/>

<!-- Second sets panel -->
<PanelContainer Margin="5 5">
<PanelContainer.PanelOverride>
<gfx:StyleBoxFlat BackgroundColor="#050505" />
</PanelContainer.PanelOverride>
<ScrollContainer
HScrollEnabled="False"
MinSize="0 600"
SizeFlagsStretchRatio="2"
VerticalExpand="True">
<BoxContainer Name="SetsGrid" Orientation="Vertical" MinSize="460 200">
<!-- Sets is filled by code -->

</BoxContainer>
</ScrollContainer>
</PanelContainer>

<!-- Third approve button panel -->
<PanelContainer Margin="10">
<Button Name="ApproveButton"
Text="{Loc 'thief-backpack-window-approve-button'}"
Margin="0 5"
Access="Public"
HorizontalAlignment ="Right"
StyleClasses="OpenRight"/>
</PanelContainer>
</BoxContainer>
</controls:FancyWindow>
56 changes: 56 additions & 0 deletions Content.Client/Thief/ThiefBackpackMenu.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using Content.Client.UserInterface.Controls;
using Content.Shared.Thief;
using Robust.Client.AutoGenerated;
using Robust.Client.GameObjects;
using Robust.Client.UserInterface.XAML;

namespace Content.Client.Thief;

[GenerateTypedNameReferences]
public sealed partial class ThiefBackpackMenu : FancyWindow
{
[Dependency] private readonly IEntitySystemManager _sysMan = default!;
private readonly SpriteSystem _spriteSystem;

private readonly ThiefBackpackBoundUserInterface _owner;

public ThiefBackpackMenu(ThiefBackpackBoundUserInterface owner)
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
_spriteSystem = _sysMan.GetEntitySystem<SpriteSystem>();

_owner = owner;

ApproveButton.OnButtonDown += (args) =>
{
_owner.SendApprove();
};
}

public void UpdateState(ThiefBackpackBoundUserInterfaceState state)
{
SetsGrid.RemoveAllChildren();
int count = 0;
int selectedNumber = 0;
foreach (var set in state.Sets)
{
var child = new ThiefBackpackSet(set.Value, _spriteSystem);

child.SetButton.OnButtonDown += (args) =>
{
_owner.SendChangeSelected(set.Key);
};

SetsGrid.AddChild(child);

count++;

if (set.Value.Selected)
selectedNumber++;
}

SelectedSets.Text = Loc.GetString("thief-backpack-window-selected", ("selectedCount", selectedNumber), ("maxCount", state.MaxSelectedSets));
ApproveButton.Disabled = selectedNumber == state.MaxSelectedSets ? false : true;
}
}
23 changes: 23 additions & 0 deletions Content.Client/Thief/ThiefBackpackSet.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Control xmlns="https://spacestation14.io"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client">
<!-- Name and button -->
<PanelContainer Margin="5 5 0 5">
<PanelContainer.PanelOverride>
<gfx:StyleBoxFlat BackgroundColor="#18211b" />
</PanelContainer.PanelOverride>
<BoxContainer Orientation="Vertical" HorizontalExpand="True">
<GridContainer Margin="5" Columns="2" MinSize="600 0">
<Label Name="SetName" Text="Set" StyleClasses="StatusFieldTitle"></Label>
<Button Margin="0 10" Name="SetButton" Text="Select" StyleClasses="OpenRight" Access="Public" HorizontalAlignment="Right"/>
</GridContainer>
<controls:HLine Color="#404040" Thickness="1" Margin="0 5"/>
<!-- Icon and Description -->
<GridContainer Margin="0 5" Columns="2">
<TextureRect Name="Icon" Margin="10" Stretch="KeepAspectCentered"
VerticalAlignment="Center" HorizontalAlignment="Right" SetSize="64 64"/>
<Label Name="SetDescription" Text="Description"></Label>
</GridContainer>
</BoxContainer>
</PanelContainer>
</Control>
22 changes: 22 additions & 0 deletions Content.Client/Thief/ThiefBackpackSet.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.XAML;
using Content.Shared.Thief;
using Robust.Client.GameObjects;

namespace Content.Client.Thief;

[GenerateTypedNameReferences]
public sealed partial class ThiefBackpackSet : Control
{
public ThiefBackpackSet(ThiefBackpackSetInfo set, SpriteSystem spriteSystem)
{
RobustXamlLoader.Load(this);

Icon.Texture = spriteSystem.Frame0(set.Sprite);
SetName.Text = Loc.GetString(set.Name);
SetDescription.Text = Loc.GetString(set.Description);
SetButton.Text = Loc.GetString(set.Selected ? "thief-backpack-button-deselect" : "thief-backpack-button-select");
SetButton.ModulateSelfOverride = set.Selected ? new Color(40, 84, 35) : new Color(68, 75, 103);
}
}
19 changes: 19 additions & 0 deletions Content.Server/Administration/Systems/AdminVerbSystem.Antags.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Content.Server.GameTicking;
using Content.Server.GameTicking.Rules;
using Content.Server.StationEvents.Events;
using Content.Server.Zombies;
using Content.Shared.Administration;
using Content.Shared.Database;
Expand All @@ -15,6 +16,7 @@ namespace Content.Server.Administration.Systems;
public sealed partial class AdminVerbSystem
{
[Dependency] private readonly ZombieSystem _zombie = default!;
[Dependency] private readonly ThiefRuleSystem _thief = default!;
[Dependency] private readonly TraitorRuleSystem _traitorRule = default!;
[Dependency] private readonly NukeopsRuleSystem _nukeopsRule = default!;
[Dependency] private readonly PiratesRuleSystem _piratesRule = default!;
Expand Down Expand Up @@ -119,5 +121,22 @@ private void AddAntagVerbs(GetVerbsEvent<Verb> args)
Message = Loc.GetString("admin-verb-make-head-rev"),
};
args.Verbs.Add(headRev);

Verb thief = new()
{
Text = Loc.GetString("admin-verb-text-make-thief"),
Category = VerbCategory.Antag,
Icon = new SpriteSpecifier.Rsi(new ResPath("/Textures/Clothing/Hands/Gloves/ihscombat.rsi"), "icon"),
Act = () =>
{
if (!_minds.TryGetSession(targetMindComp.Mind, out var session))
return;
_thief.MakeThief(session);
},
Impact = LogImpact.High,
Message = Loc.GetString("admin-verb-make-thief"),
};
args.Verbs.Add(thief);
}
}
67 changes: 67 additions & 0 deletions Content.Server/Antag/AntagSelectionSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
using Robust.Server.Containers;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Content.Server.Shuttles.Components;

namespace Content.Server.Antag;

Expand Down Expand Up @@ -149,6 +150,72 @@ public void EligiblePlayers(string antagPrototype,
}
}

/// <summary>
/// The function walks through all players, checking their role and preferences to generate a list of players who can become antagonists.
/// </summary>
/// <param name="candidates">a list of players to check out</param>
/// <param name="antagPreferenceId">antagonist's code id</param>
/// <returns></returns>
public List<ICommonSession> FindPotentialAntags(in Dictionary<ICommonSession, HumanoidCharacterProfile> candidates, string antagPreferenceId)
{
var list = new List<ICommonSession>();
var pendingQuery = GetEntityQuery<PendingClockInComponent>();

foreach (var player in candidates.Keys)
{
// Role prevents antag.
if (!_jobs.CanBeAntag(player))
continue;

// Latejoin
if (player.AttachedEntity != null && pendingQuery.HasComponent(player.AttachedEntity.Value))
continue;

list.Add(player);
}

var prefList = new List<ICommonSession>();

foreach (var player in list)
{
//player preferences to play as this antag
var profile = candidates[player];
if (profile.AntagPreferences.Contains(antagPreferenceId))
{
prefList.Add(player);
}
}
if (prefList.Count == 0)
{
Log.Info($"Insufficient preferred antag:{antagPreferenceId}, picking at random.");
prefList = list;
}
return prefList;
}

/// <summary>
/// selects the specified number of players from the list
/// </summary>
/// <param name="antagCount">how many players to take</param>
/// <param name="prefList">a list of players from which to draw</param>
/// <returns></returns>
public List<ICommonSession> PickAntag(int antagCount, List<ICommonSession> prefList)
{
var results = new List<ICommonSession>(antagCount);
if (prefList.Count == 0)
{
Log.Info("Insufficient ready players to fill up with antags, stopping the selection.");
return results;
}

for (var i = 0; i < antagCount; i++)
{
results.Add(_random.PickAndTake(prefList));
Log.Info("Selected a preferred antag.");
}
return results;
}

/// <summary>
/// Will take a group of entities and check if they are all alive or dead
/// </summary>
Expand Down
54 changes: 54 additions & 0 deletions Content.Server/GameTicking/Rules/Components/ThiefRuleComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using Robust.Shared.Audio;
using Robust.Shared.Prototypes;
using Content.Shared.Roles;
using Robust.Shared.Player;
using Content.Shared.Preferences;

namespace Content.Server.GameTicking.Rules.Components;

/// <summary>
/// Stores data for <see cref="ThiefRuleSystem/">.
/// </summary>
[RegisterComponent, Access(typeof(ThiefRuleSystem))]
public sealed partial class ThiefRuleComponent : Component
{
/// <summary>
/// A chance for this mode to be added to the game.
/// </summary>
[DataField]
public float RuleChance = 1f;

[DataField]
public ProtoId<AntagPrototype> ThiefPrototypeId = "Thief";

public Dictionary<ICommonSession, HumanoidCharacterProfile> StartCandidates = new();

[DataField]
public float MaxObjectiveDifficulty = 2.5f;

[DataField]
public int MaxStealObjectives = 10;

/// <summary>
/// Things that will be given to thieves
/// </summary>
[DataField]
public List<EntProtoId> StarterItems = new List<EntProtoId> { "ToolboxThief", "ClothingHandsChameleonThief" }; //TO DO - replace to chameleon thieving gloves whem merg

/// <summary>
/// All Thiefes created by this rule
/// </summary>
public readonly List<EntityUid> ThiefMinds = new();

/// <summary>
/// Max Thiefs created by rule on roundstart
/// </summary>
[DataField]
public int MaxAllowThief = 3;

/// <summary>
/// Sound played when making the player a thief via antag control or ghost role
/// </summary>
[DataField]
public SoundSpecifier? GreetingSound = new SoundPathSpecifier("/Audio/Misc/thief_greeting.ogg");
}
Loading

0 comments on commit d340269

Please sign in to comment.