SRL Archive - Reflection Discussion

Offsreen npc


alar82

2009-08-28 20:36:08

Can anyone give me few lines code, how to limit offscreen npc searching. Like sometimes it searches fishing spots from message area, yeah there are fishing spots under it.
Yeah I did get it,it searches from 104*104 loaded area. but how you limit that area?:rolleyes:??

Blumblebee

2009-08-28 20:37:08

just do a simple TileOnMS() check

senrath

2009-08-28 23:23:30

Or use FindNPCEx, which takes an additional parameter of how many tiles away from your character you want to search.

alar82

2009-08-29 01:06:29

SPOTTT: TNPCEx;
if FindNPCEx(313,SPOTTT) then
begin
…………
spott := TileToMS(SPOTTT.Tile, Random(0));

Gives error about type mismatch:/Whats wrong?
And why the hell there aint any tutorials about using FindNPCEx…

Sabzi

2009-08-29 01:19:44

You declare spott as a TNPCEx and then you want to store a TPoint in it.
TileToMS returns a TPoint.
http://www.villavu.com/forum/showthread.php?t=48399
Although it's not about FindNPCEx but should give you some idea.

Also if you look into that type
{type TNPCEx;
Description: Holds information related to an NPC. }
TNPCEx = record
MS, MM: TPoint;
Tile: TTile;
Index, NPCType, Height, Animation, TurnDirection, Combat: Integer;
HPRatio: Integer;
Name: string;
InFight, IsMoving: Boolean;
end;
you can see that it already got an MS record or whatever it's called.
So what I would do:

var
N: TNPCEx;

FindNPCEx(313, N); //so we find it
if TileOnMS(N.Tile, 5) then //we see if it is on MS or not
MMouse(N.MS.x, N.MS.y, 3, 3); //move the mouse there
etc, etc //uptext and such

Please note that this is not the actual code for it. Just an example.

Hahh I just looked at it. There is already a TileOnMs check in GetNPC or whatever it uses. So I think we don't need it.
I got some stick movie to watch so if you got any more problem and nobody(who better in reflection) answered the question I will look more deeply in it.

alar82

2009-08-29 01:32:11

Well main problem is that it stills tries click through message area:/

edit3:If it(TileOnMS) is allready in npc check why doesnt work for fishing spots and message area? Is it broken somehow?