SRL Archive - OSR Help

TNPC.Tile and TNPC.Pixel not working correctly


blackfire553

2011-06-15 02:58:21

this is moving the mouse to the upper right corner instead of where the NPC is, and it does the same with NPCs.Pixel.x and NPCs.Pixel.y:

procedure GetFight;
var
NPCs : array of TNPC;
TPoints : TPointArray;
i,j,tries,checkFight : integer;
begin
if not (LoggedIn) then
Exit;
NPCs := SortNPCs(GetNPCs(false));
If GetArrayLength(NPCs) = 0 then
begin
writeln('No mobs');
Exit;
end;
for i := 0 to High(NPCs) do
begin
for j:= 0 to High(Players[0].Strings) do
If NPCs[i].Name = Players[0].Strings[j] then
begin

If (NPCs[i].Interacting = 0) then
begin

MMouse( TileToMS(NPCs[i].Tile,NPCs[i].Height).x , TileToMS(NPCs[i].Tile,NPCs[i].Height).y ,3,3);
//ChooseOption('ttack');
NPCKill := NPCs[i];
writeln('Got a fight');
wait(2000);
end;
end;
end;
end;

what am i doing wrong? I need to make it move the mouse to the NPC

Coh3n

2011-06-15 04:04:46

I have the same issue, and I don't know why it happens. It sets the tile to the upper left corner of the NPC, rather than the middle of all the tiles it NPC occupies. What I do is have offsets for the NPC. So I'll have it move the mouse to (x - 20), (y + 20) so it will end up on the NPC. The offsets will vary depending on the NPC.

Capricorn

2011-06-15 08:14:57

That is how it has always worked.

tom99

2011-06-15 09:14:54

Try this, change 9710 with the npc id you are searching, this is what i was trying to tell you on irc as well.

var
minid:TNPC;npcpos:tpoint;
begin

if(findnpc(9710,minid)) then
Begin
npcpos := tiletoms(minid.tile,0);
mouse(npcpos.x,npcpos.y,2,2,true);
wait(500);
end;
end;

Drakan

2011-06-15 11:34:29

Are you referring to its moving the mouse to the upper right corner of the screen, or upper right corner of the monster?

tom99

2011-06-15 11:44:36

he is talking about upper left corner of screen.

Drakan

2011-06-15 11:50:01

Just do your own TileToMS(NPC.Tile, NPC.Height*3/4);

Yago

2011-06-15 16:08:19

From: drags111
Just do your own TileToMS(NPC.Tile, NPC.Height*3/4);


Why 3/4? Does this give you accurate results?

blackfire553

2011-06-15 16:49:00

FindNPCs(Players[0].Strings[0],NPCs); works
thanks guys