The NPC Stalker script can be put made the OnHeartbeat event handler of a non-player character, causing that NPC to follow literally at the heels of the nearest player character.

Notes Edit

  • This was an experiment with the AngleToVector command, originally posted in the BioWare forums by Cheiron the Centaur.
  • The original post included a "CorrectDirection" function that was used as a work-around for a bug that existed before NWN patch 1.23.

The Script Edit

void main() 
   object oTarget = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC);
   object oArea = GetArea(oTarget);
   vector vPosition = GetPosition(oTarget);
   float fOrientation = GetFacing(oTarget);
   vector vNewPos = AngleToVector(fOrientation);
   float vX = vPosition.x - vNewPos.x;
   float vY = vPosition.y - vNewPos.y;
   float vZ = vPosition.z;
   vNewPos = Vector(vX, vY, vZ);
   ActionMoveToLocation( Location( oArea, vNewPos, fOrientation) ); // go stand right behind the PC (if he's still there)
   ActionDoCommand(SetFacing(fOrientation)); // turn towards PC

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.