From 1a67e6fa5d63787fd7f393a673a0a140227e988c Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Sat, 1 Jun 2013 02:43:36 +0000 Subject: [PATCH] - Added PlaySound and StopSound functions for ACS. They are mostly analogous to their DECORATE counterparts except that (1) PlaySound requires you to specify a sound instead of defaulting to "weapons/pistol", and (2) StopSound defaults to CHAN_BODY instead of CHAN_VOICE. SVN r4306 (trunk) --- src/p_acs.cpp | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 2ac34ebc9..a594d0179 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -4116,6 +4116,8 @@ enum EACSFunctions ACSF_GetUserCVarString, ACSF_SetUserCVarString, ACSF_LineAttack, + ACSF_PlaySound, + ACSF_StopSound, // ZDaemon ACSF_GetTeamScore = 19620, // (int team) @@ -4884,6 +4886,62 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, SDWORD *args) } break; + case ACSF_PlaySound: + // PlaySound(tid, "SoundName", channel, volume, looping, attenuation) + { + const char *lookup = FBehavior::StaticLookupString(args[1]); + if (lookup != NULL) + { + FActorIterator it(args[0]); + AActor *spot; + + FSoundID sid(lookup); + int chan = argCount > 2 ? args[2] : CHAN_BODY; + float vol = argCount > 3 ? FIXED2FLOAT(args[3]) : 1.f; + INTBOOL looping = argCount > 4 ? args[4] : false; + float atten = argCount > 5 ? FIXED2FLOAT(args[5]) : ATTN_NORM; + + if (args[0] == 0) + { + spot = activator; + goto doplaysound; + } + while ((spot = it.Next()) != NULL) + { +doplaysound: if (!looping) + { + S_Sound(spot, chan, sid, vol, atten); + } + else if (!S_IsActorPlayingSomething(spot, chan, sid)) + { + S_Sound(spot, chan | CHAN_LOOP, sid, vol, atten); + } + } + } + } + break; + + case ACSF_StopSound: + { + int chan = argCount > 1 ? args[1] : CHAN_BODY; + + if (args[0] == 0) + { + S_StopSound(activator, chan); + } + else + { + FActorIterator it(args[0]); + AActor *spot; + + while ((spot = it.Next()) != NULL) + { + S_StopSound(spot, chan); + } + } + } + break; + default: break; }