NWN2 Scripting.




Simulation Training.

Introduction
Home
First Program
Seeing Results
Variables and Data Types
Comments
Functions
Data Conversion
Random Numbers
Concatenation
Arithmetic Operators
Compound Assignments
One More or Less
Precedence
Relational Operators
The Open Branch
The Closed Branch
Logical AND
Logical OR
Compound Statements
ELSE If
Switch Case
The ? Operator
The for Loop
The while Loop
The do while Loop
Introduction to Functions
Passing Values
Passing Multiple Values
Multiple Functions
Simplifying Functions
TRUE/fALSE Conditions
Return Values
Setting Global Variables
Getting Global Variables
Setting Local Variables
Getting Local Variables
WayPoints Introduction
Static Waypoint Sets
Dynamic Waypoint Sets
Dynamic WP Cycles
Input Output

Dynamic WP Sets

Dynamic Waypoint Sets offer a new dimension of realism for a NWN2 module. A Dynamic Waypoint Set allows different creatures to transverse different sets of waypoints from a given Waypoint Group.


Dynamic Sets

A Dynamic Waypoint Set is a series of NWN2 Waypoints connected to each other through Scripting. The Dynamic Waypoint Set may be any series of Waypoints including one or more Waypoints form a pre-defined Static Waypoint Set.


Waypoint Cycles

Static Cycles

A Static Waypoint Cycle is a pre-defined Set of Waypoints, either Static Waypoints or Dynamic Waypoints where the transversal of the Set is always the same sequence of Waypoints.

Dynamic Cycles

A Dynamic Waypoint Cycle may or may not consist of any pre-defined Sets of Waypoints either Static  or Dynamic where the transversal paths are completly determined through Scripting.


What Waypoints Can do

The actions taken by the NWN2 Waypoints can be used as follows:

  • NWN2 Waypoints can be assigned as Sets where each Set consister of a series of interconnected and ordered waypoints Called a Waypoint Set.
  • NWN2 Waypoint Sets can be either Static or Dynamic or a combination of Static and Dynamic.
  • NWN2 Waypoints which are Seted (grouped) can be used as pathways for NPCs to travel in a predefind and designated or random order.
  • NWN2 Waypoints are normally transversed by NPCs from the lowest numbered Waypoint to the highest numbered Waypoint and then back again from the highest numbered to the lowest numbered in which is called a Waypoint Cycle.
  • NWN2 Waypoint Cycles may be either Static or Dynamic or a combination of both.
  • NWN2 Waypoints can serve as triggers for specific or random actions by NPCs when a Waypoint within the Waypoint Set is reached by the consists of three or more Waypoints where two or more of them will be uses as a Waypoint Set by one or more Creatures.

 


Dynamic WP Set Example

A Module Area is created with a Group of five Waypoints. The Waypoints are assigned the following Tags:

  Waypoint 1 Tag = WP1

   Waypoint 2 Tag = WP2

   Waypoint 3 Tag = WP3

   Waypoint 4 Tag = WP4

  Waypoint 5 Tag = WP5

Once these Waypoints are created and their Tags assigned, the following script is created. The Script is named: wp_set1.



void main()

 {

  object oWP1=GetNearestObjectByTag("WP1");

  object oWP2=GetNearestObjectByTag("WP2");

  object oWP3=GetNearestObjectbyTag("WP3");

  object oWP4=GetNearestObjectbyTag("WP4");

  object oWP5=GetNearestObjectbyTag("WP5");

   ActionMoveToObject(oWP1);

   ActionMoveToObject(oWP2);

   ActionMoveToObject(oWP3);

   ActionMoveToObject(oWP4);

   ActionMoveToObject(oWP5);

 }

 


 

Any Creatures can now be created in the Module and its Properties/Scripts/On Heartbeart Script is assigned the above Script: wp_set1. The selected Creature will now transverse the Waypoint Set as defined in the above program.

 


Creating a New Set

A new Waypoint Set may now be created from the same Waypoint Group of the five Waypoints placed in the Module Area. The following Script, called

wp_set2, shows how:

 

void main()

 {

  object oWP1=GetNearestObjectByTag("WP1");

  object oWP3=GetNearestObjectByTag("WP2");

  object oWP5=GetNearestObjectByTag("WP3");

   ActionMoveToObject(oWP1);

   ActionMoveToObject(oWP3);

   ActionMoveToObject(oWP5);

 }

If another Creature is nwo created in teh same Area and its Properties/Scripts/On Heartbreak Script is now assigned the above script wp_set2, then a new Waypoint Set is created for that Creature from the original Waypoint Group of five. This creature will now transverse from WP1 to WP3 to WP5, then repeat the process.


Adding Variety

Some variety in the Waypoint Set may be added as illustrated by the following Script called wp_set3:


void main()

 {

  object oWP1=GetNearestObjectByTag("WP1");

  object oWP2=GetNearestObjectByTag("WP2");

  object oWP4=GetNearestObjectByTag("WP4");

   ActionMoveToObject(oWP1);

    ActionWait(3.0);

   ActionMoveToObject(oWP2);

    ActionWait(4.0);

   ActionMoveToObject(oWP4);

    ActionWait(7.0);

 }

If antoher Creature is assigned the above script (wp_set3) in its Properties/Scripts/On Heartbeat Script, then it will follow the sequence of WP1, wait htree seconds, WP2, wait four seconds, and WP4, waiting for seven seconds, then the process will be repeated.

Dynamic WP Sets offer an almost limitless variety of activites for NPCs from any given Waypoint Group.

 


 

Where do we go from here

In this section all of the Waypoint Cycles were still Static. This is because the NPcs assigned to a Waypoint Set performed the same Waypoint sequence over and over again. The next section illustrates how to create Dynamic Waypoint Cycles where NPCs will take different paths for a given Waypoitn Set.

Nwn2Scripting provides material for training only. We do not warrant the correctness of its contents. The risk from using it lies entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy.

Copyright 2008 by Adamson House, Ltd. All Rights Reserved.

Questions or Comments: EMail Webmaster

Donations are to Adamson House, Ltd who maintains this site.
All donations go the the improvement of this site.