From e2eb80c0fe05bc8c1914d186cc09cc1769cf020c Mon Sep 17 00:00:00 2001
From: Nemanja <98561806+EmoGarbage404@users.noreply.github.com>
Date: Sat, 2 Dec 2023 21:21:51 -0500
Subject: [PATCH] RNG timers for IEDs + small tweaks (#22099)
---
.../Components/RandomTimerTriggerComponent.cs | 22 ++++++++++++++++++
.../EntitySystems/TriggerSystem.OnUse.cs | 12 +++++++++-
.../Explosion/EntitySystems/TriggerSystem.cs | 2 ++
.../Entities/Objects/Weapons/Bombs/ied.yml | 13 +++++++++--
.../Objects/Weapons/Bombs/ied.rsi/base.png | Bin 884 -> 913 bytes
.../Objects/Weapons/Bombs/ied.rsi/meta.json | 9 +++++++
.../Objects/Weapons/Bombs/ied.rsi/primed.png | Bin 0 -> 1033 bytes
7 files changed, 55 insertions(+), 3 deletions(-)
create mode 100644 Content.Server/Explosion/Components/RandomTimerTriggerComponent.cs
create mode 100644 Resources/Textures/Objects/Weapons/Bombs/ied.rsi/primed.png
diff --git a/Content.Server/Explosion/Components/RandomTimerTriggerComponent.cs b/Content.Server/Explosion/Components/RandomTimerTriggerComponent.cs
new file mode 100644
index 0000000000..3863b9c313
--- /dev/null
+++ b/Content.Server/Explosion/Components/RandomTimerTriggerComponent.cs
@@ -0,0 +1,22 @@
+using Content.Server.Explosion.EntitySystems;
+
+namespace Content.Server.Explosion.Components;
+
+///
+/// This is used for randomizing a on MapInit
+///
+[RegisterComponent, Access(typeof(TriggerSystem))]
+public sealed partial class RandomTimerTriggerComponent : Component
+{
+ ///
+ /// The minimum random trigger time.
+ ///
+ [DataField]
+ public float Min;
+
+ ///
+ /// The maximum random trigger time.
+ ///
+ [DataField]
+ public float Max;
+}
diff --git a/Content.Server/Explosion/EntitySystems/TriggerSystem.OnUse.cs b/Content.Server/Explosion/EntitySystems/TriggerSystem.OnUse.cs
index fb1f72eb44..c4b0d9c9ba 100644
--- a/Content.Server/Explosion/EntitySystems/TriggerSystem.OnUse.cs
+++ b/Content.Server/Explosion/EntitySystems/TriggerSystem.OnUse.cs
@@ -4,7 +4,6 @@ using Content.Shared.Examine;
using Content.Shared.Interaction.Events;
using Content.Shared.Popups;
using Content.Shared.Verbs;
-using Robust.Shared.Player;
namespace Content.Server.Explosion.EntitySystems;
@@ -18,6 +17,7 @@ public sealed partial class TriggerSystem
SubscribeLocalEvent(OnExamined);
SubscribeLocalEvent>(OnGetAltVerbs);
SubscribeLocalEvent(OnStuck);
+ SubscribeLocalEvent(OnRandomTimerTriggerMapInit);
}
private void OnStuck(EntityUid uid, OnUseTimerTriggerComponent component, EntityStuckEvent args)
@@ -114,6 +114,16 @@ public sealed partial class TriggerSystem
}
}
+ private void OnRandomTimerTriggerMapInit(Entity ent, ref MapInitEvent args)
+ {
+ var (_, comp) = ent;
+
+ if (!TryComp(ent, out var timerTriggerComp))
+ return;
+
+ timerTriggerComp.Delay = _random.NextFloat(comp.Min, comp.Max);
+ }
+
private void CycleDelay(OnUseTimerTriggerComponent component, EntityUid user)
{
if (component.DelayOptions == null || component.DelayOptions.Count == 1)
diff --git a/Content.Server/Explosion/EntitySystems/TriggerSystem.cs b/Content.Server/Explosion/EntitySystems/TriggerSystem.cs
index 854fa7f661..323dae493a 100644
--- a/Content.Server/Explosion/EntitySystems/TriggerSystem.cs
+++ b/Content.Server/Explosion/EntitySystems/TriggerSystem.cs
@@ -25,6 +25,7 @@ using Content.Shared.Mobs;
using Content.Shared.Mobs.Components;
using Content.Shared.Weapons.Ranged.Events;
using Robust.Shared.Audio.Systems;
+using Robust.Shared.Random;
namespace Content.Server.Explosion.EntitySystems
{
@@ -62,6 +63,7 @@ namespace Content.Server.Explosion.EntitySystems
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedTransformSystem _transformSystem = default!;
[Dependency] private readonly RadioSystem _radioSystem = default!;
+ [Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
public override void Initialize()
diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Bombs/ied.yml b/Resources/Prototypes/Entities/Objects/Weapons/Bombs/ied.yml
index 9e66a06971..14906c7c2d 100644
--- a/Resources/Prototypes/Entities/Objects/Weapons/Bombs/ied.yml
+++ b/Resources/Prototypes/Entities/Objects/Weapons/Bombs/ied.yml
@@ -11,6 +11,7 @@
sprite: Objects/Weapons/Bombs/ied.rsi
layers:
- state: base
+ map: ["enum.TriggerVisualLayers.Base"]
- state: fuel
- state: wires
- type: Item
@@ -19,8 +20,12 @@
delay: 5
examinable: false
initialBeepDelay: 0
- beepSound: /Audio/Effects/lightburn.ogg
- # TODO: random timer when crafted
+ beepSound:
+ path: /Audio/Weapons/Guns/MagOut/pistol_magout.ogg
+ volume: 1
+ - type: RandomTimerTrigger
+ min: 0
+ max: 60
- type: Explosive # Weak explosion in a very small radius. Doesn't break underplating.
explosionType: Default
totalIntensity: 20
@@ -28,6 +33,10 @@
maxIntensity: 3
canCreateVacuum: false
- type: ExplodeOnTrigger
+ - type: Appearance
+ - type: AnimationPlayer
+ - type: TimerTriggerVisuals
+ unprimedSprite: base
- type: Damageable
damageContainer: Inorganic
- type: Destructible
diff --git a/Resources/Textures/Objects/Weapons/Bombs/ied.rsi/base.png b/Resources/Textures/Objects/Weapons/Bombs/ied.rsi/base.png
index dda9a11195bce3c9ddcf372ec5e9e012d25759cd..300ee5552aeff5bec0c994201f10adc9cdc8ce11 100644
GIT binary patch
delta 511
zcmV
z830B{LOiLC&%>~_b08YZIC}eMgYPLCOY-*XvR5pVH!whBa<}jq2ps_cY`*P)I>q=+f^!vH)|1{m+0yIs7zTfKc
z9ac8B@k^b+{JUWQKw#>#=>iPH7^6reLX0sk(O8nMGFi&YGMy|gn;Jr)on?%X+wJDM
zrfJyi>f$p{fE~Htwf5cvheLIg_8T}Hs&iZ4*KeX>#0q!N?}3jUPIy*rc;ovADa<
z^$P?_KhV6rHC=%48de4e;Yw$46`R1R(hJ}P)=(!$or(3IM?CT4Tm!6
delta 482
zcmV<80UiF42lNK8odJIU32;bR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