anchor.diff:            end;
           end;
   
  -      if (SqrClosestDistToRanged = INIT_DIST) then
  -        SqrClosestDistToRanged := SqrClosestDist; 
  -
         // Calculate threat level
         with fTargetU[I] do
         begin
  
positive.code: 
  function TAISquad.PlanPath(var aActualPosition, aTargetPosition: TKMPoint; aOrderAttack: Boolean = False): Boolean;
  const
    SQR_TARGET_REACHED_TOLERANCE = 5*5;
    SQR_TARGET_REACHED_RANGED = 14*14; // This should be more than maximal range (11*11)
  var
    InitPolygon, ClosestPolygon, Distance: Word;
    I: Integer;
  
negative.code:             // Calculate distant threat level (determine whether archers are shooting at our troops)
              DistantThreat := DistantThreat * Byte(SQR_RANGE_OF_PROJECTILES > SqrClosestDist);
              // Close threat level is computed with using influences
              CloseCombatProtection := 0;
              Polygon := gAIFields.NavMesh.KMPoint2Polygon[ UGA[I].Position ];
              for GT := Low(TKMGroupType) to High(TKMGroupType) do
                if (GT <> gt_Ranged) then
                  CloseCombatProtection := CloseCombatProtection + gAIFields.Influences.EnemyGroupPresence[fOwner, Polygon, GT]; // Tune parameters
              if (DistantThreat < CloseCombatProtection) then // Ranged units are well protected -> try shoot them
                CloseThreat := Byte(SqrClosestDistToRanged <= SQR_RANGE_OF_PROJECTILES) // Lowest priority but dont ignore them (if we have no archers call infantry)
              else // Ranged units are not protected -> attack with close combat units
                DistantThreat := Byte(SqrClosestDist <= SQR_RANGE_OF_PROJECTILES); // Lowest priority but dont ignore them (if they are in range of archers shoot at them)
            end
            else
            begin
  