SRL Archive - OSR Help

NPC Locating Reflection/Reflection2


Bixby Sayz

2011-08-01 12:52:20

Anyone have code for finding NPCs that works, either in Reflection or (better still) Reflection 2?

Tried this code with Simba 0.96 and Reflection and a fresh install of Simba 0.97rc6 with Reflection 2 (on 2 separate machines). Neither finds a thing.

Usage: Login and stand next to a chicken.

program new;

{$DEFINE SMART}
{$i SRL\SRL.scar}
{$i Reflection\Reflection.simba}

var
NPCs: TNPCArray;
I: integer;

begin
Smart_Server := 152;
Smart_Signed := True;
Smart_Members:= False;
Smart_SuperDetail := False;
SetupSRL;
ClearDebug;

NPCs := GetNPCs('Chicken');
if (Length(NPCs) = 0) then
begin
writeln('No NPCs Found.');
exit;
end;
for I := 0 to High(NPCs) do
begin
writeln(Format('Name: %s, ID: %d, Tile(%d,%d)', [NPCs[I].Name, NPCs[I].ID, NPCs[I].Tile.X, NPCs[I].Tile.Y]));
end;
end.

Shuttleu

2011-08-01 12:55:15

do you have the latest hooks?

what hook revision do you have?

~shut

Brandon

2011-08-01 13:04:06

Are u trying to debug NPC's?? If your not then grab the ID's of it and then findNPC by ID.. else make sure its not a NULL Npc like the varrock monk

Flight

2011-08-01 13:19:22


program NPCFinder;
{$define SMART}
{$i srl/srl.scar}
{$i Reflection/Reflection.simba}

Procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
with Players[0] do
begin
Name := '';
Pass := '';
Nick := '';
Pin := '';
Active := True;
end;
end;

Procedure DisplayNPCs;
Var
N: TNPC;
begin
Wait(500);
ClearDebug;
N := R_GetNPCAt(Point(R_GetMyPos.x,R_GetMyPos.y+1),False);
if (N = NULL_NPC) then
Exit;
Writeln('ID: '+IntToStr(N.ID)+' at Tile('+IntToStr(N.Tile.X)+','+IntToStr(N.Tile.Y)+')');
end;

begin
Smart_Server := 86;
Smart_Members := True;
Smart_Signed := True;
Smart_SuperDetail := False;
SetupSRL;
DeclarePlayers;

repeat
DisplayNPCs;
until(false)
end.

This will output the NPC (ID/Tile) 1 tile north of your position.

Edit:
By the way, this is R2.

Bixby Sayz

2011-08-01 13:59:16

From: Flight
This will output the NPC (ID/Tile) 1 tile north of your position.


This completely fails to find anything.

From: Shuttleu
do you have the latest hooks?

what hook revision do you have?

~shut


659 Rev 4. Both are running that. Manually updated hooks to 660 rev 1 (which I should not have to do?) and now my script above works. Flight's still does not.

I should have thought of that. Have had ongoing problems with hooks not updating in a timely manner. Thanks for the help guys. Was just being stupid and not checking my hooks version.

Edit: Spoke too soon. It works under Reflection. Reflection2 still finds diddly squat.
Edit2: Updated wrong hooks file on my Reflection2 machine. Grrr. Drives me crazy.

Smarter Child

2011-08-01 14:03:42

Use Rsbot if you want the easy way out ;)

pyroryan

2011-08-01 14:51:34

Calling R_UpdateHooks() at the start of your script?

Bixby Sayz

2011-08-01 16:31:40

From: Smarter Child
Use Rsbot if you want the easy way out ;)


Grabbed the latest but it keeps throwing an error everytime I turn on show NPCs. Can't win. :angry:

Flight

2011-08-01 21:54:30

In my debug script change this:


N := R_GetNPCAt(Point(R_GetMyPos.x,R_GetMyPos.y+1),False);
if (N = NULL_NPC) then
Exit;

to this:


N := R_GetNPCAt(Point(R_GetMyPos.x,R_GetMyPos.y+1),True);
if (N.ID = -1) then
Exit;

That includes 'nulled' NPCs in the search.