RNG timers for IEDs + small tweaks (#22099)
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
using Content.Server.Explosion.EntitySystems;
|
||||
|
||||
namespace Content.Server.Explosion.Components;
|
||||
|
||||
/// <summary>
|
||||
/// This is used for randomizing a <see cref="RandomTimerTriggerComponent"/> on MapInit
|
||||
/// </summary>
|
||||
[RegisterComponent, Access(typeof(TriggerSystem))]
|
||||
public sealed partial class RandomTimerTriggerComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// The minimum random trigger time.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public float Min;
|
||||
|
||||
/// <summary>
|
||||
/// The maximum random trigger time.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public float Max;
|
||||
}
|
||||
@@ -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<OnUseTimerTriggerComponent, ExaminedEvent>(OnExamined);
|
||||
SubscribeLocalEvent<OnUseTimerTriggerComponent, GetVerbsEvent<AlternativeVerb>>(OnGetAltVerbs);
|
||||
SubscribeLocalEvent<OnUseTimerTriggerComponent, EntityStuckEvent>(OnStuck);
|
||||
SubscribeLocalEvent<RandomTimerTriggerComponent, MapInitEvent>(OnRandomTimerTriggerMapInit);
|
||||
}
|
||||
|
||||
private void OnStuck(EntityUid uid, OnUseTimerTriggerComponent component, EntityStuckEvent args)
|
||||
@@ -114,6 +114,16 @@ public sealed partial class TriggerSystem
|
||||
}
|
||||
}
|
||||
|
||||
private void OnRandomTimerTriggerMapInit(Entity<RandomTimerTriggerComponent> ent, ref MapInitEvent args)
|
||||
{
|
||||
var (_, comp) = ent;
|
||||
|
||||
if (!TryComp<OnUseTimerTriggerComponent>(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)
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 884 B After Width: | Height: | Size: 913 B |
@@ -18,6 +18,15 @@
|
||||
},
|
||||
{
|
||||
"name": "wires"
|
||||
},
|
||||
{
|
||||
"name": "primed",
|
||||
"delays": [
|
||||
[
|
||||
0.5,
|
||||
0.5
|
||||
]
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
BIN
Resources/Textures/Objects/Weapons/Bombs/ied.rsi/primed.png
Normal file
BIN
Resources/Textures/Objects/Weapons/Bombs/ied.rsi/primed.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.0 KiB |
Reference in New Issue
Block a user