]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
remove robotics console emag checking, make it a bit fairer (#27876)
authordeltanedas <39013340+deltanedas@users.noreply.github.com>
Mon, 17 Jun 2024 03:30:10 +0000 (03:30 +0000)
committerGitHub <noreply@github.com>
Mon, 17 Jun 2024 03:30:10 +0000 (23:30 -0400)
12 files changed:
Content.Client/Robotics/UI/RoboticsConsoleWindow.xaml.cs
Content.Server/Explosion/Components/AutomatedTimerComponent.cs
Content.Server/Explosion/EntitySystems/TriggerSystem.OnUse.cs
Content.Server/Explosion/EntitySystems/TriggerSystem.cs
Content.Server/Silicons/Borgs/BorgSystem.Transponder.cs
Content.Server/Silicons/Borgs/BorgSystem.cs
Content.Shared/Robotics/Components/RoboticsConsoleComponent.cs
Content.Shared/Robotics/RoboticsConsoleUi.cs
Content.Shared/Silicons/Borgs/Components/BorgTransponderComponent.cs
Resources/Locale/en-US/borg/borg.ftl
Resources/Locale/en-US/research/components/robotics-console.ftl
Resources/Prototypes/Entities/Mobs/Cyborgs/base_borg_chassis.yml

index 367114f2aa6c5e2dab0ce34d325fa26491c35e26..fc7b234bccc1435c018f0ef5888a7b7d43e25f28 100644 (file)
@@ -134,7 +134,7 @@ public sealed partial class RoboticsConsoleWindow : FancyWindow
         BorgInfo.SetMessage(text);
 
         // how the turntables
-        DisableButton.Disabled = !data.HasBrain;
+        DisableButton.Disabled = !(data.HasBrain && data.CanDisable);
         DestroyButton.Disabled = _timing.CurTime < _console.Comp1.NextDestroy;
     }
 
index 7019c08d43d7b233c745c7dac612172fe7483476..c01aeb91e55dcea2e4abf099b0a2f60074a079db 100644 (file)
@@ -1,7 +1,7 @@
 namespace Content.Server.Explosion.Components;
 
 /// <summary>
-///     Disallows starting the timer by hand, must be stuck or triggered by a system.
+///     Disallows starting the timer by hand, must be stuck or triggered by a system using <c>StartTimer</c>.
 /// </summary>
 [RegisterComponent]
 public sealed partial class AutomatedTimerComponent : Component
index 8725dd1ae738ed7ed921cd5f2d9fdaa8da58e577..dcd11062bb78df73da88757a93ed09365e96ba1b 100644 (file)
@@ -26,13 +26,7 @@ public sealed partial class TriggerSystem
         if (!component.StartOnStick)
             return;
 
-        HandleTimerTrigger(
-            uid,
-            args.User,
-            component.Delay,
-            component.BeepInterval,
-            component.InitialBeepDelay,
-            component.BeepSound);
+        StartTimer((uid, component), args.User);
     }
 
     private void OnExamined(EntityUid uid, OnUseTimerTriggerComponent component, ExaminedEvent args)
@@ -54,14 +48,7 @@ public sealed partial class TriggerSystem
             args.Verbs.Add(new AlternativeVerb()
             {
                 Text = Loc.GetString("verb-start-detonation"),
-                Act = () => HandleTimerTrigger(
-                    uid,
-                    args.User,
-                    component.Delay,
-                    component.BeepInterval,
-                    component.InitialBeepDelay,
-                    component.BeepSound
-                ),
+                Act = () => StartTimer((uid, component), args.User),
                 Priority = 2
             });
         }
@@ -174,13 +161,7 @@ public sealed partial class TriggerSystem
         if (component.DoPopup)
             _popupSystem.PopupEntity(Loc.GetString("trigger-activated", ("device", uid)), args.User, args.User);
 
-        HandleTimerTrigger(
-            uid,
-            args.User,
-            component.Delay,
-            component.BeepInterval,
-            component.InitialBeepDelay,
-            component.BeepSound);
+        StartTimer((uid, component), args.User);
 
         args.Handled = true;
     }
index e03b8aff54460dd744e1172ed5c3d4cfffac9795..92e065bf4ce6984ec7af0ae99c8d117df1f4b3ed 100644 (file)
@@ -265,6 +265,18 @@ namespace Content.Server.Explosion.EntitySystems
             comp.TimeRemaining += amount;
         }
 
