Wizzup?
2007-05-29 10:09:35
EDIT:
From: nielsie95
Nice! This works for every road for me! :) (Draynor, Falador, Varrock).
program New;
{.include SRL/SRL.scar}
Var
RColor: Integer;
Function ClearTPointArray(a: TPointArray): TPointArray;
Var
I, C: Integer;
Begin
For I := 0 To GetArrayLength(a) - 1 Do
If rs_OnMiniMap(a[i].x, a[i].y) Then
Begin
C := C + 1;
SetArrayLength(Result, C + 1);
Result[C] := a[i];
End;
End;
Function NumberDoesntExist(Ar2: Array Of Integer; Number: Integer): Boolean;
Var
I: Integer;
Begin
Result := False;
For I := 0 To GetArrayLength(Ar2) - 1 Do
If Ar2[I] = Number Then
Exit;
Result := True;
End;
Function ShrinkArray(YourArray: Array Of Integer): Array Of Integer;
Var
I: Integer;
Begin
SetArrayLength(Result, 0);
For I := 0 To GetArrayLength(YourArray) - 1 Do
Begin
If NumberDoesntExist(Result, YourArray[I]) Then
Begin
SetArrayLength(Result, GetArrayLength(Result) + 1);
Result[GetArrayLength(Result) - 1] := YourArray[I];
End;
End;
End;
Function GetVarrockRoadColor: Integer;
Var
Points: TPointArray;
Colors, Colors2, Colors3, Amount, Amount2: Array Of Integer;
I, iZ: Integer;
myZ: Extended;
X, Y, Z: Array Of Extended;
Begin
ColorToleranceSpeed(0);
FindColorsTolerance(Points, RColor, MMX1, MMY1, MMX2, MMY2, 50);
Points := ClearTPointArray(Points);
Colors := ShrinkArray(GetColors(Points));
SetArrayLength(Amount, GetArrayLength(Colors));
For I := 0 To GetArrayLength(Colors) - 1 Do
Begin
Amount[i] := CountColor(Colors[I], MMX1, MMY1, MMX2, MMY2);
// If Amount[I] > 50 Then WriteLn('Color ' + IntToStr(Colors[I]) + ': '+IntToStr(Amount[I]));
End;
For I := 0 To GetArrayLength(Colors) - 1 Do
Begin
If Amount[I] > 200 Then // You might want to tweak the 200.
Begin
SetArrayLength(Amount2, GetArrayLength(Amount2) + 1);
SetArrayLength(Colors2, GetArrayLength(Colors2) + 1);
Amount2[GetArrayLength(Amount2) - 1] := Amount[I];
Colors2[GetArrayLength(Colors2) - 1] := Colors[I];
End;
End;
SetArrayLength(X, GetArrayLength(Colors2));
SetArrayLength(Y, GetArrayLength(Colors2));
SetArrayLength(Z, GetArrayLength(Colors2));
For I := 0 To GetArrayLength(Colors2) - 1 Do
Begin
ColorToXYZ(Colors2[I], X[I], Y[I], Z[I]);
If (X[I] > 10) And (X[I] < 30) And (Y[I] > 10) And (Y[I] < 30)
And (Z[I] > 10) And (Z[I] < 30) Then
Begin
SetArrayLength(Colors3, GetArrayLength(Colors3) + 1);
Colors3[GetArrayLength(Colors3) - 1] := Colors2[I];
AddToReport('Color['+IntToStr(I)+']: ' + IntToStr(Colors3[GetArrayLength(Colors3) - 1]));
End;
End;
MyZ := 0;
For I := 0 To GetArrayLength(Colors3) - 1 Do
Begin
If MaxE(Z[I], MyZ) <> MyZ Then
Begin
iZ := I;
MyZ := MaxE(Z[I], MyZ);
End;
End;
If iZ < GetArrayLength(Colors3) Then Result := Colors3[iZ]
Else Result := -1;
WriteLn('The Color is: '+IntToStr(Result));
End;
Var
I1, I2: LongInt;
begin
SetupSRL;
ClearDebug;
RColor := 8357513;
Repeat
I1 := GetSystemTime;
GetVarrockRoadColor;
I2 := GetSystemTime;
WriteLn(InttoStr(I2-I1));
Wait(1000);
ClearReport;
Until False;
end.
