Author Sticky: Post Working Scripts Here
Phalzyr Posted: Saturday, 06 July 01:15PM
1. advanced post waypoint

2. What it does: Script is much more detail below, but what this does is check the npc's local variables. if they have a value in the first one(so it won't effect other npcs that don't) it'll make them walk to the object which can be anything uniquely named waypoint etc. and if it is a placeable (ie. chair) sit on it. gives alternative facing option default to same as object. Also allows to make them jump, set a quest var on reaching destination..

3. Notes: like i said look in script, would waist too much space posting instruction here.

4. The Script itself:

NWScript:
//This is an include file(desprition of function are right before the function being described)

//put #include "nameofthisscript" as first line in script you want to use it in.

//  FUNCTION NAME - (EVENT SCRIPTED FOR) - DESCRIPTION

//

//  MyWalkToStandPoint() - (onheartbeat) I made this so that one can just set a few

//variables(only first one needed to function) during conversation a trigger, etc.

//These variables will control where your npc character stands at and not conintue

//quest plot until reaching there, so simply doing a set local to these vars will

//change their standpoint location, and if the object is a placeable(chair, etc)

//then have them sit on it.

//

//  In order for this to work you must have an object(waypoint prefered)

//with the tagname of what you assign to "M1_WP_STAND". Also for field

//3 to mean anything, you must be using OBJECT_SELF quest scripting

//ala using "yourvarname" as a storage on npc for what plot stage your

//character is at for that npc. If (Quest To) is never changed then a local

//quest var will not be set and thus you can use this script even if you

//do not want it for that purpose.

//

//My OBJECT_SELF Quest Scripts example(using "M1_PLOTQUEST" as the var):

//  SetLocalInt(OBJECT_SELF,"M1_PLOTQUEST",1);

//is what I use to set a npc quest to 1 and:

//  if (GetLocalInt(OBJECT_SELF,"M1_PLOTQUEST") == 1) {

//is what I use for dialog conditional checking to see if it = 1

//

//Now an explanation of the local variables: (vartype/name/desc)

//

//String "M1_WP_STAND" - (Destination) Put the tagname of the object here that

//you want the npc to move to. Example:

//SetLocalString(OBJECT_SELF,"M1_WP_STAND","WP_Dragon_Nest");

//

//Float "M1_WP_STAND_FACE" - (Facing) Put the direction you want them to face

//once they reach the destination. If left out will use the facing of the

//destination object. Example:

//SetLocalFloat(OBJECT_SELF,"M1_WP_STAND_FACE",DIRECTION_WEST);

//

//Integer "M1_WP_STAND_QTO" - (Quest To) Put the value you want to change it to,

//once they reach the destination. If = 0 will not change quest stage,

//If != 0 it will change the quest stage to this value reset to 0.

//I use this to make a npc have to reach the destination before quest plot

//continues, such as follow me here then I'll tell you.  Example:

//SetLocalInt(OBJECT_SELF,"M1_WP_STAND_QTO",5);

//

//integer "M1_WP_STAND_RUN" - (Walk/Run) set to true if you want them to run set

//to false to have them walk. Default is false.

//SetLocalInt(OBJECT_SELF,"M1_WP_STAND_RUN",TRUE);

//

//integer "M1_WP_STAND_JUMP" - (Move/Jump) set to true if you want them to jump set

//to false to have them move. Default is false. Will reset to 0!

//SetLocalInt(OBJECT_SELF,"M1_WP_STAND_JUMP",TRUE);

//

void MyWalkToStandPoint()

{

//replace if needed with your quest name

  string myquestname = "M1_PLOTQUEST";

//Destination

  object wpobj = GetObjectByTag(GetLocalString(OBJECT_SELF,"M1_WP_STAND"));

//Facing

  float objface = GetLocalFloat(OBJECT_SELF, "M1_WP_STAND_FACE");

//Quest To

  int myint1 = GetLocalInt(OBJECT_SELF, "M1_WP_STAND_QTO");

//Walk/Run

  int myint2 = GetLocalInt(OBJECT_SELF, "M1_WP_STAND_RUN");

//Move/Jump

  int myint3 = GetLocalInt(OBJECT_SELF, "M1_WP_STAND_JUMP");

//First make sure npc is not in conversation, not in combat, and not moving.

  if (((!IsInConversation(OBJECT_SELF)) || (myint3 == 1)) && (!GetIsInCombat(OBJECT_SELF)) && (GetLocalString(OBJECT_SELF,"M1_WP_STAND") != "")) {

//Check to see if the object is valid so if nothing is in destination they won't

//try to go anywhere and thus skip this sctipt and thus be compatible with the

//default walkwaypoints script.

    if (GetIsObjectValid(wpobj)) {

      //Get what the quest stage for this npc is and store it in "questnum"

      int questnum = GetLocalInt(OBJECT_SELF, myquestname);

      //Get the locations of npc and the destination

      location myloc1 = GetLocation(OBJECT_SELF);

      location myloc2 = GetLocation(wpobj);

      //Check to see if the npc is close to their destination or not.

      float disdif = 0.6;

      if (GetObjectType(wpobj) == OBJECT_TYPE_PLACEABLE) {

        disdif = 2.0;

      }

      if ((GetDistanceBetweenLocations(myloc1,myloc2) < -0.6) || (GetDistanceBetweenLocations(myloc1,myloc2) > disdif)) {

         //If they aren't near desination tell them to go to within .6 or 2.0 feet of there.

         //Check for Move or jump

   //      SendMessageToPC(GetFirstPC(),GetTag(OBJECT_SELF) + "|" + FloatToString(GetDistanceBetweenLocations(myloc1,myloc2)));

         if (myint3 == 0) {

           ActionDoCommand(ActionForceMoveToObject(wpobj,myint2,0.5));

         } else {

           ActionDoCommand(ActionJumpToObject(wpobj));

           SetLocalInt(OBJECT_SELF,"M1_WP_STAND_JUMP",FALSE);

         }

      } else {

         //If they are near desination check to see if they are facing the specified direction.

        if (objface != 0.0) {

          if (GetFacing(OBJECT_SELF) != objface) {

            SetFacing(objface);

          }

        } else {

          if (GetFacing(OBJECT_SELF) != GetFacing(wpobj)) {

            SetFacing(GetFacing(wpobj));

          }

        }

        //Check to see if you wanted to set the quest to something

        if (myint1 != 0) {

          //Set the quest to the value and then clears value.

          SetLocalInt(OBJECT_SELF,myquestname,myint1);

          SetLocalInt(OBJECT_SELF, "M1_WP_STAND_QTO",0);

        }

        if (GetObjectType(wpobj) == OBJECT_TYPE_PLACEABLE) {

          if (!GetIsObjectValid(GetSittingCreature(wpobj)))

          {

              AssignCommand(OBJECT_SELF, ActionSit(wpobj));

          }

        }

      }

    }

  }

}



_________________
Phalzyr
--------------------------------------
Insanity Is Just A Matter Of Opinion!