This was one of those '5 minute jobs' that I've spent hours scratching my head over... I just want to make a simple sound 'randomizer' that alternates between 3 sounds. I initially thought this would just be a case of an ifrnd with a switch statement... but the problem I was having was that my sounds starting playing on top of one another. I tried a number of things, and have alternated between using ifcount and using my own timer (soundtimer)...
The following actually seems to work (I put that spawn SMOKEPUFF1 bit in there just to check that the timer is actually counting down to zero ) however it only seems to play one of the 3 sounds. I've sat there in the level for 5 mins and it will just play the same sound over and over...
defstate AIRPORTPAstate
{
ifsound AIRPORTPA1 sub soundtimer 1
ifsound AIRPORTPA2 sub soundtimer 1
ifsound AIRPORTPA3 sub soundtimer 1
ife soundtimer 0 { spawn SMOKEPUFF1 set soundtimer 270 }
else
ife soundtimer 270
{
randvar tempA 2
switch tempA
case 0 { sound AIRPORTPA1 break }
case 1 { sound AIRPORTPA2 break }
case 2 { sound AIRPORTPA3 break }
endswitch
}
else nullop
}
ends
And then my actor itself is very basic;
useractor notenemy AIRPORTPA cstat 32768 state AIRPORTPAstate enda
TempA is a per-actor var (I also experimented with global vars but it didn't seem to make much difference). soundtimer is initiated to 270, as each sound is approx 9 seconds in length.