# ****************************************************************************
# CUI
#
# The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
#
# The use, dissemination or disclosure of data in this file is subject to
# limitation or restriction. See accompanying README and LICENSE for details.
# ****************************************************************************


behavior  adjust_priority_for_escort

   precondition
      return true;
   end_precondition

   execute
      extern string mEscortName;
      WsfPlatform escortPlatform = WsfSimulation.FindPlatform( mEscortName );
      if( escortPlatform.IsValid() )
      {

         extern double cPursueTargetPriority;
         Array<WsfRIPRJob> jobs = PROCESSOR.GetJobs();
         foreach (WsfRIPRJob x in jobs)
         {
            double jobPriority = cPursueTargetPriority / (1 + x.SlantRangeTo( escortPlatform ) );
            x.Priority( jobPriority );
         }
      }
   end_execute

end_behavior
