Added S_StartSoundAt

Allows for positional sounds that aren't attached to any Actor.
This commit is contained in:
Boondorl 2025-01-17 14:38:25 -05:00 committed by Rachael Alexanderson
parent dad8e4719c
commit a1460e88af
2 changed files with 25 additions and 1 deletions

View file

@ -379,7 +379,7 @@ void S_InitData()
void S_SoundPitch(int channel, EChanFlags flags, FSoundID sound_id, float volume, float attenuation, float pitch, float startTime)
{
soundEngine->StartSound(SOURCE_None, nullptr, nullptr, channel, flags, sound_id, volume, attenuation, 0, pitch);
soundEngine->StartSound(SOURCE_None, nullptr, nullptr, channel, flags, sound_id, volume, attenuation, nullptr, pitch, startTime);
}
void S_Sound(int channel, EChanFlags flags, FSoundID sound_id, float volume, float attenuation)
@ -414,6 +414,29 @@ DEFINE_ACTION_FUNCTION(DObject, S_StartSound)
return 0;
}
static void S_StartSoundAt(double x, double y, double z, int sound_id, int channel, int flags, double volume, double attenuation, double pitch, double startTime)
{
FVector3 pos = { (float)x, (float)z, (float)y };
soundEngine->StartSound(SOURCE_Unattached, nullptr, &pos, channel, EChanFlags::FromInt(flags), FSoundID::fromInt(sound_id), (float)volume, (float)attenuation, nullptr, (float)pitch, (float)startTime);
}
DEFINE_ACTION_FUNCTION_NATIVE(DObject, S_StartSoundAt, S_StartSoundAt)
{
PARAM_PROLOGUE;
PARAM_FLOAT(x);
PARAM_FLOAT(y);
PARAM_FLOAT(z);
PARAM_INT(id);
PARAM_INT(channel);
PARAM_INT(flags);
PARAM_FLOAT(volume);
PARAM_FLOAT(attn);
PARAM_FLOAT(pitch);
PARAM_FLOAT(startTime);
S_StartSoundAt(x, y, z, id, channel, flags, volume, attn, pitch, startTime);
return 0;
}
//==========================================================================
//

View file

@ -132,6 +132,7 @@ extend class Object
}
deprecated("4.3", "Use S_StartSound() instead") native static void S_Sound (Sound sound_id, int channel, float volume = 1, float attenuation = ATTN_NORM, float pitch = 0.0, float startTime = 0.0);
native static void S_StartSound (Sound sound_id, int channel, int flags = 0, float volume = 1, float attenuation = ATTN_NORM, float pitch = 0.0, float startTime = 0.0);
native static void S_StartSoundAt(Vector3 pos, Sound sound_id, int channel, int flags = 0, double volume = 1, double attenuation = ATTN_NORM, double pitch = 0.0, double startTime = 0.0);
native static void S_PauseSound (bool notmusic, bool notsfx);
native static void S_ResumeSound (bool notsfx);
native static bool S_ChangeMusic(String music_name, int order = 0, bool looping = true, bool force = false);