]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Cleaned up a bit of the Derelict Cyborg code.
authorThe Canned One <greentopcan@gmail.com>
Tue, 1 Oct 2024 08:02:25 +0000 (10:02 +0200)
committerThe Canned One <greentopcan@gmail.com>
Tue, 1 Oct 2024 08:02:25 +0000 (10:02 +0200)
Content.Server/Silicons/Laws/IonStormSystem.cs
Content.Server/Silicons/Laws/StartIonStormedSystem.cs
Content.Shared/Silicons/Laws/Components/StartIonStormedComponent.cs
Resources/Locale/en-US/silicons/derelict-cyborg-role.ftl [new file with mode: 0644]
Resources/Locale/en-US/silicons/derelict/role.ftl [deleted file]
Resources/Prototypes/Entities/Mobs/Cyborgs/base_borg_chassis.yml
Resources/Prototypes/GameRules/events.yml

index 1acfe2e3896fa560edbdf73fc6f94796185c19e5..87df0d8cf2c259a4dd3094db5f23c4e8b4b99bc7 100644 (file)
@@ -60,108 +60,108 @@ public sealed class IonStormSystem : EntitySystem
     [ValidatePrototypeId<DatasetPrototype>]
     private const string Foods = "IonStormFoods";
 
-    public void IonStormTarget(EntityUid ent, SiliconLawBoundComponent lawBound, TransformComponent xform, IonStormTargetComponent target, EntityUid? chosenStation, bool ignoreStation = false, bool DoNotAdminlog = false)
+    public void IonStormTarget(EntityUid ent, SiliconLawBoundComponent lawBound, TransformComponent xform, IonStormTargetComponent target, EntityUid? chosenStation, bool ignoreStation = false, bool adminlog = true)
     {
-            // only affect law holders on the station unless ignoreStation is true.
-            if (CompOrNull<StationMemberComponent>(xform.GridUid)?.Station != chosenStation && !ignoreStation)
-                return;
+        // only affect law holders on the station unless ignoreStation is true.
+        if (CompOrNull<StationMemberComponent>(xform.GridUid)?.Station != chosenStation && !ignoreStation)
+            return;
 
-            if (!_robustRandom.Prob(target.Chance))
-                return;
+        if (!_robustRandom.Prob(target.Chance))
+            return;
 
-            var laws = _siliconLaw.GetLaws(ent, lawBound);
-            if (laws.Laws.Count == 0)
-                return;
+        var laws = _siliconLaw.GetLaws(ent, lawBound);
+        if (laws.Laws.Count == 0)
+            return;
 
-            // try to swap it out with a random lawset
-            if (_robustRandom.Prob(target.RandomLawsetChance))
-            {
-                var lawsets = _proto.Index<WeightedRandomPrototype>(target.RandomLawsets);
-                var lawset = lawsets.Pick(_robustRandom);
-                laws = _siliconLaw.GetLawset(lawset);
-            }
-            else
+        // try to swap it out with a random lawset
+        if (_robustRandom.Prob(target.RandomLawsetChance))
+        {
+            var lawsets = _proto.Index<WeightedRandomPrototype>(target.RandomLawsets);
+            var lawset = lawsets.Pick(_robustRandom);
+            laws = _siliconLaw.GetLawset(lawset);
+        }
+        else
+        {
+            // clone it so not modifying stations lawset
+            laws = laws.Clone();
+        }
+
+        // shuffle them all
+        if (_robustRandom.Prob(target.ShuffleChance))
+        {
+            // hopefully work with existing glitched laws if there are multiple ion storms
+            FixedPoint2 baseOrder = FixedPoint2.New(1);
+            foreach (var law in laws.Laws)
             {
-                // clone it so not modifying stations lawset
-                laws = laws.Clone();
+                if (law.Order < baseOrder)
+                    baseOrder = law.Order;
             }
 
-            // shuffle them all
-            if (_robustRandom.Prob(target.ShuffleChance))
+            _robustRandom.Shuffle(laws.Laws);
+
+            // change order based on shuffled position
+            for (int i = 0; i < laws.Laws.Count; i++)
             {
-                // hopefully work with existing glitched laws if there are multiple ion storms
-                FixedPoint2 baseOrder = FixedPoint2.New(1);
-                foreach (var law in laws.Laws)
-                {
-                    if (law.Order < baseOrder)
-                        baseOrder = law.Order;
-                }
+                laws.Laws[i].Order = baseOrder + i;
+            }
+        }
 
-                _robustRandom.Shuffle(laws.Laws);
+        // see if we can remove a random law
+        if (laws.Laws.Count > 0 && _robustRandom.Prob(target.RemoveChance))
+        {
+            var i = _robustRandom.Next(laws.Laws.Count);
+            laws.Laws.RemoveAt(i);
+        }
 
-                // change order based on shuffled position
-                for (int i = 0; i < laws.Laws.Count; i++)
-                {
-                    laws.Laws[i].Order = baseOrder + i;
-                }
-            }
+        // generate a new law...
+        var newLaw = GenerateLaw();
 
