SRL Archive - SRL Snippets

WaitMMChange


Nebula

2012-10-29 22:07:41

I made this function just earlier for use in a script of mine. I think some people will find it useful (eg. determining if your player has teleported or entered a new area).


{*******************************************************************************
function WaitMMChange(Tol, Percent, TimeOut: Integer): boolean;
Description: Compares your minimap to your starting minimap repeatedly with a
tolerance of Tol. Waits for a max of TimeOut or until the difference
is greater than percent.
*******************************************************************************}
function WaitMMChange(Tol, Percent, TimeOut: Integer): boolean;
var
boxCoords, tmpCoords: array of TPoint;
boxCols, tmpCols: array of Integer;
bools: array of Boolean;
j, TimePlace, maxT, falseBools: Integer;
begin
boxCoords := TPAFromBox(IntToBox(MMX1, MMY1, MMx2, MMY2));
RemoveDistTPointArrayWrap(MMCX, MMCY, 75, boxCoords, true, boxCoords);
RAaSTPA(boxCoords, 3);
boxCols := GetColors(boxCoords);
maxT := TimeOut;
MarkTime(TimePlace);
while (TimeFromMark(TimePlace) < maxT) and (not result) do
begin
falseBools := 0;
tmpCoords := CopyTPA(boxCoords);
tmpCols := GetColors(boxCoords);
SetLength(bools, Length(boxCoords));
for j:= 0 to high(bools) do
bools[j] := SimilarColors(boxCols[j], tmpCols[j], Tol);
for j:= 0 to high(bools) do
if not bools[j] then
inc(falseBools);
result := Round(falseBools * 100.0 / Length(bools)) >= Percent;
end;
end;

Flight

2012-10-29 22:18:46

Handy indeed. I'm wondering though, would it not be easier to use PixelShift?

riwu

2012-10-29 22:23:25

From: Flight
Handy indeed. I'm wondering though, would it not be easier to use PixelShift?

The problem is that you cannot afford to miss that one moment when the map changes. So you can't have antiban, or any long waits in between while teleporting. I personally like to do antiban while teleporting :p