- 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)
This commit is contained in:
Randy Heit 2013-06-01 02:43:36 +00:00
parent 2d13a45773
commit 1a67e6fa5d

View file

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