From 864ec0af9f89ec679a8fc60ca162e48e55614053 Mon Sep 17 00:00:00 2001 From: Marisa Kirisame Date: Sun, 7 Jan 2018 00:42:37 +0100 Subject: [PATCH] Exported S_IsActorPlayingSomething and S_GetMSLength to ZScript. --- src/s_advsound.cpp | 6 ++++++ src/s_sound.cpp | 8 ++++++++ wadsrc/static/zscript/actor.txt | 1 + wadsrc/static/zscript/base.txt | 1 + 4 files changed, 16 insertions(+) diff --git a/src/s_advsound.cpp b/src/s_advsound.cpp index 5aa52981d..a157adaa2 100644 --- a/src/s_advsound.cpp +++ b/src/s_advsound.cpp @@ -491,6 +491,12 @@ unsigned int S_GetMSLength(FSoundID sound) else return 0; } +DEFINE_ACTION_FUNCTION(DObject,S_GetLength) +{ + PARAM_PROLOGUE; + PARAM_SOUND(sound_id); + ACTION_RETURN_FLOAT(S_GetMSLength(sound_id)/1000.0); +} //========================================================================== // diff --git a/src/s_sound.cpp b/src/s_sound.cpp index fede842b1..ab007ee06 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -1895,6 +1895,14 @@ bool S_IsActorPlayingSomething (AActor *actor, int channel, int sound_id) return false; } +DEFINE_ACTION_FUNCTION(AActor, A_IsPlayingSound) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_INT(channel); + PARAM_SOUND(sound); + ACTION_RETURN_BOOL(S_IsActorPlayingSomething(self,channel,sound)); +} + //========================================================================== // // S_PauseSound diff --git a/wadsrc/static/zscript/actor.txt b/wadsrc/static/zscript/actor.txt index 6dd222fbf..ee5700c80 100644 --- a/wadsrc/static/zscript/actor.txt +++ b/wadsrc/static/zscript/actor.txt @@ -1007,6 +1007,7 @@ class Actor : Thinker native native void A_StopSound(int slot = CHAN_VOICE); // Bad default but that's what is originally was... deprecated("2.3") native void A_PlaySoundEx(sound whattoplay, name slot, bool looping = false, int attenuation = 0); deprecated("2.3") native void A_StopSoundEx(name slot); + native bool A_IsPlayingSound(int channel = 0, sound sound_id = ""); native void A_SeekerMissile(int threshold, int turnmax, int flags = 0, int chance = 50, int distance = 10); native action state A_Jump(int chance, statelabel label, ...); native Actor A_SpawnProjectile(class missiletype, double spawnheight = 32, double spawnofs_xy = 0, double angle = 0, int flags = 0, double pitch = 0, int ptr = AAPTR_TARGET); diff --git a/wadsrc/static/zscript/base.txt b/wadsrc/static/zscript/base.txt index 01e2af795..c47a778e8 100644 --- a/wadsrc/static/zscript/base.txt +++ b/wadsrc/static/zscript/base.txt @@ -354,6 +354,7 @@ class Object native 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); + native static float S_GetLength(Sound sound_id); native static uint BAM(double angle); native static void SetMusicVolume(float vol); native static uint MSTime();