SRL Archive - SRL Archives

FindFallyRoadColor, FindVarrockRoadColor and more!


Camaro'

2010-09-19 00:48:09


Program New;
{.include SRL/SRL.scar}

function FindDraynorRoadColor: Integer;
var
R,G,B,TestColor : Integer;
H,S,L : Extended;
X,Y,Z : Extended;
MyColor : Integer;
ColorsTPA : TPointArray;
C1 : TIntegerArray;
i,C2: Integer;
begin
MyColor := 6975343;
FindColorsSpiralTolerance(MMCX, MMCY, ColorsTPA, MyColor, MMX1, MMY1, MMX2, MMY2, 60);
C1 := GetColors(ColorsTPA);
C2 := High(C1);
for i := 0 to C2 do
begin
if RS_OnMinimap(ColorsTPA[i].X, ColorsTPA[i].Y) then
begin
TestColor := GetColor(ColorsTPA[i].X, ColorsTPA[i].Y);

if SimilarColors(TestColor, 6975343 , 40) then
begin
ColorToRGB(TestColor, R, G, B);
ColorToHSL(TestColor, H, S, L);
ColorToXYZ(TestColor, X, Y, Z);

if InRange(R - G, -20, 20) then
if InRange(R - B, -15, 25) then
if InRange(G - B, -15, 25) then
if InRange(Round(S) - Round(H), -30, 0) then
if InRange(Round(L) - Round(H), 11, 41) then
if InRange(Round(S) - Round(L), -56, -26) then
if InRange(Round(X) - Round(Y), -8, 6) then
if InRange(Round(Y) - Round(Z), -7, 7) then
if (SimilarColors(MyColor, GetColor(ColorsTPA[i].X + 1, ColorsTPA[i].Y + 1), 8)) then
if (SimilarColors(MyColor, GetColor(ColorsTPA[i].X - 1, ColorsTPA[i].Y - 1), 8)) then
begin
Result := TestColor;
Writeln('Draynor Road Color = '+inttostr(testcolor)+'');
Exit;
end;

end;
end;
end;
Writeln('Couldnt find Draynor Road Color!');
Result := 0;
end;

function FindFallyRoadColor: Integer;
var
R,G,B,TestColor : Integer;
H,S,L : Extended;
X,Y,Z : Extended;
MyColor : Integer;
ColorsTPA : TPointArray;
C1 : TIntegerArray;
i,C2: Integer;
begin
MyColor := 7766665 ;
FindColorsSpiralTolerance(MMCX, MMCY, ColorsTPA, MyColor, MMX1, MMY1, MMX2, MMY2, 60);
C1 := GetColors(ColorsTPA);
C2 := High(C1);
for i := 0 to C2 do
begin
if RS_OnMinimap(ColorsTPA[i].X, ColorsTPA[i].Y) then
begin
TestColor := GetColor(ColorsTPA[i].X, ColorsTPA[i].Y);

if SimilarColors(TestColor, 7766665 , 40) then
begin
ColorToRGB(TestColor, R, G, B);
ColorToHSL(TestColor, H, S, L);
ColorToXYZ(TestColor, X, Y, Z);

if InRange(R - G, -13, 27) then
if InRange(R - B, -1, 39) then
if InRange(G - B, -8, 32) then
if InRange(Round(S) - Round(H), -19, 11) then
if InRange(Round(L) - Round(H), 24, 54) then
if InRange(Round(S) - Round(L), -58, -28) then
if InRange(Round(X) - Round(Y), -8, 6) then
if InRange(Round(Y) - Round(Z), -4, 10) then
if (SimilarColors(MyColor, GetColor(ColorsTPA[i].X + 1, ColorsTPA[i].Y + 1), 6)) then
if (SimilarColors(MyColor, GetColor(ColorsTPA[i].X - 1, ColorsTPA[i].Y - 1), 6)) then
begin
Result := TestColor;
Writeln('Fally Road Color = '+inttostr(testcolor)+'');
Exit;
end;

end;
end;
end;
Writeln('Couldnt find Fally Road Color!');
Result := 0;
end;

function FindBarbarianRoadColor: Integer;
var
R,G,B,TestColor : Integer;
H,S,L : Extended;
X,Y,Z : Extended;
MyColor : Integer;
ColorsTPA : TPointArray;
C1 : TIntegerArray;
i,C2: Integer;
begin
MyColor := 4284271;
FindColorsSpiralTolerance(MMCX, MMCY, ColorsTPA, MyColor, MMX1, MMY1, MMX2, MMY2, 60);
C1 := GetColors(ColorsTPA);
C2 := High(C1);
for i := 0 to C2 do
begin
if RS_OnMinimap(ColorsTPA[i].X, ColorsTPA[i].Y) then
begin
TestColor := GetColor(ColorsTPA[i].X, ColorsTPA[i].Y);

