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.
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.