NPC Movementation
Posted: Fri Jan 08, 2010 12:48 pm
Hey.
Is there anyway to make a npc avoid certain positions (x,y,z,realm) while walking?
I want to make NPC learn where traps are so they don't walk into it twice or more. To do that, the npc will have a list of traps (serials) stored as a cprop (array of ints).
Here is the idea I had, but I don't know how to implement it. A function called NextStepToLocation(npc, x, y). This function, which I'll call ns() from now on, will see where the npc is and where is this location passed as argument. It'll then return a direction, which is the direction you should move to get there. This way, I could do this:
dir=ns(npc, x, y)
if has_known_trap_in_dir(npc, dir) move somewhere else
else move to dir
repeat
That raises some problems. For example, the NPC never moving if there is only one way and there is a trap in this way. But that can be easily solved by making the npc moving over the trap.
That is just one idea. The point is... Is there anyway to create a list of known traps (list of serials, ints) and make npcs avoid walking in the positions those traps are in?
Is there anyway to make a npc avoid certain positions (x,y,z,realm) while walking?
I want to make NPC learn where traps are so they don't walk into it twice or more. To do that, the npc will have a list of traps (serials) stored as a cprop (array of ints).
Here is the idea I had, but I don't know how to implement it. A function called NextStepToLocation(npc, x, y). This function, which I'll call ns() from now on, will see where the npc is and where is this location passed as argument. It'll then return a direction, which is the direction you should move to get there. This way, I could do this:
dir=ns(npc, x, y)
if has_known_trap_in_dir(npc, dir) move somewhere else
else move to dir
repeat
That raises some problems. For example, the NPC never moving if there is only one way and there is a trap in this way. But that can be easily solved by making the npc moving over the trap.
That is just one idea. The point is... Is there anyway to create a list of known traps (list of serials, ints) and make npcs avoid walking in the positions those traps are in?