Cazax
2009-07-23 04:10:14
The beginning of DraynorColorFinder tell us…
Now we have one problem. In both files there is a water color finding and ladder color finding function. I find SRL's pretty good and they don't need a backup IMO. Either:
- Remove them
- Redirect them to FindLadderColor and FindWaterColor.
So I made one with these and one without.
DraynorColorFinder.scar:
With FindDraynorWaterColor and FindDraynorLadderColor:
Without them:
FaladorColorFinder.scar: (a small include…)
With FindFaladorWaterColor:
Without it:
It took a while to collect the colors, so I hope you appreciate my work :)
This list was last updated on March 25, 2007.It's outdated. The functions use bitmaps of specific places(for example FindDraynorHouseColor uses a house bmp) and it requires the compass faced north. I made new autocoloring functions based on HSL ranges. HSL is accurate when comparing similar colors to human eye. Since I'm not making a tutorial(I was about to, this gave me some inspiration :p) I won't go in detail. I hope SRL developers finish the migration between RGB and HSL in autocoloring.scar or I could do it maybe if I have time.Now we have one problem. In both files there is a water color finding and ladder color finding function. I find SRL's pretty good and they don't need a backup IMO. Either:
- Remove them
- Redirect them to FindLadderColor and FindWaterColor.
So I made one with these and one without.
DraynorColorFinder.scar:
With FindDraynorWaterColor and FindDraynorLadderColor:
//-----------------------------------------------------------------//
//-- Scar Standard Resource Library --//
//-----------------------------------------------------------------//
// * function FindDraynorRoadColor: Integer; // * by Cazax
// * function FindDraynorLadderColor: Integer; // * by tarajunky
// * function FindDraynorHouseColor: Integer; // * by Cazax
// * function IsRoad(RX1, RY1, RX2, RY2: Integer): Boolean; // * by Cazax
// * function FindDraynorWaterColor: Integer; // * by tarajunky
// * function WaterFound(WX1, WY1, WX2, WY2: Integer): Boolean; // * by Cazax
// * function FindDraynorRockColor: Integer; // * by Cazax
// * function RockFound(WX1, WY1, WX2, WY2: Integer): Boolean; // * by Cazax
// * function FindDraynorDoorColor: Integer; // * by Cazax
// * procedure FindDraynorColors(var ColorArray : TIntegerArray); // * by Cazax
{*******************************************************************************
function FindDraynorRoadColor: Integer;
By: Cazax
Description: Finds Draynor Road Color
*******************************************************************************}
Function FindDraynorRoadColor: Integer;
Var
TPA : TPointArray;
Cols : TIntegerArray;
H, I, X, Y : Integer;
Hue, Sat, Lum : Extended;
Begin
FindColorsSpiralTolerance(MMCX, MMCY, TPA, 6184550, MMX1, MMY1, MMX2, MMY2, 35);
If Length(TPA) = 0 Then
Exit;
Cols := GetColors(TPA);
ClearSameIntegers(Cols);
H := High(Cols);
For I := 0 To H Do
Begin
ColorToHSL(Cols[I], Hue, Sat, Lum);
If (Sat > 2.8) And (Sat < 5.4) Then
If FindColoredAreaTolerance(X, Y, Cols[I], MMX1, MMY1, MMX2, MMY2, 16, 0) Then
Begin
Writeln('DraynorRoadColor = ' + IntToStr(Cols[I]));
Result := Cols[I];
Exit;
End;
End;
Writeln('Could not find Draynor Road Color!');
End;
{*******************************************************************************
function FindDraynorLadderColor: Integer;
By: tarajunky
Description: Finds Draynor Ladder Color
*******************************************************************************}
function FindDraynorLadderColor: Integer;
begin
Result := FindLadderColor;
end;
{*******************************************************************************
Function FindDraynorHouseColor: Integer;
By: Cazax
Description: Finds Draynor House Color
*******************************************************************************}
Function FindDraynorHouseColor: Integer;
Var
TPA : TPointArray;
Cols : TIntegerArray;
H, I, X, Y : Integer;
Hue, Sat, Lum : Extended;
Begin
FindColorsSpiralTolerance(MMCX, MMCY, TPA, 4217711, MMX1, MMY1, MMX2, MMY2, 35);
If Length(TPA) = 0 Then
Exit;
Cols := GetColors(TPA);
ClearSameIntegers(Cols);
H := High(Cols);
For I := 0 To H Do
Begin
ColorToHSL(Cols[I], Hue, Sat, Lum);
If (Sat > 25.5) And (Sat < 28.6) Then
If FindColoredAreaTolerance(X, Y, Cols[I], MMX1, MMY1, MMX2, MMY2, 16, 0) Then
Begin
Writeln('DraynorHouseColor = ' + IntToStr(Cols[I]));
Result := Cols[I];
Exit;
End;
End;
Writeln('Could not find Draynor House Color!');
End;
{*******************************************************************************
function IsRoad(RX1, RY1, RX2, RY2: Integer): Boolean;
By: Cazax
Description: Finds Road color inside given coordinates.
*******************************************************************************}
function IsRoad(RX1, RY1, RX2, RY2: Integer): Boolean;
var
X, Y : Integer;
begin
RoadColor := FindDraynorRoadColor;
If RoadColor = 0 Then
Exit;
Result := FindColor(X, Y, RoadColor, RX1, RY1, RX2, RY2);
end;
{*******************************************************************************
function FindDraynorWaterColor: Integer;
By: tarajunky
Description: Find Draynor Water Color.
*******************************************************************************}
function FindDraynorWaterColor: Integer;
begin
Result := FindWaterColor;
end;
{*******************************************************************************
function WaterFound(WX1, WY1, WX2, WY2: Integer): Boolean;
By: Cazax
Description: Finds Water Color at given coordinates.
*******************************************************************************}
function WaterFound(WX1, WY1, WX2, WY2: Integer): Boolean;
var
X, Y: Integer;
begin
If FindWaterColor <> 0 Then
Result := FindColor(X, Y, WaterColor, WX1, WY1, WX2, WY2);
end;
{*******************************************************************************
Function FindDraynorRockColor: Integer;
By: Cazax
Description: Find Draynor Rock Color.
*******************************************************************************}
Function FindDraynorRockColor: Integer;
Var
TPA : TPointArray;
Cols : TIntegerArray;
H, I, X, Y : Integer;
Hue, Sat, Lum : Extended;
Begin
FindColorsSpiralTolerance(MMCX, MMCY, TPA, 4869444, MMX1, MMY1, MMX2, MMY2, 35);
If Length(TPA) = 0 Then
Exit;
Cols := GetColors(TPA);
ClearSameIntegersAndTPA(Cols, TPA);
H := High(Cols);
For I := 0 To H Do
Begin
ColorToHSL(Cols[I], Hue, Sat, Lum);
If (Sat > 3.8) And (Sat < 6.6) Then
If FindColor(X, Y, FindWaterColor, TPA[I].X - 20, TPA[I].Y - 20, TPA[I].X + 20, TPA[I].Y + 20) Then
Begin
Writeln('DraynorRockColor = ' + IntToStr(Cols[I]));
Result := Cols[I];
Exit;
End;
End;
Writeln('Could not find Draynor Rock Color!');
End;
{*******************************************************************************
function RockFound(WX1, WY1, WX2, WY2: Integer): Boolean;
By: Cazax
Description: Finds Rock Color inside given coordinates.
*******************************************************************************}
function RockFound(var RockColor : Integer; WX1, WY1, WX2, WY2: Integer): Boolean;
var
X, Y, C : Integer;
begin
C := FindDraynorRockColor;
If C <> 0 Then
Result := FindColor(X, Y, C, WX1, WY1, WX2, WY2);
end;
{*******************************************************************************
function FindDraynorDoorColor(var DoorColor : Integer): Boolean;
By: WT-Fakawi and modified by Ron
Description: Find Draynor Door Color. (Red: 230-245)
*******************************************************************************}
Function FindDraynorDoorColor: Integer;
Var
TPA : TPointArray;
Cols : TIntegerArray;
H, I : Integer;
Hue, Sat, Lum : Extended;
Begin
FindColorsSpiralTolerance(MMCX, MMCY, TPA, 233, MMX1, MMY1, MMX2, MMY2, 35);
If Length(TPA) = 0 Then
Exit;
Cols := GetColors(TPA);
ClearSameIntegersAndTPA(Cols, TPA);
H := High(Cols);
For I := 0 To H Do
Begin
ColorToHSL(Cols[I], Hue, Sat, Lum);
If Hue = 0.0 Then
If (CountColor(Cols[I], TPA[I].X - 3, TPA[I].Y - 3, TPA[I].X + 3, TPA[I].Y + 3) >= 3) And (CountColor(65536, TPA[I].X - 5, TPA[I].Y - 5, TPA[I].X + 5, TPA[I].Y + 5) = 0) Then //Not to confuse with red dots
Begin
Writeln('DraynorDoorColor = ' + IntToStr(Cols[I]));
Result := Cols[I];
Exit;
End;
End;
Writeln('Could not find Draynor Door Color!');
End;
{*******************************************************************************
Procedure FindAllDraynorColors(Var ColorArray : TIntegerArray);
By: Cazax
Description: Find All Draynor Colors.
ColorArray[0] Is road color
ColorArray[1] Is rock color
ColorArray[2] Is house color
ColorArray[3] Is door color
ColorArray[4] Is ladder color
ColorArray[5] Is water color
*******************************************************************************}
Procedure FindAllDraynorColors(Var ColorArray : TIntegerArray);
Begin
SetLength(ColorArray, 6);
ColorArray[0] := FindDraynorRoadColor;
ColorArray[1] := FindDraynorRockColor;
ColorArray[2] := FindDraynorHouseColor;
ColorArray[3] := FindDraynorDoorColor;
ColorArray[4] := FindDraynorLadderColor;
ColorArray[5] := FindDraynorWaterColor;
End;Without them:
//-----------------------------------------------------------------//
//-- Scar Standard Resource Library --//
//-----------------------------------------------------------------//
// * function FindDraynorRoadColor: Integer; // * by Cazax
// * function FindDraynorHouseColor: Integer; // * by Cazax
// * function IsRoad(RX1, RY1, RX2, RY2: Integer): Boolean; // * by Cazax
// * function WaterFound(WX1, WY1, WX2, WY2: Integer): Boolean; // * by Cazax
// * function FindDraynorRockColor: Integer; // * by Cazax
// * function RockFound(WX1, WY1, WX2, WY2: Integer): Boolean; // * by Cazax
// * function FindDraynorDoorColor: Integer; // * by Cazax
// * procedure FindDraynorColors(var ColorArray : TIntegerArray); // * by Cazax
{*******************************************************************************
function FindDraynorRoadColor: Integer;
By: Cazax
Description: Finds Draynor Road Color
*******************************************************************************}
Function FindDraynorRoadColor: Integer;
Var
TPA : TPointArray;
Cols : TIntegerArray;
H, I, X, Y : Integer;
Hue, Sat, Lum : Extended;
Begin
FindColorsSpiralTolerance(MMCX, MMCY, TPA, 6184550, MMX1, MMY1, MMX2, MMY2, 35);
If Length(TPA) = 0 Then
Exit;
Cols := GetColors(TPA);
ClearSameIntegers(Cols);
H := High(Cols);
For I := 0 To H Do
Begin
ColorToHSL(Cols[I], Hue, Sat, Lum);
If (Sat > 2.8) And (Sat < 5.4) Then
If FindColoredAreaTolerance(X, Y, Cols[I], MMX1, MMY1, MMX2, MMY2, 16, 0) Then
Begin
Writeln('DraynorRoadColor = ' + IntToStr(Cols[I]));
Result := Cols[I];
Exit;
End;
End;
Writeln('Could not find Draynor Road Color!');
End;
{*******************************************************************************
function FindDraynorLadderColor: Integer;
By: tarajunky
Description: Finds Draynor Ladder Color
*******************************************************************************}
function FindDraynorLadderColor: Integer;
begin
Result := FindLadderColor;
end;
{*******************************************************************************
Function FindDraynorHouseColor: Integer;
By: Cazax
Description: Finds Draynor House Color
*******************************************************************************}
Function FindDraynorHouseColor: Integer;
Var
TPA : TPointArray;
Cols : TIntegerArray;
H, I, X, Y : Integer;
Hue, Sat, Lum : Extended;
Begin
FindColorsSpiralTolerance(MMCX, MMCY, TPA, 4217711, MMX1, MMY1, MMX2, MMY2, 35);
If Length(TPA) = 0 Then
Exit;
Cols := GetColors(TPA);
ClearSameIntegers(Cols);
H := High(Cols);
For I := 0 To H Do
Begin
ColorToHSL(Cols[I], Hue, Sat, Lum);
If (Sat > 25.5) And (Sat < 28.6) Then
If FindColoredAreaTolerance(X, Y, Cols[I], MMX1, MMY1, MMX2, MMY2, 16, 0) Then
Begin
Writeln('DraynorHouseColor = ' + IntToStr(Cols[I]));
Result := Cols[I];
Exit;
End;
End;
Writeln('Could not find Draynor House Color!');
End;
{*******************************************************************************
function IsRoad(RX1, RY1, RX2, RY2: Integer): Boolean;
By: Cazax
Description: Finds Road color inside given coordinates.
*******************************************************************************}
function IsRoad(RX1, RY1, RX2, RY2: Integer): Boolean;
var
X, Y : Integer;
begin
RoadColor := FindDraynorRoadColor;
If RoadColor = 0 Then
Exit;
Result := FindColor(X, Y, RoadColor, RX1, RY1, RX2, RY2);
end;
{*******************************************************************************
function FindDraynorWaterColor: Integer;
By: tarajunky
Description: Find Draynor Water Color.
*******************************************************************************}
function FindDraynorWaterColor: Integer;
begin
Result := FindWaterColor;
end;
{*******************************************************************************
function WaterFound(WX1, WY1, WX2, WY2: Integer): Boolean;
By: Cazax
Description: Finds Water Color at given coordinates.
*******************************************************************************}
function WaterFound(WX1, WY1, WX2, WY2: Integer): Boolean;
var
X, Y: Integer;
begin
If FindWaterColor <> 0 Then
Result := FindColor(X, Y, WaterColor, WX1, WY1, WX2, WY2);
end;
{*******************************************************************************
Function FindDraynorRockColor: Integer;
By: Cazax
Description: Find Draynor Rock Color.
*******************************************************************************}
Function FindDraynorRockColor: Integer;
Var
TPA : TPointArray;
Cols : TIntegerArray;
H, I, X, Y : Integer;
Hue, Sat, Lum : Extended;
Begin
FindColorsSpiralTolerance(MMCX, MMCY, TPA, 4869444, MMX1, MMY1, MMX2, MMY2, 35);
If Length(TPA) = 0 Then
Exit;
Cols := GetColors(TPA);
ClearSameIntegersAndTPA(Cols, TPA);
H := High(Cols);
For I := 0 To H Do
Begin
ColorToHSL(Cols[I], Hue, Sat, Lum);
If (Sat > 3.8) And (Sat < 6.6) Then
If FindColor(X, Y, FindWaterColor, TPA[I].X - 20, TPA[I].Y - 20, TPA[I].X + 20, TPA[I].Y + 20) Then
Begin
Writeln('DraynorRockColor = ' + IntToStr(Cols[I]));
Result := Cols[I];
Exit;
End;
End;
Writeln('Could not find Draynor Rock Color!');
End;
{*******************************************************************************
function RockFound(WX1, WY1, WX2, WY2: Integer): Boolean;
By: Cazax
Description: Finds Rock Color inside given coordinates.
*******************************************************************************}
function RockFound(var RockColor : Integer; WX1, WY1, WX2, WY2: Integer): Boolean;
var
X, Y, C : Integer;
begin
C := FindDraynorRockColor;
If C <> 0 Then
Result := FindColor(X, Y, C, WX1, WY1, WX2, WY2);
end;
{*******************************************************************************
function FindDraynorDoorColor(var DoorColor : Integer): Boolean;
By: WT-Fakawi and modified by Ron
Description: Find Draynor Door Color. (Red: 230-245)
*******************************************************************************}
Function FindDraynorDoorColor: Integer;
Var
TPA : TPointArray;
Cols : TIntegerArray;
H, I : Integer;
Hue, Sat, Lum : Extended;
Begin
FindColorsSpiralTolerance(MMCX, MMCY, TPA, 233, MMX1, MMY1, MMX2, MMY2, 35);
If Length(TPA) = 0 Then
Exit;
Cols := GetColors(TPA);
ClearSameIntegersAndTPA(Cols, TPA);
H := High(Cols);
For I := 0 To H Do
Begin
ColorToHSL(Cols[I], Hue, Sat, Lum);
If Hue = 0.0 Then
If (CountColor(Cols[I], TPA[I].X - 3, TPA[I].Y - 3, TPA[I].X + 3, TPA[I].Y + 3) >= 3) And (CountColor(65536, TPA[I].X - 5, TPA[I].Y - 5, TPA[I].X + 5, TPA[I].Y + 5) = 0) Then //Not to confuse with red dots
Begin
Writeln('DraynorDoorColor = ' + IntToStr(Cols[I]));
Result := Cols[I];
Exit;
End;
End;
Writeln('Could not find Draynor Door Color!');
End;
{*******************************************************************************
Procedure FindAllDraynorColors(Var ColorArray : TIntegerArray);
By: Cazax
Description: Find All Draynor Colors.
ColorArray[0] Is road color
ColorArray[1] Is rock color
ColorArray[2] Is house color
ColorArray[3] Is door color
*******************************************************************************}
Procedure FindAllDraynorColors(Var ColorArray : TIntegerArray);
Begin
SetLength(ColorArray, 4);
ColorArray[0] := FindDraynorRoadColor;
ColorArray[1] := FindDraynorRockColor;
ColorArray[2] := FindDraynorHouseColor;
ColorArray[3] := FindDraynorDoorColor;
End;FaladorColorFinder.scar: (a small include…)
With FindFaladorWaterColor:
//-----------------------------------------------------------------//
//-- Scar Standard Resource Library --//
//-----------------------------------------------------------------//
// * Function FindFaladorRoadColor: Integer; // * by Cazax
// * function FindFaladorWaterColor: Integer; // * by tarajunky
// * function FindFaladorHouseColor: Integer; // * by Cazax
// * Procedure FindFaladorBasicColors(Var ColorArray : TIntegerArray); // * by Cazax
{*******************************************************************************
Function FindFaladorRoadColor: Integer;
By: Cazax
Description: Finds Falador Road Color.
*******************************************************************************}
Function FindFaladorRoadColor: Integer;
Var
TPA : TPointArray;
Cols : TIntegerArray;
H, I, X, Y : Integer;
Hue, Sat, Lum : Extended;
Begin
FindColorsSpiralTolerance(MMCX, MMCY, TPA, 6649727, MMX1, MMY1, MMX2, MMY2, 35);
If Length(TPA) = 0 Then
Exit;
Cols := GetColors(TPA);
ClearSameIntegers(Cols);
H := High(Cols);
For I := 0 To H Do
Begin
ColorToHSL(Cols[I], Hue, Sat, Lum);
If (Sat > 10.0) And (Sat < 12.6) Then
If FindColoredAreaTolerance(X, Y, Cols[I], MMX1, MMY1, MMX2, MMY2, 14, 0) Then
Begin
Writeln('FaladorRoadColor = ' + IntToStr(Cols[I]));
Result := Cols[I];
Exit;
End;
End;
Writeln('Could not find Falador Road Color!');
End;
{*******************************************************************************
function FindFaladorWaterColor: Integer;
By: tarajunky
Description: Finds Falador Water Color.
*******************************************************************************}
function FindFaladorWaterColor: Integer;
begin
Result := FindWaterColor;
end;
{*******************************************************************************
function FindFaladorHouseColor: Integer;
By: Cazax
Description: Finds Falador House Color.
*******************************************************************************}
Function FindFaladorHouseColor: Integer;
Var
TPA : TPointArray;
Cols : TIntegerArray;
H, I, X, Y : Integer;
Hue, Sat, Lum : Extended;
Begin
FindColorsSpiralTolerance(MMCX, MMCY, TPA, 9679288, MMX1, MMY1, MMX2, MMY2, 35);
If Length(TPA) = 0 Then
Exit;
Cols := GetColors(TPA);
ClearSameIntegers(Cols);
H := High(Cols);
For I := 0 To H Do
Begin
ColorToHSL(Cols[I], Hue, Sat, Lum);
If (Hue > 12.2) And (Hue < 14.8) Then
If FindColoredAreaTolerance(X, Y, Cols[I], MMX1, MMY1, MMX2, MMY2, 16, 0) Then
Begin
Writeln('FaladorHouseColor = ' + IntToStr(Cols[I]));
Result := Cols[I];
Exit;
End;
End;
Writeln('Could not find Falador House Color!');
End;
{*******************************************************************************
Procedure FindFaladorBasicColors(Var ColorArray : TIntegerArray);
By: Cazax
Description: Finds All Falador Colors.
ColorArray[0] Is road color
ColorArray[1] Is water color
ColorArray[2] Is road color
*******************************************************************************}
Procedure FindFaladorBasicColors(Var ColorArray : TIntegerArray);
Begin
SetLength(ColorArray, 3);
ColorArray[0] := FindFaladorRoadColor;
ColorArray[1] := FindFaladorWaterColor;
ColorArray[2] := FindFaladorHouseColor;
End;Without it:
//-----------------------------------------------------------------//
//-- Scar Standard Resource Library --//
//-----------------------------------------------------------------//
// * Function FindFaladorRoadColor: Integer; // * by Cazax
// * function FindFaladorHouseColor: Integer; // * by Cazax
// * Procedure FindFaladorBasicColors(Var ColorArray : TIntegerArray); // * by Cazax
{*******************************************************************************
Function FindFaladorRoadColor: Integer;
By: Cazax
Description: Finds Falador Road Color.
*******************************************************************************}
Function FindFaladorRoadColor: Integer;
Var
TPA : TPointArray;
Cols : TIntegerArray;
H, I, X, Y : Integer;
Hue, Sat, Lum : Extended;
Begin
FindColorsSpiralTolerance(MMCX, MMCY, TPA, 6649727, MMX1, MMY1, MMX2, MMY2, 35);
If Length(TPA) = 0 Then
Exit;
Cols := GetColors(TPA);
ClearSameIntegers(Cols);
H := High(Cols);
For I := 0 To H Do
Begin
ColorToHSL(Cols[I], Hue, Sat, Lum);
If (Sat > 10.0) And (Sat < 12.6) Then
If FindColoredAreaTolerance(X, Y, Cols[I], MMX1, MMY1, MMX2, MMY2, 14, 0) Then
Begin
Writeln('FaladorRoadColor = ' + IntToStr(Cols[I]));
Result := Cols[I];
Exit;
End;
End;
Writeln('Could not find Falador Road Color!');
End;
{*******************************************************************************
function FindFaladorHouseColor: Integer;
By: Cazax
Description: Finds Falador House Color.
*******************************************************************************}
Function FindFaladorHouseColor: Integer;
Var
TPA : TPointArray;
Cols : TIntegerArray;
H, I, X, Y : Integer;
Hue, Sat, Lum : Extended;
Begin
FindColorsSpiralTolerance(MMCX, MMCY, TPA, 9679288, MMX1, MMY1, MMX2, MMY2, 35);
If Length(TPA) = 0 Then
Exit;
Cols := GetColors(TPA);
ClearSameIntegers(Cols);
H := High(Cols);
For I := 0 To H Do
Begin
ColorToHSL(Cols[I], Hue, Sat, Lum);
If (Hue > 12.2) And (Hue < 14.8) Then
If FindColoredAreaTolerance(X, Y, Cols[I], MMX1, MMY1, MMX2, MMY2, 16, 0) Then
Begin
Writeln('FaladorHouseColor = ' + IntToStr(Cols[I]));
Result := Cols[I];
Exit;
End;
End;
Writeln('Could not find Falador House Color!');
End;
{*******************************************************************************
Procedure FindFaladorBasicColors(Var ColorArray : TIntegerArray);
By: Cazax
Description: Finds All Falador Colors.
ColorArray[0] Is road color
ColorArray[1] Is road color
*******************************************************************************}
Procedure FindFaladorBasicColors(Var ColorArray : TIntegerArray);
Begin
SetLength(ColorArray, 2);
ColorArray[0] := FindFaladorRoadColor;
ColorArray[1] := FindFaladorHouseColor;
End;It took a while to collect the colors, so I hope you appreciate my work :)