SRL Archive - OSR Help

Filtering radialwalk radius


Haxz

2013-04-11 14:01:34

Not really sure how can I explain my question, but I'll try my best.

RadialWalkTolerance2(1998452, 280, 340, 65, 0, 0, 50);
Say for this radialwalk function, I am searching for the grass color with starting radial of 280 and ending radial of 340, with a radius of 65.

For example, I wanted to filter the color search from radius 0 to 30, so it will only finds the grass color at start of radius 31 to 65. Is there any way I can do this?

I'll explain more if you could not get what I'm asking. Thanks! :D

Haxz

2013-04-12 08:55:35

Was hoping someone could give me an answer to this, but I figured it out myself. Maybe the question wasn't clear enough :p

Admins or mods can close this thread if you want.

Ashaman88

2013-04-12 09:03:00

You should explain how you came to your solution so that others might benefit :)

Haxz

2013-04-12 09:13:47

From: Ashaman88
You should explain how you came to your solution so that others might benefit :)


True dat :D



function RadialWalkEx2(var TPA: TPointArray; cx, cy, TheColor, tol: Integer; StartRadial, EndRadial: Variant; Radius: Integer): Boolean;
var
time: Integer;
SD, ED: extended;
begin
Result := False;
if (not LoggedIn) then Exit;

if not (VariantIsNumber(StartRadial) and VariantIsNumber(EndRadial)) then
begin
SD := variantToDirection(StartRadial);
StartRadial := SD;
ED := variantToDirection(EndRadial);
EndRadial := ED;
end else
begin
SD := StartRadial;
ED := EndRadial;
end;

if SD > ED then SwapE(SD, ED);

if (SD = ED) then
begin
srl_Warn('RadialWalkEx', 'StartRadial = EndRadial, using LinearWalkEx.', warn_Warning);
Result := LinearWalkEx(tpa, cx, cy, TheColor, tol, StartRadial, Radius);
end;

time := GetSystemTime;
try
FindColorsTolerance(tpa, TheColor, MMX1, MMY1, MMX2, MMY2, tol);
FilterPointsPie(tpa, SD, ED, 40, Radius, cx, cy);
SortCircleWise(tpa, cx, cy, StartRadial, False, StartRadial > EndRadial);
Result := (Length(tpa) > 0);
except
srl_Warn('RadialWalkEx', 'An exception has occured', warn_AllVersions); Exit;
end;
srl_Warn('RadialWalkEx', 'Took ' + IntToStr(GetSystemTime - time) +
' ms, found' + IntToStr(Length(TPA)) + ' points', warn_Debug);
end;


function RadialWalkTolerance2(Color: Integer; sRadial, eRadial: Variant; r, modX, modY, Tol: Integer): Boolean;
var
TPA: TPointArray;
i, h: Integer;
begin
Result := False;

if RadialWalkEx2(TPA, MMCX, MMCY, Color, Tol, sRadial, eRadial, r) then
begin
h := High(TPA);
for i := 0 to h do
//MFNF(TPA[i].x-5, TPA[i].y, modX, modY)
if BankTrue = 0 then
begin
if MouseFlagEx(TPA[i].x-5, TPA[i].y, 0, 0, modX, modY, -1, False, False) then
begin
Result := FFlag(30);
Exit;
end;
end else
begin
if MouseFlagEx(TPA[i].x, TPA[i].y, 0, 0, modX, modY, -1, False, False) then
begin
Result := FFlag(30);
Exit;
end;
end;
end;
end;

In RadialWalkEx function, there's this line
FilterPointsPie(tpa, SD, ED, 40, Radius, cx, cy);
I replaced the number to 40, so it is filtering the search result from radius 0 to 40.

You want to paste the function in your script. And if you're using another radialwalk function, you need to paste and edit the function in your script too.
In my case, I'm using RadialWalkTolerance. I paste the RadialWalkTolerance function in my script, then edit the RadialWalkEx inside the function into RadialWalkEx2. You need to rename both of the function to another name, else it will give you a duplicate error.
Not sure if I am right on this, but at least it works the way I want it now.