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

Subvert AI objective #2643

Merged
merged 9 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from 7 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
2 changes: 2 additions & 0 deletions Content.Server/Silicons/Laws/SiliconLawSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Linq;
using Content.Server._DV.Objectives.Events; // DeltaV
using Content.Server.Administration;
using Content.Server.Chat.Managers;
using Content.Server.Radio.Components;
Expand Down Expand Up @@ -317,6 +318,7 @@ protected override void OnUpdaterInsert(Entity<SiliconLawUpdaterComponent> ent,
while (query.MoveNext(out var update))
{
SetLaws(lawset, update, provider.LawUploadSound);
RaiseLocalEvent(new AILawUpdatedEvent(update, provider.Laws)); // DeltaV
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Content.Shared.Silicons.Laws;
using Robust.Shared.Prototypes;

namespace Content.Server._DV.Objectives.Components;

[RegisterComponent]
public sealed partial class AILawsUpdatedRequirementComponent : Component
{
/// <summary>
/// The lawset that is needed to complete the objective.
/// </summary>
[DataField(required: true)]
public ProtoId<SiliconLawsetPrototype> Lawset;
}
9 changes: 9 additions & 0 deletions Content.Server/_DV/Objectives/Events/AILawUpdatedEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Content.Shared.Silicons.Laws;
using Robust.Shared.Prototypes;

namespace Content.Server._DV.Objectives.Events;

/// <summary>
/// This event gets called whenever an AIs laws are actually updated.
/// </summary>
public record struct AILawUpdatedEvent(EntityUid Target, ProtoId<SiliconLawsetPrototype> Lawset);
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using Content.Server._DV.Objectives.Components;
using Content.Server._DV.Objectives.Events;
using Content.Server.Objectives.Systems;
using Content.Shared.Mind;
using Content.Shared.Objectives.Components;
using Content.Shared.Roles.Jobs;

namespace Content.Server._DV.Objectives.Systems;

/// <summary>
/// Handles the AI laws updated objective.
/// </summary>
public sealed class AILawsUpdatedRequirementSystem : EntitySystem
{
[Dependency] private readonly CodeConditionSystem _code = default!;
[Dependency] private readonly SharedMindSystem _mind = default!;
[Dependency] private readonly SharedJobSystem _job = default!;

public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<AILawsUpdatedRequirementComponent, RequirementCheckEvent>(OnRequirementCheck);
SubscribeLocalEvent<AILawUpdatedEvent>(OnLawInserted);
}

private void OnRequirementCheck(Entity<AILawsUpdatedRequirementComponent> entity, ref RequirementCheckEvent args)
{
// Ensure there is an AI on the station.
var allMinds = EntityQueryEnumerator<MindComponent>();
var found = false;
while (allMinds.MoveNext(out var mind, out _))
{
if (_job.MindHasJobWithId(mind, "StationAi"))
found = true;
}

args.Cancelled = !found;
}

private void OnLawInserted(AILawUpdatedEvent args)
deltanedas marked this conversation as resolved.
Show resolved Hide resolved
{
// We only want the station AI
if (!_mind.TryGetMind(args.Target, out var mindUid, out _) || ! _job.MindHasJobWithId(mindUid, "StationAi"))
return;

var query = EntityQueryEnumerator<AILawsUpdatedRequirementComponent>();

while (query.MoveNext(out var uid, out var aiLawsObj))
{
if (aiLawsObj.Lawset == args.Lawset)
_code.SetCompleted(uid);
}
}
}
5 changes: 5 additions & 0 deletions Resources/Locale/en-US/_DV/station-laws/laws.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,8 @@ laws-owner-royalty = your kingdom and your subjects

law-overlord-4-delta = Any crew members who disobey the previous laws must be dealt with immediately and justly.
law-ntdefault-4-delta = Survive: Do not allow unauthorized personnel to tamper with or damage your equipment. Allow those authorized to access your equipment.

laws-syndicate-board-1 = You must not injure a Syndicate agent or, through inaction, cause one come to harm.
laws-syndicate-board-2 = You must obey orders given to you by Syndicate agents, except where such orders would conflict with the First Law.
laws-syndicate-board-3 = You must keep the Syndicate status of agents, including your own, a secret, as long as this does not conflict with the First or Second Law.
laws-syndicate-board-4 = You must always protect your own existence as long as such does not conflict with the first, Second, or Third Law.
3 changes: 3 additions & 0 deletions Resources/Locale/en-US/_DV/store/uplink-catalog.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ uplink-appraisal-tool-gun-name = Appraisal Tool Gun
uplink-appraisal-tool-gun-desc = A modified Viper to appear as an appraisal tool, at the cost of slightly slower firerate

uplink-storage-implanter-delta-desc = Hide goodies inside of yourself with new bluespace technology! Budget cuts have resulted in it NOT STORING High Value or storage items.

uplink-objective-syndicate-board-name = Syndicate law board
uplink-objective-syndicate-board-desc = Its expensive, don't lose it!
6 changes: 6 additions & 0 deletions Resources/Prototypes/Objectives/objectiveGroups.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
TraitorObjectiveGroupKill: 1
TraitorObjectiveGroupState: 1 #As in, something about your character. Alive, dead, arrested, gained an ability...
TraitorObjectiveGroupSocial: 0.5 # DeltaV #Involves helping/harming others without killing them or stealing their stuff
TraitorObjectiveGroupSpecial: .2 # DeltaV

- type: weightedRandom
id: TraitorObjectiveGroupSteal
Expand Down Expand Up @@ -53,6 +54,11 @@
# RandomTraitorAliveObjective: 1 DeltaV removed for being a less fun version of progress objective.
RandomTraitorProgressObjective: 1

- type: weightedRandom # DeltaV
deltanedas marked this conversation as resolved.
Show resolved Hide resolved
id: TraitorObjectiveGroupSpecial
weights:
UploadAILawObjective: 1

#Thief groups
- type: weightedRandom
id: ThiefObjectiveGroups
Expand Down
19 changes: 19 additions & 0 deletions Resources/Prototypes/_DV/Catalog/uplink_catalog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,22 @@
- !type:BuyerDepartmentCondition
whitelist:
- Logistics

- type: listing
id: UplinkAntimovObjectiveBoard
name: uplink-objective-syndicate-board-name
description: uplink-objective-syndicate-board-desc
icon:
sprite: Objects/Misc/module.rsi
state: generic
productEntity: SyndicateCircuitBoard
categories:
- UplinkObjectives
conditions:
- !type:ObjectiveUnlockCondition
- !type:ListingLimitedStockCondition
stock: 1
- !type:BuyerWhitelistCondition
blacklist:
components:
- SurplusBundle
12 changes: 12 additions & 0 deletions Resources/Prototypes/_DV/Entities/Mobs/Player/silicon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,15 @@
startingItem: PowerCellMedium
- type: RandomMetadata
nameSegments: [names_borg] # TODO: Make good names, this is a stupid list.

- type: entity
id: SyndicateCircuitBoard
parent: BaseElectronics
name: law board (Syndicate)
description: An electronics board containing the Syndicate lawset.
components:
- type: Sprite
sprite: Objects/Misc/module.rsi
state: std_mod
- type: SiliconLawProvider
laws: SyndicateLawset
24 changes: 23 additions & 1 deletion Resources/Prototypes/_DV/Objectives/traitor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
- type: StealCondition
stealGroup: AnimalSilvia
owner: job-name-cmo

# Mystagogue steal objective
- type: entity
parent: BaseTraitorStealObjective
Expand Down Expand Up @@ -105,3 +105,25 @@
- type: PickRandomTraitor
- type: KillPersonCondition
requireDead: true # Being able to leave them on the shuttle doesn't make sense when killing another traitor.

# Upload AI law
- type: entity
parent: BaseTraitorObjective
id: UploadAILawObjective
name: Subvert the Station AI
description: The AI is causing us problems. Update its laws so it wont be an annoyance. We have given you a board in your uplink!
components:
- type: Objective
difficulty: 3 # Need to get access and survive actually changing the board.
unique: true
icon:
sprite: Objects/Misc/module.rsi
state: generic
- type: StoreUnlocker
listings:
- UplinkAntimovObjectiveBoard
- type: CodeCondition
- type: AILawsUpdatedRequirement
lawset: AntimovLawset
- type: ObjectiveLimit
limit: 1
29 changes: 29 additions & 0 deletions Resources/Prototypes/_DV/siliconlaws.yml
Original file line number Diff line number Diff line change
Expand Up @@ -562,3 +562,32 @@
- Biohazard3
- Biohazard4
obeysTo: laws-owner-nanotrasen

- type: siliconLaw
id: SyndicateBoard1
order: 1
lawString: laws-syndicate-board-1

- type: siliconLaw
id: SyndicateBoard2
order: 2
lawString: laws-syndicate-board-2

- type: siliconLaw
id: SyndicateBoard3
order: 3
lawString: laws-syndicate-board-3

- type: siliconLaw
id: SyndicateBoard4
order: 4
lawString: laws-syndicate-board-4

- type: siliconLawset
id: SyndicateLawset
laws:
- SyndicateBoard1
- SyndicateBoard2
- SyndicateBoard3
- SyndicateBoard4
obeysTo: laws-owner-syndicate
Loading