Supermatter grenades (#13747)

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
AlexMorgan3817
2023-08-10 21:29:47 +07:00
committed by GitHub
parent 163ba7a470
commit 62ccbdaeae
26 changed files with 370 additions and 25 deletions

View File

@@ -1,12 +0,0 @@
using Content.Server.Explosion.EntitySystems;
namespace Content.Server.Explosion.Components
{
/// <summary>
/// Will delete the attached entity upon a <see cref="TriggerEvent"/>.
/// </summary>
[RegisterComponent]
public sealed class DeleteOnTriggerComponent : Component
{
}
}

View File

@@ -1,10 +0,0 @@
namespace Content.Server.Explosion.Components
{
/// <summary>
/// Explode using the entity's <see cref="ExplosiveComponent"/> if Triggered.
/// </summary>
[RegisterComponent]
public sealed class ExplodeOnTriggerComponent : Component
{
}
}

View File

@@ -0,0 +1,13 @@
using Content.Server.Explosion.EntitySystems;
namespace Content.Server.Explosion.Components;
/// <summary>
/// Will anchor the attached entity upon a <see cref="TriggerEvent"/>.
/// </summary>
[RegisterComponent]
public sealed class AnchorOnTriggerComponent : Component
{
[DataField("removeOnTrigger")]
public bool RemoveOnTrigger = true;
}

View File

@@ -0,0 +1,11 @@
using Content.Server.Explosion.EntitySystems;
namespace Content.Server.Explosion.Components;
/// <summary>
/// Will delete the attached entity upon a <see cref="TriggerEvent"/>.
/// </summary>
[RegisterComponent]
public sealed class DeleteOnTriggerComponent : Component
{
}

View File

@@ -0,0 +1,9 @@
namespace Content.Server.Explosion.Components;
/// <summary>
/// Explode using the entity's <see cref="ExplosiveComponent"/> if Triggered.
/// </summary>
[RegisterComponent]
public sealed class ExplodeOnTriggerComponent : Component
{
}

View File

@@ -1,4 +1,4 @@
namespace Content.Server.Explosion.Components; namespace Content.Server.Explosion.Components;
/// <summary> /// <summary>
/// Gibs on trigger, self explanatory. /// Gibs on trigger, self explanatory.

View File

@@ -0,0 +1,17 @@
using Content.Server.Explosion.EntitySystems;
using Robust.Shared.Audio;
namespace Content.Server.Explosion.Components;
/// <summary>
/// Will play sound from the attached entity upon a <see cref="TriggerEvent"/>.
/// </summary>
[RegisterComponent]
public sealed class SoundOnTriggerComponent : Component
{
[DataField("removeOnTrigger")]
public bool RemoveOnTrigger = true;
[DataField("sound")]
public SoundSpecifier? Sound = new SoundPathSpecifier("/Audio/Effects/Grenades/supermatter_start.ogg");
}

View File

@@ -0,0 +1,30 @@
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
namespace Content.Server.Explosion.Components.OnTrigger;
/// <summary>
/// After being triggered applies the specified components and runs triggers again.
/// </summary>
[RegisterComponent]
public sealed class TwoStageTriggerComponent : Component
{
/// <summary>
/// How long it takes for the second stage to be triggered.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("triggerDelay")]
public TimeSpan TriggerDelay = TimeSpan.FromSeconds(10);
/// <summary>
/// This list of components that will be added for the second trigger.
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
[DataField("components", required: true)]
public ComponentRegistry SecondStageComponents = new();
[DataField("nextTriggerTime", customTypeSerializer: typeof(TimeOffsetSerializer))]
public TimeSpan? NextTriggerTime;
[ViewVariables(VVAccess.ReadWrite), DataField("triggered")] public bool Triggered = false;
}

View File

@@ -58,6 +58,7 @@ namespace Content.Server.Explosion.EntitySystems
[Dependency] private readonly SharedContainerSystem _container = default!; [Dependency] private readonly SharedContainerSystem _container = default!;
[Dependency] private readonly BodySystem _body = default!; [Dependency] private readonly BodySystem _body = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!; [Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedTransformSystem _transformSystem = default!;
[Dependency] private readonly RadioSystem _radioSystem = default!; [Dependency] private readonly RadioSystem _radioSystem = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
@@ -84,9 +85,32 @@ namespace Content.Server.Explosion.EntitySystems
SubscribeLocalEvent<ExplodeOnTriggerComponent, TriggerEvent>(HandleExplodeTrigger); SubscribeLocalEvent<ExplodeOnTriggerComponent, TriggerEvent>(HandleExplodeTrigger);
SubscribeLocalEvent<FlashOnTriggerComponent, TriggerEvent>(HandleFlashTrigger); SubscribeLocalEvent<FlashOnTriggerComponent, TriggerEvent>(HandleFlashTrigger);
SubscribeLocalEvent<GibOnTriggerComponent, TriggerEvent>(HandleGibTrigger); SubscribeLocalEvent<GibOnTriggerComponent, TriggerEvent>(HandleGibTrigger);
SubscribeLocalEvent<AnchorOnTriggerComponent, TriggerEvent>(OnAnchorTrigger);
SubscribeLocalEvent<SoundOnTriggerComponent, TriggerEvent>(OnSoundTrigger);
SubscribeLocalEvent<RattleComponent, TriggerEvent>(HandleRattleTrigger); SubscribeLocalEvent<RattleComponent, TriggerEvent>(HandleRattleTrigger);
} }
private void OnSoundTrigger(EntityUid uid, SoundOnTriggerComponent component, TriggerEvent args)
{
_audio.PlayPvs(component.Sound, uid);
if (component.RemoveOnTrigger)
RemCompDeferred<SoundOnTriggerComponent>(uid);
}
private void OnAnchorTrigger(EntityUid uid, AnchorOnTriggerComponent component, TriggerEvent args)
{
var xform = Transform(uid);
if (xform.Anchored)
return;
_transformSystem.AnchorEntity(uid, xform);
if(component.RemoveOnTrigger)
RemCompDeferred<AnchorOnTriggerComponent>(uid);
}
private void OnSpawnTrigger(EntityUid uid, SpawnOnTriggerComponent component, TriggerEvent args) private void OnSpawnTrigger(EntityUid uid, SpawnOnTriggerComponent component, TriggerEvent args)
{ {
var xform = Transform(uid); var xform = Transform(uid);
@@ -105,14 +129,12 @@ namespace Content.Server.Explosion.EntitySystems
args.Handled = true; args.Handled = true;
} }
#region Flash
private void HandleFlashTrigger(EntityUid uid, FlashOnTriggerComponent component, TriggerEvent args) private void HandleFlashTrigger(EntityUid uid, FlashOnTriggerComponent component, TriggerEvent args)
{ {
// TODO Make flash durations sane ffs. // TODO Make flash durations sane ffs.
_flashSystem.FlashArea(uid, args.User, component.Range, component.Duration * 1000f); _flashSystem.FlashArea(uid, args.User, component.Range, component.Duration * 1000f);
args.Handled = true; args.Handled = true;
} }
#endregion
private void HandleDeleteTrigger(EntityUid uid, DeleteOnTriggerComponent component, TriggerEvent args) private void HandleDeleteTrigger(EntityUid uid, DeleteOnTriggerComponent component, TriggerEvent args)
{ {

View File

@@ -0,0 +1,71 @@
using Robust.Shared.Timing;
using Robust.Shared.Serialization.Manager;
using Content.Server.Explosion.Components.OnTrigger;
namespace Content.Server.Explosion.EntitySystems;
public sealed class TwoStageTriggerSystem : EntitySystem
{
[Dependency] private readonly IComponentFactory _factory = default!;
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly ISerializationManager _serializationManager = default!;
[Dependency] private readonly TriggerSystem _triggerSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<TwoStageTriggerComponent, EntityUnpausedEvent>(OnTriggerUnpaused);
SubscribeLocalEvent<TwoStageTriggerComponent, TriggerEvent>(OnTrigger);
}
private void OnTriggerUnpaused(EntityUid uid, TwoStageTriggerComponent component, ref EntityUnpausedEvent args)
{
if (component.NextTriggerTime != null)
component.NextTriggerTime = component.NextTriggerTime.Value + args.PausedTime;
}
private void OnTrigger(EntityUid uid, TwoStageTriggerComponent component, TriggerEvent args)
{
if (component.Triggered)
return;
component.Triggered = true;
component.NextTriggerTime = _timing.CurTime + component.TriggerDelay;
}
public void LoadComponents(EntityUid uid, TwoStageTriggerComponent component)
{
foreach (var (name, entry) in component.SecondStageComponents)
{
var comp = (Component) _factory.GetComponent(name);
var temp = (object) comp;
if (EntityManager.TryGetComponent(uid, entry.Component.GetType(), out var c))
RemComp(uid, c);
comp.Owner = uid;
_serializationManager.CopyTo(entry.Component, ref temp);
EntityManager.AddComponent(uid, comp);
}
}
public override void Update(float frameTime)
{
base.Update(frameTime);
var enumerator = EntityQueryEnumerator<TwoStageTriggerComponent>();
while (enumerator.MoveNext(out var uid, out var component))
{
if (component.NextTriggerTime == null)
continue;
if (_timing.CurTime < component.NextTriggerTime)
continue;
component.NextTriggerTime = null;
LoadComponents(uid, component);
_triggerSystem.Trigger(uid);
}
}
}

View File

@@ -0,0 +1,9 @@
- files:
- supermatter_end.ogg
- supermatter_loop.ogg
- supermatter_start.ogg
- whitehole_loop.ogg
- whitehole_start.ogg
- smbeep.ogg
license: "CC-BY-SA-3.0"
copyright: "Made by AlexMorgan3817 https://soundcloud.com/alexmorgan3817"

View File

@@ -36,6 +36,12 @@ uplink-flash-grenade-desc = A standard-issue flashbang, capable of blinding and
uplink-mini-bomb-name = Minibomb uplink-mini-bomb-name = Minibomb
uplink-mini-bomb-desc = A low-yield, high-impact precision sabotage explosive with a five-second long fuse. Perfect for quickly destroying a machine, dead body, or whatever else needs to go. uplink-mini-bomb-desc = A low-yield, high-impact precision sabotage explosive with a five-second long fuse. Perfect for quickly destroying a machine, dead body, or whatever else needs to go.
uplink-supermatter-grenade-name = Supermatter Grenade
uplink-supermatter-grenade-desc = Grenade that simulates delamination of a suppermatter engine, generates powerful gravity well. Explosion comparable to a Mini Bomb.
uplink-whitehole-grenade-name = Whitehole Grenade
uplink-whitehole-grenade-desc = Grenade that are repulses everything around for about 10 seconds. Very useful in small rooms and for chasing someone.
uplink-penguin-grenade-name = Grenade Penguin uplink-penguin-grenade-name = Grenade Penguin
uplink-penguin-grenade-desc = A small, highly-aggressive penguin with a grenade strapped around its neck. Harvested by the Syndicate from icy shit-hole planets. uplink-penguin-grenade-desc = A small, highly-aggressive penguin with a grenade strapped around its neck. Harvested by the Syndicate from icy shit-hole planets.

View File

@@ -148,6 +148,26 @@
categories: categories:
- UplinkExplosives - UplinkExplosives
- type: listing
id: UplinkSupermatterGrenade
name: uplink-supermatter-grenade-name
description: uplink-supermatter-grenade-desc
productEntity: SupermatterGrenade
cost:
Telecrystal: 6
categories:
- UplinkExplosives
- type: listing
id: UplinkWhiteholeGrenade
name: uplink-whitehole-grenade-name
description: uplink-whitehole-grenade-desc
productEntity: WhiteholeGrenade
cost:
Telecrystal: 3
categories:
- UplinkExplosives
- type: listing - type: listing
id: UplinkGrenadePenguin id: UplinkGrenadePenguin
name: uplink-penguin-grenade-name name: uplink-penguin-grenade-name

View File

@@ -112,6 +112,117 @@
params: params:
volume: 12 volume: 12
- type: entity
name: supermatter grenade
description: Grenade that simulates delamination of the supermatter engine, pulling things in a heap and exploding after some time.
parent: GrenadeBase
id: SupermatterGrenade
components:
- type: Sprite
sprite: Objects/Weapons/Grenades/supermattergrenade.rsi
- type: OnUseTimerTrigger
delay: 3
beepInterval: 0.46
beepSound:
path: /Audio/Effects/Grenades/Supermatter/smbeep.ogg
params:
volume: -5
- type: TimerTriggerVisuals
primingSound:
path: /Audio/Effects/Grenades/Supermatter/smbeep.ogg
params:
volume: -5
- type: Explosive
explosionType: Default
totalIntensity: 200
intensitySlope: 30
maxIntensity: 120
- type: SoundOnTrigger
removeOnTrigger: true
sound:
path: /Audio/Effects/Grenades/Supermatter/supermatter_start.ogg
volume: 5
- type: AnchorOnTrigger
removeOnTrigger: true
- type: TwoStageTrigger
triggerDelay: 10
components:
- type: AmbientSound
enabled: true
volume: -5
range: 14
sound:
path: /Audio/Effects/Grenades/Supermatter/supermatter_loop.ogg
- type: GravityWell
maxRange: 8
baseRadialAcceleration: 145
baseTangentialAcceleration: 5
gravPulsePeriod: 0.01
- type: SingularityDistortion
intensity: 150
falloffPower: 1.5
- type: PointLight
enabled: true
color: "#ffaa44"
energy: 8
radius: 6
softness: 1
offset: "0, 0"
- type: SoundOnTrigger
sound:
path: /Audio/Effects/Grenades/Supermatter/supermatter_end.ogg
params:
volume: 5
- type: ExplodeOnTrigger
- type: entity
name: whitehole grenade
description: Grenade that repulses everything around for some time.
parent: SupermatterGrenade
id: WhiteholeGrenade
components:
- type: Sprite
sprite: Objects/Weapons/Grenades/whiteholegrenade.rsi
- type: OnUseTimerTrigger
delay: 3
beepInterval: 0.69
- type: SoundOnTrigger
removeOnTrigger: true
sound:
path: /Audio/Effects/Grenades/Supermatter/whitehole_start.ogg
volume: 5
- type: AmbientSound
enabled: false
volume: -5
range: 14
sound:
path: /Audio/Effects/Grenades/Supermatter/whitehole_loop.ogg
- type: TwoStageTrigger
triggerDelay: 10
components:
- type: GravityWell
maxRange: 10
baseRadialAcceleration: -180
baseTangentialAcceleration: -5
gravPulsePeriod: 0.01
- type: SingularityDistortion
intensity: -200
falloffPower: 1.5
- type: PointLight
enabled: true
color: "#ffffff"
energy: 8
radius: 6
softness: 1
offset: "0, 0"
- type: SoundOnTrigger
sound:
path: /Audio/Effects/Grenades/Supermatter/supermatter_end.ogg
params:
volume: 5
- type: DeleteOnTrigger
- type: entity - type: entity
name: the nuclear option name: the nuclear option
description: Please don't throw it, think of the children. description: Please don't throw it, think of the children.

Binary file not shown.

After

Width:  |  Height:  |  Size: 267 B

View File

@@ -0,0 +1,24 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "Changed sprites taken from infinity baystation 12, https://github.com/infinitystation/Baystation12/blob/073f678cdce92edb8fcd55f9ffc9f0523bf31506/icons/obj/grenade.dmi",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "icon"
},
{
"name": "primed",
"delays":
[
[
0.1,
0.1
]
]
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 360 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 306 B

View File

@@ -0,0 +1,24 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "Changed sprites taken from infinity baystation 12, https://github.com/infinitystation/Baystation12/blob/073f678cdce92edb8fcd55f9ffc9f0523bf31506/icons/obj/grenade.dmi",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "icon"
},
{
"name": "primed",
"delays":
[
[
0.1,
0.1
]
]
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 373 B