SCAR Code:
program New;
{.include SRL/SRL.scar}
var GPS: array [1..5] of TPoint;
var Path: Function(Paths: TBooleanArray): Boolean; SetPath: array [0..1] of TbooleanArray;
var SymbolColor: Integer;
Function MidPoint(x1, x2: Integer): Integer;
begin
Result := ((x1+x2)/2);
end;
const
VEM_Mine = 0;
VEM_Bank = 1;
VWM_Mine = 2;
VWM_Bank = 3;
Cross_Split = 0;
Failsafe = 0;
Function IsRun(): Boolean;
begin
Result := GetColor(724, 112) = 6806252;
end;
Function NoRun(): Boolean;
var x, y: Integer;
begin
Result := FindColor(x, y, 255, 735, 106, 760, 121);
end;
Procedure SetRunEx();
begin
if not IsRun then
if not NoRun then
SetRun(True);
end;
type
TACInfo = record
Colour, Tol, Width, Height, Count, CTS: Integer;
HueMod, SatMod: Extended;
end;
const
SRLAC_RoadColour = 0;
SRLAC_VarrockRoadColour = 1;
SRLAC_FallyRoadColour = 2;
SRLAC_LumbyRoadColour = 3;
SRLAC_DirtRoadColour = 4;
SRLAC_WaterColour = 5;
SRLAC_SandColour = 6;
Function SRL_GetACInfo(ACIndex: Integer): TACInfo; // New Autocolor.scar made by Blumblebee & ZephrysFury
begin
case ACIndex of
SRLAC_RoadColour:
with Result do
begin
Colour := 6579821;
Tol := 10;
Width := 2;
Height := 2;
Count := 3;
CTS := 1;
end;
SRLAC_VarrockRoadColour:
with Result do
begin
Colour := 8291719;
HueMod := 0.55;
SatMod := 0.16;
Tol := 8;
Width := 3;
Height := 3;
Count := 5;
CTS := 2;
end;
SRLAC_FallyRoadColour:
with Result do
begin
Colour := 7831173;
Tol := 10;
Width := 2;
Height := 2;
Count := 5;
CTS := 1;
end;
SRLAC_LumbyRoadColour:
with Result do
begin
Colour := 8225677;
Tol := 10;
Width := 2;
Height := 2;
Count := 5;
CTS := 1;
end;
SRLAC_DirtRoadColour:
with Result do
begin
Colour := 1853272;
Tol := 5;
Width := 2;
Height := 2;
Count := 5;
CTS := 1;
end;
SRLAC_WaterColour:
with Result do
begin
Colour := 10850700;
Tol := 8;
Width := 5;
Height := 5;
Count := 5;
CTS := 1;
end;
end;
end;
Function GetMMPoints(tpa: TpointArray; width, height, count: Integer): TpointArray;
var
atpa: T2DpointArray; l, i, p: Integer;
begin
Atpa := TPAtoATPAEx(Tpa, width, height);
for i := 0 to High(atpa) do
begin
if Length(atpa) > count 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 SRL_AutoColour(ACIndex: Integer) : Integer;
var TPA, Pts: TPointArray; tAC: TACInfo; t, i, ii: Integer; aCol, uCol, tCol: TIntegerArray;
begin
try
tAC := SRL_GetACInfo(ACIndex);
ColorToleranceSpeed(1);
FindColorsSpiralTolerance(MMCX, MMCY, TPA, tAC.Colour, MMX1, MMY1, MMX2, MMY2, tAC.Tol);
if (Length(TPA) <= 0) then Exit;
Pts := GetMMPoints(TPA, tAC.Width, tAC.Height, tAC.Count);
aCol := GetColors(Pts);
uCol := aCol;
ClearSameIntegers(aCol);
SetLength(tCol, high(uCol)+1);
for i := 0 to high(aCol) do
begin
for ii := 0 to high(uCol) do
begin
if aCol[i] = uCol[ii] then
Inc(tCol[ii]);
end;
end;
t := 0;
for i := 0 to high(uCol) do
if tCol[i] > tCol[t] then
t := i;
Result := uCol[t];
except
end;
end;
Function FindNewVarrockRoadColor: Integer;
begin
Result := SRL_AutoColour(SRLAC_VarrockRoadColour);
end;
Function GetSymbolArea(Color: Integer; Hue, Sat: Extended; Tol: Integer): TPointArray;
var TPA: TPointArray; ATPA: T2DPointArray; P: TPoint; l, i: integer;
begin
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(Hue, Sat);
FindColorsSpiralTolerance(MMcx, MMcy, TPA, Color, MMx1, MMy1, MMx2, MMy2, Tol);
ColorToleranceSpeed(1);
SetColorSpeed2Modifiers(0.2, 0.2);
if Length(TPA) <= 0 then Exit;
ATPA := SplitTPAEx(TPA, 5, 5);
for i := 0 to High(ATPA) do
begin
P := MiddleTPA(ATPA[i]);
if rs_OnMiniMap(P.x,P.y) then
begin
l := getarraylength(Result);
SetArrayLength(Result, l+1);
Result[l] := P;
end;
end;
end;
Function CreateSymbolBox(TPA: TPointArray; TP: TPoint): TBox;
var nTPA, oTPA: TPointArray;
begin
oTPA := TPA;
if Length(oTPA) <= 0 then Exit;
sortTPAFrom(oTPA, Point(TP.x, TP.y));
FindColorsTolerance(nTPA, 65536, oTPA[0].x-7, oTPA[0].y-7, oTPA[0].x+7, oTPA[0].y+7, 10);
if Length(nTPA) > 0 then
Result := GetTPABounds(nTPA);
end;
Function FindUniqueColors(Col: Integer; rTPA: TPointArray; Area: TPoint): Integer;
var SymBox: TBox; TPA: TPointArray; List1, List2, List3 : TIntegerArray; i, ii, Tol, L: integer;
begin
SymBox := CreateSymbolBox(rTPA, Area);
FindColorsTolerance(TPA, 0, SymBox.x1, SymBox.y1, SymBox.x2, SymBox.y2, 225);
List1 := GetColors(TPA);
List2 := List1;
ClearSameIntegers(List1);
for i := 0 to High(List2) do
begin
for ii := 0 to High(List1) do
begin
if List1[ii] = List2[i] then
begin
L := getarraylength(List3);
SetArrayLength(List3, L+1);
List3[L] := List1[ii];
end;
end;
end;
Tol := 5;
while Result = 0 do
begin
for i := 0 to High(List3) do
begin
if SimilarColors(List3[i], Col, Tol) then
begin
Result := List3[i];
WriteLn('Unique Symbol Color = '+IntToStr(Result));
Exit;
end;
end;
IncEx(Tol, 1);
end;
end;
Function GetUniqueSymbolColor(x, y: Integer; Color: Integer; Hue, Sat: Extended; Tol: Integer): Integer;
begin
Result := FindUniqueColors(Color, GetSymbolArea(Color, Hue, Sat, Tol), Point(x, y));
end;
Function GetMMTPA(x, y, color, width, height, tolerance: Integer): TpointArray;
var tpa: TpointArray; atpa: T2DpointArray; l, i, 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 ExaminePlayerFormation: Boolean;
var TPA: TPointArray; ATPA: T2DPointArray; P: TPoint;
begin
FindColors(TPA, 16711422, MMx1, MMy1, MMx2, MMy2);
if Length(TPA) <= 0 then Exit;
ATPA := TPAtoATPAEx(TPA, 10, 10);
if length(ATPA) <= 0 then Exit;
SortATPASize(ATPA, True);
P := MiddleTPA(ATPA[0]);
Mouse(P.x, P.y, 5, 5, True);
Wait(500+random(100));
FFlag(0);
Result := True;
end;
Function SetLandMarkRecord(Index: Integer): Boolean;
var i, Q, x, y: Integer; MainPoint: TDTMPointDef; SubPoints: Array of TDTMPointDef; TempTDTM: TDTM;
begin
case Index of
Cross_Split:
begin
SetArrayLength(SubPoints, 4);
with MainPoint do
begin
x := 609;
y := 49;
AreaSize := 3;
AreaShape := 0;
Color := RoadColor;
Tolerance := 8;
end;
SubPoints[0].x := 609;
SubPoints[0].y := 49;
SubPoints[1].x := 621;
SubPoints[1].y := 18;
SubPoints[2].x := 581;
SubPoints[2].y := 49;
SubPoints[3].x := 619;
SubPoints[3].y := 71;
for i := 0 to High(SubPoints) do
begin
SubPoints[i].Color := RoadColor;
SubPoints[i].AreaSize := 3;
SubPoints[i].AreaShape := 0;
SubPoints[i].Tolerance := 8;
end;
end;
end;
TempTDTM.MainPoint := MainPoint;
TempTDTM.SubPoints := SubPoints;
Q := AddDTM(TempTDTM);
Result := DTMRotated(Q, x, y, MMx1, MMy1, MMx2, MMy2);
WriteLn('DTM['+IntToStr(Index)+'] Found. Point('+InTToStr(x)+', '+IntToStr(y)+');');
Mouse(x-15, y, 5, 5, True);
FFlag(10);
FreeDTM(Q);
end;
Function 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 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;
Function RadialWalkExEx(TheColor, StartRadial, EndRadial, Radius, Xmod, Ymod: Integer): Boolean;
var TPA: TPointArray; I: Integer;
begin
if RadialWalkEx(tpa, MMCX, MMCY, TheColor, 0, StartRadial, EndRadial, Radius) then
for i := 0 to High(tpa) do
if MFNF(tpa[i].x+Xmod, tpa[i].y+Ymod, 5, 5) then
begin
FFlag(10);
Result := True;
Exit;
end;
end;
Function SetPathRecord(Index: Integer): Boolean;
var TPA: TPointArray; i, x, y, DTM: Integer; modx, mody: Integer; P: TPoint; AreaBox: TBox;
begin
case Index of
0:
begin
{TPA := GetMMTPA(MMx2, MMcy, FindRockColor, 5, 5, 5); // RoadColor
if Length(TPA) <= 0 then Exit;
SortTPAFrom(TPA, Point(690, 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-5, TPA[i].y+5, 5, 5, True);
Wait(750+random(450));
if FlagPresent then
begin
FFlag(10);
Result := True;
Exit;
end;
end;}
Result := FindColorInBox(RoadColor, CreateColorBox(FindRockColor));
end;
1..5:
begin
case Index of
1:
begin
Modx := 0;
Mody := 8;
RoadColor := FindNewVarrockRoadColor;
end;
2:
begin
Modx := 4;
Mody := -2;
end;
3: Mody := 4;
end;
TPA := GetMMTPA(MMcx, MMcy, RoadColor, 5, 5, 18);
if Length(TPA) <= 1 then Exit;
SortTPAFrom(TPA, Point(GPS[index].x, GPS[index].y));
for i := 0 to High(TPA) do
begin
if not rs_OnMiniMap(TPA[i].x, TPA[i].y) then continue;
Mouse(TPA[i].x+modx, TPA[i].y+mody, 5, 5, True);
Wait(150+random(150));
if FlagPresent then
begin
FFlag(10);
if Index = 3 then
begin
Flag;
Wait(550+random(550));
end;
Result := True;
Exit;
end;
end;
end;
6:
begin
TPA := GetMMTPA(MMcx, MMy2-15, 2902389, 3, 3, 15);
WriteLn('Length TPA = '+IntToStr(Length(TPA)));
if Length(TPA) <= 0 then
begin
if Players[CurrentPlayer].Integers[Failsafe] > 1 then Exit;
SetPathRecord(2);
SetPathRecord(4);
Inc(Players[CurrentPlayer].Integers[Failsafe]);
end;
SortTPAFrom(TPA, Point(600, 150));
P := MiddleTPA(TPA);
Mouse(P.x, P.y, 5, 5, True);
wait(550+random(500));
if FlagPresent then
begin
Flag;
Result := True;
end;
end;
7:
begin
WriteLn('Searching for Red Door profile');
FindColorsTolerance(TPA, 328944, MMx1, MMy1, MMx2, MMy2, 15);
if Length(TPA) <= 0 then Exit;
SortTPAfrom(TPA, Point(MMx1, MMy1));
for i := 0 to High(TPA) do
begin
Mouse(TPA[i].x+15, TPA[i].y, 3, 5, True);
Wait(450+random(450));
if FlagPresent then
begin
FFlag(10);
Wait(750+random(750));
Result := True;
Exit;
end;
end;
end;
8:
begin
while i < 3 do
begin
if SetPathRecord(4) then
inc(i);
end;
Result := SetLandMarkRecord(Cross_Split);
Flag;
end;
9:
begin
DTM := DTMFromString('78DA63CC64666068676400016606083870E00' +
'0C37F20CD08E533A60265FA203C98D89F3F4C0C5CC86A128950134B8' +
'49A5CC26A002CF6102D');
DTMRotated(DTM, x, y, MMx1, MMy1, MMx2, MMy2);
FreeDTM(DTM);
if ((x <> 0) and (y <> 0)) then
begin
Mouse(x, y, 5, 2, True);
wait(500+Random(500));
if FlagPresent then
begin
FFlag(0);
Wait(750+random(750));
Result := True;
Exit;
end;
end;
end;
10:
begin
AreaBox.x1 := 500;
AreaBox.y1 := 100;
AreaBox.x2 := 600;
AreaBox.y2 := 136;
TPA := GetMMTPA(MMcx, MMcy, RoadColor, 3, 3, 10);
if Length(TPA) <= 0 then Exit;
SortTPAfrom(TPA, Point(635, 150));
for i := 0 to High(TPA) do
begin
if PointInBox(Point(TPA[i].x, TPA[i].y), AreaBox) then continue;
Mouse(TPA[i].x+15, TPA[i].y, 3, 5, True);
Wait(450+random(450));
if FlagPresent then
begin
FFlag(10);
Wait(150+random(150));
Result := True;
Exit;
end;
end;
end;
11:
begin
TPA := GetMMTPA(MMcx, MMcy, RoadColor, 5, 5, 18);
if Length(TPA) <= 1 then Exit;
SortTPAFrom(TPA, Point(MMx1, MMy2));
for i := 0 to High(TPA) do
begin
if not rs_OnMiniMap(TPA[i].x, TPA[i].y) then continue;
Mouse(TPA[i].x+modx, TPA[i].y+mody, 5, 5, True);
Wait(1050+random(550));
if FlagPresent then
begin
FFlag(10);
Result := True;
Exit;
end;
end;
end;
12:
begin
FindColorsTolerance(TPA, 15397877, MMx1, MMy1, MMx2, MMy2, 20);
if Length(TPA) <= 0 then Exit;
SortTPAFrom(TPA, Point(MMcx, MMy2));
for i := 0 to High(TPA) do
begin
if not rs_OnMiniMap(TPA[i].x, TPA[i].y) then continue;
Mouse(TPA[i].x-10, TPA[i].y-3, 5, 5, True);
Wait(150+random(150));
if FlagPresent then
begin
FFlag(10);
Result := True;
Exit;
end;
end;
end;
13:
begin
//TPA := GetMMTPA(MMcx, MMy2-15, 2902389, 3, 3, 15);
FindColorsTolerance(TPA, 2902389, MMx1, MMcy, MMx2, MMy2, 10);
WriteLn('Length TPA = '+IntToStr(Length(TPA)));
if Length(TPA) <= 0 then
begin
if Players[CurrentPlayer].Integers[Failsafe] > 1 then Exit;
WriteLn('Insert Failsafes here');
Inc(Players[CurrentPlayer].Integers[Failsafe]);
end;
SortTPAFrom(TPA, Point(600, 150));
AreaBox := GetTPABounds(TPA);
x := MidPoint(AreaBox.x1, Areabox.x2);
y := MidPoint(AreaBox.y1, AreaBox.y2);
Mouse(x, y, 5, 5, True);
wait(550+random(500));
if FlagPresent then
begin
Flag;
Result := True;
end;
end;
14:
begin
SymbolColor := GetUniqueSymbolColor(MMcx, MMcy, 7237742, 1.67, 0.06, 25);
FindColors(TPA, SymbolColor, MMx1, MMy1, MMx2, MMy2);
SortTPAFrom(TPA, Point(MMcx, MMcy));
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(150+random(150));
if FlagPresent then
begin
FFlag(10);
Result := True;
Exit;
end;
end;
end;
15:
begin
FindColorsTolerance(TPA, 15397877, MMx1, MMy1, MMx2, MMy2, 20);
if Length(TPA) <= 0 then Exit;
SortTPAFrom(TPA, Point(MMcx, MMy1));
for i := 0 to High(TPA) do
begin
if not rs_OnMiniMap(TPA[i].x, TPA[i].y) then continue;
Mouse(TPA[i].x-10, TPA[i].y+3, 5, 5, True);
Wait(150+random(150));
if FlagPresent then
begin
FFlag(10);
Result := True;
Exit;
end;
end;
end;
16:
begin
if not RadialWalkExEx(RoadColor, 330, 45, 70, 0, 0) then
if not RadialWalkExEx(RoadColor, 320, 55, 70, 0, 0) then
if not RadialWalkExEx(RoadColor, 300, 75, 70, 0, 0) then
begin
WriteLn('Could not Find Varrock Road');
nextPlayer(False);
end;
end;
17:
begin
DTM := DTMFromString('78DA639CC3CCC0A0C5C80002AC0C10D05AE9C' +
'DB00C28C408E5337602D5D84378CC50B13F7F9818B81890D47401658' +
'C8850A349841A45FC6A0004130DD8');
Result := DTMRotated(DTM, x, y, MMx1, MMy1, MMx2, MMy2);
FreeDTM(DTM);
if Result then
begin
Mouse(x-7, y+10, 5, 5, True);
Result := True;
Players[CurrentPlayer].Active := True;
Flag;
Exit;
end;
end;
18:
begin
while not ((FindColor(x, y, RoadColor, MMcx, MMy1, MMx2, MMcy)) and (i < 3)) do
begin
Result := SetPathRecord(15);
Inc(i);
end;
end;
end;
end;
Function CreatePath(Paths: Array of Boolean): Boolean;
var i: Integer;
begin
WriteLn(' Walking Path, Path Length = '+IntToStr(Length(Paths))+' and original index = '+IntToStr(low(paths)));
for i := 0 to High(Paths) do
begin
if not Paths[i] then
begin
NextPlayer(False);
Exit;
end;
end;
Result := True;
WriteLn(' Path [0..'+IntToStr(High(Paths))+'] Concluded');
end;
Function ReEnterMine: Boolean;
begin
Result := SetPathRecord(14);
end;
begin
SetUpSRL;
ActivateClient;
RoadColor := FindNewVarrockRoadColor;
GPS[1].x := MMx2-7;
GPS[1].y := MMcy+10;
GPS[2].x := MMcx;
GPS[2].y := MMy2-4;
GPS[3].x := 650;
GPS[3].y := 22;
GPS[4].x := 625;
GPS[4].y := 30;
GPS[5].x := MMx1;
GPS[5].y := MMcy;
//SetPath[VEM_Mine] := [SetPathRecord(0), SetPathRecord(1), SetPathRecord(10), SetPathRecord(2), SetPathRecord(2), SetPathRecord(6)];
//Wait(10000+Random(2000));
SetPath[VEM_Bank] := [SetPathRecord(3), SetPathRecord(8), SetPathRecord(5), SetPathRecord(9)];
// SetPath[VWM_Mine] := [SetPathRecord(11), SetPathRecord(12), SetPathRecord(12), SetPathRecord(12), SetPathRecord(13)];
// Wait(10000);
//SetPath[VWM_Bank] := [SetPathRecord(18), SetPathRecord(16), SetPathRecord(18)];
end.