if SimilarColors(TestColor, 4284271, 40) then
begin
ColorToRGB(TestColor, R, G, B);
ColorToHSL(TestColor, H, S, L);
ColorToXYZ(TestColor, X, Y, Z);

if InRange(R - G, -4, 36) then
if InRange(R - B, 26, 66) then
if InRange(G - B, 10, 50) then
if InRange(Round(S) - Round(H), 0, 30) then
if InRange(Round(L) - Round(H), 9, 39) then
if InRange(Round(S) - Round(L), -24, 6) then
if InRange(Round(X) - Round(Y), -7, 7) then
if InRange(Round(Y) - Round(Z), -2, 12) then
if (SimilarColors(MyColor, GetColor(ColorsTPA[i].X + 1, ColorsTPA[i].Y + 1), 5)) then
if (SimilarColors(MyColor, GetColor(ColorsTPA[i].X - 1, ColorsTPA[i].Y - 1), 5)) then
begin
Result := TestColor;
Writeln('Barbarian Road Color = '+inttostr(testcolor)+'');
Exit;
end;

end;
end;
end;
Writeln('Couldnt find Barbarian Road Color!');
Result := 0;
end;


function FindVarrockRoadColor: Integer;
var
R,G,B,TestColor : Integer;
H,S,L : Extended;
X,Y,Z : Extended;
MyColor : Integer;
ColorsTPA : TPointArray;
C1 : TIntegerArray;
i,C2: Integer;
begin
MyColor := 9078929;
FindColorsSpiralTolerance(MMCX, MMCY, ColorsTPA, MyColor, MMX1, MMY1, MMX2, MMY2, 60);
C1 := GetColors(ColorsTPA);
C2 := High(C1);
for i := 0 to C2 do
begin
if RS_OnMinimap(ColorsTPA[i].X, ColorsTPA[i].Y) then
begin
TestColor := GetColor(ColorsTPA[i].X, ColorsTPA[i].Y);

if SimilarColors(TestColor, 9078929, 40) then
begin
ColorToRGB(TestColor, R, G, B);
ColorToHSL(TestColor, H, S, L);
ColorToXYZ(TestColor, X, Y, Z);

if InRange(R - G, -11, 29) then
if InRange(R - B, -13, 27) then
if InRange(G - B, -22, 18) then
if InRange(Round(S) - Round(H), -107, -77) then
if InRange(Round(L) - Round(H), -56, -26) then
if InRange(Round(S) - Round(L), -66, -36) then
if InRange(Round(X) - Round(Y), -7, 7) then
if InRange(Round(Y) - Round(Z), -10, 4) then
if (SimilarColors(MyColor, GetColor(ColorsTPA[i].X + 1, ColorsTPA[i].Y + 1), 7)) then
if (SimilarColors(MyColor, GetColor(ColorsTPA[i].X - 1, ColorsTPA[i].Y - 1), 7)) then
begin
Result := TestColor;
Writeln('Varrock Road Col = '+inttostr(testcolor)+'');
Exit;
end;

end;
end;
end;
Writeln('Couldnt find Varrock Road Color!');
Result := 0;
end;

begin
SetUpSRL;
end.

Compiles on Scar - Confirmed
Compiles on Simba - NOT Confirmed

Usage:

FindColorsTolerance(FindFallyRoadColor, Tol = 15)

I rewrote them without even testing the old ones. I last tested varrock a couple of months ago and it was broken and I confirmed that draynor was broken.
;)

bugger0001

2010-09-19 06:39:30

If you want those to get in the include, then better got them all optimized and combined…

Camaro'

2010-09-19 13:10:36

From: bugger0001
If you want those to get in the include, then better got them all optimized and combined…


How would one combine these?

I could care less if it makes it into the include, I thought this could help some people.

bugger0001

2010-09-19 14:00:16

There are lots of options, but one could be made like this:
Program New;
{.include SRL/SRL.scar}

Type TColorParams =
Record
name: String;
myCol, Tolerance: integer;
inRL: TIntegerArray;
inRH: TIntegerArray;
end;

