Conditional area transitions
From NWNWiki
Contents |
[edit] Description
I had an area in a module where I needed to do something similar to the end of the Charwood quest, but I wanted a clean and simple script to do it. I found using an Area Transition trigger easier than using a door transition for this, although the programmer in me wants to work on that.
[edit] Notes
Use these scripts if:
- you have a puzzle in an area and want to change the appearance of the area
- but, you don't want the player to be able to re-enter the old area once they've solved the puzzle
- yet you don't care if they re-enter the new area.
You first build the old area, then make a copy of it and name it something different. Then put a unique waypoint in the old area (WP_AT_OLDAREA), and another one in the copied and modified area (WP_AT_NEWAREA). Although of course you can name them anything you want -- just make sure the scripts accurately reflect the waypoints.
To use them, have the puzzle set the variable to the module.
[edit] The Scripts
[edit] On Click script of the Area Transition
//
// Script: cond_area_trans1.nss
// Author: Trinity
// Date: 20 November 2002
//
// This script goes into the On Click script for the
// area transition trigger. Some people click on
// AT triggers.
//
void main()
{
// Assign the variables
object oPC = GetClickingObject();
object oWP = GetWaypointByTag("WP_AT_NEWAREA");
object oWP1 = GetWaypointByTag("WP_AT_OLDAREA");
int iVar1 = GetLocalInt(GetModule(), "iVar");
// Now we test to make sure at iVar1 is what you need to
// go into the new area. If it isn't, you go to the old.
if (iVar1 != number)
{
AssignCommand(oPC, JumpToObject(oWP1));
}
else
{
AssignCommand(oPC, JumpToObject(oWP));
}
}
[edit] The On Enter script slot of the area transition
//
// Script: cond_area_trans2.nss
// Author: Trinity
// Date: 20 November 2002
//
// This script goes into the On Enter script for the
// area transition trigger. Some people just enter
// AT triggers.
//
void main()
{
// Assign the variables.
object oPC = GetEnteringObject();
object oWP = GetWaypointByTag("WP_AT_NEWAREA");
object oWP1 = GetWaypointByTag("WP_AT_OLDAREA");
int iVar1 = GetLocalInt(GetModule(), "iVar");
// Now we test to make sure at iVar1 is what you need to
// go into the new area. If it isn't, you go to the old.
if (iVar1 != number)
{
AssignCommand(oPC, JumpToObject(oWP1));
}
else
{
AssignCommand(oPC, JumpToObject(oWP));
}
}
Trinity