+        /// <summary>
+        /// Start the timer for triggering the device.
+        /// </summary>
+        public void StartTimer(Entity<OnUseTimerTriggerComponent?> ent, EntityUid? user)
+        {
+            if (!Resolve(ent, ref ent.Comp, false))
+                return;
+
+            var comp = ent.Comp;
+            HandleTimerTrigger(ent, user, comp.Delay, comp.BeepInterval, comp.InitialBeepDelay, comp.BeepSound);
+        }
+
         public void HandleTimerTrigger(EntityUid uid, EntityUid? user, float delay, float beepInterval, float? initialBeepDelay, SoundSpecifier? beepSound)
         {
             if (delay <= 0)
index 1c10cbe667ef19e562ce586792f1adfbca403c91..781f847be35ea2c232cbaf4e6b66421d0ec4d8f1 100644 (file)
@@ -1,5 +1,6 @@
 using Content.Shared.DeviceNetwork;
 using Content.Shared.Emag.Components;
+using Content.Shared.Movement.Components;
 using Content.Shared.Popups;
 using Content.Shared.Robotics;
 using Content.Shared.Silicons.Borgs.Components;
@@ -26,6 +27,9 @@ public sealed partial class BorgSystem
         var query = EntityQueryEnumerator<BorgTransponderComponent, BorgChassisComponent, DeviceNetworkComponent, MetaDataComponent>();
         while (query.MoveNext(out var uid, out var comp, out var chassis, out var device, out var meta))
         {
+            if (comp.NextDisable is {} nextDisable && now >= nextDisable)
+                DoDisable((uid, comp, chassis, meta));
+
             if (now < comp.NextBroadcast)
                 continue;
 
@@ -33,13 +37,16 @@ public sealed partial class BorgSystem
             if (_powerCell.TryGetBatteryFromSlot(uid, out var battery))
                 charge = battery.CurrentCharge / battery.MaxCharge;
 
+            var hasBrain = chassis.BrainEntity != null && !comp.FakeDisabled;
+            var canDisable = comp.NextDisable == null && !comp.FakeDisabling;
             var data = new CyborgControlData(
                 comp.Sprite,
                 comp.Name,
                 meta.EntityName,
                 charge,
                 chassis.ModuleCount,
-                chassis.BrainEntity != null);
+                hasBrain,
+                canDisable);
 
             var payload = new NetworkPayload()
             {
@@ -52,6 +59,24 @@ public sealed partial class BorgSystem
         }
     }
 
+    private void DoDisable(Entity<BorgTransponderComponent, BorgChassisComponent, MetaDataComponent> ent)
+    {
+        ent.Comp1.NextDisable = null;
+        if (ent.Comp1.FakeDisabling)
+        {
+            ent.Comp1.FakeDisabled = true;
+            ent.Comp1.FakeDisabling = false;
+            return;
+        }
+
+        if (ent.Comp2.BrainEntity is not {} brain)
+            return;
+
+        var message = Loc.GetString(ent.Comp1.DisabledPopup, ("name", Name(ent, ent.Comp3)));
+        Popup.PopupEntity(message, ent);
+        _container.Remove(brain, ent.Comp2.BrainContainer);
+    }
+
     private void OnPacketReceived(Entity<BorgTransponderComponent> ent, ref DeviceNetworkPacketEvent args)
     {
         var payload = args.Data;
@@ -61,28 +86,28 @@ public sealed partial class BorgSystem
         if (command == RoboticsConsoleConstants.NET_DISABLE_COMMAND)
             Disable(ent);
         else if (command == RoboticsConsoleConstants.NET_DESTROY_COMMAND)
-            Destroy(ent.Owner);
+            Destroy(ent);
     }
 
     private void Disable(Entity<BorgTransponderComponent, BorgChassisComponent?> ent)
     {
-        if (!Resolve(ent, ref ent.Comp2) || ent.Comp2.BrainEntity is not {} brain)
+        if (!Resolve(ent, ref ent.Comp2) || ent.Comp2.BrainEntity == null || ent.Comp1.NextDisable != null)
             return;
 
-        // this won't exactly be stealthy but if you are malf its better than actually disabling you
+        // update ui immediately
+        ent.Comp1.NextBroadcast = _timing.CurTime;
+
+        // pretend the borg is being disabled forever now
         if (CheckEmagged(ent, "disabled"))
-            return;
+            ent.Comp1.FakeDisabling = true;
+        else
+            Popup.PopupEntity(Loc.GetString(ent.Comp1.DisablingPopup), ent);
 
-        var message = Loc.GetString(ent.Comp1.DisabledPopup, ("name", Name(ent)));
-        Popup.PopupEntity(message, ent);
-        _container.Remove(brain, ent.Comp2.BrainContainer);
+        ent.Comp1.NextDisable = _timing.CurTime + ent.Comp1.DisableDelay;
     }
 
