SRL Archive - Reflection Help

Get NPC ID at tile ...


Floor66

2009-04-18 20:36:48

How do I do this?
The NPC doesn't move.

I've tried GetObjectAt but that just won't work =\

Frt

2009-04-18 21:06:06

TNPC = record
Tile, MS, MM: TPoint;
Index, NPCType, Height, Animation, TurnDirection, Combat: Integer;
HPRatio: Integer;
Name: string;
InFight, IsMoving: Boolean;

A TNPC hold the tile so you could just search through the NPCs and when the tile matches it return the ID.

EDIT: Here you go:
function GetNPCAtTile(Tile: TPoint): Integer;
var
NPCs: array of TNPC;
i: Integer;
begin
NPCs := GetNPCs;
for i := 0 to High(NPCs) do
begin
if (NPCs[i].Tile.x = Tile.x) and (NPCs[i].Tile.y = Tile.y) then
Result := NPCs[i].NPCType;
end;
end;

Floor66

2009-04-18 21:09:16

Never thought of that way :p
Thanks, will try.

Method

2009-04-19 01:29:29

You never thought of using the NPC type and functions to find an NPC? That doesn't make much sense.

Floor66

2009-04-19 10:19:11

I did, but never of looping through it all and looking if the tiles matched ;)