SRL Archive - SRL Archives

FindWaterColor Fix


king vash

2008-03-20 19:18:47

FindWaterColor is seriously flawed in Falador (probable due to the easter bunny update)

by changing AutoColor (found under includes\SRL\SRL\core\AutoColor.scar) to this I've corrected most of the error
{*******************************************************************************
function FindWaterColor: Integer;
By: Tarajunky
Description: Autodetects Water Color on Minimap
*******************************************************************************}

function FindWaterColor: Integer;
var
GC, a, l, TestColor, Red, Green, Blue : integer;
var
P:array of Tpoint;
begin
GC := 12095356;
Flag;
FindColorsSpiralTolerance(MMCX, MMCY, P, GC, MMX1, MMY1, MMX2, MMY2, 50);
l:=GetArrayLength(P);
for a:= 0 to l-1 do
begin
if rs_OnMinimap(P[a].x,P[a].y) then
begin
TestColor := GetColor(P[a].x,P[a].y);
if SimilarColors(TestColor,GC,50) then
begin
ColorToRGB(TestColor,Red,Green,Blue);
if InRange(Green - Red, 18, 30) then
if InRange(Blue - Red, 55, 72) then
if InRange(Blue - Green, 34, 52) then
if GetColor(P[a].x + 2, P[a].y + 2) = TestColor then
if GetColor(P[a].x + 1, P[a].y + 1) = TestColor then
if GetColor(P[a].x, P[a].y + 2) = TestColor then
if GetColor(P[a].x + 2, P[a].y) = TestColor then
if GetColor(P[a].x, P[a].y + 1) = TestColor then
if GetColor(P[a].x + 1, P[a].y) = TestColor then
if GetColor(P[a].x + 2, P[a].y + 1) = TestColor then
if GetColor(P[a].x + 1, P[a].y + 2) = TestColor then
begin
Result := TestColor;
WaterColor := TestColor;
WriteLn('WaterColor = ' + IntToStr(TestColor));
Exit;
end;
end;
end;
end;
WriteLn('Could not find Water Color!');
Result := 0;
end;

FindFaladorRoadFix
{*******************************************************************************
function FindFallyRoadColor: Integer;
By: Tarajunky
Description: Autodetects Falador Road Color on Minimap
*******************************************************************************}

function FindFallyRoadColor: Integer;
var
GC, a, l, TestColor, Red, Green, Blue : integer;
var
P:array of Tpoint;
begin
GC := 6187637;
Flag;
FindColorsSpiralTolerance(MMCX, MMCY, P, GC, MMX1, MMY1, MMX2, MMY2, 50);
l:=GetArrayLength(P);
for a:= 0 to l-1 do
begin
if rs_OnMinimap(P[a].x,P[a].y) then
begin
TestColor := GetColor(P[a].x,P[a].y);
if SimilarColors(TestColor,GC,50) then
begin
ColorToRGB(TestColor,Red,Green,Blue);
if InRange(Red - Blue, 18, 33)then
if InRange(Red - Green, 0, 15) then
if InRange(Green - Blue, 8, 30) then
if GetColor(P[a].x + 5, P[a].y + 5) = TestColor then
if GetColor(P[a].x + 3, P[a].y + 3) = TestColor then
if GetColor(P[a].x, P[a].y + 5) = TestColor then
if GetColor(P[a].x + 5, P[a].y) = TestColor then
if GetColor(P[a].x, P[a].y + 3) = TestColor then
if GetColor(P[a].x + 3, P[a].y) = TestColor then
if GetColor(P[a].x + 5, P[a].y + 3) = TestColor then
if GetColor(P[a].x + 3, P[a].y + 5) = TestColor then
begin
Result := TestColor;
WriteLn('Falador RoadColor = ' +
IntToStr(TestColor));
Exit;
end;
end;
end;
end;
WriteLn('Could not find Falador Road Color!');
Result := 0;
end;

Harry

2008-03-20 19:28:09

It is messed up all over RS, like in Draynor.

Thanks for t3h fix :)

oliver1205

