New Thief minor antagonist (#21520)

* 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 <78941145+Flareguy@users.noreply.github.com>

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

Co-authored-by: Flareguy <78941145+Flareguy@users.noreply.github.com>

* 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 <113523727+Colin-Tel@users.noreply.github.com>

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

Co-authored-by: Colin-Tel <113523727+Colin-Tel@users.noreply.github.com>

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

Co-authored-by: Colin-Tel <113523727+Colin-Tel@users.noreply.github.com>

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

Co-authored-by: Colin-Tel <113523727+Colin-Tel@users.noreply.github.com>

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

Co-authored-by: Colin-Tel <113523727+Colin-Tel@users.noreply.github.com>

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

Co-authored-by: Colin-Tel <113523727+Colin-Tel@users.noreply.github.com>

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

Co-authored-by: Colin-Tel <113523727+Colin-Tel@users.noreply.github.com>

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

Co-authored-by: Colin-Tel <113523727+Colin-Tel@users.noreply.github.com>

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

Co-authored-by: Colin-Tel <113523727+Colin-Tel@users.noreply.github.com>

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

Co-authored-by: Colin-Tel <113523727+Colin-Tel@users.noreply.github.com>

* update

* fix

* more reusable function, add documentation

* fix doc

* faint fixes

---------

Co-authored-by: Flareguy <78941145+Flareguy@users.noreply.github.com>
Co-authored-by: Colin-Tel <113523727+Colin-Tel@users.noreply.github.com>

(cherry picked from commit 144af233c4f4135cccacfa5d50281fce44a1595e)
This commit is contained in:
Ed
2023-12-24 10:58:28 +01:00
committed by Debug
parent ed1813f1dd
commit 8bca049ca7
94 changed files with 2545 additions and 129 deletions

View File

@@ -0,0 +1,15 @@
using Content.Server.Objectives.Systems;
using Content.Shared.Humanoid.Prototypes;
using Robust.Shared.Prototypes;
namespace Content.Server.Objectives.Components;
/// <summary>
/// Requires that the player's species matches a whitelist.
/// </summary>
[RegisterComponent, Access(typeof(SpeciesRequirementSystem))]
public sealed partial class SpeciesRequirementComponent : Component
{
[DataField(required: true), ViewVariables(VVAccess.ReadWrite)]
public List<ProtoId<SpeciesPrototype>> AllowedSpecies = new();
}

View File

@@ -1,28 +1,64 @@
using Content.Server.Objectives.Systems;
using Content.Shared.Objectives;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Server.Objectives.Components;
/// <summary>
/// Requires that you steal a certain item.
/// Requires that you steal a certain item (or several)
/// </summary>
[RegisterComponent, Access(typeof(StealConditionSystem))]
public sealed partial class StealConditionComponent : Component
{
/// <summary>
/// The id of the item to steal.
/// A group of items to be stolen
/// </summary>
/// <remarks>
/// Works by prototype id not tags or anything so it has to be the exact item.
/// </remarks>
[DataField(required: true, customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>)), ViewVariables(VVAccess.ReadWrite)]
public string Prototype = string.Empty;
[DataField(required: true)]
public ProtoId<StealTargetGroupPrototype> StealGroup;
/// <summary>
/// When enabled, disables generation of this target if there is no entity on the map (disable for objects that can be created mid-round).
/// </summary>
[DataField]
public bool VerifyMapExistance = true;
/// <summary>
/// If the target may be alive but has died, it will not be counted
/// </summary>
[DataField]
public bool CheckAlive = false;
/// <summary>
/// The minimum number of items you need to steal to fulfill a objective
/// </summary>
[DataField]
public int MinCollectionSize = 1;
/// <summary>
/// The maximum number of items you need to steal to fulfill a objective
/// </summary>
[DataField]
public int MaxCollectionSize = 1;
/// <summary>
/// Target collection size after calculation
/// </summary>
[DataField]
public int CollectionSize;
/// <summary>
/// Help newer players by saying e.g. "steal the chief engineer's advanced magboots"
/// instead of "steal advanced magboots. Should be a loc string.
/// </summary>
[DataField("owner"), ViewVariables(VVAccess.ReadWrite)]
[DataField("owner")]
public string? OwnerText;
// All this need to be loc string
[DataField(required: true)]
public LocId ObjectiveText;
[DataField(required: true)]
public LocId ObjectiveNoOwnerText;
[DataField(required: true)]
public LocId DescriptionText;
[DataField(required: true)]
public LocId DescriptionMultiplyText;
}

View File

@@ -0,0 +1,18 @@
using Content.Server.Objectives.Systems;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Server.Objectives.Components.Targets;
/// <summary>
/// Allows an object to become the target of a StealCollection objection
/// </summary>
[RegisterComponent]
public sealed partial class StealTargetComponent : Component
{
/// <summary>
/// The theft group to which this item belongs.
/// </summary>
[DataField(required: true), ViewVariables(VVAccess.ReadWrite)]
public string StealGroup;
}

