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; }