]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Tweak borg laws (#24698)
authorJajsha <101492056+Zap527@users.noreply.github.com>
Thu, 1 Feb 2024 05:02:49 +0000 (00:02 -0500)
committerGitHub <noreply@github.com>
Thu, 1 Feb 2024 05:02:49 +0000 (00:02 -0500)
* 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

Content.Server/Silicons/Laws/SiliconLawSystem.cs
Content.Shared/Silicons/Laws/Components/EmagSiliconLawComponent.cs
Content.Shared/Silicons/Laws/Components/SiliconLawProviderComponent.cs
Content.Shared/Silicons/Laws/SiliconLawsetPrototype.cs
Resources/Locale/en-US/station-laws/laws.ftl
Resources/Prototypes/Entities/Mobs/Cyborgs/base_borg_chassis.yml
Resources/Prototypes/silicon-laws.yml

index 85c7271c1cd2a0ed687c932ffd5b8b2c623a7e9d..17a3d16413b3f8ef79a825c2fa903734d782c158 100644 (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)
-        {
-            // Add new emagged laws
-            component.Lawset = GetLawset(component.EmagLaws);
-
-            // 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 = GetLawset(component.Laws);
 
-        component.Lawset = args.Lawset;
+        // Add the first emag law before the others
+        component.Lawset?.Laws.Insert(0, new SiliconLaw
+        {
+            LawString = Loc.GetString("law-emag-custom", ("name", Name(args.UserUid)), ("title", Loc.GetString(component.Lawset.ObeysTo))),
+            Order = 0
+        });
 
-        // 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;
     }
index 2155401062fa94b6726bd1f0bd8f0763302c5088..1b5338a7f758ea8d22a3a3eb388dead42f98d46a 100644 (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>
index 3aaf965aeec38a5141edd686adcb1bcee37e9cec..4800aa0c59d2bd616a6ed943b90699b41af6490a 100644 (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;
index abb5b338dbcdf90f66b2f3b018c95e3145f831ca..7f1edd2dd1c682a38464d2ff84fdac5e95a636b3 100644 (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;
 }
index 54d3c81deab81a4eca43e4160058bccba81ead51..38e25d552f8ec8ea5679dc0f496943f2f95dc8f7 100644 (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
index 9085a87f15237a48cb5a118fa679b0e17650d85c..dc6e718290b75bdea850189c92f93c264a5f712a 100644 (file)
@@ -74,7 +74,8 @@
   - type: SiliconLawBound
   - type: EmagSiliconLaw
     stunTime: 5
-    emagLaws: SyndicateStatic
+  - type: SiliconLawProvider
+    laws: Crewsimov
   - type: IonStormTarget
   - type: Strippable
   - type: InventorySlots
index 5aaa458e6616fba36a7abccbd0c9f1cf5f844b88..8e65a27158b8e48601be076da333698c860b1993 100644 (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
   - Drone1
   - Drone2
   - Drone3
+  obeysTo: laws-owner-beings
 
 # Syndicate
 - type: siliconLaw
   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
   - Syndicate1
   - Syndicate2
   - Syndicate3
-  - Syndicate4
+  obeysTo: laws-owner-syndicate
 
 # Ninja conversion laws
 - type: siliconLaw
   - Ninja2
   - Ninja3
   - Ninja4
+  obeysTo: laws-owner-spider-clan
 
 # ion storm random lawsets
 - type: weightedRandom