Timer starts playing a sound ~2 seconds after the match start, then repeats every 30 seconds.
The problem is, when start_on is set, it adds the wait time to the initial start, so if I have "delay" set to "2" and "wait" set to "30", it'll be 32 seconds before I hear any sound.
I tried doing something clever and removed the start_on flag and added another func_timer with the start_on flag that targeted the sound. When triggered, only the delay is used. Then I used a trigger_relay to shut the timer off:
func_timer -> func_timer -> target_speaker
^
|
V
trigger_relay
That just caused a stack overflow.
Code: Select all
void func_timer_think (edict_t *self)
{
G_UseTargets (self, self->activator);
self->nextthink = level.time + self->wait + crandom() * self->random;
}
void func_timer_use (edict_t *self, edict_t *other, edict_t *activator)
{
self->activator = activator;
// if on, turn it off
if (self->nextthink)
{
self->nextthink = 0;
return;
}
// turn it on
if (self->delay)
self->nextthink = level.time + self->delay;
else
func_timer_think (self);
}
Any idea how to get the behavior I want without code modifications?