I wrote this function to find a Npc, but the NPC keeps moving, so I have repeats in it.I want it to be faster, yet I cannot see how yet. Does anyone have any ideas that could improve it?
Simba Code:
Function FindNPC:Boolean;
var
Cts,a, y, Tries:Integer;
NPCTPA:Tpointarray;
NPCATPA:T2DPointarray;
begin
CTS:= GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.13, 1.05);
marktime(y);
repeat
if FindColorsSpiralTolerance(MSCX, MSCY, NPCTPA, 4025793, msx1, msy1, msx2, msy2, 14) then
begin
if Debug then
Writeln('Found npc colors...');
NPCATPA := SplitTPAEx(NPCTPA, 5, 5);
SortATPAFromMidPoint(NPCATPA, Point(262, 224-50))
end;
for a :=0 to high(NPCATPA) do
begin
MouseSpeed:=(Randomrange(9, 15));
HumanMMouse(NPCTPA[a].x, NPCTPA[a].y, 3, 3);
wait(300+Random(100));
Inc(Tries);
if isUptext('to') then
begin
Result := True;
Exit;
end else
Result := False;
end;
Until(TimeFromMark(y) > 20000);
ColorToleranceSpeed(CTS);
SetColorSpeed2Modifiers(0.02, 0.02);
end;