SRL Archive - Research & Development Lounge

NPC Tracker using the MM


Camaro'

2011-01-27 15:18:39

What it does:
Uses the mini map to find yellow dots,and based on that, it then loops through all the NPC's on the main screen to find the specified uptext.

How to use:
MouseNPC('Uptext');

Things to know:
Currently it only left clicks when up text is found.
There is probably a shorter method, but, eh.

Code:

function GetNpcsATPA: T2DPointArray;
var
TPA: TPointArray;
ATPA : T2DPointArray;


begin
//if not (LoggedIn) then Exit;
FindColorsTolerance(TPA, 195836, MMX1, MMY1, MMX2, MMY2, 20);
if (Length(TPA) < 0) then
Exit;
ATPA := TPAToATPA(TPA, 7);
Result := ATPA;
end;

function MouseNPC(UpText: String): Boolean;
var
ATPA : T2DPointArray;
I, C, X, Y, dX, dXX, dY, dYY, nX, nY, k, cX, cY: Integer;

begin
for k := 0 to 3 do
begin
ATPA := GetNPCSATPA;
DebugATPA(ATPA, '');
if (Length(ATPA) < 1) then
Exit;
SortATPAFrom(ATPA, Point(MSCX, MSCY));
for I := 0 to High(ATPA) do
begin
MiddleTPAEx(ATPA[i], X, Y);
if (Distance(X, Y, MMCX, MMCY) > 20) then
Continue;
//W('X: ', X);
//W('Y: ', Y);
C := Distance(X, Y, MMCX, MMCY);
if (X >= MMCX) then
begin
dX := X - MMCX;
dXX := (dx * 36) / 4;
cX := MSCX + dXX + 5;
end;
if (X <= MMCX) then
begin
dX := MMCX - X;
dXX := (dX * 36) / 4;
cX := MSCX - dXX + 5;
end;

if (Y >= MMCY) then
begin
dY := Y - MMCY;

dYY := (dY * 36) / 4;
cY := MSCY + dYY;
end;
if (Y <= MMCY) then
begin
dY := MMCY - Y;
dYY := (dY * 36) / 4;
cY := MSCY - dYY;
end;
MMouse(CX, CY, 5, 5);
if (WaitUpText(UpText, 125)) then
begin
GetMousePos(nX, nY);
Mouse(nX, nY, 0, 0, True);
Result := True;
FFlag(0);
Wait(400 + Random(400));
Exit;
end;
Wait(300 + Random(600));
Continue;
end;
end;
end;



:p

Gu3st...

2011-01-27 15:24:15

Woah! Sounds awesome! :)
How good does it work?

Also, there is pretty much repeated code in your function… Maybe shorten it by putting it at the end?

Camaro'

2011-01-27 15:54:08

Revamped and has been tested.

Works really well, really well :)

Nava2

2011-01-27 15:59:18

Uhm.. Isn't this kinda inefficient?

Camaro'

2011-01-27 16:05:50

It works well, for example if your finding a banker… Or fighting some guards…

Edit: Commented out something to make it compile :D

NCDS

2011-01-27 16:10:08

Why not use FindObjThroughMM?

Camaro'

2011-01-27 16:12:30

I didn't even know that existed, oh well :(

Nava2

2011-01-28 16:08:49

This is cool, sorry I should have said that.

Its just that I feel like its not that useful :p

Sir R. M8gic1an

2011-01-30 05:57:41

Yeh, FindObjThroughMM is a great function… I never really looked properly through the code, but I helped Naike out while he was writing it :)

~RM