-    private void Destroy(Entity<ExplosiveComponent?> ent)
+    private void Destroy(Entity<BorgTransponderComponent> ent)
     {
-        if (!Resolve(ent, ref ent.Comp))
-            return;
-
         // this is stealthy until someone realises you havent exploded
         if (CheckEmagged(ent, "destroyed"))
         {
@@ -91,7 +116,12 @@ public sealed partial class BorgSystem
             return;
         }
 
-        _explosion.TriggerExplosive(ent, ent.Comp, delete: false);
+        var message = Loc.GetString(ent.Comp.DestroyingPopup, ("name", Name(ent)));
+        Popup.PopupEntity(message, ent);
+        _trigger.StartTimer(ent.Owner, user: null);
+
+        // prevent a shitter borg running into people
+        RemComp<InputMoverComponent>(ent);
     }
 
     private bool CheckEmagged(EntityUid uid, string name)
index 1ab7f5387f31eb7dd850f1c190d7c15df91c228f..c97ca9cbc0db39e6dad84b86fd70e83521f777aa 100644 (file)
@@ -43,8 +43,8 @@ public sealed partial class BorgSystem : SharedBorgSystem
     [Dependency] private readonly ActionsSystem _actions = default!;
     [Dependency] private readonly AlertsSystem _alerts = default!;
     [Dependency] private readonly DeviceNetworkSystem _deviceNetwork = default!;
-    [Dependency] private readonly ExplosionSystem _explosion = default!;
     [Dependency] private readonly SharedAppearanceSystem _appearance = default!;
+    [Dependency] private readonly TriggerSystem _trigger = default!;
     [Dependency] private readonly HandsSystem _hands = default!;
     [Dependency] private readonly MetaDataSystem _metaData = default!;
     [Dependency] private readonly SharedMindSystem _mind = default!;
index 4329e437a2907710d68a3c89bc37c5b794b43db5..9e4b51866f3adf29c3494b028d2f2f1d4c08da4c 100644 (file)
@@ -36,7 +36,7 @@ public sealed partial class RoboticsConsoleComponent : Component
     /// Radio message sent when destroying a borg.
     /// </summary>
     [DataField]
-    public LocId DestroyMessage = "robotics-console-cyborg-destroyed";
+    public LocId DestroyMessage = "robotics-console-cyborg-destroying";
 
     /// <summary>
     /// Cooldown on destroying borgs to prevent complete abuse.
index 1be89beff0beeb4158c70ef0aa7c473eca01514d..996c65cb0e68ff367df70731632cb97734018caf 100644 (file)
@@ -97,6 +97,13 @@ public record struct CyborgControlData
     [DataField]
     public bool HasBrain;
 
+    /// <summary>
+    /// Whether the borg can currently be disabled if the brain is installed,
+    /// if on cooldown then can't queue up multiple disables.
+    /// </summary>
+    [DataField]
+    public bool CanDisable;
+
     /// <summary>
     /// When this cyborg's data will be deleted.
     /// Set by the console when receiving the packet.
@@ -104,7 +111,7 @@ public record struct CyborgControlData
     [DataField(customTypeSerializer: typeof(TimeOffsetSerializer))]
     public TimeSpan Timeout = TimeSpan.Zero;
 
-    public CyborgControlData(SpriteSpecifier? chassisSprite, string chassisName, string name, float charge, int moduleCount, bool hasBrain)
+    public CyborgControlData(SpriteSpecifier? chassisSprite, string chassisName, string name, float charge, int moduleCount, bool hasBrain, bool canDisable)
     {
         ChassisSprite = chassisSprite;
         ChassisName = chassisName;
@@ -112,6 +119,7 @@ public record struct CyborgControlData
         Charge = charge;
         ModuleCount = moduleCount;
         HasBrain = hasBrain;
+        CanDisable = canDisable;
     }
 }
 
