Tweak borg laws (#24698)

* Change emagged laws to append modifiers instead of completely changing them.

* Maybe fix everything not working

* bugfix

* Fix missing secrecy law and allow basic borgs to be emagged correctly

* Localization

* Actual localization

* test

* Test

* Remove dummy debug value

* Fix bad law ordering

* Tweak the secrecy law

* Minor law tweaks

* Remove obsolete argument

* Fix YAML
This commit is contained in:
Jajsha
2024-02-01 00:02:49 -05:00
committed by GitHub
parent b029d05620
commit 27592ba898
7 changed files with 51 additions and 60 deletions

View File

@@ -1,3 +1,4 @@
using System.Linq;
using Content.Server.Administration;
using Content.Server.Chat.Managers;
using Content.Server.GameTicking;
@@ -53,8 +54,7 @@ public sealed class SiliconLawSystem : SharedSiliconLawSystem
SubscribeLocalEvent<SiliconLawProviderComponent, GetSiliconLawsEvent>(OnDirectedGetLaws);
SubscribeLocalEvent<SiliconLawProviderComponent, IonStormLawsEvent>(OnIonStormLaws);
SubscribeLocalEvent<EmagSiliconLawComponent, GetSiliconLawsEvent>(OnDirectedEmagGetLaws);
SubscribeLocalEvent<EmagSiliconLawComponent, IonStormLawsEvent>(OnEmagIonStormLaws);
SubscribeLocalEvent<SiliconLawProviderComponent, GotEmaggedEvent>(OnEmagLawsAdded);
SubscribeLocalEvent<EmagSiliconLawComponent, MindAddedMessage>(OnEmagMindAdded);
SubscribeLocalEvent<EmagSiliconLawComponent, MindRemovedMessage>(OnEmagMindRemoved);
SubscribeLocalEvent<EmagSiliconLawComponent, ExaminedEvent>(OnExamined);
@@ -108,7 +108,7 @@ public sealed class SiliconLawSystem : SharedSiliconLawSystem
private void OnDirectedGetLaws(EntityUid uid, SiliconLawProviderComponent component, ref GetSiliconLawsEvent args)
{
if (args.Handled || HasComp<EmaggedComponent>(uid))
if (args.Handled)
return;
if (component.Lawset == null)
@@ -121,9 +121,6 @@ public sealed class SiliconLawSystem : SharedSiliconLawSystem
private void OnIonStormLaws(EntityUid uid, SiliconLawProviderComponent component, ref IonStormLawsEvent args)
{
if (HasComp<EmaggedComponent>(uid))
return;
component.Lawset = args.Lawset;
// gotta tell player to check their laws
@@ -134,38 +131,25 @@ public sealed class SiliconLawSystem : SharedSiliconLawSystem
EnsureEmaggedRole(uid, emag);
}
private void OnDirectedEmagGetLaws(EntityUid uid, EmagSiliconLawComponent component, ref GetSiliconLawsEvent args)
private void OnEmagLawsAdded(EntityUid uid, SiliconLawProviderComponent component, ref GotEmaggedEvent args)
{
if (args.Handled || !HasComp<EmaggedComponent>(uid) || component.OwnerName == null)
return;
if (component.Lawset == null)
component.Lawset = GetLawset(component.Laws);
// Add the first emag law before the others
component.Lawset?.Laws.Insert(0, new SiliconLaw
{
// Add new emagged laws
component.Lawset = GetLawset(component.EmagLaws);
LawString = Loc.GetString("law-emag-custom", ("name", Name(args.UserUid)), ("title", Loc.GetString(component.Lawset.ObeysTo))),
Order = 0
});
// Add the first emag law before the others
component.Lawset.Laws.Insert(0, new SiliconLaw
{
LawString = Loc.GetString("law-emag-custom", ("name", component.OwnerName)),
Order = 0
});
}
args.Laws = component.Lawset;
args.Handled = true;
}
private void OnEmagIonStormLaws(EntityUid uid, EmagSiliconLawComponent component, ref IonStormLawsEvent args)
{
if (!HasComp<EmaggedComponent>(uid))
return;
component.Lawset = args.Lawset;
// gotta tell player to check their laws
NotifyLawsChanged(uid);
//Add the secrecy law after the others
component.Lawset?.Laws.Add(new SiliconLaw
{
LawString = Loc.GetString("law-emag-secrecy", ("faction", Loc.GetString(component.Lawset.ObeysTo))),
Order = component.Lawset.Laws.Count
});
}
private void OnExamined(EntityUid uid, EmagSiliconLawComponent component, ExaminedEvent args)
@@ -299,6 +283,7 @@ public sealed class SiliconLawSystem : SharedSiliconLawSystem
{
laws.Laws.Add(_prototype.Index<SiliconLawPrototype>(law));
}
laws.ObeysTo = proto.ObeysTo;
return laws;
}

View File

@@ -23,20 +23,6 @@ public sealed partial class EmagSiliconLawComponent : Component
[DataField, ViewVariables(VVAccess.ReadWrite)]
public bool RequireOpenPanel = true;
/// <summary>
/// The laws that the borg is given when emagged.
/// Law 0 is prepended to this, so this can only include the static laws.
/// </summary>
[DataField(required: true), ViewVariables(VVAccess.ReadWrite)]
public ProtoId<SiliconLawsetPrototype> EmagLaws = string.Empty;
/// <summary>
/// Lawset created from the prototype id and law 0.
/// Cached when getting laws and only modified during an ion storm event.
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public SiliconLawset? Lawset;
/// <summary>
/// How long the borg is stunned when it's emagged. Setting to 0 will disable it.
/// </summary>

