City Guards

I’m trying to implement the attached city guard spawn system.

GAURDS.txt (8.9 KB)

I’m new to scripting and I don’t know how to do steps 3c,d,e (quoted below). I was wondering if anyone might have some extra detail that might help. Or if there are better systems I am open to your suggestions.

"c) Either by modifying the OnDeath script, or by setting the OnSpawn script to give a user defined event on death and modifying the OnUserDefined script accordingly, these guard templates must be set to call GuardDied(OBJECT_SELF) upon death of the guard. Don’t forget to #include this script, or it won’t compile.

d) Unless you want your guards to just stand around the guardhouse door doing nothing, you will want to set up a set of waypoints for creatures of their tag.

e) Somewhere, probably in the OnModuleLoad script in the module properties, set the local variable MAXGUARDS for the area. This should be set to whatever number of guards you desire to be patrolling this area under normal circumstances."

If you haven’t already, grab the toolset manual from the Vault, and Google the NWNLexicon.

c) can be done by editing the guard’s OnDeath script. Open the guard in the toolset, tab to scripts, edit and save with a new name. You will need to add two lines - a #include at the beginning to include the custom code, and the GuardDied statement at the end, just before the final } of the main block.

d) Place a guard in the toolset, select it, then right click to paint several waypoints around the area. The guard will walk up and down that path in game.

e) is most simply done in the area OnEnter event (with all due respect to the author). If you don’t have such a script, make a new one in the area properties. For, say, 5 guards this should read

void main{}
  {
    SetLocalInt(OBJECT_SELF, "MAXGUARDS", 5);
  }

If any if that doesn’t work, feel free to post the script snippets that are failing.

1 Like

Thank you Proleric. The OnModuleLoad typo really mixed me up. I always appreciate your experienced eye to help sort these things out.

Thank you.

When compiling the OnEnter I get an ERROR: VARIABLE DEFINED WITHOUT TYPE

#include “atfr_inc_guards”

void main()
{
SetLocalInt(OBJECT_SELF, MAXGUARDS, 5);
}

with and without the #include

SetLocalInt (OBJECT_SELF, “MAXGUARDS”, 5);

Needed quotes

Thank you

1 Like

Sorry about the typo - now fixed - I wasn’t at my desk.

You don’t need the #include in the area OnEnter (but it does no harm).