Fix: Grenades don't make trigger sound (#25321)

* Fix: Grenades don't make trigger sound

* transform instead of trycomp transform

---------

Co-authored-by: Plykiya <plykiya@protonmail.com>
This commit is contained in:
Plykiya
2024-02-17 08:54:58 -08:00
committed by GitHub
parent f27d78c271
commit 7d94cc719c
2 changed files with 12 additions and 4 deletions

View File

@@ -29,6 +29,8 @@ using Robust.Shared.Physics.Events;
using Robust.Shared.Physics.Systems; using Robust.Shared.Physics.Systems;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using Robust.Shared.Random; using Robust.Shared.Random;
using Robust.Shared.Player;
using Content.Shared.Coordinates;
namespace Content.Server.Explosion.EntitySystems namespace Content.Server.Explosion.EntitySystems
{ {
@@ -103,9 +105,15 @@ namespace Content.Server.Explosion.EntitySystems
private void OnSoundTrigger(EntityUid uid, SoundOnTriggerComponent component, TriggerEvent args) private void OnSoundTrigger(EntityUid uid, SoundOnTriggerComponent component, TriggerEvent args)
{ {
_audio.PlayPvs(component.Sound, uid); if (component.RemoveOnTrigger) // if the component gets removed when it's triggered
if (component.RemoveOnTrigger) {
RemCompDeferred<SoundOnTriggerComponent>(uid); var xform = Transform(uid);
_audio.PlayPvs(component.Sound, xform.Coordinates); // play the sound at its last known coordinates
}
else // if the component doesn't get removed when triggered
{
_audio.PlayPvs(component.Sound, uid); // have the sound follow the entity itself
}
} }
private void OnAnchorTrigger(EntityUid uid, AnchorOnTriggerComponent component, TriggerEvent args) private void OnAnchorTrigger(EntityUid uid, AnchorOnTriggerComponent component, TriggerEvent args)

View File

@@ -67,7 +67,7 @@
sprite: Objects/Weapons/Grenades/flashbang.rsi sprite: Objects/Weapons/Grenades/flashbang.rsi
- type: FlashOnTrigger - type: FlashOnTrigger
range: 7 range: 7
- type: EmitSoundOnTrigger - type: SoundOnTrigger
sound: sound:
path: "/Audio/Effects/flash_bang.ogg" path: "/Audio/Effects/flash_bang.ogg"
- type: DeleteOnTrigger - type: DeleteOnTrigger