NewToAutoing
2007-06-26 07:33:02
So the way this works (or should work) is that it'll search in the same way as RadialWalk/RadialRoadWalk, but without clicking. Also, it'll search multiple times for multiple colors, in multiple areas. Then, if you set ClickCenter to true, it'll find the center of the points it found the colors at. If MaxDist is higher than 0, it'll check to see if the colors it searched for are within MaxDist of the center.
As of now it can only find the center if you're using two, three, or four different spots. The one for three is probably the wrong way to find a center of a triangle, but i was lazy and it worked. If anyone knows how to and wants me to add 5,6, etc, lemme know.
How would this be useful?
Well, you could sort of use it like a DDTM if used when walking. You'd set the colors to the colors of the road. Then the paramaters would be the different splits of the road (The idea of this being you'd use it at a road split) So it could be used as the until of a RadialRoadWalk loop, basically until it finds the three colors at the three spots. Or, until it reaches the road split (h)
I didn't test it much, and i'm sure a lot of it could be made a lot better, but i'm really tired now and i'll take another look over it later.
Example of usage:
This should work for the example i was talking about. I was using this at the split between Rimmington and Falador, closer to Rimmington.
Credits to the makers of RadialWalk/RadialRoadWalk, as all i did was change things around in it to make it work the way i wanted.
{*******************************************************************************
function NumbersAreEqual(Numbers: array of Integer): Boolean;
By: NewToAutoing
Description: Made it because I couldn't find something like this already
*******************************************************************************}
function NumbersAreEqual(Numbers: array of Integer): Boolean;
var
i,j: Integer;
begin
Result := True;
for i := 0 to GetArrayLength(Numbers) - 1 do
begin
for j := 0 to GetArrayLength(Numbers) - 1 do
begin
if (not(Numbers[i] = Numbers[j])) then
begin
Result := False;
Writeln(IntToStr(Numbers[i]) + ' and ' + IntToStr(Numbers[j]) + ' are not equal.');
Exit;
end;
end;
end;
end;
{*******************************************************************************
function FindColorRadialMulti(TheColor,StartRadial,EndRadial,StartRadius,EndRadius: array of Integer;
XMod,YMod,MaxDist: Integer; ClickCenter: Boolean): Boolean;
By: NewToAutoing
Description: Searches for the colors you set in the areas you set like RadialWalk.
If ClickCenter = True it'll find the center of the points it found the colors at,
and walk there. If MaxDist > 0 it'll check for the colors it searched for within MaxDist
of the center.
*******************************************************************************}
function FindColorRadialMulti(TheColor,StartRadial,EndRadial,StartRadius,EndRadius: array of Integer;
XMod,YMod,MaxDist: Integer; ClickCenter: Boolean): Boolean;
var
cc: TPointArray;
i,Z, X1, Y1,x2,y2: Integer;
begin
Result := True;
if (not(NumbersAreEqual([GetArrayLength(TheColor),GetArrayLength(StartRadial),GetArrayLength(EndRadial),GetArrayLength(StartRadius),GetArrayLength(EndRadius)]))) then
begin
Writeln('Error. ');
Result := False;
Exit;
end;
SetArrayLength(cc,GetArrayLength(TheColor));
for Z := 0 to GetArrayLength(TheColor) - 1 do
begin
if (RoadColorChecker) then
if (DebugRadialRoad) then
WriteLn(' THROUGH RADIALROADWALK= ---> ' + IntToStr(RoadColor));
if (StartRadial[Z] < EndRadial[Z]) then
begin
repeat
for i := StartRadial[Z] to EndRadial[Z] do
begin
x1 := Round(StartRadius[Z] * Sine(i)) + 646;
y1 := Round(-StartRadius[Z] * Cose(i)) + 84;
if Not LoggedIn then Exit;
if (FindColor(cc[Z].x,cc[Z].y, TheColor[Z], X1, Y1, X1 + 1, Y1 + 1)) then
Break;
end;
StartRadius[Z] := StartRadius[Z] - 4;
if (Result = True) then Break;
until (StartRadius[Z] <= EndRadius[Z]);
end else
if (StartRadial[Z] > EndRadial[Z]) then
begin
repeat
for i := StartRadial[Z] downto EndRadial[Z] do
begin
x1 := Round(StartRadius[Z] * Sine(i)) + 646;
y1 := Round(-StartRadius[Z] * Cose(i)) + 84;
if Not LoggedIn then Exit;
if (FindColor(cc[Z].x,cc[Z].y, TheColor[Z], X1, Y1, X1 + 1, Y1 + 1)) then
Break;
end;
StartRadius[Z] := StartRadius[Z] - 4;
if (Result = True) then Break;
until (StartRadius[Z] <= EndRadius[Z]);
end;
if StartRadius[Z] <= EndRadius[Z] then
begin
Result := False;
Exit;
end;
end;
if (ClickCenter) then
begin
if GetArrayLength(cc) = 2 then
begin
x := cc[0].x + Round((Abs(cc[0].x - cc[1].x))/2);
y := cc[0].y + Round((Abs(cc[0].x - cc[1].y))/2);
end;
if GetArrayLength(cc) = 3 then
begin
x := cc[0].x + Round((Abs(cc[0].x - cc[1].x))/2);
y := cc[0].y + Round((Abs(cc[0].y - cc[1].y))/2);
x := x + Round((Abs(x - cc[2].x))/2);
y := y + Round((Abs(y - cc[2].y))/2);
end;
if GetArrayLength(cc) = 4 then
begin
x := cc[0].x + Round((Abs(cc[0].x - cc[1].x))/2);
x2 := cc[2].x + Round((abs(cc[2].x - cc[3].x))/2);
x := x + Round((Abs(x - x2))/2);
y := cc[0].y + Round((Abs(cc[0].y - cc[1].y))/2);
y2 := cc[2].y + Round((abs(cc[2].y - cc[3].y))/2);
y := y + Round((Abs(y - y2))/2);
end;
if(not(MaxDist = 0)) then
if(rs_OnMinimap(x,y)) then
begin
for i := 0 to GetArrayLength(TheColor) do
begin
if FindColor(x,y,TheColor[I],x-MaxDist,y-MaxDist,x+MaxDist,y+MaxDist) then
Break
else
Result := False;
end;
end else
begin
Result := False;
Exit;
end;
if (rs_OnMinimap(x,y)) then
begin
MouseFindNoFlag(X,Y,Xmod,Ymod);
CountFlag(10);
end else
begin
Exit;
Result := False;
end;
end;
end;As of now it can only find the center if you're using two, three, or four different spots. The one for three is probably the wrong way to find a center of a triangle, but i was lazy and it worked. If anyone knows how to and wants me to add 5,6, etc, lemme know.
How would this be useful?
Well, you could sort of use it like a DDTM if used when walking. You'd set the colors to the colors of the road. Then the paramaters would be the different splits of the road (The idea of this being you'd use it at a road split) So it could be used as the until of a RadialRoadWalk loop, basically until it finds the three colors at the three spots. Or, until it reaches the road split (h)
I didn't test it much, and i'm sure a lot of it could be made a lot better, but i'm really tired now and i'll take another look over it later.
Example of usage:
TheColor := FindRoadColor;
FindColorRadialMulti([TheColor,TheColor,TheColor],[265,25,180],[325,85,250],[55,55,55],[20,20,20],2,2,20,True);This should work for the example i was talking about. I was using this at the split between Rimmington and Falador, closer to Rimmington.
Credits to the makers of RadialWalk/RadialRoadWalk, as all i did was change things around in it to make it work the way i wanted.