function SetUpColorParams(s: string): TColorParams;
begin
with Result do
case s of
'draynor': begin
name := 'Draynor';
myCol := 6975343;
tolerance := 8;
inRL := [-20, -15, -15, -30, 11, -56, -8, -7];
inRH := [ 20, 25, 25, 0, 41, -26, 6, 7];
end;
'fally' : begin
name := 'Falador';
myCol := 7766665;
tolerance := 6;
inRL := [-13, -1, -8, -19, 24, -58, -8, -4];
inRH := [ 27, 39, 32, 11, 54, -28, 6, 10];
end;
'barb' : begin
name := 'Barbarian';
myCol := 4284271;
tolerance := 5;
inRL := [-4, 26, 10, 0, 9, -24, -7, -2];
inRH := [36, 66, 50, 30, 39, 6, 7, 12];
end;
'varrock': begin
name := 'Varrock';
myCol := 9078929;
tolerance := 7;
inRL := [-11, -13, -22, -107, -56, -66, -7, -10];
inRH := [ 29, 27, 18, -77, -26, -36, 7, 4];
end;
end;
end;

function FindCustomRoadColor(whichRoad: String): Integer;
var
R,G,B,TestColor : Integer;
H,S,L : Extended;
X,Y,Z : Extended;
ColPars : TColorParams;
ColorsTPA : TPointArray;
C1 : TIntegerArray;
i,C2: Integer;
begin
ColPars := SetUpColorParams(Lowercase(whichRoad));
FindColorsSpiralTolerance(MMCX, MMCY, ColorsTPA, ColPars.myCol, MMX1, MMY1, MMX2, MMY2, 60);
C1 := GetColors(ColorsTPA);
C2 := High(C1);
for i := 0 to C2 do
begin
if RS_OnMinimap(ColorsTPA[i].X, ColorsTPA[i].Y) then
begin
TestColor := GetColor(ColorsTPA[i].X, ColorsTPA[i].Y);

if SimilarColors(TestColor, ColPars.myCol, 40) then
begin
ColorToRGB(TestColor, R, G, B);
ColorToHSL(TestColor, H, S, L);
ColorToXYZ(TestColor, X, Y, Z);

if InRange(R - G, ColPars.inRL[0], ColPars.inRH[0]) then
if InRange(R - B, ColPars.inRL[1], ColPars.inRH[1]) then
if InRange(G - B, ColPars.inRL[2], ColPars.inRH[2]) then
if InRange(Round(S) - Round(H), ColPars.inRL[3], ColPars.inRH[3]) then
if InRange(Round(L) - Round(H), ColPars.inRL[4], ColPars.inRH[4]) then
if InRange(Round(S) - Round(L), ColPars.inRL[5], ColPars.inRH[5]) then
if InRange(Round(X) - Round(Y), ColPars.inRL[6], ColPars.inRH[6]) then
if InRange(Round(Y) - Round(Z), ColPars.inRL[7], ColPars.inRH[7]) then
if (SimilarColors(ColPars.myCol, GetColor(ColorsTPA[i].X + 1, ColorsTPA[i].Y + 1), ColPars.tolerance)) then
if (SimilarColors(ColPars.myCol, GetColor(ColorsTPA[i].X - 1, ColorsTPA[i].Y - 1), ColPars.tolerance)) then
begin
Result := TestColor;
Writeln(ColPars.name + ' Road Col = '+inttostr(testcolor)+'');
Exit;
end;

end;
end;
end;
Writeln('Couldnt find ' + ColPars.name + ' Road Color!');
Result := 0;
end;

begin
SetUpSRL;
end.

Camaro'

2010-09-19 14:33:01

From: bugger0001
There are lots of options, but one could be made like this:
Program New;
{.include SRL/SRL.scar}

Type TColorParams =
Record
name: String;
myCol, Tolerance: integer;
inRL: TIntegerArray;
inRH: TIntegerArray;
end;

function SetUpColorParams(s: string): TColorParams;
begin
with Result do
case s of
'draynor': begin
name := 'Draynor';
myCol := 6975343;
tolerance := 8;
inRL := [-20, -15, -15, -30, 11, -56, -8, -7];
inRH := [ 20, 25, 25, 0, 41, -26, 6, 7];
end;
'fally' : begin
name := 'Falador';
myCol := 7766665;
tolerance := 6;
inRL := [-13, -1, -8, -19, 24, -58, -8, -4];
inRH := [ 27, 39, 32, 11, 54, -28, 6, 10];
end;
'barb' : begin
name := 'Barbarian';
myCol := 4284271;
tolerance := 5;
inRL := [-4, 26, 10, 0, 9, -24, -7, -2];
inRH := [36, 66, 50, 30, 39, 6, 7, 12];
end;
'varrock': begin
name := 'Varrock';
myCol := 9078929;
tolerance := 7;
inRL := [-11, -13, -22, -107, -56, -66, -7, -10];
inRH := [ 29, 27, 18, -77, -26, -36, 7, 4];
end;
end;
end;

