SRL Archive - Help

Minimap radius problems?


Brandon

2011-12-26 18:34:25

When searching for objects on the minimap such as a ladder, there is a huge problem…

It will find the brown colour.. but it will not find it "On the minimap" instead.. it finds such an object in this SQUARE:


Thus it will sometimes click North on the compass or click the brown area AROUND what I would consider the mini"Map".. which is actually this:


Now see the difference? It will now find objects Inside this area.. which is exactly 152px in diameter.. where as the latter is a 165 px sq.

Why isn't the second used when searching in minimaps..

For example:

FindBitmapToleranceIn(Bmp, X, Y, MMX1, MMX2, MMY1, MMY2, tol) will actually search within a square for the bitmap rather than in that circle :S

euphemism

2011-12-26 18:50:15

Don't know what to tell you, if you use InCircle with the minimap center, and a radius of 76 to check if points are in the minimap circle, or use FilterPointsPie to do that automatically. Doesn't help with bitmaps, though.

mormonman

2011-12-26 18:52:42

Use FilterPointsDist(tpa, 0, 76, MMCX, MMCY);

Brandon

2011-12-26 19:25:43

From: mormonman
Use FilterPointsDist(tpa, 0, 76, MMCX, MMCY);



OI!! Thanks for that so much! lol I was using InCircle.. But that did the trick for sure.

Can you help me though.. I want it to sort objects from closest to me and instead if finds the one that is the furthest -__- total opposite..

I think it has to do with that MiddleTPA but I read in the advanced TPA tutorial that its the best to use MiddleTPA because it finds the best point :S Even though I have the thing sorting the ATPA from MMCX, MMCY.. it still does not output the closest point to me:



Function FindObjectMM(Colors: TIntegerArray; var X, Y, Dist: Integer; Width, Height, tol: integer): Boolean;
var
I: integer;
TPA: TPointArray;
ATPA: T2DPointArray;

begin
SetLength(TPA, Length(Colors));

For I:= 0 To High(Colors) do
FindColorsSpiralTolerance(MSCX, MSCY, TPA, Colors[i], MMX1, MMY1, MMX2, MMY2, tol); //Find colours starting from the middle outwards..

FilterPointsPie(TPA, 0.0, 360.0, 0.0, 76.0, MMCX, MMCY); //Filter them so they are on the MM itself..
ATPA:= TPAToATPAEx(TPA, Width, Height); //Group TPA into cirles by Distance..
SortATPAFrom(ATPA, Point(MMCX, MMCY)); //Sort the colours from the closest to the center.. AKA Me..
if(Length(ATPA) = 0) then
Exit;

MiddleTPAEx(ATPA[0], X, Y); //In that 2D Array, Pick out the closest to the middle a.k.a. the first one..
MMouse(x, y, 5, 5); //Move the mouse to the colours found..

Wait(randomrange(200, 500));
begin
MMouse(X, Y, 0, 0);
Dist:= Distance(X, Y, MMCX, MMCY);
Result:= True;
end;
GetMousePos(X, Y);
end;

mormonman

2011-12-26 19:46:09

I added a new function to Simba, its called SortATPAFromMidPoint(). It should be in the next Simba build.

euphemism

2011-12-26 20:01:07

From: mormonman
I added a new function to Simba, its called SortATPAFromMidPoint(). It should be in the next Simba build.


E: If I may ask, what is it you are trying to find on the minimap?

Which is good, because I can't wait for it. In the mean time, ggzz, you could use this little bit I've written:


procedure ATPASortFromPoint(var ATPA: T2DPointArray; SortPoint: TPoint);
var
I, Len, MinDist, Swaps, TestDist: Integer;
MinTP, TestTP: TPoint;
begin

Swaps := 1;
Len := Length(ATPA);

while (Swaps > 0) do
begin

Swaps := 0;

for I := 0 to (Len - 2) do
begin

MinTP := MiddleTPA(ATPA[i]);
MinDist := Distance(MinTP.x, MinTP.y, SortPoint.x, SortPoint.y);

TestTP := MiddleTPA(ATPA[i + 1]);
TestDist := Distance(TestTP.x, TestTP.y, SortPoint.x, SortPoint.y);

if (MinDist > TestDist) then
begin

Inc(Swaps);
TPASwap(ATPA[i + 1], ATPA[i]);
I := 0;
end;
end;
end;
end;

mormonman

2011-12-26 20:37:39

Use this….way faster.

procedure SortATPAFromMidPoint(var a: T2DPointArray; const From: TPoint);
var
i, l: Integer;
DistArr: TIntegerArray;
MidPt: TPoint;
begin
l := High(a);
if (l < 0) then Exit;
SetLength(DistArr, l + 1);
for i := 0 to l do
begin
MidPt := MiddleTPA(a[i]);
DistArr[i] := Round(Sqr(From.x - MidPt.x) + Sqr(From.y - MidPt.y));
end;
QuickATPASort(DistArr, a, 0, l, True);
end;

euphemism

2011-12-26 23:20:06

From: mormonman
Use this….way faster.


;) I would expect nothing less, you are a much more accomplished programmer than I am. I simply did the best I could with my current knowledge.