/** * How often a script re-evaluates what to do next. This is unrelated to any * server tick rate — Adventure Land doesn't expose one to scripts. Actions * are independently rate-limited by their own cooldowns (attack speed, skill * cooldowns, etc.), which the guard functions like `can_attack()` and * `can_use()` already check. This just needs to be frequent enough to react * promptly once those cooldowns clear. */ export const DEFAULT_LOOP_INTERVAL_MS = 1000 / 4; /** * Runs `tick` on a fixed interval, defaulting to * {@link DEFAULT_LOOP_INTERVAL_MS}. Returns a function that stops it. */ export function startLoop( tick: () => void, intervalMs: number = DEFAULT_LOOP_INTERVAL_MS, ): () => void { const id = setInterval(tick, intervalMs); return () => clearInterval(id); }