From: The Canned One Date: Tue, 1 Oct 2024 08:02:25 +0000 (+0200) Subject: Cleaned up a bit of the Derelict Cyborg code. X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=834b6ebaaac99f5827857d2fef293c9466bb23fa;p=space-station-14.git Cleaned up a bit of the Derelict Cyborg code. --- diff --git a/Content.Server/Silicons/Laws/IonStormSystem.cs b/Content.Server/Silicons/Laws/IonStormSystem.cs index 1acfe2e389..87df0d8cf2 100644 --- a/Content.Server/Silicons/Laws/IonStormSystem.cs +++ b/Content.Server/Silicons/Laws/IonStormSystem.cs @@ -60,108 +60,108 @@ public sealed class IonStormSystem : EntitySystem [ValidatePrototypeId] 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(xform.GridUid)?.Station != chosenStation && !ignoreStation) - return; + // only affect law holders on the station unless ignoreStation is true. + if (CompOrNull(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(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(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(ent); - var ev = new IonStormLawsEvent(laws); - RaiseLocalEvent(ent, ref ev); + // laws unique to this silicon, dont use station laws anymore + EnsureComp(ent); + var ev = new IonStormLawsEvent(laws); + RaiseLocalEvent(ent, ref ev); } // for your own sake direct your eyes elsewhere diff --git a/Content.Server/Silicons/Laws/StartIonStormedSystem.cs b/Content.Server/Silicons/Laws/StartIonStormedSystem.cs index 4b1b4da033..f7b65e1a04 100644 --- a/Content.Server/Silicons/Laws/StartIonStormedSystem.cs +++ b/Content.Server/Silicons/Laws/StartIonStormedSystem.cs @@ -6,7 +6,7 @@ using Content.Shared.Silicons.Laws; namespace Content.Server.Silicons.Laws; /// -/// 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. /// 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); diff --git a/Content.Shared/Silicons/Laws/Components/StartIonStormedComponent.cs b/Content.Shared/Silicons/Laws/Components/StartIonStormedComponent.cs index ae9b49a49c..4157bee9f2 100644 --- a/Content.Shared/Silicons/Laws/Components/StartIonStormedComponent.cs +++ b/Content.Shared/Silicons/Laws/Components/StartIonStormedComponent.cs @@ -1,10 +1,8 @@ -using Content.Shared.Random; -using Robust.Shared.Prototypes; namespace Content.Shared.Silicons.Laws.Components; /// -/// Runs the IonStormSystem on an entity IonStormAmount times. +/// Applies law altering ion storms on a specific entity IonStormAmount times when the entity is spawned. /// [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 index 0000000000..87e500d3e6 --- /dev/null +++ b/Resources/Locale/en-US/silicons/derelict-cyborg-role.ftl @@ -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 index 96a33ae6b1..0000000000 --- a/Resources/Locale/en-US/silicons/derelict/role.ftl +++ /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 diff --git a/Resources/Prototypes/Entities/Mobs/Cyborgs/base_borg_chassis.yml b/Resources/Prototypes/Entities/Mobs/Cyborgs/base_borg_chassis.yml index 2fc04a6aa9..f94436dc33 100644 --- a/Resources/Prototypes/Entities/Mobs/Cyborgs/base_borg_chassis.yml +++ b/Resources/Prototypes/Entities/Mobs/Cyborgs/base_borg_chassis.yml @@ -332,16 +332,6 @@ - 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 diff --git a/Resources/Prototypes/GameRules/events.yml b/Resources/Prototypes/GameRules/events.yml index 72ab8b104d..36ded039ec 100644 --- a/Resources/Prototypes/GameRules/events.yml +++ b/Resources/Prototypes/GameRules/events.yml @@ -564,9 +564,6 @@ - type: AntagSelection agentName: derelict-cyborg-round-end-agent-name definitions: -# briefing: -# text: derelict-cyborg-role-greetin -# color: Blue - spawnerPrototype: SpawnPointGhostDerelictCyborg min: 1 max: 1