// stating the step, start at 0 so first repetition runs step 1
int BANG_STEP=0;
// should the loop continue?
bool bCONTINUE_LIGHTNING=true;
void BANG_LIGHTNING(string &in timer)
{
// add 1 to the event step
BANG_STEP++;
// if last bang occurred, break the loop
if(BANG_STEP==9) bCONTINUE_LIGHTNING=false;
// turn the lights on!
BANG_LIGHTS_ON(BANG_STEP);
}
// this is a float array - contains timer durations for pauses between lights on/off at each bang step
const float[] fPAUSE_VALUES={ 0.25f, 0.35f, 0.37f,
0.27f, 0.38f, 0.4f,
0.19f, 0.33f, 0.28f
};
void BANG_LIGHTS_ON(int BANG_STEP)
{
// turn the lights on
for(int i=1;i<=23;i++) SetLightVisible("thunder"+i, true);
// wait a specific duration (unique to each ban step) until turning hte lights off
AddTimer("", fPAUSE_VALUES[BANG_STEP], "BANG_LIGHTS_OFF");
}
void BANG_LIGHTS_OFF(string &in timer)
{
// turn the lights off
for(int i=1;i<=23;i++) SetLightVisible("thunder"+i, false);
// if not last lightning step, wait a random duration to play the next lightning bang
if(bCONTINUE_LIGHTNING) AddTimer(timer, RandFloat(45.0f, 70.0f), timer);
}