SRL Archive - OSR Help

Help, MMtoMS always return -1, -1


johnbrown8976

2012-05-02 23:01:54

Hi,
I saw an useful function MMtoMS used on Narcle's fast figher. I myself thought of implementing the function on my own script to find door, but it always returns me -1, -1. What am I missing?


Procedure findDoor;
var
x, y: Integer;
p: TPoint;
begin
MouseSpeed := 15;
if FindColorTolerance(x, y, 67062, MMX1, MMY1, MMX2, MMY2, 15) then
begin
writeln('color found');
//Testing if Minimap center if found on MainScreen
p := MMtoMS(Point(MMCX, MMCY));
MMouse(p.x, p.y, 0, 0);

p := MMtoMS(Point(x, y));
MMouse(p.x, p.y, 0, 0);
end else
writeln('Color not found');
end;

It outputs: "Color found", but moves the mouse to -1, -1 ALWAYS. What are the requirements for using the particular function MMtoMS.

NCDS

2012-05-02 23:21:20

Try reading the documentation. You're using the function all wrong..

(*
MMToMSEx
~~~~~~

.. code-block:: pascal

Function MMtoMSEx(Xmod, Ymod: integer; MM: TPoint): TPoint;

Turns a Minimap point into a close MS point. New one compensates for angles.
Xmod and Ymod change the starting point on MainScreen. Ymod = -30 would
raise the points on screen by 30 pixels. This is good if you know the
Height of the npc or object your looking for on MS.
Formula in GridCoords16Ex now.

.. note::

by Narcle

Example:

.. code-block:: pascal

FindTreeOnMinimap(x, y);
msPoint := MMToMSEx(0, -20, Point(x,y));
MMouse(msPoint.x, msPoint.y, 0, 0);
//...

*)
It's there to learn from, use it. ;)

Edit: To elaborate; you don't need to call MMToMS() twice. You call it once to set the TPoint, then from that point on P carries the x and y values of your coordinate(hence the p.x and p.y). All that's left to do is click.

Brandon

2012-05-02 23:33:14

From: NCDS
Try reading the documentation. You're using the function all wrong..

Edit: To elaborate; you don't need to call MMToMS() twice. You call it once to set the TPoint, then from that point on P carries the x and y values of your coordinate(hence the p.x and p.y). All that's left to do is click.


He's MM to MS-ing two different points.. One is the minimap center which he calls MMToMS for and it returns the middle of the mainscreen.

The next he calls MMToMS for the Point returned from his finder function.. and that returns (-1, -1). The only problem I see there is that his finder function does not find the colours he's searching for on the MM.

johnbrown8976

2012-05-02 23:38:04

From: NCDS
Try reading the documentation. You're using the function all wrong..

(*
MMToMSEx
~~~~~~

.. code-block:: pascal

Function MMtoMSEx(Xmod, Ymod: integer; MM: TPoint): TPoint;

Turns a Minimap point into a close MS point. New one compensates for angles.
Xmod and Ymod change the starting point on MainScreen. Ymod = -30 would
raise the points on screen by 30 pixels. This is good if you know the
Height of the npc or object your looking for on MS.
Formula in GridCoords16Ex now.

.. note::

by Narcle

Example:

.. code-block:: pascal

FindTreeOnMinimap(x, y);
msPoint := MMToMSEx(0, -20, Point(x,y));
MMouse(msPoint.x, msPoint.y, 0, 0);
//...

*)
It's there to learn from, use it. ;)

Edit: To elaborate; you don't need to call MMToMS() twice. You call it once to set the TPoint, then from that point on P carries the x and y values of your coordinate(hence the p.x and p.y). All that's left to do is click.


Hi, thanks for the reply. I did read the documentation and example. But seems like I am misunderstanding something.

Because even I just try the same example in the documentation, it returns -1, -1.

msPoint := MMToMSEx(0, -20, Point(MMCX,MMCY));
MMouse(msPoint.x, msPoint.y, 0, 0);

Could you provide me a working example please. I know I am missing something, but cant figure out what.

johnbrown8976

2012-05-02 23:40:43

~Problem Fixed~

Sorry for the confusion. I think The function only works when SMART is enabled, I tried the script on a browser window, and always return -1, -1.

Thanks all for the help.

Brandon

2012-05-02 23:53:02

Start by Any NPC on screen..


function RandomPointDist(TPA: TPointArray; MaxDist: Integer): TPoint; //By MormonMan
var
MP, P: TPoint;
begin
if not LoggedIn then Exit;
P := Point(-1, -1);
MP := MiddleTPA(TPA);
while (Distance(MP.x, MP.y, P.x, P.y) > MaxDist) do
P := TPA[Random(Length(TPA) - 1)];
Result := P;
end;

Function NPCDotsToMS: Boolean;
var
NPCs: TPointArray;
P: TPoint;
B: TBox;
begin
NPCs:= GetMMDotsOnMS('NPC');
SortTPAByY(NPCs, True);
P:= RandomPointDist(NPCs, 20);
P:= MMToMS(P);
Result:= P <> Point(-1, -1);
B:= IntToBox(P.X - 20, P.Y - 20, P.X + 20, P.Y + 20);
MouseTBox(B, 3);
end;

NCDS

2012-05-03 09:02:20

From: johnbrown8976
~Problem Fixed~

Sorry for the confusion. I think The function only works when SMART is enabled, I tried the script on a browser window, and always return -1, -1.

Thanks all for the help.


Did you select the client..? And also Call ActivateClient.

johnbrown8976

2012-05-08 00:55:18

From: NCDS
Did you select the client..? And also Call ActivateClient.


Oh, I did not call ActivateClient, I thought that would not be needed coz my window was on the top.

Thanks for clearing it.