Detect mobs champions

Searching for champions with the aura in a separate thread . When a champion is found, the script will stop the fighting in the bot, move to the champion, take it to the target and turn fighting on. Actions upon detection should be adapted to your ch

uses SysUtils;

procedure FindChampionsThread(R: integer = 2000);
var i: integer;   point: TXYZ;
begin
  while delay(555) do begin
    if (Engine.Status = lsOnline) then begin
      for i:= 0 to NpcList.Count-1 do begin             // running through the list of mobs
        if (NpcList(i).Team <> 0) and                   // if mob is champion and 
        (User.DistTo(NpcList(i)) < R) and               // distance to mob < search radius and
        (Abs(User.Z - NpcList(i).Z) < 500) then begin   // the difference in absolute value of the Z coordinate of the bot and mob is < 500, then
          Print('Detected champion: '+NpcList(i).Name+', [HP: '+IntToStr(NpcList(i).CurHP)+'], Dist: '+IntToStr(User.DistTo(NpcList(i))));
          // then we do what is needed, the following will be enough simple steps without special checks
          Engine.FaceControl(1, false);                 // turn off combat in bot
          point:= CalcXYZ(User, NpcList(i), 500);       // calculate coordinates where it is necessary to run up to the champion
          Engine.MoveTo(point.X, point.Y, point.Z);     // run to the mob
          Engine.SetTarget(NpcList(i));                 // take it to target 
          Engine.FaceControl(1, true);                  // turn on combat back

          break;                                        // do not forget to exit the loop
        end;
      end;
    end;
  end;
end;
        
begin
  Script.NewThread(@FindChampionsThread);    
  // code ...   
  Delay(-1);
end.