Explosion SFX juicing + higher persistence (#22544)

This commit is contained in:
Kara
2023-12-15 09:57:46 -07:00
committed by GitHub
parent 46b59329b0
commit e4a227ff0d
40 changed files with 151 additions and 22 deletions

View File

@@ -19,11 +19,6 @@ public sealed class ExplosionOverlaySystem : EntitySystem
[Dependency] private readonly IOverlayManager _overlayMan = default!; [Dependency] private readonly IOverlayManager _overlayMan = default!;
[Dependency] private readonly SharedPointLightSystem _lights = default!; [Dependency] private readonly SharedPointLightSystem _lights = default!;
/// <summary>
/// For how many seconds should an explosion stay on-screen once it has finished expanding?
/// </summary>
public float ExplosionPersistence = 0.3f;
public override void Initialize() public override void Initialize()
{ {
base.Initialize(); base.Initialize();

View File

@@ -63,7 +63,7 @@ public sealed partial class ExplosionSystem : EntitySystem
/// </summary> /// </summary>
public const ushort DefaultTileSize = 1; public const ushort DefaultTileSize = 1;
private AudioParams _audioParams = AudioParams.Default.WithVolume(-3f); public const int MaxExplosionAudioRange = 30;
/// <summary> /// <summary>
/// The "default" explosion prototype. /// The "default" explosion prototype.
@@ -328,15 +328,33 @@ public sealed partial class ExplosionSystem : EntitySystem
var visualEnt = CreateExplosionVisualEntity(epicenter, type.ID, spaceMatrix, spaceData, gridData.Values, iterationIntensity); var visualEnt = CreateExplosionVisualEntity(epicenter, type.ID, spaceMatrix, spaceData, gridData.Values, iterationIntensity);
// camera shake // camera shake
CameraShake(iterationIntensity.Count * 2.5f, epicenter, totalIntensity); CameraShake(iterationIntensity.Count * 4f, epicenter, totalIntensity);
//For whatever bloody reason, sound system requires ENTITY coordinates. //For whatever bloody reason, sound system requires ENTITY coordinates.
var mapEntityCoords = EntityCoordinates.FromMap(EntityManager, _mapManager.GetMapEntityId(epicenter.MapId), epicenter); var mapEntityCoords = EntityCoordinates.FromMap(EntityManager, _mapManager.GetMapEntityId(epicenter.MapId), epicenter);
// play sound. // play sound.
var audioRange = iterationIntensity.Count * 5; // for the normal audio, we want everyone in pvs range
// + if the bomb is big enough, people outside of it too
// this is capped to 30 because otherwise really huge bombs
// will attempt to play regular audio for people who can't hear it anyway because the epicenter is so far away
var audioRange = Math.Min(iterationIntensity.Count * 2, MaxExplosionAudioRange);
var filter = Filter.Pvs(epicenter).AddInRange(epicenter, audioRange); var filter = Filter.Pvs(epicenter).AddInRange(epicenter, audioRange);
_audio.PlayStatic(type.Sound.GetSound(), filter, mapEntityCoords, true, _audioParams); var sound = iterationIntensity.Count < type.SmallSoundIterationThreshold
? type.SmallSound
: type.Sound;
_audio.PlayStatic(sound, filter, mapEntityCoords, true, sound.Params);
// play far sound
// far sound should play for anyone who wasn't in range of any of the effects of the bomb
var farAudioRange = iterationIntensity.Count * 5;
var farFilter = Filter.Empty().AddInRange(epicenter, farAudioRange).RemoveInRange(epicenter, audioRange);
var farSound = iterationIntensity.Count < type.SmallSoundIterationThreshold
? type.SmallSoundFar
: type.SoundFar;
_audio.PlayGlobal(farSound, farFilter, true, farSound.Params);
return new Explosion(this, return new Explosion(this,
type, type,

View File

@@ -127,7 +127,7 @@ public sealed partial class AnomalyComponent : Component
/// The sound plays when an anomaly goes supercritical /// The sound plays when an anomaly goes supercritical
/// </summary> /// </summary>
[DataField] [DataField]
public SoundSpecifier? SupercriticalSound = new SoundCollectionSpecifier("explosion"); public SoundSpecifier? SupercriticalSound = new SoundCollectionSpecifier("Explosion");
#endregion #endregion
/// <summary> /// <summary>

View File

@@ -846,7 +846,7 @@ namespace Content.Shared.CCVar
/// This determines for how many seconds an explosion should stay visible once it has finished expanding. /// This determines for how many seconds an explosion should stay visible once it has finished expanding.
/// </summary> /// </summary>
public static readonly CVarDef<float> ExplosionPersistence = public static readonly CVarDef<float> ExplosionPersistence =
CVarDef.Create("explosion.persistence", 0.3f, CVar.SERVERONLY); CVarDef.Create("explosion.persistence", 1.0f, CVar.SERVERONLY);
/// <summary> /// <summary>
/// If an explosion covers a larger area than this number, the damaging/processing will always start during /// If an explosion covers a larger area than this number, the damaging/processing will always start during

View File

@@ -62,8 +62,26 @@ public sealed partial class ExplosionPrototype : IPrototype
[DataField("fireColor")] [DataField("fireColor")]
public Color? FireColor; public Color? FireColor;
[DataField("Sound")] /// <summary>
public SoundSpecifier Sound = new SoundCollectionSpecifier("explosion"); /// If an explosion finishes in less than this many iterations, play a small sound instead.
/// </summary>
/// <remarks>
/// This value is tuned such that a minibomb is considered small, but just about anything larger is normal
/// </remarks>
[DataField("smallSoundIterationThreshold")]
public int SmallSoundIterationThreshold = 6;
[DataField("sound")]
public SoundSpecifier Sound = new SoundCollectionSpecifier("Explosion");
[DataField("smallSound")]
public SoundSpecifier SmallSound = new SoundCollectionSpecifier("ExplosionSmall");
[DataField("soundFar")]
public SoundSpecifier SoundFar = new SoundCollectionSpecifier("ExplosionFar", AudioParams.Default.WithVolume(2f));
[DataField("smallSoundFar")]
public SoundSpecifier SmallSoundFar = new SoundCollectionSpecifier("ExplosionSmallFar", AudioParams.Default.WithVolume(2f));
[DataField("texturePath")] [DataField("texturePath")]
public ResPath TexturePath = new("/Textures/Effects/fire.rsi"); public ResPath TexturePath = new("/Textures/Effects/fire.rsi");

View File

@@ -71,7 +71,7 @@ public sealed partial class LightBulbComponent : Component
/// </summary> /// </summary>
[DataField("breakSound")] [DataField("breakSound")]
[ViewVariables(VVAccess.ReadWrite)] [ViewVariables(VVAccess.ReadWrite)]
public SoundSpecifier BreakSound = new SoundCollectionSpecifier("GlassBreak"); public SoundSpecifier BreakSound = new SoundCollectionSpecifier("GlassBreak", AudioParams.Default.WithVolume(-6f));
#region Appearance #region Appearance

View File

@@ -171,3 +171,8 @@
copyright: '"jumps from reason.3.Rev.wav" by martian of Freesound.org. Modified by reversing and altering volume.' copyright: '"jumps from reason.3.Rev.wav" by martian of Freesound.org. Modified by reversing and altering volume.'
license: CC0-1.0 license: CC0-1.0
source: https://freesound.org/people/martian/sounds/19261/ source: https://freesound.org/people/martian/sounds/19261/
- files: ["explosion_small1.ogg", "explosion_small2.ogg", "explosion_small3.ogg", "explosion1.ogg", "explosion2.ogg", "explosion3.ogg", "explosion4.ogg", "explosion5.ogg", "explosion6.ogg", "explosionfar.ogg", "explosionsmallfar.ogg"]
copyright: "vgstation at c5edbfd7179288080f081e2b8ac2496b7e4455db"
license: CC-BY-SA-3.0
source: https://github.com/vgstation-coders/vgstation13/tree/c5edbfd7179288080f081e2b8ac2496b7e4455db/sound/effects

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -149,7 +149,8 @@
damage: 300 damage: 300
behaviors: behaviors:
- !type:PlaySoundBehavior - !type:PlaySoundBehavior
sound: /Audio/Effects/metalbreak.ogg sound:
path: /Audio/Effects/metalbreak.ogg
- !type:EmptyContainersBehaviour - !type:EmptyContainersBehaviour
containers: containers:
- borg_brain - borg_brain

View File

@@ -34,6 +34,8 @@
- !type:PlaySoundBehavior - !type:PlaySoundBehavior
sound: sound:
collection: GlassBreak collection: GlassBreak
params:
volume: -8
- !type:SpawnEntitiesBehavior - !type:SpawnEntitiesBehavior
spawn: spawn:
FoodPlateTrash: FoodPlateTrash:
@@ -84,6 +86,8 @@
- !type:PlaySoundBehavior - !type:PlaySoundBehavior
sound: sound:
collection: GlassBreak collection: GlassBreak
params:
volume: -8
- !type:SpawnEntitiesBehavior - !type:SpawnEntitiesBehavior
spawn: spawn:
FoodPlateSmallTrash: FoodPlateSmallTrash:

View File

@@ -48,6 +48,8 @@
- !type:PlaySoundBehavior - !type:PlaySoundBehavior
sound: sound:
collection: GlassBreak collection: GlassBreak
params:
volume: -8
- !type:SpillBehavior { } - !type:SpillBehavior { }
- !type:SpawnEntitiesBehavior - !type:SpawnEntitiesBehavior
spawn: spawn:

View File

@@ -36,6 +36,8 @@
- !type:PlaySoundBehavior - !type:PlaySoundBehavior
sound: sound:
collection: GlassBreak collection: GlassBreak
params:
volume: -4
- !type:SpawnEntitiesBehavior - !type:SpawnEntitiesBehavior
spawn: spawn:
ShardGlass: ShardGlass:
@@ -157,6 +159,8 @@
- !type:PlaySoundBehavior - !type:PlaySoundBehavior
sound: sound:
collection: GlassBreak collection: GlassBreak
params:
volume: -4
- !type:SpawnEntitiesBehavior - !type:SpawnEntitiesBehavior
spawn: spawn:
ShardGlassReinforced: ShardGlassReinforced:
@@ -231,6 +235,8 @@
- !type:PlaySoundBehavior - !type:PlaySoundBehavior
sound: sound:
collection: GlassBreak collection: GlassBreak
params:
volume: -4
- !type:SpawnEntitiesBehavior - !type:SpawnEntitiesBehavior
spawn: spawn:
ShardGlassPlasma: ShardGlassPlasma:
@@ -357,6 +363,8 @@
- !type:PlaySoundBehavior - !type:PlaySoundBehavior
sound: sound:
collection: GlassBreak collection: GlassBreak
params:
volume: -4
- !type:SpawnEntitiesBehavior - !type:SpawnEntitiesBehavior
spawn: spawn:
ShardGlassUranium: ShardGlassUranium:

View File

@@ -39,6 +39,8 @@
- !type:PlaySoundBehavior - !type:PlaySoundBehavior
sound: sound:
collection: GlassBreak collection: GlassBreak
params:
volume: -4
- !type:SpawnEntitiesBehavior - !type:SpawnEntitiesBehavior
spawn: spawn:
ShardGlass: ShardGlass:

View File

@@ -24,7 +24,7 @@
thresholds: thresholds:
- trigger: - trigger:
!type:DamageTrigger !type:DamageTrigger
damage: 40 damage: 30
behaviors: behaviors:
- !type:DoActsBehavior - !type:DoActsBehavior
acts: [ "Destruction" ] acts: [ "Destruction" ]
@@ -33,7 +33,10 @@
damage: 20 damage: 20
behaviors: behaviors:
- !type:PlaySoundBehavior - !type:PlaySoundBehavior
sound: /Audio/Effects/metalbreak.ogg sound:
path: /Audio/Effects/metalbreak.ogg
params:
volume: -8
- !type:DoActsBehavior - !type:DoActsBehavior
acts: [ "Destruction" ] acts: [ "Destruction" ]
- type: DamageOnLand - type: DamageOnLand

View File

@@ -39,6 +39,8 @@
- !type:PlaySoundBehavior - !type:PlaySoundBehavior
sound: sound:
collection: GlassBreak collection: GlassBreak
params:
volume: -8
- !type:DoActsBehavior - !type:DoActsBehavior
acts: [ "Breakage" ] acts: [ "Breakage" ]
- trigger: - trigger:
@@ -48,6 +50,8 @@
- !type:PlaySoundBehavior - !type:PlaySoundBehavior
sound: sound:
collection: GlassBreak collection: GlassBreak
params:
volume: -8
- !type:SpawnEntitiesBehavior - !type:SpawnEntitiesBehavior
spawn: spawn:
ShardGlass: ShardGlass:

View File

@@ -79,6 +79,8 @@
- !type:PlaySoundBehavior - !type:PlaySoundBehavior
sound: sound:
collection: GlassBreak collection: GlassBreak
params:
volume: -4
- !type:SpillBehavior { } - !type:SpillBehavior { }
- !type:SpawnEntitiesBehavior - !type:SpawnEntitiesBehavior
spawn: spawn:

View File

@@ -62,6 +62,8 @@
- !type:PlaySoundBehavior - !type:PlaySoundBehavior
sound: sound:
collection: GlassBreak collection: GlassBreak
params:
volume: -4
- !type:SpillBehavior - !type:SpillBehavior
solution: beaker solution: beaker
- !type:SpawnEntitiesBehavior - !type:SpawnEntitiesBehavior

View File

@@ -93,6 +93,8 @@
- !type:PlaySoundBehavior - !type:PlaySoundBehavior
sound: sound:
collection: GlassBreak collection: GlassBreak
params:
volume: -4
- !type:SpawnEntitiesBehavior - !type:SpawnEntitiesBehavior
spawn: spawn:
PartRodMetal1: PartRodMetal1:

View File

@@ -42,6 +42,8 @@
- !type:PlaySoundBehavior - !type:PlaySoundBehavior
sound: sound:
path: /Audio/Effects/metalbreak.ogg path: /Audio/Effects/metalbreak.ogg
params:
volume: -6
- !type:SpawnEntitiesBehavior - !type:SpawnEntitiesBehavior
spawn: spawn:
PartRodMetal1: PartRodMetal1:
@@ -140,6 +142,8 @@
- !type:PlaySoundBehavior - !type:PlaySoundBehavior
sound: sound:
path: /Audio/Effects/metalbreak.ogg path: /Audio/Effects/metalbreak.ogg
params:
volume: -6
- !type:SpawnEntitiesBehavior - !type:SpawnEntitiesBehavior
spawn: spawn:
SheetSteel1: SheetSteel1:
@@ -179,6 +183,8 @@
- !type:PlaySoundBehavior - !type:PlaySoundBehavior
sound: sound:
path: /Audio/Effects/metalbreak.ogg path: /Audio/Effects/metalbreak.ogg
params:
volume: -6
- !type:SpawnEntitiesBehavior - !type:SpawnEntitiesBehavior
spawn: spawn:
SheetSteel1: SheetSteel1:
@@ -215,6 +221,8 @@
- !type:PlaySoundBehavior - !type:PlaySoundBehavior
sound: sound:
path: /Audio/Effects/metalbreak.ogg path: /Audio/Effects/metalbreak.ogg
params:
volume: -6
- !type:SpawnEntitiesBehavior - !type:SpawnEntitiesBehavior
spawn: spawn:
SheetSteel1: SheetSteel1:
@@ -601,6 +609,8 @@
- !type:PlaySoundBehavior - !type:PlaySoundBehavior
sound: sound:
path: /Audio/Effects/metalbreak.ogg path: /Audio/Effects/metalbreak.ogg
params:
volume: -6
- !type:SpawnEntitiesBehavior - !type:SpawnEntitiesBehavior
spawn: spawn:
SheetSteel1: SheetSteel1:

View File

@@ -91,6 +91,8 @@
- !type:PlaySoundBehavior - !type:PlaySoundBehavior
sound: sound:
path: /Audio/Effects/metalbreak.ogg path: /Audio/Effects/metalbreak.ogg
params:
volume: -6
- !type:SpawnEntitiesBehavior - !type:SpawnEntitiesBehavior
spawn: spawn:
SheetSteel1: SheetSteel1:

View File

@@ -34,6 +34,8 @@
- !type:PlaySoundBehavior - !type:PlaySoundBehavior
sound: sound:
path: /Audio/Effects/metalbreak.ogg path: /Audio/Effects/metalbreak.ogg
params:
volume: -8
- !type:SpawnEntitiesBehavior - !type:SpawnEntitiesBehavior
spawn: spawn:
GasPipeBroken: GasPipeBroken:

View File

@@ -56,6 +56,8 @@
- !type:PlaySoundBehavior - !type:PlaySoundBehavior
sound: sound:
path: /Audio/Effects/metalbreak.ogg path: /Audio/Effects/metalbreak.ogg
params:
volume: -6
- !type:SpawnEntitiesBehavior - !type:SpawnEntitiesBehavior
spawn: spawn:
SheetSteel1: SheetSteel1:

View File

@@ -36,6 +36,8 @@
- !type:PlaySoundBehavior - !type:PlaySoundBehavior
sound: sound:
path: /Audio/Effects/metalbreak.ogg path: /Audio/Effects/metalbreak.ogg
params:
volume: -6
- !type:SpawnEntitiesBehavior - !type:SpawnEntitiesBehavior
spawn: spawn:
SheetSteel1: SheetSteel1:

View File

@@ -75,6 +75,8 @@
- !type:PlaySoundBehavior - !type:PlaySoundBehavior
sound: sound:
path: /Audio/Effects/metalbreak.ogg path: /Audio/Effects/metalbreak.ogg
params:
volume: -6
- !type:SpawnEntitiesBehavior - !type:SpawnEntitiesBehavior
spawn: spawn:
SheetSteel1: SheetSteel1:
@@ -148,6 +150,8 @@
- !type:PlaySoundBehavior - !type:PlaySoundBehavior
sound: sound:
path: /Audio/Effects/metalbreak.ogg path: /Audio/Effects/metalbreak.ogg
params:
volume: -6
- !type:SpawnEntitiesBehavior - !type:SpawnEntitiesBehavior
spawn: spawn:
SheetSteel1: SheetSteel1:
@@ -254,6 +258,8 @@
- !type:PlaySoundBehavior - !type:PlaySoundBehavior
sound: sound:
path: /Audio/Effects/metalbreak.ogg path: /Audio/Effects/metalbreak.ogg
params:
volume: -6
- !type:SpawnEntitiesBehavior - !type:SpawnEntitiesBehavior
spawn: spawn:
SheetSteel1: SheetSteel1:

View File

@@ -48,6 +48,8 @@
- !type:PlaySoundBehavior - !type:PlaySoundBehavior
sound: sound:
path: /Audio/Effects/metalbreak.ogg path: /Audio/Effects/metalbreak.ogg
params:
volume: -6
- !type:SpawnEntitiesBehavior - !type:SpawnEntitiesBehavior
spawn: spawn:
SheetSteel1: SheetSteel1:

View File

@@ -103,6 +103,8 @@
- !type:PlaySoundBehavior - !type:PlaySoundBehavior
sound: sound:
path: /Audio/Effects/metalbreak.ogg path: /Audio/Effects/metalbreak.ogg
params:
volume: -4
- type: entity - type: entity
id: AirAlarmAssembly id: AirAlarmAssembly

View File

@@ -55,6 +55,8 @@
- !type:PlaySoundBehavior - !type:PlaySoundBehavior
sound: sound:
path: /Audio/Effects/metalbreak.ogg path: /Audio/Effects/metalbreak.ogg
params:
volume: -4
placement: placement:
mode: SnapgridCenter mode: SnapgridCenter

View File

@@ -102,6 +102,8 @@
- !type:PlaySoundBehavior - !type:PlaySoundBehavior
sound: sound:
path: /Audio/Effects/metalbreak.ogg path: /Audio/Effects/metalbreak.ogg
params:
volume: -4
placement: placement:
mode: SnapgridCenter mode: SnapgridCenter
snap: snap:

View File

@@ -82,6 +82,8 @@
- !type:PlaySoundBehavior - !type:PlaySoundBehavior
sound: sound:
path: /Audio/Effects/metalbreak.ogg path: /Audio/Effects/metalbreak.ogg
params:
volume: -4
- type: GenericVisualizer - type: GenericVisualizer
visuals: visuals:
enum.PowerDeviceVisuals.Powered: enum.PowerDeviceVisuals.Powered:

View File

@@ -64,6 +64,8 @@
- !type:PlaySoundBehavior - !type:PlaySoundBehavior
sound: sound:
path: /Audio/Effects/metalbreak.ogg path: /Audio/Effects/metalbreak.ogg
params:
volume: -8
placement: placement:
mode: SnapgridCenter mode: SnapgridCenter
snap: snap:

View File

@@ -92,6 +92,8 @@
- !type:PlaySoundBehavior - !type:PlaySoundBehavior
sound: sound:
path: /Audio/Effects/metalbreak.ogg path: /Audio/Effects/metalbreak.ogg
params:
volume: -8
- type: entity - type: entity
id: ApcNetSwitch id: ApcNetSwitch

View File

@@ -44,6 +44,8 @@
- !type:PlaySoundBehavior - !type:PlaySoundBehavior
sound: sound:
path: /Audio/Effects/metalbreak.ogg path: /Audio/Effects/metalbreak.ogg
params:
volume: -6
- !type:SpawnEntitiesBehavior - !type:SpawnEntitiesBehavior
spawn: spawn:
PartRodMetal1: PartRodMetal1:
@@ -111,6 +113,8 @@
- !type:PlaySoundBehavior - !type:PlaySoundBehavior
sound: sound:
path: /Audio/Effects/metalbreak.ogg path: /Audio/Effects/metalbreak.ogg
params:
volume: -6
- !type:SpawnEntitiesBehavior - !type:SpawnEntitiesBehavior
spawn: spawn:
PartRodMetal1: PartRodMetal1:
@@ -169,6 +173,8 @@
- !type:PlaySoundBehavior - !type:PlaySoundBehavior
sound: sound:
path: /Audio/Effects/metalbreak.ogg path: /Audio/Effects/metalbreak.ogg
params:
volume: -6
- !type:SpawnEntitiesBehavior - !type:SpawnEntitiesBehavior
spawn: spawn:
PartRodMetal1: PartRodMetal1:
@@ -242,6 +248,8 @@
- !type:PlaySoundBehavior - !type:PlaySoundBehavior
sound: sound:
path: /Audio/Effects/metalbreak.ogg path: /Audio/Effects/metalbreak.ogg
params:
volume: -6
- !type:SpawnEntitiesBehavior - !type:SpawnEntitiesBehavior
spawn: spawn:
PartRodMetal1: PartRodMetal1:

View File

@@ -720,8 +720,6 @@
path: /Audio/Effects/metalbreak.ogg path: /Audio/Effects/metalbreak.ogg
- !type:DoActsBehavior - !type:DoActsBehavior
acts: ["Destruction"] acts: ["Destruction"]
destroySound:
path: /Audio/Effects/metalbreak.ogg
- type: Construction - type: Construction
graph: Girder graph: Girder
node: diagonalshuttleWall node: diagonalshuttleWall

View File

@@ -32,6 +32,8 @@
- !type:PlaySoundBehavior - !type:PlaySoundBehavior
sound: sound:
path: /Audio/Effects/metalbreak.ogg path: /Audio/Effects/metalbreak.ogg
params:
volume: -4
- !type:SpawnEntitiesBehavior - !type:SpawnEntitiesBehavior
spawn: spawn:
SheetSteel1: SheetSteel1:

View File

@@ -1,5 +1,5 @@
- type: soundCollection - type: soundCollection
id: explosion id: Explosion
files: files:
- /Audio/Effects/explosion1.ogg - /Audio/Effects/explosion1.ogg
- /Audio/Effects/explosion2.ogg - /Audio/Effects/explosion2.ogg
@@ -7,3 +7,20 @@
- /Audio/Effects/explosion4.ogg - /Audio/Effects/explosion4.ogg
- /Audio/Effects/explosion5.ogg - /Audio/Effects/explosion5.ogg
- /Audio/Effects/explosion6.ogg - /Audio/Effects/explosion6.ogg
- type: soundCollection
id: ExplosionSmall
files:
- /Audio/Effects/explosion_small1.ogg
- /Audio/Effects/explosion_small2.ogg
- /Audio/Effects/explosion_small3.ogg
- type: soundCollection
id: ExplosionFar
files:
- /Audio/Effects/explosionfar.ogg
- type: soundCollection
id: ExplosionSmallFar
files:
- /Audio/Effects/explosionsmallfar.ogg