SRL Archive - SRL Archives

function FindRockColorX: integer;


WhiteShadow

2007-07-08 18:27:43

I wrote this fairly quickly just now, with 6 color samples so the values may need to be edited a little.

program RockColorBruteForcer;

var
RockColor: integer;

{
Returns a an array of colors that match dColor/Tol given
inside the Minimap.
}

function FindColorsCircleTolerance(dColor, Tol: integer): TIntegerArray;
var
Points, TPA: TPointArray;
ci, Wlength, k: integer;
begin
FindColorsTolerance(Points, dColor, 565, 9, 719, 1592, Tol);
Wlength := GetArrayLength(Points);
for ci := 0 to WLength - 1 do
begin
if (rs_OnMinimap(Points[ci].x, Points[ci].y))then
begin
SetArrayLength(TPA, GetArrayLength(TPA) + 1);
TPA[GetArrayLength(TPA) - 1] := Points[ci];
end;
end;
Result := GetColors(TPA);
end;

{
Using HSL, autocolors the MM Rock.
}
function FindRockColorX: integer;
var
aRockColors: TIntegerArray;
Time, wLength, ci : integer;
HV, SV, LV: extended;
begin
Time := GetSystemTime;
aRockColors := FindColorsCircleTolerance(4406089, 50);
wLength := GetArrayLength(aRockColors);
for ci := 0 to wLength - 1 do
begin
ColorToHSL(aRockColors[ci], HV, SV, LV);
if(HV > 14) and (HV < 86) and
(SV > 1 ) and (SV < 12) and
(LV > 24) and (LV < 45) then
begin
Result := aRockColors[ci];
Break;
end;
end;
Writeln('Took '+IntToStr(GetSystemTime - Time) + ' msec.');
if (Result > 0)then
Writeln('RockColor = '+IntToStr(Result))
else
begin
Writeln('ERROR: Could not get RockColor.');
end;
end;

begin
ClearDebug;
RockColor := FindRockColorX;
end.

-WhiteShadow.

Sumilion

2007-07-09 04:00:15

Tip:

    begin
SetArrayLength(TPA, Length(TPA) + 1);
TPA[Length(TPA) - 1] := Points[ci];
end;

instead of

    begin
k := k + 1;
SetArrayLength(TPA, k + 1);
TPA[k] := Points[ci];
end;

WhiteShadow

2007-07-09 17:18:31

You meant, GetArrayLength, yes? x]

n3ss3s

2007-07-18 08:46:50

You mean FindMMRockColorX?
:D gj

Boreas

2007-07-18 16:25:22

Nice.

Another tip
program New;
var colors,colors2:array of integer;
color,al,t:integer;
sv,lv,hv:extended;
begin
t:=getsystemtime;
for color:=0 to 10000000 do
begin
ColortoHSL(color,hv,sv,lv);
if (SV < 12) then
if (LV > 24) then
if (LV < 45) then
if (HV < 86) then
if (HV > 14) then
if (SV > 1 ) then
begin
setarraylength(colors,AL+1);
colors[al]:=color;
al:=al+1;
end;
end;
writeln(inttostr(getsystemtime-t));
writeln(inttostr(al)+' colors');
t:=getsystemtime;
al:=0;
for color:=0 to 10000000 do
begin
ColortoHSL(color,hv,sv,lv);
if(HV > 14) and (HV < 86) and
(SV > 1 ) and (SV < 12) and
(LV > 24) and (LV < 45) then
begin
setarraylength(colors2,AL+1);
colors2[al]:=color;
al:=al+1;
end;
end;
writeln(inttostr(getsystemtime-t));
writeln(inttostr(al)+' colors');
end.

173610
52915 colors
375859
52915 colors

:p

WhiteShadow

2007-07-18 21:22:51

Tbh, at first I was like Boreas is on crack. :]

Until I read the last part. xD Thanks, <3. :)