Imagine
2012-03-31 14:12:07
So currently I have a function which "tracks" an NPC. At this point, all it does is output the NPC's center coordinates (will make a TBox in the near future) to the debug box. How can I make it return them as the function runs so I can have a FindColorsSpiralTolerance avoid the specific area where the NPC is?
I can upload what I have of the function so far if anybody would like it.
Seeing as there are no replies yet, I'll upload what I have so far:
Making a TBox around the object is on the to-do list. But I need to figure out a way I can get the results of this function to a mainloop so I can run the regular script and not find whatever it found with this over and over again - if that makes sense.
I can upload what I have of the function so far if anybody would like it.
Seeing as there are no replies yet, I'll upload what I have so far:
function TrackNPC(hue, saturation: extended; Color, Tol : Integer; Uptext : TStringArray; XBounds, YBounds, Tries : Integer): Boolean;
var
I, N, x, y, t: Integer;
TPA: TPointArray;
ATPA: Array of TPointArray;
FoundIt: Boolean;
begin
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(h, s);
FindColorsSpiralTolerance(MSCX, MSCY, TPA, Color, MSX1, MSY1, MSX2, MSY2, Tol);
ATPA := TPAToATPAEx(TPA, 15, 15);
N := High(ATPA);
for I := 0 to N do
begin
MiddleTPAEx(ATPA[i], x, y);
MMouse(x, y, 2, 2);
if(IsUpTextMultiCustom([Uptext])) then
begin
FoundIt := True;
GetMousePosition(x, y);
end;
end;
while(FoundIt = true) do
for t := 0 to Tries do
if FindColorsSpiralTolerance(x, y, TPA, Color, (x - (XBounds/2)) , (y - (YBounds/2)), (x + (XBounds/2)), (y + (XBounds/2)), Tol) then
begin
ATPA := TPAToATPAEx(TPA, 15, 15);
MiddleTPAEx(ATPA[i], x, y);
writeln('Object is currently at ' + IntToStr(x)+ ',' + IntToStr(y));
break; // Found object
FoundIt := true;
end
else begin
writeln('Failed to find object - Trying again');
Inc(t);
FoundIt := False;
end;
wait(100 + Random(100));
end;Making a TBox around the object is on the to-do list. But I need to figure out a way I can get the results of this function to a mainloop so I can run the regular script and not find whatever it found with this over and over again - if that makes sense.