-            // see if we can remove a random law
-            if (laws.Laws.Count > 0 && _robustRandom.Prob(target.RemoveChance))
+        // see if the law we add will replace a random existing law or be a new glitched order one
+        if (laws.Laws.Count > 0 && _robustRandom.Prob(target.ReplaceChance))
+        {
+            var i = _robustRandom.Next(laws.Laws.Count);
+            laws.Laws[i] = new SiliconLaw()
             {
-                var i = _robustRandom.Next(laws.Laws.Count);
-                laws.Laws.RemoveAt(i);
-            }
+                LawString = newLaw,
+                Order = laws.Laws[i].Order
+            };
+        }
+        else
+        {
+            laws.Laws.Insert(0, new SiliconLaw
+            {
+                LawString = newLaw,
+                Order = -1,
+                LawIdentifierOverride = Loc.GetString("ion-storm-law-scrambled-number", ("length", _robustRandom.Next(5, 10)))
+            });
+        }
+
+        // sets all unobfuscated laws' indentifier in order from highest to lowest priority
+        // This could technically override the Obfuscation from the code above, but it seems unlikely enough to basically never happen
+        int orderDeduction = -1;
 
-            // generate a new law...
-            var newLaw = GenerateLaw();
+        for (int i = 0; i < laws.Laws.Count; i++)
+        {
+            string notNullIdentifier = laws.Laws[i].LawIdentifierOverride ?? (i - orderDeduction).ToString();
 
-            // see if the law we add will replace a random existing law or be a new glitched order one
-            if (laws.Laws.Count > 0 && _robustRandom.Prob(target.ReplaceChance))
+            if (notNullIdentifier.Any(char.IsSymbol))
             {
-                var i = _robustRandom.Next(laws.Laws.Count);
-                laws.Laws[i] = new SiliconLaw()
-                {
-                    LawString = newLaw,
-                    Order = laws.Laws[i].Order
-                };
+                orderDeduction += 1;
             }
             else
             {
-                laws.Laws.Insert(0, new SiliconLaw
-                {
-                    LawString = newLaw,
-                    Order = -1,
-                    LawIdentifierOverride = Loc.GetString("ion-storm-law-scrambled-number", ("length", _robustRandom.Next(5, 10)))
-                });
-            }
-
-            // sets all unobfuscated laws' indentifier in order from highest to lowest priority
-            // This could technically override the Obfuscation from the code above, but it seems unlikely enough to basically never happen
-            int orderDeduction = -1;
-
-            for (int i = 0; i < laws.Laws.Count; i++)
-            {
-                string notNullIdentifier = laws.Laws[i].LawIdentifierOverride ?? (i - orderDeduction).ToString();
-
-                if (notNullIdentifier.Any(char.IsSymbol))
-                {
-                    orderDeduction += 1;
-                }
-                else
-                {
-                    laws.Laws[i].LawIdentifierOverride = (i - orderDeduction).ToString();
-                }
+                laws.Laws[i].LawIdentifierOverride = (i - orderDeduction).ToString();
             }
+        }
 
-            //DoNotAdminlog is used to prevent adminlog spam.
-            if (!DoNotAdminlog)
-                _adminLogger.Add(LogType.Mind, LogImpact.High, $"{ToPrettyString(ent):silicon} had its laws changed by an ion storm to {laws.LoggingString()}");
+        // adminlog is used to prevent adminlog spam.
+        if (adminlog)
+            _adminLogger.Add(LogType.Mind, LogImpact.High, $"{ToPrettyString(ent):silicon} had its laws changed by an ion storm to {laws.LoggingString()}");
 
