# File generated by Wizard 2.9.0 on Dec 16, 2024.

processor pathPatrol WSF_TASK_PROCESSOR
   script_variables
      double launchRange = 20.0 * MATH.M_PER_NM();
      double salvoSize = 2;
      string weaponName = "aa_mrm";
      WsfWeapon aa_mrm  = PLATFORM.Weapon(weaponName);
      bool canPursue = false;
   end_script_variables

   script bool pursueCondition()
      return (
               aa_mrm.QuantityRemaining() > 0 &&
               TRACK.Target().IsValid()
             );
   end_script


   script bool Pursue()
      if(pursueCondition())
      {
         PLATFORM.GoToLocation(TRACK.CurrentLocation());
         return canPursue;
      }
      return canPursue;
   end_script
   
   script bool runAround()
      if(PLATFORM.Side() == "red")
      {
         PLATFORM.FollowRoute(PLATFORM.Name());
      }
      return (TRACK.Target().IsValid());
   end_script
   
   on_initialize2 
      PLATFORM.FollowRoute(PLATFORM.Name());
   end_on_initialize2
//////////////////////////////////////////STATE MACHINE///////////////////////////////////////
evaluation_interval DETECTED 1 sec
state DETECTED
   next_state RUNAROUND
      return (!pursueCondition()
               || PLATFORM.MasterTrackList().Count() <= 0
             );
   end_next_state
   
   next_state PURSUE
      return (pursueCondition());
   end_next_state
end_state

evaluation_interval PURSUE 1 sec
state PURSUE
   next_state WAIT
      return Pursue();
   end_next_state
end_state

evaluation_interval WAIT 1 sec
state WAIT
   next_state DETECTED
      return pursueCondition();
   end_next_state
   
   next_state RUNAROUND
      return (!pursueCondition()
              || PLATFORM.MasterTrackList().Count() <= 0
               );
   end_next_state
end_state

evaluation_interval RUNAROUND 1 sec
state RUNAROUND
   next_state DETECTED
      return runAround();
   end_next_state
end_state
end_processor