SRL Archive - Research & Development Lounge

isMoving and waitUntilStopMoving


danrox2004

2007-11-15 07:36:56

Two new functions i made today:
isMoving
Returns true if your player is moving (based on points on the minimap)

waitUntilStopMoving
Waits until your player has stopped moving (similar to fFlag(0) but uses points on the minimap)

function isSpecCol(col: integer): boolean;
begin
case col of
1310462: result := true; //NPCs
982782: result := true;
195836: result := true;
62965: result := true;
56797: result := true;
60909: result := true;
52428: result := true; //End of NPCs

16711422: result := true; //Players
15527148: result := true;
13816530: result := true;
14869218: result := true;
12961221: result := true; //End of Players

3553023: result := true; //Drops
789758: result := true;
2105598: result := true;
395004: result := true;
233: result := true;
241: result := true;
206: result := true;
217: result := true;
188: result := true; //End of Drops

16777215: result := true; //Your player

65536: result := true; //Bottom of drop dots

255: result := true; //Flag
284358: result := true;
1127261: result := true; //End of flag
end;
//if(result) then
// writeln(intToStr(col));
end;

function isMoving: boolean;
var
NumOfPoints: integer;
numDone: integer;
Points: array of record
x, y, color: integer;
end;
x, y: integer;
color: integer;
i: integer;
begin
NumOfPoints := 20;
numDone := 0;
setLength(points, NumOfPoints);
repeat
wait(1);
x := random(MMX2 - MMX1) + MMX1;
y := random(MMY2 - MMY1) + MMY1;
if(not isOnMinimap(x, y)) then
continue;
color := getColor(x, y);
if(isSpecCol(color)) then
continue;
points[numDone].x := x;
points[numDone].y := y;
points[numDone].color := color;
numDone := numDone + 1;
if(numDone = NumOfPoints) then
break;
until(false)
wait(100 + random(50));
for i := 0 to NumOfPoints - 1 do
begin
wait(1);
color := getColor(points[i].x, points[i].y);
if(color <> points[i].color) then
begin
if(not isSpecCol(color)) then
begin
//writeln('Yea ' + intToStr(color) + ', ' + intTOStr(points[i].color) + ' ' + intToStr(points[i].x) + ', ' + intToStr(points[i].y));
result := true;
exit;
end;
end;
end;
end;

procedure waitUntilStopMoving;
var
t1, t2: integer;
begin
T1 := GetTickCount;
repeat
T2 := GetTickCount;
Wait(100);
if T2 - T1 > 30000 then
begin
Mouse(MMCX, MMCY, 0, 0, True);
Break;
end;
if Random(20) = 1 then IdleTime(500, 1000, 0.01);
until (not isMoving);
end;

vilon

2007-11-15 08:11:26

This could be really useful as a failsafe when walking, nice work!
I'll try it out for sure.

n3ss3s

2007-11-15 11:19:36

Nice job, though some tips:

a) For the case, instead make an array of integer, load all the colors there and do Result := InIntArray(Array, Int).

b) The function seems good, and I believe it works better than the following, but maybe comparing distance from MMC to flag would be simpler?

And no, I am not saying anything about converting to that, simple and short = shit.

SSS

Hugolord

2007-11-15 11:45:10

what points on the MM does it use?

danrox2004

2007-11-15 18:36:48

@n3ss3s

Cool, thanks dont know what the use of it is though…

#hugolord
It picks random points on the minimap which arnt covered by things that can move, such as player/drop/NPC dots etc.

Smartzkid

2007-11-18 16:46:00

Ahh, I like!

Great for stuff that moves you but doesn't flag.