SRL Archive - OSR Help

Help with RadialWalk


APinAP

2012-02-19 16:47:51

Basically, I've got everything else working but I can't for the life of me figure out how to make RadialWalk search in the correct area, like so:It should search in that area with -20 and 20, or 340 and 380, or 700 and 740, or anything like that, right?
Instead, seemingly no matter which variation of '-20, 20' I put into the function, it searches in this kind of area:
I can tell because it walks south when it's supposed to be walking north. Also, these images are not the exact location I'm having this problem in.

Please help, I'm stumped.

The specific function I'm using is RadialWalkTolerance, if that makes a difference

APinAP

2012-02-20 09:14:06

58 views and not a single response? Come on, guys :(

masterBB

2012-02-20 09:34:21

Use 340,20. And here is the proof

program new;

function getBlackSquare:TPointArray;
var
x,y:Integer;
begin
setLength(result,100*100);
for x := 0 to 99 do
for y := 0 to 99 do
result[x*100+y] := Point(x,y);
end;

var
points:TPointArray;
bitmap:integer;

begin
DisplayDebugImgWindow(100,100);

points := getBlackSquare;

FilterPointsPie(points,340,20,0,100,50,50); //as you can see,340 and 20 works like a charm

bitmap := CreateBitmap(100,100);

DrawTPABitmap(bitmap,points,2927209);

DrawBitmapDebugImg(bitmap);
end.

APinAP

2012-02-20 10:57:01

It's still doing it, even though the FilterPointsPie snippet seems to do it fine.
See here:
http://dl.dropbox.com/u/9623428/screenies/why%20won%27t.png
http://dl.dropbox.com/u/9623428/screenies/you.png
http://dl.dropbox.com/u/9623428/screenies/work.png

The 3rd screenshot is from the moment when it clicks on the road to the south instead of the road to the north. I can make this mostly work by making it walk a bit more to the east and then searching between 340 and 359, though, but that's suboptimal and a bit unreliable.

I checked in mapwalk.simba and I think this might be the cause:

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

That's in RadialWalkEx, the function that the other radialwalks seem to be built from, and SD is variantToDirection(StartRadial) and ED variantToDirection(EndRadial)

Testing results:
versus

RadialWalkEx for reference:

function RadialWalkEx(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;

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

time := GetSystemTime;
try
FindColorsTolerance(tpa, TheColor, MMX1, MMY1, MMX2, MMY2, tol);
FilterPointsPie(tpa, SD, ED, 10, 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;

masterBB

2012-02-20 11:20:16

I will find this out.

APinAP

2012-02-20 11:26:06

Thanks in advance :D

masterBB

2012-02-20 11:31:12

Made a suggestion: http://villavu.com/forum/showthread.php?t=75712