Flagloop Explanation:
 
This routine is run when Torque has scanned a flag directly in front of him, but does not know how far ahead of him it is. At this point, Torque has at least one unit of damage, so it is safe for him to collect a flag.

As the name suggests, this routine is looped repeatedly until either Torque collects the flag, or the flag is no longer there.

The operation of the routine is:

  1. Move forward.
  2. Check for enemies on the perimeter.
  3. Long range scan.
  4. If a flag is scanned and no flag has been collected, loop back to 1.
  5. If an enemy is scanned, then attack it.
  6. If there is an enemy on the same axis as you, or an inbound missile, then jump to a routine to deal with this.
  7. Go back to the main hunting routines unless a flag is still scanned ahead.
  8. If a flag was scanned, jump to getflag routine.