SRL Archive - Reflection Help

Finding npcs...


neeger

2009-07-30 03:01:17

Hey!
Im stuck with NPCs :mad:

1.Can someone share a NPC finding/talking funktion that works atm?

2.Is ther a way to click on a NPC if i only know NPCs tiles like(3243, 4322)?


Thanks

vilon

2009-07-31 00:13:58

From: neeger
1.Can someone share a NPC finding/talking funktion that works atm?


There are a few ways to do it, easiest is probably to use FindNPC() in Characters.scar:

procedure FindTheNPC;
var
NPC: TNPC; // The variable used to store the information about the NPC
begin
if(FindNPC('Name', NPC))then // The information is here stored in NPC.
WriteLn('Found the NPC!'); // The NPC was found and we write a message to confirm
end;

From: neeger
2.Is ther a way to click on a NPC if i only know NPCs tiles like(3243, 4322)?


Yes. You can do so by converting the tile to a mainscreen point, using the function TileToMS() inside Core.scar.
An alternative way would be if you already have the found the NPC and has it stored in a variable (TNPC):

procedure ClickNPC;
var
NPC: TNPC; // The variable used to store the information about the NPC
begin
if(FindNPC('Name', NPC))then // The information is here stored in NPC.
Mouse(NPC.MS.X, NPC.MS.Y, 5, 5); // Clicks the NPC using a randomness of 5
end;

I would recommend you to read up on the subject. NPC-related routines are to be found inside Characters.scar.
There are also a few tutorials regarding this, for example: http://www.villavu.com/forum/showthread.php?t=46636

masterBB

2009-08-03 01:49:22

From: neeger

2.Is ther a way to click on a NPC if i only know NPCs tiles like(3243, 4322)?


Yes there is, TileToMS turns a tile to a mainscreen point.

procedure ClickthatBastard;
var
ClickPoint:Tpoint;
begin
ClickPoint := TileToMs(Point(3243, 4322),10);
Mouse(ClickPoint.x,ClickPoint.y,5,5,true);
end;

Richard

2009-08-03 01:57:36

From: masterBB
Yes there is, TileToMS turns a tile to a mainscreen point.

procedure ClickthatBastard;
var
ClickPoint:Tpoint;
begin
ClickPoint := TileToMs(3243, 4322,10);
Mouse(3243,4322,5,5,true);
end;


procedure ClickthatBastard;
var
ClickPoint:Tpoint;
begin
ClickPoint := TileToMs(3243, 4322,10);
Mouse(ClickPoint.x,ClickPoint.y,5,5,true);
end;

masterBB

2009-08-03 01:58:45

Oops…. fixed in my post

neeger

2009-08-05 00:01:03

Thanks guys, got it finally working :P