Lee Lok Hin
05-23-2008, 01:44 PM
Just in case that does not work, here is mine.
//-----------------------------------------------------------------//
//-- Scar Standard Resource Library --//
//-- » AutoColorFinding Routines --//
//-----------------------------------------------------------------//
// » function FindWaterColor: Integer; | by Tarajunky
// » function FindRoadColor: Integer; | by Tarajunky
// » function FindVarrockRoadColor: Integer; | by Tarajunky
// » function FindFallyRoadColor: Integer; | by Tarajunky
// » function FindRockColor: Integer; | by Tarajunky
// » function FindStoneColor: Integer; | by Tarajunky
// » function FindDirtRoadColor: Integer; | by Tarajunky
// » function FindBridgeColor: Integer; | by Tarajunky
// » function FindLadderColor: Integer; | by Tarajunky
// » function AutoColorThis(Bitmap, MaxTol, X1, Y1, X2, Y2:Integer) : integer; | by Sumilion
{************************************************* ******************************
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, 60);
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
red := (TestColor mod 256);
green := ((TestColor / 256) mod 256);
blue := ((TestColor / 256) / 256);
if Green - Red <= 26 then if Green - Red >= 18 then
if Blue - Red >= 55 then if Blue - Red <= 72 then
if Blue - Green >= 35 then if Blue - Green <= 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 FindRoadColor: Integer;
By: Tarajunky
Description: Autodetects Normal Road Color on Minimap
************************************************** *****************************}
function FindRoadColor: Integer;
var
GC, a, l, TestColor, Red, Green, Blue : integer;
var
P:array of Tpoint;
begin
GC := 5987170;
Flag;
FindColorsSpiralTolerance(MMCX, MMCY, P, GC, MMX1, MMY1, MMX2, MMY2, 60);
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,60) then
begin
red := (TestColor mod 256);
green := ((TestColor / 256) mod 256);
blue := ((TestColor / 256) / 256);
if Red - Green <= 10 then if Red - Green >= 5 then
if Red - Blue <= 10 then if Red - Blue >= 5 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;
RoadColor := TestColor;
WriteLn('RoadColor = ' + IntToStr(TestColor));
Exit;
end;
end;
end;
end;
WriteLn('Could not find Road Color!');
Result := 0;
end;
{************************************************* ******************************
function FindVarrockRoadColor: Integer;
By: Tarajunky
Description: Autodetects Varrock Road Color on Minimap
************************************************** *****************************}
function FindVarrockRoadColor: Integer;
var
GC, a, l, TestColor, Red, Green, Blue : integer;
var
P:array of Tpoint;
begin
GC := 7304312;
Flag;
FindColorsSpiralTolerance(MMCX, MMCY, P, GC, MMX1, MMY1, MMX2, MMY2, 60);
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,60) then
begin
red := (TestColor mod 256);
green := ((TestColor / 256) mod 256);
blue := ((TestColor / 256) / 256);
if Red - Blue <= 12 then if Red - Blue >= 8 then
if Red - Green <= 6 then if Red - Green >= -1 then
if Green - Blue <= 10 then if Green - Blue >= 4 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('Varrock RoadColor = ' +
IntToStr(TestColor));
Exit;
end;
end;
end;
end;
WriteLn('Could not find Varrock Road Color!');
Result := 0;
end;
{************************************************* ******************************
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, 60);
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
red := (TestColor mod 256);
green := ((TestColor / 256) mod 256);
blue := ((TestColor / 256) / 256);
if Red - Blue >= 18 then if Red - Blue <= 33 then
if Red - Green <= 13 then if Red - Green >= 0 then
if Green - Blue >= 8 then if Green - Blue <= 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;
{************************************************* ******************************
function FindRockColor: Integer;
By: Tarajunky
Description: Autodetecs Rock (Gray) Color on Minimap
************************************************** *****************************}
function FindRockColor: Integer;
var
GC, a, l, TestColor: integer;
var
P:array of Tpoint;
begin
GC := 6444639;
Flag;
FindColorsSpiralTolerance(MMCX,MMCY, P, GC, MMX1,MMY1,MMX2,MMY2, 75);
l:=GetArrayLength(P);
for a:= 0 to l-1 do
begin
TestColor := GetColor(P[a].x,P[a].y);
if (GetColor(P[a].x-1,P[a].y)=TestColor-789772) then
begin
Result := TestColor;
WriteLn('Rock Color = ' + IntToStr(TestColor));
Exit;
end;
end;
WriteLn('Could not find Rock Color!');
Result := 0;
end;
{************************************************* ******************************
function FindStoneColor: Integer;
By: Tarajunky
Description: Autodetecs Stone (Mine Rock) Color on Minimap
************************************************** *****************************}
function FindStoneColor: Integer;
var
GC, a, l, TestColor: integer;
var
P:array of Tpoint;
begin
GC := 3561615;
Flag;
FindColorsSpiralTolerance(MMCX, MMCY, P, GC, MMX1,MMY1,MMX2,MMY2, 60);
l:=GetArrayLength(P);
for a:= 0 to l-1 do
begin
TestColor := GetColor(P[a].x,P[a].y);
if (GetColor(P[a].x-1,P[a].y)=TestColor-461068) then
begin
Result := TestColor;
WriteLn('Stone Color = ' + IntToStr(TestColor));
Exit;
end;
end;
WriteLn('Could not find Stone Color!');
Result := 0;
end;
{************************************************* ******************************
function FindDirtRoadColor: Integer;
By: Tarajunky
Description: Autodetects Dirt Road Color on Minimap
************************************************** *****************************}
function FindDirtRoadColor: Integer;
var
GC, a, l, TestColor, Red, Green, Blue, x, y : integer;
var
P:array of Tpoint;
begin
if WaterColor = 0 then WaterColor:=FindWaterColor;
if not (FindColor(x, y, WaterColor, MMX1, MMY1, MMX2, MMY2)) then
WaterColor := FindWaterColor;
GC := 4548987;
Flag;
FindColorsSpiralTolerance(MMCX, MMCY, P, GC, MMX1, MMY1, MMX2, MMY2, 140);
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,140) then
begin
red := (TestColor mod 256);
green := ((TestColor / 256) mod 256);
blue := ((TestColor / 256) / 256);
if Red - Green <= 33 then if Red - Green >= 5 then if Red <= 120 then
if Green - Blue >= 17 then if Green - Blue <= 58 then
if Blue <=45 then if Red - Blue >= 30 then if Red - Blue <= 75 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
if ((WaterColor = 0) or not (FindColor(x, y,
WaterColor, P[a].x - 10, P[a].y - 10,
P[a].x + 10, P[a].y + 10))) then
begin
Result := TestColor;
WriteLn('Dirt Road Color = ' +
IntToStr(TestColor));
Exit;
end;
end;
end;
end;
WriteLn('Could not find Dirt Road Color!');
Result := 0;
end;
{************************************************* ******************************
function FindBridgeColor: Integer;
By: Tarajunky
Description: Autodetects Bridge Color on Minimap
************************************************** *****************************}
function FindBridgeColor: Integer;
var
GC, a, l, TestColor, x, y: integer;
var
P:array of Tpoint;
begin
if WaterColor = 0 then WaterColor := FindWaterColor;
if not(FindColor(x, y, WaterColor, MMX1, MMY1, MMX2, MMY2)) then
WaterColor := FindWaterColor;
if WaterColor = 0 then
begin
WriteLn('No water on screen... aborting');
Result := 0;
Exit;
end;
GC := 1389645;
Flag;
FindColorsSpiralTolerance(MMCX, MMCY, P, GC, MMX1, MMY1, MMX2, MMY2, 60);
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 GetColor(P[a].x,P[a].y-1)=WaterColor then
begin
if GetColor(P[a].x-1,P[a].y)=Testcolor+198926 then
begin
Result := TestColor;
WriteLn('Bridge Color = ' + IntToStr(TestColor));
Exit;
end;
end;
end;
end;
WriteLn('Could not find Bridge Color!');
Result := 0;
end;
{************************************************* ******************************
function FindLadderColor: Integer;
By: Tarajunky
Description: Autodetects Ladder Color on Minimap
************************************************** *****************************}
function FindLadderColor:integer;
var
GC, ColorCount, a, i, j, n, l, TestColor, Red, Green, Blue : integer;
var
ColorArray : array of integer;
var
P : array of Tpoint;
begin
GC := 10837;
Flag;
FindColorsSpiralTolerance(MMCX, MMCY, P, GC, MMX1, MMY1, MMX2, MMY2, 60);
l:=GetArrayLength(P);
SetArrayLength(ColorArray,32);
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,60) then
begin
red := (TestColor mod 256);
green := ((TestColor / 256) mod 256);
blue := ((TestColor / 256) / 256);
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 Red - Green >= 25 then if Red - Green <= 65 then
if Red - Blue >= 55 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('Ladder color = ' + 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;
{************************************************* ******************************
function AutoColorThis(Bitmap, MaxTol, X1, Y1, X2, Y2: Integer): Integer;
By: Sumilion
Description: Resturns exact color of a bmp with tol found on the screen.
************************************************** *****************************}
function AutoColorThis(Bitmap, MaxTol, X1, Y1, X2, Y2: Integer): Integer;
var
lTol, Ax, Ay: Integer;
begin
Result := 0;
repeat;
if (FindBitmapToleranceIn(Bitmap, Ax, Ay, X1, Y1, X2, Y2, lTol)) then
begin
Result := GetColor(Ax, Ay);
Exit;
end;
lTol := lTol + 5;
until (lTol >= MaxTol);
srl_Warn('AutoColorThis', 'The Color was not found', warn_Warning);
WriteLn('Color NOT found.');
end;
Just copy and paste that
Powered by vBulletin® Version 4.2.1 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.