Chasing AI

Here you can post threads requesting help on the official POL Ultima Online Emulator Core 097.
Note: Core 097 is no longer officially supported.

Moderator: POL Developer

Post Reply
mystu
New User
Posts: 1
Joined: Tue Feb 03, 2009 6:05 pm

Chasing AI

Post by mystu »

Hi.. I've been testing NPCs' chasing around against obstacles such as doors and stairs.. is any method of smart chasing such as A*, considering statics and door supported by POL? I mean, is there any core feature that enables a NPC to find the best path, if there's one, to the target?
Thanks in advance!
User avatar
CWO
POL Expert
Posts: 1158
Joined: Sat Feb 04, 2006 5:49 pm
Location: Chicago, IL USA

Re: Chasing AI

Post by CWO »

Use FindPath()...

FindPath(npc.x, npc.y, npc.z, target.x, target.y, target.z, npc.realm, FP_IGNORE_DOORS);
something along that line... This returns an array of structs with each step the NPC must take along a path to get to the target so then you do a loop going through the entire array and doing WalkTowardLocation/RunTowardLocation for each step. The FP_IGNORE_DOORS ignores doors, you can also add in FP_IGNORE_MOBILES too to keep other PCs/NPCs that may be in the path from interrupting the path. But now when the NPC needs to walk through the door, you'll also have to script for it to open the door otherwise it will get hung up there but if the door is already open it won't interfere.
Documentation on FindPath() is here...
Post Reply