SRL Archive - SRL Archives

[Function]RadialFindObj


Avaphi

2007-02-16 13:17:11

Hey there guys, I just decided to make another FindObj function… But I modeled this to how RadialRoadWalk works, so it will scan in a circular motion just like RRW, except from the middle out, finding the object nearest you. Hope it gets implemented :) Here it is :

Function RadialFindObj(var Obx, Oby : integer; Text : string; Color, Tolerance : integer): boolean;
var MinRadius, MaxRadius, SRadial, ERadial, i, Tempx, Tempy : integer;
begin
SRadial := 0;
ERadial := 360;
MinRadius := 15;
MaxRadius := 175;
BenMouse := True;
begin
repeat
for i := SRadial to ERadial do
begin
Tempx := Round(MinRadius * Sine(i)) + MSCX;
Tempy := Round(-MinRadius * Cose(i)) + MSCY;
if (FindColorTolerance(x, y, Color, Tempx, Tempy, Tempx+1, Tempy+1, Tolerance)) then
begin
Obx := x;
Oby := y;
MMouse(Obx, Oby, 0, 0);
if (IsUpText(Text)) then
begin
Result := True;
Exit;
end;
end;
end;
MinRadius := MinRadius + 5;
until (MinRadius >= MaxRadius);
end;
end;

syberium

2007-02-16 18:28:05

wow this very nice from the looks.. now if i only i understood how radial walk works then i could test this for ya-:rolleyes:

pwnaz0r

2007-02-16 19:02:19

:p To syberium.. Maybe add user controled direction later on? Like radialwalk? This is basically a " Find Object from centre " thing you got going here :p