2008-03-20 19:59:01

i get a sytnax error in the findwatercolor

oliver1205

2008-03-20 20:41:50

works perfect thanks man

king vash

2008-03-20 21:20:11

Sorry about the HTML, forgot about that when i moved it from my other post

Santa_Clause

2008-03-20 22:18:31

I already edited mine earlier today so I could use your script :p

rockman

2008-03-20 22:48:46

Thanks for the fix, works great.

n3ss3s

2008-03-21 03:30:00

Yay, now I can use your script too :p

By the way, in future post SRL fixes to the new Development section :)


(Now I am running your script, works great ;))

Wizzup?

2008-03-21 06:36:24

This one is pretty fast and accurate, too:

Function w_GetWaterColor: Integer;

Var
x, y, z: Integer;

Begin
Result := -1;
z := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
If FindColoredAreaTolerance(x, y, 12161662, MMX1, MMY1, MMX2, MMY2, 10, 25) Then
Result := GetColor(x, y)
Else
Begin
WriteLn('Could not find water Color.');
ColorToleranceSpeed(z);
TerminateScript;
End;
ColorToleranceSpeed(z);
End;

It needs a 5x5 pixel box of water color.

EvilChicken!

2008-04-02 10:26:23

I made my FindWaterColor like this combining both your functions:

function FindWaterColor2: Integer;
var
GC, a, l, TestColor, Red, Green, Blue : integer;
var
P:array of Tpoint;
begin
GC := 12095356;
FFlag(0);
FindColorsSpiralTolerance(MMCX, MMCY, P, GC, MMX1, MMY1, MMX2, MMY2, 50);
l:=GetArrayLength(P);
for a:= 0 to l-1 do
begin
if rs_OnMinimap(P[a].x,P[a].y) then
begin
TestColor := GetColor(P[a].x,P[a].y);
if SimilarColors(TestColor,GC,50) then
begin
ColorToRGB(TestColor,Red,Green,Blue);
if InRange(Green - Red, 18, 30) then
if InRange(Blue - Red, 55, 72) then
if InRange(Blue - Green, 34, 52) then
if GetColor(P[a].x + 2, P[a].y + 2) = TestColor then
if GetColor(P[a].x + 1, P[a].y + 1) = TestColor then
if GetColor(P[a].x, P[a].y + 2) = TestColor then
if GetColor(P[a].x + 2, P[a].y) = TestColor then
if GetColor(P[a].x, P[a].y + 1) = TestColor then
if GetColor(P[a].x + 1, P[a].y) = TestColor then
if GetColor(P[a].x + 2, P[a].y + 1) = TestColor then
if GetColor(P[a].x + 1, P[a].y + 2) = TestColor then
begin
Result := TestColor;
WaterColor := TestColor;
WriteLn('WaterColor = ' + IntToStr(TestColor));
Exit;
end;
end;
end;
end;
WriteLn('Could not find Water Color!');
Result := 0;
end;

Function FindWaterColor: Integer;

Var
x, y, z: Integer;

Begin
Result := 0;
z := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
If FindColoredAreaTolerance(x, y, 12161662, MMX1, MMY1, MMX2, MMY2, 10, 25) Then
Result := GetColor(x, y)
Else
Begin
WriteLn('Could not find water Color.');
ColorToleranceSpeed(z);
Result := FindWaterColor2;
End;
End;

Would this work slightly better than Wizzup?'s function alone? And did I do it correctly?

Edit: Why is the autocoloring functions still using "Flag"? They should be changed to "FFlag(0)"'s!

Edit2: FindRockColor is broken too.. Does someone have a fix?

n3ss3s

2008-04-02 11:30:56

What do you have agains Flag?

FFlag maybe does some antiban, but it's a bit close to FF LAG…



Procedure n_FFlag(Dist: Integer);

Var
Sf: Integer;

Begin
If LoggedIn Then
Begin
Sf := GetSystemTime;
While FlagDistance > Dist Do
If GetSystemTime - Sf >= 20000 Then
Break
Else
Wait(20);
End;
End;

No lag ;)