SRL Archive - Research & Development Lounge

GetNPCInfo


Waddo

2008-07-24 16:02:14

Procedure GetNPCInfo;
{*******************************************************************
Procedure GetNPCInfo;
By: Waddo
Description: Displays the info of loaded NPC's.
********************************************************************}
var
i: integer;
NPCs: array of TNPC;
begin
NPCs := GetNPCs;
if (GetArrayLength(NPCs)=0) then Exit;
for i := 0 to High(NPCs) do
writeln('NPC: '+NPCs[i].Name+' ID: '+IntToStr(NPCs[i].NPCType)+
' Tile X: '+IntToStr(NPCs[i].TileX)+' Tile Y: '+IntToStr(NPCs[i].TileY));
end;

Helpful when creating scripts using reflection.

When ran in the courtyard above the mining guild it returned

NPC: Dwarf ID: 3220 Tile X: 3010 Tile Y: 3337
NPC: Banker ID: 6200 Tile X: 3010 Tile Y: 3353
NPC: Banker ID: 6200 Tile X: 3011 Tile Y: 3353
NPC: Banker ID: 6200 Tile X: 3012 Tile Y: 3353
NPC: Banker ID: 6200 Tile X: 3013 Tile Y: 3353
NPC: Banker ID: 6200 Tile X: 3014 Tile Y: 3353
NPC: Banker ID: 6200 Tile X: 3015 Tile Y: 3353
NPC: Dwarf ID: 3221 Tile X: 3018 Tile Y: 3332
NPC: Dwarf ID: 382 Tile X: 3018 Tile Y: 3340
NPC: Dwarf ID: 3294 Tile X: 3020 Tile Y: 3338
NPC: Dwarf ID: 3295 Tile X: 3018 Tile Y: 3337 <---this is the ID I created this to
NPC: Dwarf ID: 3219 Tile X: 3022 Tile Y: 3348 find it is the dwarf with the mining
NPC: Guard ID: 9 Tile X: 3009 Tile Y: 3323 skill cape the X and Y tiles help you
NPC: Guard ID: 9 Tile X: 3005 Tile Y: 3324 to tell him a part from the other dwarfs

noidea

2008-07-24 16:15:17

Dude, thats pretty cool. Will it only work in S.M.A.R.T. like Reflections?

Waddo

2008-07-24 16:21:30

It is reflection. XD

Widget

2008-07-24 17:18:41

This is the format I've been using:
    for i := 0 to High(NPCs) do
begin
s := padr(NPCs[i].TheName,15);
s := s + ' ID: '+padr(inttostr(NPCs[i].NPCType),7);
s := s + ' ('+inttostr(NPCs[i].x)+', '+inttostr(NPCs[i].y)+')';
s := s + ' In Fight: '+BoolToStr(NPCs[i].InFight);
s := s + ' Is Moving: '+BoolToStr(NPCs[i].IsMoving);
Writeln(s);
end;

:)

NiCbaZ

2008-07-24 18:00:43

From: Waddo
Procedure GetNPCInfo;
{*******************************************************************
Procedure GetNPCInfo;
By: Waddo
Description: Writes the info of loaded NPC's.
********************************************************************}
var
i: integer;
NPCs: array of TNPC;
begin
NPCs := GetNPCs;
if (GetArrayLength(NPCs)=0) then Exit;
for i := 0 to High(NPCs) do
writeln('NPC: '+NPCs[i].TheName+' ID: '+inttostr(NPCs[i].NPCType)+
' Tile X:'+inttostr(NPCs[i].x)+' Tile Y: '+inttostr(NPCs[i].y));
end;

Helpful when creating scripts using reflection.

When ran in the courtyard above the mining guild it returned

NPC: Dwarf ID: 3220 Tile X: 3010 Tile Y: 3337
NPC: Banker ID: 6200 Tile X: 3010 Tile Y: 3353
NPC: Banker ID: 6200 Tile X: 3011 Tile Y: 3353
NPC: Banker ID: 6200 Tile X: 3012 Tile Y: 3353
NPC: Banker ID: 6200 Tile X: 3013 Tile Y: 3353
NPC: Banker ID: 6200 Tile X: 3014 Tile Y: 3353
NPC: Banker ID: 6200 Tile X: 3015 Tile Y: 3353
NPC: Dwarf ID: 3221 Tile X: 3018 Tile Y: 3332
NPC: Dwarf ID: 382 Tile X: 3018 Tile Y: 3340
NPC: Dwarf ID: 3294 Tile X: 3020 Tile Y: 3338
NPC: Dwarf ID: 3295 Tile X: 3018 Tile Y: 3337
NPC: Dwarf ID: 3219 Tile X: 3022 Tile Y: 3348
NPC: Guard ID: 9 Tile X: 3009 Tile Y: 3323
NPC: Guard ID: 9 Tile X: 3005 Tile Y: 3324



cool function then we could use
TileToMM? for the finding right?

Method

2008-07-24 18:18:10

You could use TileToMM to walk to the tile, then use FindNPC to try and find the NPC you're looking for.

Cool function, though. :)

Waddo

2008-07-24 18:27:32

yep

or just walktotile(x,y)

or you can use the id to find the npc using the id and walk to it dynamically during runtime