View File

@@ -129,6 +129,9 @@ public sealed class ObjectivesSystem : SharedObjectivesSystem
foreach (var objectiveGroup in objectives.GroupBy(o => Comp<ObjectiveComponent>(o).Issuer))
{
//TO DO:
//check for the right group here. Getting the target issuer is easy: objectiveGroup.Key
//It should be compared to the type of the group's issuer.
result += "\n" + Loc.GetString($"objective-issuer-{objectiveGroup.Key}");
foreach (var objective in objectiveGroup)

View File

@@ -0,0 +1,34 @@
using Content.Server.Objectives.Components;
using Content.Shared.Humanoid;
using Content.Shared.Objectives.Components;
namespace Content.Server.Objectives.Systems;
/// <summary>
/// Handles species requirement for objectives that require a certain species.
/// </summary>
public sealed class SpeciesRequirementSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<SpeciesRequirementComponent, RequirementCheckEvent>(OnCheck);
}
private void OnCheck(Entity<SpeciesRequirementComponent> requirement, ref RequirementCheckEvent args)
{
if (args.Cancelled)
return;
if (!TryComp<HumanoidAppearanceComponent>(args.Mind.OwnedEntity, out var appearance)) {
args.Cancelled = true;
return;
}
if (!requirement.Comp.AllowedSpecies.Contains(appearance.Species))
{
args.Cancelled = true;
return;
}
}
}

View File

