DoFlicker(Victim : agent, Character : fort_character) : void = # Set the timer for how long they are vulnerable if (set PlayerVisibilitySeconds[Victim] = VulnerableSeconds) {} else: set PlayerVisibilitySeconds[Victim] = VulnerableSeconds # Show the character so enemies can see the flicker Character.Show() # Track elapsed time manually since map subtraction needs a failable set var Elapsed : float = 0.0 loop: if (PlayerVisibilitySeconds[Victim] - Elapsed <= 0.0): break # Toggle: show on even steps, hide on odd steps if (Elapsed mod (FlickerRateSeconds * 2.0) < FlickerRateSeconds): Character.Show() else: Character.Hide() Sleep(FlickerRateSeconds) set Elapsed += FlickerRateSeconds # Make sure they are fully invisible again when done Character.Hide()