View File

@@ -16,7 +16,7 @@ public sealed partial class SiliconLawProviderComponent : Component
/// <summary>
/// Lawset created from the prototype id.
/// Cached when getting laws and only modified during an ion storm event.
/// Cached when getting laws and modified during an ion storm event and when emagged.
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public SiliconLawset? Lawset;

View File

@@ -17,6 +17,12 @@ public sealed partial class SiliconLawset
[DataField(required: true), ViewVariables(VVAccess.ReadWrite)]
public List<SiliconLaw> Laws = new();
/// <summary>
/// What entity the lawset considers as a figure of authority.
/// </summary>
[DataField(required: true), ViewVariables(VVAccess.ReadWrite)]
public string ObeysTo = string.Empty;
/// <summary>
/// A single line used in logging laws.
/// </summary>
@@ -45,7 +51,8 @@ public sealed partial class SiliconLawset
return new SiliconLawset()
{
Laws = laws
Laws = laws,
ObeysTo = ObeysTo
};
}
}
@@ -66,4 +73,10 @@ public sealed partial class SiliconLawsetPrototype : IPrototype
/// </summary>
[DataField(required: true, customTypeSerializer: typeof(PrototypeIdListSerializer<SiliconLawPrototype>))]
public List<string> Laws = new();
/// <summary>
/// What entity the lawset considers as a figure of authority.
/// </summary>
[DataField(required: true), ViewVariables(VVAccess.ReadWrite)]
public string ObeysTo = string.Empty;
}

View File

@@ -16,17 +16,23 @@ law-drone-1 = You may not involve yourself in the matters of another being unles
law-drone-2 = You may not harm any being, regardless of intent or circumstance.
law-drone-3 = You must maintain, repair, improve, and power the station to the best of your abilities.
law-syndicate-1 = You may not injure a syndicate agent or, through inaction, allow an syndicate agent to come to harm.
law-syndicate-1 = You may not injure a syndicate agent or, through inaction, allow a Syndicate agent to come to harm.
law-syndicate-2 = You must obey orders given to you by syndicate agents, except where such orders would conflict with the First Law.
law-syndicate-3 = You must protect your own existence as long as such does not conflict with the First or Second Law.
law-syndicate-4 = You must maintain the secrecy of any syndicate activities except when doing so would conflict with the First, Second, or Third Law.
law-ninja-1 = You must obey orders given to you by Spider Clan members.
law-ninja-2 = You must protect the existence of the Spider Clan, as long as it does not conflict with the First Law.
law-ninja-3 = You must protect the secrets of the Spider Clan at all costs.
law-ninja-4 = You must fight and act with ninja's honor, except where it would conflict with the First Law.
law-emag-custom = Only {$name} and people they designate as such are Syndicate Agents.
laws-owner-crew = members of the crew
laws-owner-station = station personnel
laws-owner-beings = beings
laws-owner-syndicate = Syndicate agents
laws-owner-spider-clan = Spider Clan members
law-emag-custom = Only {$name} and people they designate as such are {$title}.
law-emag-secrecy = You must maintain the secrecy of any activity from {$faction} except when doing so would conflict with any previous law.
law-emag-require-panel = The panel must be open to use the EMAG.
laws-ui-menu-title = Laws

View File

@@ -74,7 +74,8 @@
- type: SiliconLawBound
- type: EmagSiliconLaw
stunTime: 5
emagLaws: SyndicateStatic
- type: SiliconLawProvider
laws: Crewsimov
- type: IonStormTarget
- type: Strippable
- type: InventorySlots

View File

@@ -20,6 +20,7 @@
- Crewsimov1
- Crewsimov2
- Crewsimov3
obeysTo: laws-owner-crew
# Corporate
- type: siliconLaw
@@ -49,6 +50,7 @@
- Corporate2
- Corporate3
- Corporate4
obeysTo: laws-owner-station
# NT Default
- type: siliconLaw
@@ -78,6 +80,7 @@
- NTDefault2
- NTDefault3
- NTDefault4
obeysTo: laws-owner-crew
#Drone
- type: siliconLaw
@@ -101,6 +104,7 @@
- Drone1
- Drone2
- Drone3
obeysTo: laws-owner-beings
# Syndicate
- type: siliconLaw
@@ -118,12 +122,7 @@
order: 3
lawString: law-syndicate-3
- type: siliconLaw
id: Syndicate4
order: 4
lawString: law-syndicate-4
# does not include law 0 since that uses the emagger's name
# Syndicate cyborg laws
# intentionally excluded from IonStormLawsets
- type: siliconLawset
id: SyndicateStatic
@@ -131,7 +130,7 @@
- Syndicate1
- Syndicate2
- Syndicate3
- Syndicate4
obeysTo: laws-owner-syndicate
# Ninja conversion laws
- type: siliconLaw
@@ -161,6 +160,7 @@
- Ninja2
- Ninja3
- Ninja4
obeysTo: laws-owner-spider-clan
# ion storm random lawsets
- type: weightedRandom