SRL Archive - OSR Help

npc yellow dot tracking/finding


Getdropped

2012-07-29 23:26:58

Isnt there a getnpcdots function… I feel like i saw this a while back but im not sure… I have noticed that the yellow dot can change its colors from light yellow to almost an orangy color so I was just woundering if someone knows what I can do I just want to location the npc dots and click them. And i think there is also a count npc dots aswell.. I remember it being used to find the frog rando…. but for some reason I can't seem to find the include someone want to help me out here ;)

Sin

2012-07-29 23:32:31

GetMinimapDots():TPointArray;

Flight

2012-07-29 23:36:28

Indeed there is, look over this as an example:

function CountNPCs_MM: Integer;
var
NPCs: TPointArray;
begin
NPCs := GetMiniMapDots('npc');
Result := Length(NPCs);
end;

Getdropped

2012-07-29 23:53:41

From: Flight
Indeed there is, look over this as an example:

function CountNPCs_MM: Integer;
var
NPCs: TPointArray;
begin
NPCs := GetMiniMapDots('npc');
Result := Length(NPCs);
end;


Thanks flight much more helpful than shay :p
So one more question now in this:
function GetMiniMapDotsIn(WhatDot: String; x1, y1, x2, y2: Integer): TPointArray;
var
I, Dif, Radius, Hi, C: Integer;
TPA: TPointArray;
begin
case LowerCase(WhatDot) of
'npc', 'n', 'yellow', 'y': Dif := 4369;
'item', 'i', 'red', 'r': Dif := 23;
'player', 'p', 'white', 'w': Dif := 1907997;
'friend', 'f', 'green', 'g': Dif := 5376;
'team', 't', 'blue', 'b', 'cape': Dif := 2171941;
{'clan', 'c', 'orange', 'o': Dif := -1;}
else
srl_Warn('GetMiniMapDotsIn', '"' + WhatDot + '" is not a valid dot type', warn_AllVersions);
end;
Freeze;
Radius := Max((x2-x1)/2, (y2-y1)/2);
FindColorsPie(TPA, 65536, 0, 0, 360, 0, radius, x1, y1, x2, y2, (x1+x2)/2, (y1+y2)/2);
Hi := High(TPA);
SetLength(Result, Hi + 1);
if (Hi < 0) then
begin
UnFreeze;
Exit;
end;
C := 0;
for I := 0 to Hi do
begin
if (GetColor(TPA[I].X-1, TPA[I].Y-1) - GetColor(TPA[I].X, TPA[I].Y-1) = Dif) then
begin
Result[C] := Point(TPA[I].x, TPA[i].y - 2);//it results the point as a array
Inc(C);
end;
end;
Unfreeze;
SetLength(Result, C);
end;

If I am going to click the (npc) dots could I do some kind of a mmouse to a random dot
heres the idea:

var //This is just the idea
i : TPA;
begin
i := GetMiniMapDotsIn(minimap stuff);
Mouse(i[random(length(i))], 2, 2, true);
end;

NKN

2012-07-30 00:01:21


var
i:integer;
NPCTPA:TPointArray;
begin
NPCTPA := GetMiniMapDots('y')
i := random(length(NPCTPA))
Mouse(NPCTPA[i].x,NPCTPA[i].y,2, 2,1);
end;

This may be on or off, did it off the top of my head.

Flight

2012-07-30 00:07:54

From: getdropped69
Thanks flight much more helpful than shay :p

If I am going to click the (npc) dots could I do some kind of a mmouse to a random dot
heres the idea:

var //This is just the idea
i : TPA;
begin
i := GetMiniMapDotsIn(minimap stuff);
Mouse(i[random(length(i))], 2, 2, true);
end;


Very close. Let's say, for example, you wanted to walk to the closest NPC to your current location. Here's what you could do:

procedure WalkToClosestNPC_MM;
var
i: TPointArray;
begin
i := GetMiniMapDots('npc'); //Populate the 'i' point array with all the NPC dots
SortTPAFrom(i, Point(MMCX, MMCY)); //Now sort the 'i' array starting from the center of the MM
Mouse(i[0].X, i[0].Y, 2, 2, mouse_left);
end;