function FindCustomRoadColor(whichRoad: String): Integer;
var
R,G,B,TestColor : Integer;
H,S,L : Extended;
X,Y,Z : Extended;
ColPars : TColorParams;
ColorsTPA : TPointArray;
C1 : TIntegerArray;
i,C2: Integer;
begin
ColPars := SetUpColorParams(Lowercase(whichRoad));
FindColorsSpiralTolerance(MMCX, MMCY, ColorsTPA, ColPars.myCol, MMX1, MMY1, MMX2, MMY2, 60);
C1 := GetColors(ColorsTPA);
C2 := High(C1);
for i := 0 to C2 do
begin
if RS_OnMinimap(ColorsTPA[i].X, ColorsTPA[i].Y) then
begin
TestColor := GetColor(ColorsTPA[i].X, ColorsTPA[i].Y);

if SimilarColors(TestColor, ColPars.myCol, 40) then
begin
ColorToRGB(TestColor, R, G, B);
ColorToHSL(TestColor, H, S, L);
ColorToXYZ(TestColor, X, Y, Z);

if InRange(R - G, ColPars.inRL[0], ColPars.inRH[0]) then
if InRange(R - B, ColPars.inRL[1], ColPars.inRH[1]) then
if InRange(G - B, ColPars.inRL[2], ColPars.inRH[2]) then
if InRange(Round(S) - Round(H), ColPars.inRL[3], ColPars.inRH[3]) then
if InRange(Round(L) - Round(H), ColPars.inRL[4], ColPars.inRH[4]) then
if InRange(Round(S) - Round(L), ColPars.inRL[5], ColPars.inRH[5]) then
if InRange(Round(X) - Round(Y), ColPars.inRL[6], ColPars.inRH[6]) then
if InRange(Round(Y) - Round(Z), ColPars.inRL[7], ColPars.inRH[7]) then
if (SimilarColors(ColPars.myCol, GetColor(ColorsTPA[i].X + 1, ColorsTPA[i].Y + 1), ColPars.tolerance)) then
if (SimilarColors(ColPars.myCol, GetColor(ColorsTPA[i].X - 1, ColorsTPA[i].Y - 1), ColPars.tolerance)) then
begin
Result := TestColor;
Writeln(ColPars.name + ' Road Col = '+inttostr(testcolor)+'');
Exit;
end;

end;
end;
end;
Writeln('Couldnt find ' + ColPars.name + ' Road Color!');
Result := 0;
end;

begin
SetUpSRL;
end.


Thats all nifty and cool and all, but I still think it won't be added to SRL either way.

Sir R. M8gic1an

2010-09-19 14:42:04

Er…. SRL already has these?

http://villavu.com/repositories/srl-opendev/SRL/core/AutoColor.scar


const
srl_AutoColorCount = 13;
srl_VarrockRoadColor = 0;
srl_LumbridgeRoadColor = 1;
srl_FaladorRoadColor = 2;
srl_AlKharidRoadColor = 3;
srl_DarkDirtRoadColor = 4;
srl_LightDirtRoadColor = 5;
srl_SandColor = 6;
srl_WaterColor = 7;
srl_SwampWaterColor = 8;
srl_LadderColor = 9;
srl_RockColor = 10;
srl_MineRockColor = 11;
srl_TreeColor = 12;

~RM

JuKKa

2010-09-19 14:47:03

Last time i tested finding varrock road color didn't work..

bugger0001

2010-09-19 14:53:55

Apparently, I must admit I haven't used SRL's auto-coloring for quite some time and the last time I did, it certainly was not converted to current system. Anyways, good to know :p

Nava2

2010-09-19 16:50:35

From: JuKKa
Last time i tested finding varrock road color didn't work..


Using the new system?

MylesMadness

2010-09-19 17:17:22

The new system hasn't worked for me ever, but I know I already made a thread about this

Naum

2010-09-19 17:48:21

Yeah, maybe it was an update which killed it. Because I can't seem to get it working on my end also?

Camaro'

2010-09-19 17:52:53

Sooo?

bugger0001

2010-09-20 12:16:13

Camaro, do you still have the original list of colors you picked to make your auto-coloring functions? If you do, then maybe developers could just replace the SRL's colors arrays with your colors. Should probably do the trick as SRL's auto-coloring seems to be very universal and should find all the needed mods itself.

Camaro'

2010-09-20 20:03:21

From: bugger0001
Camaro, do you still have the original list of colors you picked to make your auto-coloring functions? If you do, then maybe developers could just replace the SRL's colors arrays with your colors. Should probably do the trick as SRL's auto-coloring seems to be very universal and should find all the needed mods itself.


I thought I saved them, but it turns out I didn't. That was the best color though.