-            // laws unique to this silicon, dont use station laws anymore
-            EnsureComp<SiliconLawProviderComponent>(ent);
-            var ev = new IonStormLawsEvent(laws);
-            RaiseLocalEvent(ent, ref ev);
+        // laws unique to this silicon, dont use station laws anymore
+        EnsureComp<SiliconLawProviderComponent>(ent);
+        var ev = new IonStormLawsEvent(laws);
+        RaiseLocalEvent(ent, ref ev);
     }
 
     // for your own sake direct your eyes elsewhere
index 4b1b4da033d46937d3e56489d7beb425724cb5c3..f7b65e1a041f1fc052974f4e90e7b68a96e14547 100644 (file)
@@ -6,7 +6,7 @@ using Content.Shared.Silicons.Laws;
 namespace Content.Server.Silicons.Laws;
 
 /// <summary>
-/// This handles running the ion storm event on specific entities when spawned in.
+/// This handles running the ion storm event a on specific entity when that entity is spawned in.
 /// </summary>
 public sealed class StartIonStormedSystem : EntitySystem
 {
@@ -31,7 +31,7 @@ public sealed class StartIonStormedSystem : EntitySystem
 
         for (int currentIonStorm = 0; currentIonStorm < component.IonStormAmount; currentIonStorm++)
         {
-            _ionStorm.IonStormTarget(uid, lawBound, xform, target, null, true, true);
+            _ionStorm.IonStormTarget(uid, lawBound, xform, target, null, true, false);
         }
 
         var laws = _siliconLaw.GetLaws(uid, lawBound);
index ae9b49a49cfae759a5e34384bd18c282031e8005..4157bee9f2dbfc89e7e77f7c5c651cad5cc374ee 100644 (file)
@@ -1,10 +1,8 @@
-using Content.Shared.Random;
-using Robust.Shared.Prototypes;
 
 namespace Content.Shared.Silicons.Laws.Components;
 
 /// <summary>
-/// Runs the IonStormSystem on an entity IonStormAmount times.
+/// Applies law altering ion storms on a specific entity IonStormAmount times when the entity is spawned.
 /// </summary>
 [RegisterComponent]
 public sealed partial class StartIonStormedComponent : Component
diff --git a/Resources/Locale/en-US/silicons/derelict-cyborg-role.ftl b/Resources/Locale/en-US/silicons/derelict-cyborg-role.ftl
new file mode 100644 (file)
index 0000000..87e500d
--- /dev/null
@@ -0,0 +1 @@
+derelict-cyborg-round-end-agent-name = derelict cyborg
\ No newline at end of file
diff --git a/Resources/Locale/en-US/silicons/derelict/role.ftl b/Resources/Locale/en-US/silicons/derelict/role.ftl
deleted file mode 100644 (file)
index 96a33ae..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-derelict-cyborg-round-end-agent-name = derelict cyborg
-
-derelict-cyborg-role-greeting =
-    You are a cyborg that has been lost in space for many years that has now drifted close to a space station. You can use your fire extinguisher and GPS to get board the station. Remember to follow your laws.
\ No newline at end of file
index 2fc04a6aa9cd97dd723f4f9c3b25ea6d875ef369..f94436dc3361011956150a61d56aa1e742ab9705 100644 (file)
     - AllAccess #Randomized access would be fun. AllAccess is the best i can think of right now that does make it too hard for it to enter the station or navigate it..
   - type: AccessReader
     access: [["Command"], ["Research"]]
-  - type: IntrinsicRadioTransmitter
-    channels:
-    - Binary
-    - Common
-    - Science
-  - type: ActiveRadio
-    channels:
-    - Binary
-    - Common
-    - Science
   - type: StartIonStormed
     ionStormAmount: 5
   - type: IonStormTarget
index 72ab8b104d0d718fd319a61a2c33c4235ccd5434..36ded039eca27f0c41d975dc614440973d1a6f6c 100644 (file)
   - type: AntagSelection
     agentName: derelict-cyborg-round-end-agent-name
     definitions:
-#      briefing:
-#        text: derelict-cyborg-role-greetin
-#        color: Blue
     - spawnerPrototype: SpawnPointGhostDerelictCyborg
       min: 1
       max: 1