@@ -1,76 +1,136 @@
using Content.Server.Objectives.Components;
using Content.Server.Objectives.Components.Targets;
using Content.Shared.Mind;
using Content.Shared.Objectives.Components;
using Content.Shared.Objectives.Systems;
using Robust.Shared.Containers;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
using Robust.Shared.Random;
using Content.Shared.Pulling.Components;
using Content.Shared.Objectives;
using Content.Shared.Mind.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.Mobs.Components;
namespace Content.Server.Objectives.Systems;
public sealed class StealConditionSystem : EntitySystem
{
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly IPrototypeManager _proto = default!;
[Dependency] private readonly MetaDataSystem _metaData = default!;
[Dependency] private readonly MobStateSystem _mobState = default!;
[Dependency] private readonly SharedObjectivesSystem _objectives = default!;
private EntityQuery<ContainerManagerComponent> containerQuery;
private EntityQuery<MetaDataComponent> metaQuery;
private EntityQuery<ContainerManagerComponent> _containerQuery;
private EntityQuery<MetaDataComponent> _metaQuery;
public override void Initialize()
{
base.Initialize();
containerQuery = GetEntityQuery<ContainerManagerComponent>();
metaQuery = GetEntityQuery<MetaDataComponent>();
_containerQuery = GetEntityQuery<ContainerManagerComponent>();
_metaQuery = GetEntityQuery<MetaDataComponent>();
SubscribeLocalEvent<StealConditionComponent, ObjectiveAssignedEvent>(OnAssigned);
SubscribeLocalEvent<StealConditionComponent, ObjectiveAfterAssignEvent>(OnAfterAssign);
SubscribeLocalEvent<StealConditionComponent, ObjectiveGetProgressEvent>(OnGetProgress);
}
private void OnAssigned(EntityUid uid, StealConditionComponent comp, ref ObjectiveAssignedEvent args)
/// start checks of target acceptability, and generation of start values.
private void OnAssigned(Entity<StealConditionComponent> condition, ref ObjectiveAssignedEvent args)
{
// cancel if the item to steal doesn't exist
args.Cancelled |= !_proto.HasIndex<EntityPrototype>(comp.Prototype);
List<StealTargetComponent?> targetList = new();
// cancel if invalid TargetStealName
var group = _proto.Index<StealTargetGroupPrototype>(condition.Comp.StealGroup);
if (group == null)
{
args.Cancelled = true;
Log.Error("StealTargetGroup invalid prototype!");
return;
}
var query = EntityQueryEnumerator<StealTargetComponent>();
while (query.MoveNext(out var uid, out var target))
{
if (condition.Comp.StealGroup != target.StealGroup)
continue;
targetList.Add(target);
}
// cancel if the required items do not exist
if (targetList.Count == 0 && condition.Comp.VerifyMapExistance)
{
args.Cancelled = true;
return;
}
//setup condition settings
var maxSize = condition.Comp.VerifyMapExistance
? Math.Min(targetList.Count, condition.Comp.MaxCollectionSize)
: condition.Comp.MaxCollectionSize;
var minSize = condition.Comp.VerifyMapExistance
? Math.Min(targetList.Count, condition.Comp.MinCollectionSize)
: condition.Comp.MinCollectionSize;
condition.Comp.CollectionSize = _random.Next(minSize, maxSize);
}
private void OnAfterAssign(EntityUid uid, StealConditionComponent comp, ref ObjectiveAfterAssignEvent args)
//Set the visual, name, icon for the objective.
private void OnAfterAssign(Entity<StealConditionComponent> condition, ref ObjectiveAfterAssignEvent args)
{
var proto = _proto.Index<EntityPrototype>(comp.Prototype);
var title = comp.OwnerText == null
? Loc.GetString("objective-condition-steal-title-no-owner", ("itemName", proto.Name))
: Loc.GetString("objective-condition-steal-title", ("owner", Loc.GetString(comp.OwnerText)), ("itemName", proto.Name));
var description = Loc.GetString("objective-condition-steal-description", ("itemName", proto.Name));
var group = _proto.Index(condition.Comp.StealGroup);
_metaData.SetEntityName(uid, title, args.Meta);
_metaData.SetEntityDescription(uid, description, args.Meta);
_objectives.SetIcon(uid, new SpriteSpecifier.EntityPrototype(comp.Prototype), args.Objective);
var title =condition.Comp.OwnerText == null
? Loc.GetString(condition.Comp.ObjectiveNoOwnerText, ("itemName", group.Name))
: Loc.GetString(condition.Comp.ObjectiveText, ("owner", Loc.GetString(condition.Comp.OwnerText)), ("itemName", group.Name));
var description = condition.Comp.CollectionSize > 1
? Loc.GetString(condition.Comp.DescriptionMultiplyText, ("itemName", group.Name), ("count", condition.Comp.CollectionSize))
: Loc.GetString(condition.Comp.DescriptionText, ("itemName", group.Name));
_metaData.SetEntityName(condition.Owner, title, args.Meta);
_metaData.SetEntityDescription(condition.Owner, description, args.Meta);
_objectives.SetIcon(condition.Owner, group.Sprite, args.Objective);
}
private void OnGetProgress(Entity<StealConditionComponent> condition, ref ObjectiveGetProgressEvent args)
{
args.Progress = GetProgress(args.Mind, condition);
}
private void OnGetProgress(EntityUid uid, StealConditionComponent comp, ref ObjectiveGetProgressEvent args)
private float GetProgress(MindComponent mind, StealConditionComponent condition)
{
args.Progress = GetProgress(args.Mind, comp.Prototype);
}
private float GetProgress(MindComponent mind, string prototype)
{
// TODO make this a container system function
// or: just iterate through transform children, instead of containers?
if (!metaQuery.TryGetComponent(mind.OwnedEntity, out var meta))
if (!_metaQuery.TryGetComponent(mind.OwnedEntity, out var meta))
return 0;
if (!_containerQuery.TryGetComponent(mind.OwnedEntity, out var currentManager))
return 0;
// who added this check bruh
if (meta.EntityPrototype?.ID == prototype)
return 1;
var stack = new Stack<ContainerManagerComponent>();
var count = 0;
if (!containerQuery.TryGetComponent(mind.OwnedEntity, out var currentManager))
return 0;
//check pulling object
if (TryComp<SharedPullerComponent>(mind.OwnedEntity, out var pull)) //TO DO: to make the code prettier? don't like the repetition
{
var pullid = pull.Pulling;
if (pullid != null)
{
// check if this is the item
if (CheckStealTarget(pullid.Value, condition)) count++;
//we don't check the inventories of sentient entity
if (!TryComp<MindContainerComponent>(pullid, out var pullMind))
{
// if it is a container check its contents
if (_containerQuery.TryGetComponent(pullid, out var containerManager))
stack.Push(containerManager);
}
}
}
// recursively check each container for the item
// checks inventory, bag, implants, etc.
var stack = new Stack<ContainerManagerComponent>();
do
{
foreach (var container in currentManager.Containers.Values)
@@ -78,16 +138,38 @@ public sealed class StealConditionSystem : EntitySystem
foreach (var entity in container.ContainedEntities)
{
// check if this is the item
if (metaQuery.GetComponent(entity).EntityPrototype?.ID == prototype)
return 1;
if (CheckStealTarget(entity, condition)) count++; //To Do: add support for stackable items
// if it is a container check its contents
if (containerQuery.TryGetComponent(entity, out var containerManager))
if (_containerQuery.TryGetComponent(entity, out var containerManager))
stack.Push(containerManager);
}
}
} while (stack.TryPop(out currentManager));
return 0;
var result = (float) count / (float) condition.CollectionSize;
result = Math.Clamp(result, 0, 1);
return result;
}
private bool CheckStealTarget(EntityUid entity, StealConditionComponent condition)
{
// check if this is the target
if (!TryComp<StealTargetComponent>(entity, out var target))
return false;
if (target.StealGroup != condition.StealGroup)
return false;
// check if needed target alive
if (condition.CheckAlive)
{
if (TryComp<MobStateComponent>(entity, out var state))
{
if (!_mobState.IsAlive(entity))
return false;
}
}
return true;
}
}