Because arrays always being at 0, then in this case the i[0] would be the closest NPC to our player (MMCX,MMCY). So to grab the X/Y coordinate of the closest NPC we'd first separate that NPC point then we can grab the X/Y coordinates of it, like so:

Mouse(i[0].X, i[0].Y, 2, 2, mouse_left);

i[0] simply means i's first point in the array, i[1] would be the second point, and so on… So if i[0] is a point you could do i[0].X to get the X value of that point, same with the Y value.

Does that make sense?

Getdropped

2012-07-30 00:23:49

From: Flight
Very close. Let's say, for example, you wanted to walk to the closest NPC to your current location. Here's what you could do:

procedure WalkToClosestNPC_MM;
var
i: TPointArray;
begin
i := GetMiniMapDots('npc'); //Populate the 'i' point array with all the NPC dots
SortTPAFrom(i, Point(MMCX, MMCY)); //Now sort the 'i' array starting from the center of the MM
Mouse(i[0].X, i[0].Y, 2, 2, mouse_left);
end;

Because arrays always being at 0, then in this case the i[0] would be the closest NPC to our player (MMCX,MMCY). So to grab the X/Y coordinate of the closest NPC we'd first separate that NPC point then we can grab the X/Y coordinates of it, like so:

Mouse(i[0].X, i[0].Y, 2, 2, mouse_left);

i[0] simply means i's first point in the array, i[1] would be the second point, and so on… So if i[0] is a point you could do i[0].X to get the X value of that point, same with the Y value.

Does that make sense?


I really like the sorting idea would work much better ;) oh and It was working great for a few seconds but then when it tried again I got:
Error: Out Of Range at line 190
The following DTMs were not freed: [SRL - Lamp bitmap, 1]
The following bitmaps were not freed: [SRL - Mod bitmap, SRL - Admin bitmap, SRL - Flag bitmap, SRL - NavBar Bitmap]

as an error I think it was because I moved on top of the npc dot…. Here is what is needed to be changed because the random(1) will return 0, 1 if I am correct. This works: just need to add the sort
procedure FindMonster;
var
i:integer;
NPCTPA:TPointArray;
begin
NPCTPA := GetMiniMapDots('npc');
if not(length(NPCTPA) = 0) then
begin
i := random(length(NPCTPA));
if (NPCTPA[i].x >= 0) then
Mouse(NPCTPA[i].x, NPCTPA[i].y, 2, 2, true);
end
else
writeln('No NPC dot found.');
end;

Edit: This is what I am using now thanks guys ;)

procedure FindMonster;
var
NPCTPA:TPointArray;
begin
NPCTPA := GetMiniMapDots('npc');
if not(length(NPCTPA) = 0) then
begin
SortTPAFrom(NPCTPA, Point(MMCX, (MMCY - 20)));//wanted off center ;)
Mouse(NPCTPA[0].x, NPCTPA[0].y, 2, 2, true);
end
else
writeln('No NPC dot found.');
end;

J J

2012-07-30 04:57:05

if (length(NPCTPA) > 0) then
That means there is actually some stuff in it, some functions return -1 or null if they find nothing.

Also what I like to do is not only have a positive offset but also a negative one.
Mouse(NPCTPA[0].x, NPCTPA[0].y, RandomRange(-2, 2), RandomRange(-2, 2), true);

Anyways goodluck with the dungeoneering script

Getdropped

2012-07-30 11:52:38

From: J J
if (length(NPCTPA) > 0) then
That means there is actually some stuff in it, some functions return -1 or null if they find nothing.

Also what I like to do is not only have a positive offset but also a negative one.
Mouse(NPCTPA[0].x, NPCTPA[0].y, RandomRange(-2, 2), RandomRange(-2, 2), true);

Anyways goodluck with the dungeoneering script


Thanks for the help ;)