NPC directional movement

Using Pixies NPC Library, I notice there are some predefined possible actions. There are at least two for moving NPC to a specific room, one room at a time, or all at once, but there is no predefined script for making the NPC travel East, say, or South. How would I write that? What script moved not a player, but an NPC, in a specific direction?


I'm sorry, I answered before without fully reading and understanding that you had already checked out the move functions and documentation for the library.

this question is probably a tiny bit over my head. If I gave ideas, MrAngel would probably have to fix whatever mess I made anyway haha.


I don't know how NpcLib works; but here's a script which attempts to move an npc north as a regular script. Maybe you can work how to combine it with the library:

exits = FilterByAttribute (FilterByType (AllExits (), "northdirection"), "parent", npc.parent)

// depending on how you're using it, you might want to filter out locked or hidden exits here.

if (ListCount (exits) = 0) {
  msg ("NPC can't go north from here")
}
else {
  // If you have script-oonly exits without a destination, you'll need to decide what to do with them here
  exit = PickOneObject (exits)
  npc.parent = exit.to
}

Thanks, mrangel. I will try that as soon as I get home. NpcLib has just one area for a "script" for each NPC, so that once it is filled you can write "script" in the NPCs list of actions which it follows in a loop, one action per turn, as many times as you like. After that, you can add verbs and commands and things.
I think it looks like it should work well.


Does this work without the library? I tried to use it
Like this, except with the NPC named (not npc)
exits = FilterByAttribute (FilterByType (AllExits (), "northdirection"), "parent", npc.parent)
exit = PickOneObject (exits)
npc.parent = exit.to
And it did nothing.
The library, which gives error messages if NPC is asked to wait for player or search for player when it is already in the same room, should actually run that script every other turn, but it does nothing.

I may be doing something wrong. Other NPC actions did work.


I turned it into a timer and it works perfectly. Every second the wind blows into or out of the room.
Excitingly useful script!


Log in to post a reply.

Support

Forums