Log in

View Full Version : Minimap radius problems?



Brandon
12-26-2011, 11:34 PM
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:

http://i.imgur.com/OyYNe.png

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:

http://i.imgur.com/pkhhP.png

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
12-26-2011, 11:50 PM
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.

tls
12-26-2011, 11:52 PM
Use FilterPointsDist(tpa, 0, 76, MMCX, MMCY);

Brandon
12-27-2011, 12:25 AM
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;

tls
12-27-2011, 12:46 AM
I added a new function to Simba, its called SortATPAFromMidPoint(). It should be in the next Simba build.

euphemism
12-27-2011, 01:01 AM
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;

tls
12-27-2011, 01:37 AM
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
12-27-2011, 04:20 AM
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.