Log in

View Full Version : ?Find Dead center of minimap dot?



Brandon
12-28-2011, 02:23 PM
How can I find the dead center of a minimap dot? I've been thinking about it for some time and it's been taking me forever to come up with an idea so I thought I'd ask here.

This is what I have to debug minimap dots and items on the floor that are related to those dots..

It paints the pixel on the dot that is found, BLUE. The thing is.. It does not paint the one right in the center! It always paints the one closest to me :c

Also I cannot figure out how to get it to accurately find the dot center because some dots overlap! huge problem there. It gets sooooo close to the item tile.. but yet so far due to being 1 pixel off on the minimap :c Each dot is exactly 12 pixels in size. Not including the black shadow.

Dots:
http://i.imgur.com/Fw9BK.png

What I want it to paint:

http://i.imgur.com/NATlU.png <---- See how I coloured the dead center of the dot? That's what I want to paint.. Just that one pixel.


Accuracy Loss Due to one pixel:
http://i.imgur.com/XhPlx.png


Debugger Script:


program New;
{$define SMART}
{$i srl/srl.scar}
{$i srl/srl/skill/fighting.scar}
{$i sps/sps.simba}
{$i SRL/SRL/misc/paintsmart.scar}

Procedure DrawBox(B: TBox; Time: Integer);
Var
T: Integer;
drawing : TBitmap;
Begin
drawing := TBitmap.Create;
drawing.canvas.handle := SmartGetDebugDC;
ClearRSCanvas(Drawing.Canvas);
drawing.canvas.Pen.Color := CLBLUE;
MarkTime(T);
Repeat
drawing.canvas.MoveTo(B.X1,B.y1);
drawing.canvas.LineTo(B.X2,B.y1);
drawing.canvas.LineTo(B.X2,B.y2);
drawing.canvas.LineTo(B.X1,B.y2);
drawing.canvas.LineTo(B.X1,B.y1);
Wait(2);
Until(TimeFromMark(T) > Time);
End;

//By Mormonman..
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;

Function FindColorMM(Colors: TIntegerArray; var X, Y: 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..
SortATPAFromFirstPoint(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..
if(X AND Y <> 0) then
Result:= True;
end;

Function MMtoMSEx(mm: TPoint): TPoint;
var
X, Y, Yh: integer;
begin
X := (mm.x-627);
Y := (mm.y-85);
Yh := round(abs(mm.y-104));

Result := Point(Round((X*3.0/(Yh/42+3))*((10.015))+258.5), Round(168+Y*(8.0)));
if not PointInBox(Result, MSBox) then
Result := Point(-1, -1);
end;

Procedure PickUpItems(Items: TStringArray);
var
x, y: Integer;
Item: TPoint;
MS, Box: TBox;
begin
if FindColorMM([591083], X, Y, 0, 0, 20) then
begin
Box:= IntToBox(X - 1, Y - 1, X + 1, Y + 1);
DrawBox(Box, 300);
Item:= MMToMS(Point(X, Y));
MS:= IntToBox(MSX1, MSY1, MSX2, MSY2);
if PointInBox(Item, MS) then
begin
MMouse(Item.X, Item.Y, 0, 0);
Box:= IntToBox(Item.X - 10, Item.y - 10, Item.x + 10, Item.y + 10);
DrawBox(Box, 300);
end;
end;
end;

begin
Smart_Server := 45;
Smart_Members := True;
Smart_Signed := True;
Smart_SuperDetail := False;

SetupSRL;
repeat
PickupItems(['harm', 'eath rune', 'lood rune', 'oul rune', 'rune', 'essence', 'ak plank', 'eak plank']);
until(false);
end.

Narcle
12-28-2011, 02:28 PM
There is no center, unless you go to Extended.

E:
We would have to use Extended points for MMtoMS to work better.

Kyle Undefined
12-28-2011, 02:31 PM
So basically, you're trying to paint the dots blue even if they overlap? Sorry, I'm just confused on the whole post.

Brandon
12-28-2011, 02:32 PM
There is no center, unless you go to Extended.

E:
We would have to use Extended points for MMtoMS to work better.


Ahhh I see :c I was hoping it would actually be easier. One pixel off actually matters now *sigh* I'll live though. My item finding is perfect other than that.. Just that one pixel throws it off by exactly one tile which I can probably compensate for by using a +- 1 in my function.

@Camo.. I'm trying to paint the center of the red dot closest to me. Problem is that some dots actually overlap so its hard to find a center but like Narcle said, I cannot get the center unless we used extended points which don't exist afiak? because all TPoints are int x, int y.

Edit: Now that there are no extended points, is there a way to paint the four pixels in the center of the dot?
Edit2: I added a picture to show the accuracy of one pixel in the first post. Usually off by a tile.

Narcle
12-28-2011, 02:57 PM
I have an idea I'll post after I get back from work.

Edit:
So first off the function is incomplete. I still haven't compensated for Y value yet. Second you can just -0.5 from both points to make it center of dot inside MMtoMS.

This will NEVER be accurate we can only get close.

Brandon
12-29-2011, 04:37 PM
I have an idea I'll post after I get back from work.

Edit:
So first off the function is incomplete. I still haven't compensated for Y value yet. Second you can just -0.5 from both points to make it center of dot inside MMtoMS.

This will NEVER be accurate we can only get close.

Do you mean the pickup items is incomplete? Because I only intended to hover over it for this post in-order to see how close I can get the mouse to it. And -0.5 from which two points?

legoace
12-31-2011, 02:30 AM
The problem is that there is no center - the dots are 4 pixels across, so the center is the intersection of 4 pixels. Finding items from the MM is okay to move your char to the general vicinity, but you should generally be using TPA object finding to actually locate the items on the MS.

Brandon
12-31-2011, 02:54 AM
The problem is that there is no center - the dots are 4 pixels across, so the center is the intersection of 4 pixels. Finding items from the MM is okay to move your char to the general vicinity, but you should generally be using TPA object finding to actually locate the items on the MS.

You know how hard that is to find bones on a background that is the almost the exact same colour as the bone? Even using ACA with CTS 2, I couldn't do it.. 100 colours and it still couldn't find the bones.. It found the whole place instead.. It's the same with differentiating pure essence vs super strength..

Plus I'd have to make a TPA for each and every item.. what about when I'm standing on it or another person is.. Or fighting in an area with a large amount of items on the floor.. it'd have to loop through every single one of those. Finding charms is pretty ridiculous on the floor.