Author Topic: How do you make an NPC leave an area?  (Read 324 times)

Legacy_Jthesunshinegirl

  • Newbie
  • *
  • Posts: 34
  • Karma: +0/-0
How do you make an NPC leave an area?
« on: July 06, 2011, 10:44:50 pm »


               I feel like this should be a very simple thing to accomplish, but I'm very new at this and can't seem to figure it out. All I want to do is have an NPC say, "I'm going downstairs," and then walk to the stairs and disappear. I searched the lexicon and found the Activate Flee to Exit function, which seems like the one I want, but I can't get it to work since I don't know how/where to insert the waypoint information. (I'm assuming waypoints are involved, but since the old website is gone I can't go to the tutorials to make sure I'm using them correctly.)
I'm almost ashamed to post this since it seems like such a simple question, but any help anyone could give would be greatly appreciated.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
How do you make an NPC leave an area?
« Reply #1 on: July 06, 2011, 11:18:43 pm »


               I have never used the FleeToExit function and do not know if I would full trust it.  Some of the generic AI functions can have unreliable results and not always go the tohe point where you want them to go.

This script fragment assums that the script is running on your NPC. 

    object oLeavePoint = GetNearestObjectByTag("Tag Of waypoint");

    ActionForceMoveToObject(oLeavePoint);
    ActionDoCommand(DestroyObject(OBJECT_SELF));
    SetCommandable(FALSE); // Just so nothing stops him.
               
               

               
            

Legacy_Rowwena

  • Jr. Member
  • **
  • Posts: 62
  • Karma: +0/-0
How do you make an NPC leave an area?
« Reply #2 on: July 07, 2011, 09:52:37 am »


               If you want to try to generic method, at the end of the conversation click the Current File Tab (the last one) and you will see a spot for two scripts Normal and Aborted. Put a new script in the Normal option

#include "nw_i0_plot"
void main()
{
   // Change FALSE to TRUE if you want the NPC to Run.
   // If you use the default Waypoint Tag of "NW_EXIT"
   // then all you need is EscapeArea();
   // Or, EscapeArea(TRUE); if you want him to Run.
   EscapeArea(TRUE, "YourCharacterTag_EXIT");
}

Then place a waypoint at the door on the stairs to match the one above - YourCharacterTag_EXIT

I have used it for two different NPCs and so far no problems.