SRL Archive - SRL Archives

FindLadderColor - Fix*


noidea

2009-05-24 00:58:52

{*******************************************************************************
Function FindLadderColor: Integer;
by: noidea
Description: Finds the ladder color on the minimap.
*******************************************************************************}
Function FindLadderColor: Integer;
var
TestColor, R, G, B, GC, CTS, AL, i, CC: Integer;
H, S, L : Extended;
TPA: Array of TPoint;
begin
GC := 9039;
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.36, 0.97);
FindColorsSpiralTolerance(mmcx, mmcy, TPA, GC , mmx1, mmy1, mmx2, mmy2, 50);
SetColorSpeed2Modifiers(0.2, 0.2);
If Length(TPA) < 1 then
begin
writeln('No Ladder Colors Found!');
exit;
end;
DebugTPA(TPA, '');
AL := GetArrayLength(TPA);
For i := 0 to AL - 1 do
begin
If RS_OnMiniMap(TPA[i].x, TPA[i].y) then
begin
TestColor := GetColor(TPA[i].x, TPA[i].y);
ColorToRGB(TestColor, R, G, B);
ColorToHSL(TestColor, H, S, L);
if InRange(R - B, 50, 110) then
if InRange(R - G, 25, 65) then
if InRange(G - B, 12, 60) then
if InRange(Round(H - L), -25, 0) then
if InRange(Round(S - H), 45, 100) then
if InRange(Round(S - L), 20, 90) then
If InRange(CountColor(TestColor, TPA[i].x - 10, TPA[i].y - 10, TPA[i].x + 10, TPA[i].y + 10), 25, 120) then
if GetColor(TPA[i].x - 1, TPA[i].y) = TestColor then
if GetColor(TPA[i].x, TPA[i].y + 1) = TestColor then
if GetColor(TPA[i].x, TPA[i].y - 1) = TestColor then
begin
writeln('Found Ladder Color ('+inttostr(TestColor)+') at '+inttostr(TPA[i].x) + ', '+ Inttostr(TPA[i].y));
Result := TestColor;
exit;
end;

end;
end;
writeln('Couldnt Find Ladder Color2!');
Result := 0;
end;

The old one ocationally breaks on me.
Like on colour 1193055.

Saturn tells me he made a fix in one of his scripts, but I wanted to release mine like this.

Rate/Hate?

Dynamite

2009-05-24 01:07:28

Well I cant hate, because you put in the effort, and anyone who puts in effort, is good for me :)
Well done
M

Shuttleu

2009-05-24 01:10:47

surely it should be

if GetColor(TPA[i].x + 1, TPA[i].y) = TestColor then
if GetColor(TPA[i].x, TPA[i].y + 1) = TestColor then
if GetColor(TPA[i].x, TPA[i].y - 1) = TestColor then
?

~shut

noidea

2009-05-24 01:20:42

From: Shuttleu
surely it should be

if GetColor(TPA[i].x + 1, TPA[i].y) = TestColor then
if GetColor(TPA[i].x, TPA[i].y + 1) = TestColor then
if GetColor(TPA[i].x, TPA[i].y - 1) = TestColor then
?

~shut


Why do those getColor points matter. The Ones in there work nicely.

Naum

2009-05-24 01:32:44

The tolerance seems a little too high, apart from that GJ!

noidea

2009-05-24 01:49:34

Shut was right ( Sorry :( )
I changed it, and it worked better.

Shuttleu

2009-05-24 02:23:15

:)
a ladder is like this
.  .
....
. .
....
. .
....

not like this

......
. .
......
. .
......
. .

so if you searched left and right then down you wont get the color the majority of the time
whereas if you search up then down then left then you will :)

~shut

Quickmarch

2009-05-24 15:40:47

The WriteLn imo is to long, all it needs to say is: Ladder Colour = the color…

noidea

2009-05-24 17:45:06

that can be changed easily. I just made it like that for debuging.

lordsaturn

