- Added ACS function PlayActorSound. It's functionally equivalent to PlaySound, except instead

of taking an actual sound name as its second parameter, it selects the sound to play based on
  the actor playing the sound and the selector passed as the second parameter.

SVN r4323 (trunk)
This commit is contained in:
Randy Heit 2013-06-03 00:09:46 +00:00
parent aa40801015
commit 44a9c75b6b

View file

@ -4080,6 +4080,38 @@ int DLevelScript::DoClassifyActor(int tid)
return classify;
}
enum
{
SOUND_See,
SOUND_Attack,
SOUND_Pain,
SOUND_Death,
SOUND_Active,
SOUND_Use,
SOUND_Bounce,
SOUND_WallBounce,
SOUND_CrushPain,
SOUND_Howl,
};
static FSoundID GetActorSound(const AActor *actor, int soundtype)
{
switch (soundtype)
{
case SOUND_See: return actor->SeeSound;
case SOUND_Attack: return actor->AttackSound;
case SOUND_Pain: return actor->PainSound;
case SOUND_Death: return actor->DeathSound;
case SOUND_Active: return actor->ActiveSound;
case SOUND_Use: return actor->UseSound;
case SOUND_Bounce: return actor->BounceSound;
case SOUND_WallBounce: return actor->WallBounceSound;
case SOUND_CrushPain: return actor->CrushPainSound;
case SOUND_Howl: return actor->GetClass()->Meta.GetMetaInt(AMETA_HowlSound);
default: return 0;
}
}
enum EACSFunctions
{
ACSF_GetLineUDMFInt=1,
@ -4152,6 +4184,7 @@ enum EACSFunctions
ACSF_GetActorClass,
ACSF_GetWeapon,
ACSF_SoundVolume,
ACSF_PlayActorSound,
// ZDaemon
ACSF_GetTeamScore = 19620, // (int team)
@ -4927,15 +4960,24 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, SDWORD *args, const
break;
case ACSF_PlaySound:
case ACSF_PlayActorSound:
// PlaySound(tid, "SoundName", channel, volume, looping, attenuation)
{
const char *lookup = FBehavior::StaticLookupString(args[1]);
if (lookup != NULL)
FSoundID sid;
if (funcIndex == ACSF_PlaySound)
{
const char *lookup = FBehavior::StaticLookupString(args[1]);
if (lookup != NULL)
{
sid = lookup;
}
}
if (sid != 0 || funcIndex == ACSF_PlayActorSound)
{
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;
@ -4948,13 +4990,20 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, SDWORD *args, const
}
while ((spot = it.Next()) != NULL)
{
doplaysound: if (!looping)
doplaysound: if (funcIndex == ACSF_PlayActorSound)
{
S_Sound(spot, chan, sid, vol, atten);
sid = GetActorSound(spot, args[1]);
}
else if (!S_IsActorPlayingSomething(spot, chan, sid))
if (sid != 0)
{
S_Sound(spot, chan | CHAN_LOOP, sid, vol, atten);
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);
}
}
}
}