Well, I am probably not the most experienced at this type of script (not having much experience with the NPC AI) and I am not fully certain what is wanted here. If the boss can just be teleported back to some starting point in the maze, then this sounds pretty straightforward. Since I may be the first to provide a script, I will assume that is true.
The idea is to just draw a trigger around the area the boss is to be confined to and make sure a his starting point waypoint and patrol waypoints are in it somewhere. The OnEnter script checks that there isn't already a boss on this map and then spawns one. The OnExit script for the trigger clears his action queue and moves him to that waypoint. (I don't know if some further fiddling with his AI priorities would be necessary to get him to leave the PC alone until the PC gets near again.) Use ActionJumpToLocation() on the waypoint's location to move the boss.
I am also assuming the OP is using the walkway system noted in the script. I am not an expert at that, either, but it seems to be pretty well known and the link I provided has some examples and troubleshooting advice.
So, draw the trigger around the maze area, add the patrol waypoints, then try the following as the OnEnter and OnExit scripts. Note that the constants near the tops of the scripts (where I refer to a standard NWN Minotaur Chief and his first walk waypoint) should be customized to the particular boss.
BTW, I chose randomly among the patrol waypoints for the "random" spawn (and respawn) points. One could certainly set up separate waypoints, if those aren't random enough. Also, I used a function to count those waypoints, for flexibility. But, if the number is known ahead of time, the call to CountWalkpoints could be replaced by that number.
// MazeBossEnter.nss
// The OnEnter script for http://forum.bioware.com/topic/501623-script-request-for-a-creature-confined-within-a-confined-trigger/
// Set these for the boss. Same as OnExit script
const string MAZEBOSSTAG = "NW_MINOTAURBOSS"; // The boss' tag
const string MAZEBOSSRESREF = "nw_minotaurboss"; // The boss' ResRef
const string MAZEBOSSSPAWNTAG = "nw_minotaurboss"; // The tag of the waypoint where the boss will spawn
// only counts up to 99
int CountWalkpoints()
{
int nWPTest = 0;
object oWP;
string sWPTag = "WP_" + MAZEBOSSTAG + "_01";
oWP = GetObjectByTag(sWPTag);
while ( GetIsObjectValid(oWP) )
{
nWPTest++;
if (nWPTest<9)
sWPTag = "WP_" + MAZEBOSSTAG + "_0" + IntToString(nWPTest+1);
else
sWPTag = "WP_" + MAZEBOSSTAG + "_" + IntToString(nWPTest+1);
oWP = GetObjectByTag(sWPTag);
}
return nWPTest;
}
void main ()
{
object oPC = GetEnteringObject();
// Check the PC
if ( !GetIsObjectValid(oPC) )
return;
if ( !GetIsPC(oPC) )
return;
if ( GetIsDM(oPC) )
return;
// Check if we already have a boss here
object oBoss = GetObjectByTag(MAZEBOSSTAG);
if ( GetIsObjectValid(oBoss) && GetArea(oBoss)==GetArea(OBJECT_SELF) )
return;
// Still here? Spawn the boss
// Using walkpoints for "random" location.
string sWPTag;
int nLocIndex = Random(CountWalkpoints()) + 1;
if (nLocIndex<10)
sWPTag = "WP_" + MAZEBOSSTAG + "_0" + IntToString(nLocIndex);
else
sWPTag = "WP_" + MAZEBOSSTAG + "_" + IntToString(nLocIndex);
location lSpawnPoint = GetLocation(GetObjectByTag(sWPTag));
oBoss = CreateObject(OBJECT_TYPE_CREATURE, MAZEBOSSRESREF, lSpawnPoint);
}
// MazeBossExit.nss
// The OnExit script for http://forum.bioware.com/topic/501623-script-request-for-a-creature-confined-within-a-confined-trigger/
#include "x0_i0_walkway"
// Set these for the boss. Same as OnEnter script
const string MAZEBOSSTAG = "NW_MINOTAURBOSS"; // The boss' tag
const string MAZEBOSSRESREF = "nw_minotaurboss"; // The boss' ResRef
const string MAZEBOSSSPAWNTAG = "nw_minotaurboss"; // The tag of the waypoint where the boss will spawn
void main ()
{
object oPC = GetExitingObject();
// Check the PC
if ( !GetIsObjectValid(oPC) )
return;
if ( !GetIsPC(oPC) )
return;
if ( GetIsDM(oPC) )
return;
// Check that we have a boss and he is here
object oBoss = GetObjectByTag(MAZEBOSSTAG);
if ( !GetIsObjectValid(oBoss) || GetArea(oBoss)!=GetArea(OBJECT_SELF) )
return;
// Still here? Move the boss to his start point.
location lSpawnPoint = GetLocation(GetObjectByTag(MAZEBOSSSPAWNTAG));
AssignCommand(oBoss, ClearAllActions(TRUE));
AssignCommand(oBoss, ActionJumpToLocation(lSpawnPoint));
AssignCommand(oBoss, WalkWayPoints()); // see http://nwn.wikia.com/wiki/Waypoints_used_with_walkwaypoints
}
For the OnDeath handler, this just checks that any boss creature with the specified tag in the area is dead and then respawns that boss. One could certainly do this with a delay or with some effects.
// MazeBossDeath.nss
// The OnDeath script for http://forum.bioware.com/topic/501623-script-request-for-a-creature-confined-within-a-confined-trigger/
// Set these for the boss. Same as OnEnter script
const string MAZEBOSSTAG = "NW_MINOTAURBOSS"; // The boss' tag
const string MAZEBOSSRESREF = "nw_minotaurboss"; // The boss' ResRef
const string MAZEBOSSSPAWNTAG = "nw_minotaurboss"; // The tag of the waypoint where the boss will spawn
// only counts up to 99
int CountWalkpoints()
{
int nWPTest = 0;
object oWP;
string sWPTag = "WP_" + MAZEBOSSTAG + "_01";
oWP = GetObjectByTag(sWPTag);
while ( GetIsObjectValid(oWP) )
{
nWPTest++;
if (nWPTest<9)
sWPTag = "WP_" + MAZEBOSSTAG + "_0" + IntToString(nWPTest+1);
else
sWPTag = "WP_" + MAZEBOSSTAG + "_" + IntToString(nWPTest+1);
oWP = GetObjectByTag(sWPTag);
}
return nWPTest;
}
void main ()
{
object oPC = GetEnteringObject();
// Check the PC
if ( !GetIsObjectValid(oPC) )
return;
if ( !GetIsPC(oPC) )
return;
if ( GetIsDM(oPC) )
return;
// Check if we already have a boss here
if ( GetIsObjectValid(oBoss) && GetArea(oBoss)==GetArea(OBJECT_SELF) )
if ( !GetIsDead(oBoss) )
return;
// Still here? Spawn the boss
// Using walkpoints for "random" location.
string sWPTag;
int nLocIndex = Random(CountWalkpoints()) + 1;
if (nLocIndex<10)
sWPTag = "WP_" + MAZEBOSSTAG + "_0" + IntToString(nLocIndex);
else
sWPTag = "WP_" + MAZEBOSSTAG + "_" + IntToString(nLocIndex);
location lSpawnPoint = GetLocation(GetObjectByTag(sWPTag));
oBoss = CreateObject(OBJECT_TYPE_CREATURE, MAZEBOSSRESREF, lSpawnPoint);
}
Anyway, it's getting a little late here and my time to test this is minimal, but that's a first attempt. I expect others will know better ways of doing this, but this should get the ball rolling.