2009-05-24 18:27:01

My fix, works fine with color 1193055.
function LadderColor: integer;
var
GC, GC2, ColorCount, a, i, j, n, l, TestColor, Red, Green, Blue : integer;
ColorArray : array of integer;
P, P2 : array of Tpoint;
begin
GC := 10837;
GC2 := 1849186;
Flag;
FindColorsSpiralTolerance(MMCX, MMCY, P, GC, MMX1, MMY1, MMX2, MMY2, 60);
SetArrayLength(ColorArray,32);
FindColorsSpiralTolerance(MMCX, MMCY, P2, GC2, MMX1, MMY1, MMX2, MMY2, 20);
P := CombineTPA(P, P2);
l:=GetArrayLength(P);
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,60) or SimilarColors(TestColor,GC2,20) then
begin
ColorToRGB(TestColor,Red,Green,Blue);
if Blue <= 30 then if Red - Blue <= 105 then if Red <= 115 then
if Green <= 70 then if Green >= 5 then if Green - Blue >= 5 then
if Green - Blue <= 60 then if Red >= 55 then
if InRange((Red - Green),25,65) then
if Red - Blue >= 55 then if Blue <> 1 then if Blue <> 3 then
begin
n:=0;
for i:= 0 to 3 do
begin
for j:= 0 to 7 do
begin
ColorArray[n]:=GetColor(P[a].x+i,P[a].y-3+j);
n:=n+1;
end;
end;
ColorCount:=0;
for n:= 0 to 31 do
begin
if ColorArray[n]=TestColor then ColorCount:=ColorCount+1;
end;
if ColorCount<17 then if ColorCount>12 then
begin
Result := TestColor;
WriteLn('LadderColor = ' + IntToStr(TestColor));
//+
//' at ' + IntToStr(P[a].x) + ',' + IntToStr(P[a].y));
Exit;
end;
end;
end;
end;
end;
WriteLn('Could not find Ladder Color!');
Result := 0;
end;

nielsie95

2009-05-24 18:41:53


function FindLadderColor: Integer;
var
i, n, cts:Integer;
p: TPointArray;
ca: TIntegerArray;
pa: T2DPointArray;
W, H, hMod, sMod: Extended;
b: TBox;
begin
Result := -1;
cts := GetColorToleranceSpeed;
GetColorspeed2Modifiers(hMod, sMod);
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.225, 6.5);
FindColorsSpiralTolerance(MMCX, MMCY, p, 77925, MMX1, MMY1, MMX2, MMY2, 16);
ColorToleranceSpeed(cts);
SetColorspeed2Modifiers(hMod, sMod);

pa := SplitTPAEx(p, 2, 2);
SortATPAFromSize(pa, 32, True);
n := High(pa);
for i := 0 to n do
if (Length(pa[i]) > 15) and (Length(pa[i]) < 42) then
begin
ca := GetColors(pa[i]);
ClearSameIntegers(ca);
if (Length(ca) = 1) and (ca[0] > 0) then
begin
b := GetTPABounds(pa[i]);
w := b.x2 - b.x1;
h := b.y2 - b.y1;
if (w > h) then
SwapE(w, h);
if (w = 0) or (h = 0) then
Continue;
if (h div w >= 1.12) and (h div w <= 1.8) then
begin
Result := ca[0];
Break;
end;
end;
end;
if (Result > 1) then
WriteLn('LadderColor = '+IntToStr(Result));
end;

Let's throw mine in :p It has been working for ages.

noidea

2009-05-24 18:45:01

FML. Has some one tried to fix FindRockColor, before I try? It broke for me this morning.

Shuttleu

2009-05-24 20:51:02

From: noidea
FML. Has some one tried to fix FindRockColor, before I try? It broke for me this morning.


http://www.villavu.com/forum/showthread.php?t=45682
i would fix it if it was broken

~shut

EDIT: someone gave me negative rep but said thanks :(
now my rep has gone down :(