index 8c15e20d5d07408e69f5acd652d019e1b42cbda3..577056bb46d33c0b20742b8172d285058a6867d1 100644 (file)
@@ -23,12 +23,25 @@ public sealed partial class BorgTransponderComponent : Component
     public string Name = string.Empty;
 
     /// <summary>
-    /// Popup shown to everyone when a borg is disabled.
+    /// Popup shown to everyone after a borg is disabled.
     /// Gets passed a string "name".
     /// </summary>
     [DataField]
     public LocId DisabledPopup = "borg-transponder-disabled-popup";
 
+    /// <summary>
+    /// Popup shown to the borg when it is being disabled.
+    /// </summary>
+    [DataField]
+    public LocId DisablingPopup = "borg-transponder-disabling-popup";
+
+    /// <summary>
+    /// Popup shown to everyone when a borg is being destroyed.
+    /// Gets passed a string "name".
+    /// </summary>
+    [DataField]
+    public LocId DestroyingPopup = "borg-transponder-destroying-popup";
+
     /// <summary>
     /// How long to wait between each broadcast.
     /// </summary>
@@ -40,4 +53,28 @@ public sealed partial class BorgTransponderComponent : Component
     /// </summary>
     [DataField(customTypeSerializer: typeof(TimeOffsetSerializer))]
     public TimeSpan NextBroadcast = TimeSpan.Zero;
+
+    /// <summary>
+    /// When to next disable the borg.
+    /// </summary>
+    [DataField(customTypeSerializer: typeof(TimeOffsetSerializer))]
+    public TimeSpan? NextDisable;
+
+    /// <summary>
+    /// How long to wait to disable the borg after RD has ordered it.
+    /// </summary>
+    [DataField]
+    public TimeSpan DisableDelay = TimeSpan.FromSeconds(5);
+
+    /// <summary>
+    /// Pretend that the borg cannot be disabled due to being on delay.
+    /// </summary>
+    [DataField]
+    public bool FakeDisabling;
+
+    /// <summary>
+    /// Pretend that the borg has no brain inserted.
+    /// </summary>
+    [DataField]
+    public bool FakeDisabled;
 }
index 72667f318e353cc6ca605744cf7905c1aeb0dfb4..6c495510b05aeec48645ea85efe792581a3b2bb1 100644 (file)
@@ -21,5 +21,7 @@ borg-ui-module-counter = {$actual}/{$max}
 
 # Transponder
 borg-transponder-disabled-popup = A brain shoots out the top of {$name}!
+borg-transponder-disabling-popup = Your transponder begins to lock you out of the chassis!
+borg-transponder-destroying-popup = The self destruct of {$name} starts beeping!
 borg-transponder-emagged-disabled-popup = Your transponder's lights go out!
 borg-transponder-emagged-destroyed-popup = Your transponder's fuse blows!
index 978fa9a43c078c72c6cfa7a27e21596963ab9350..a4c82bd03229acfa41644c86384e07bc8e802fb9 100644 (file)
@@ -16,4 +16,4 @@ robotics-console-locked-message = Controls locked, swipe ID.
 robotics-console-disable = Disable
 robotics-console-destroy = Destroy
 
-robotics-console-cyborg-destroyed = The cyborg {$name} has been remotely destroyed.
+robotics-console-cyborg-destroying = {$name} is being remotely detonated!
index baea453cb88e881411453ae1636922e855b07e05..6ff9a9ec909d460bdcf2f9140d68391e774f34e7 100644 (file)
     deviceNetId: Wireless
     receiveFrequencyId: CyborgControl
     transmitFrequencyId: RoboticsConsole
+  - type: OnUseTimerTrigger
+    delay: 10
+    examinable: false
+    beepSound:
+      path: /Audio/Effects/Cargo/buzz_two.ogg
+      params:
+        volume: -4
+  # prevent any funnies if someone makes a cyborg item...
+  - type: AutomatedTimer
+  - type: ExplodeOnTrigger
   # explosion does most of its damage in the center and less at the edges
   - type: Explosive
     explosionType: Minibomb
+    deleteAfterExplosion: false # let damage threshold gib the borg
     totalIntensity: 30
     intensitySlope: 20
     maxIntensity: 20