SCAR Code:
program new;
{$i SRL/SRL.scar}
{******************************************************************************}
{ procedure MSI_SortColors(var Colors: tIntegerArray; col: Integer); }
{ By: Blumblebee }
{ Description: Sorts an array of colors }
{******************************************************************************}
procedure MSI_SortColors(var Colors: tIntegerArray; col: Integer);
var
tempB: tIntegerArray;
Tol: ShortInt;
I: Integer;
timer, L: LongInt;
begin
timer := getsystemtime;
tempB := Colors;
SetArrayLength(Colors, 0);
Tol := 0;
while Length(Colors) < (Length(tempB)/2 or 5) do
begin
if Getsystemtime-timer > 100 then Break;
for i := 0 to High(tempB) do
begin
if SimilarColors(tempB[i], col, Tol) then
begin
L := GetArrayLength(Colors);
SetArrayLength(Colors, L+1);
Colors[L] := tempB[i];
end;
if Tol > 10 then Break;
Inc(Tol);
end;
end;
end;
{******************************************************************************}
{ function MSI_AutoColorMM(const color: Integer): Integer; }
{ By: Blumblebee }
{ Description: Autocolors the color 'color' on the minimap }
{******************************************************************************}
function MSI_AutoColorMM(const color: Integer): Integer;
var
TPA: tPointArray;
List: tIntegerArray;
I: Integer;
begin
for i := 0 to 20 do
begin
FindColorsTolerance(TPA, color, MMx1, MMy1, MMx2, MMy2, 5+i);
if Length(TPA) > 0 then Break;
end;
if Length(TPA) <= 0 then Exit;
List := getColors(TPA);
MSI_SortColors(List, color);
if Length(List) <= 0 then Exit;
result := List[0];
end;
{******************************************************************************}
{ function MSI_CreateWalkTPA( ... ): TPointArray; }
{ By: Blumblebee }
{ Description: Creats a TPA of which can be walked to }
{******************************************************************************}
function MSI_CreateWalkTPA(x, y, color, width, height, tolerance: Integer): TpointArray;
var
TPA: tPointArray;
aTPA: t2DPointArray;
i: Integer;
L, P: Integer;
begin
FindColorsSpiralTolerance(x, y, TPA, color, MMx1, MMy1, MMx2, MMy2, tolerance);
aTPA := TPAtoATPAEx(TPA, width, height);
for i := 0 to High(aTPA) do
begin
if Length(aTPA) > 5 then
begin
l := getarraylength(Result);
SetArrayLength(Result, l+1);
Result[l] := MiddleTpa(aTPA[i]);
end;
end;
if Length(result) = 0 then Exit;
for i := 0 to High(Result) do
if rs_OnMiniMap(result[i].x, result[i].y) then Inc(p);
if p = 0 then SetArrayLength(Result, 0);
end;
{******************************************************************************}
{ function MSI_WalkTPAPoint( ... ): Boolean; }
{ By: Blumblebee }
{ Description: Walks to a point on the minimap }
{******************************************************************************}
function MSI_WalkTPAPoint(TPA: tPointArray; sortP: tPoint; flagDist: shortInt): Boolean;
var
i: Integer;
t: LongInt;
begin
t := getSystemTime;
if Length(TPA) <= 0 then Exit;
SortTPAFrom(TPA, sortP);
for i := 0 to High(TPA) do
begin
if rs_OnMiniMap(TPA[i].x, TPA[i].y) then
begin
Mouse(TPA[i].x, TPA[i].y, random(8), random(8), true);
wait(randomRange(1000, 2000));
while not FlagPresent do
begin
wait(250+randomRange(150, 350));
if getSystemTime-t > randomRange(2500, 3750) then
continue;
end;
FFlag(flagDist);
Result := True;
Exit;
end;
end;
end;
{******************************************************************************}
{ function MSI_CreateColorBox(Color: Integer): TBox; }
{ By: Blumblebee }
{ Description: Returns a box around the colors found }
{******************************************************************************}
function MSI_CreateColorBox(Color: Integer): TBox;
var
TPA: tPointArray;
begin
FindColors(TPA, Color, MMx1, MMy1, MMx2, MMy2);
if Length(TPA) <= 0 then Exit;
Result := GetTPABounds(TPA);
end;
{******************************************************************************}
{ function MSI_FindColorInBox(Color: Integer; Box: TBox): Boolean; }
{ By: Blumblebee }
{ Description: Returns true if the color is found in a box }
{******************************************************************************}
function MSI_FindColorInBox(Color: Integer; Box: TBox): Boolean;
var
TPA: tPointArray;
i: Integer;
begin
FindColorsTolerance(TPA, Color, Box.x1-5, Box.y1-5, Box.x2+5, Box.y2+5, 15);
if Length(TPA) <= 0 then Exit;
SortTPAFrom(TPA, Point(687, 50));
for i := 0 to High(TPA) do
begin
if not rs_OnMiniMap(TPA[i].x, TPA[i].y) then continue;
Mouse(TPA[i].x, TPA[i].y, 5, 5, True);
Wait(750+random(450));
if FlagPresent then
begin
FFlag(10);
Result := True;
Exit;
end;
end;
end;
const
COLOR_MM_ROCK = 5922133;
COLOR_MM_ROAD = 8554627;
COLOR_MM_BUSH = 731446;
COLOR_MM_NPC = 195836;
COLOR_MM_MINE = 3233669;
function CreateWalkIndex(Index: Byte): tPoint;
var
TPA, nTPA: tPointArray;
aTPA: t2DPointArray;
I, AC: Integer;
DTM, x, y: Integer;
begin
case Index of
0:
begin
AC := MSI_AutoColorMM(COLOR_MM_ROAD);
if AC = 0 then
Exit;
TPA := MSI_CreateWalkTPA(MMx2, MMcy, AC, 5, 5, 3);
FindColorsTolerance(nTPA, COLOR_MM_ROCK, MMx1, MMy1, MMx2, MMy2, 12);
if Length(nTPA) or Length(TPA) <= 0 then
Exit;
writeLn('Length TPA = '+inttostr(length(tpa)));
writeLn('Length nTPA = '+inttostr(length(ntpa)));
SortTPAFrom(nTPA, point(MMx2, MMcy));
SortTPAFrom(TPA, nTPA[0]);
for I := 0 to high(TPA) do
begin
if rs_OnMiniMap(TPA[i].x, TPA[i].y) then
begin
result := TPA[i];
Exit;
end;
end;
end;
1:
begin
AC := MSI_AutoColorMM(COLOR_MM_ROAD);
if AC = 0 then
Exit;
TPA := MSI_CreateWalkTPA(MMx2, MMcy, AC, 5, 5, 3);
if Length(nTPA) or Length(TPA) <= 0 then
Exit;
SortTPAFrom(TPA, point(MMx2, MMcy));
for I := 0 to high(TPA) do
begin
if rs_OnMiniMap(TPA[i].x, TPA[i].y) then
begin
result := TPA[i];
Exit;
end;
end;
end;
2:
begin
AC := MSI_AutoColorMM(COLOR_MM_ROAD);
if AC = 0 then
Exit;
TPA := MSI_CreateWalkTPA(MMcx, MMy2, AC, 5, 5, 3);
if Length(nTPA) or Length(TPA) <= 0 then
Exit;
SortTPAFrom(TPA, point(MMcx, MMy2));
for I := 0 to high(TPA) do
begin
if rs_OnMiniMap(TPA[i].x, TPA[i].y) then
begin
result := TPA[i];
Exit;
end;
end;
end;
3:
begin
AC := MSI_AutoColorMM(COLOR_MM_ROAD);
FindColorsTolerance(TPA, COLOR_MM_NPC, MMcx, MMcy, MMx2, MMy2, 15);
nTPA := MSI_CreateWalkTPA(MMcx, MMcy, AC, 5, 5, 3);
if Length(TPA) or Length(nTPA) <= 0 then
Exit;
SortTPAFrom(nTPA, TPA[0]);
result := point(nTPA[0].x-20, nTPA[0].y);
end;
4:
begin
AC := MSI_AutoColorMM(COLOR_MM_MINE);
if AC = 0 then
Exit;
FindColorsTolerance(TPA, AC, MMx1, MMy1, MMx2, MMy2, 10);
if Length(TPA) <= 0 then
Exit;
aTPA := SplitTPAEx(TPA, 20, 20);
sortATPAFrom(aTPA, Point(MMcx, MMcy));
result := MiddleTPA(aTPA[0]);
end;
end;
end;
var TP: tPoint;
begin
SetUpSRL();
TP := CreateWalkIndex(0);
Mouse(TP.x, TP.y, 5, 5, true);
Flag;
TP := CreateWalkIndex(1);
Mouse(TP.x, TP.y, 5, 5, true);
Flag;
TP := CreateWalkIndex(2);
Mouse(TP.x, TP.y, 5, 5, true);
Flag;
TP := CreateWalkIndex(2);
Mouse(TP.x, TP.y, 5, 5, true);
Flag;
TP := CreateWalkIndex(2);
Mouse(TP.x, TP.y, 5, 5, true);
Flag;
TP := CreateWalkIndex(3);
Mouse(TP.x, TP.y, 5, 5, true);
Flag;
TP := CreateWalkIndex(4);
Mouse(TP.x, TP.y, 5, 5, true);
Flag;
end.