DM not crossing seamless area transitions
#1
Posté 13 février 2013 - 04:55
Spent 3 months rebuilding an abandonned PW, and am almost at the part where I only have the fun bits left to do. However for the life of me I cannot work out this problem.
DM will not cross seamless area transitions (DM possessed creature does no problem). I'm not a scripter, though I've improved a little from zero knowledge over the last three months.
Here is the script, I'm sure I am only missing a line in the right place, any ideas?
Any advice gratefully received...
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
////// ALL-IN-ONE SEAMLESS AREA TRANSITIONER (for Neverwinter Nights) //////
////// Date: July 19, 2002 - Version 1.1 //////
////// Created by: Jaga Te'lesin (jaga-nwn@earthlink.net) //////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
////// Copyright Notice //////
////// You may use this script for personal use however you like. But if you redistribute you *must* //////
////// leave all code untouched and with all comments intact. //////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
////// For detailed instructions: //////
////// Please see the readme file that comes with the standard .zip distribution of this script. //////
////// It contains detailed installation and configuration instructions. A current version of this //////
////// script and the accompanying demo module can be found at: //////
////// http://home.earthlin... //////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include "op_dynamicareas"
#include "op_inc_navmsgs"
const int nKS_WBORDER = 47;
const int nKS_NBORDER = 51;
const int nGS_EBORDER = 57;
const int nGS_SBORDER = 47;
const int nTW_NBORDERX = 38;
const int nTW_WLIMIT = 20;
const int nTW_SBORDER = 57;
const int nHP_NBORDER = 40;
const int nHP_SBORDERX = 61;
const int nHP_ELIMIT = 80;
const int nHP_NLIMIT = 20;
const int nTW_SLIMIT = 80;
const string sNWMESSAGE = "The wide river and the tall mountains loom before you; you cannot go further north.";
const string sWKSMESSAGE = "The tall peaks of the Kora Shan loom before you; you cannot go further east.";
const string sTWWMESSAGE = "Due to module limitations, you may not go further west.";
const string sHPEMESSAGE = "Due to module limitations, you may not go further east.";
const string sEKSMESSAGE = "The sodden bog and the tall mountains loom before you; you may not go further south.";
const string sEGSMESSAGE = "The towering peaks of the Glittering Spires loom before you; you cannot go further west.";
const string sHPNMESSAGE = "Due to module limitations, you may not go further north.";
const string sTWSMESSAGE = "Due to module limitations, you may not go further south.";
void TransportEffect ( object oTarget , float fDuration );
string GetNumberPadding ( int nNumber );
int GetIsValidTransArea ( string sAreaTag );
int NLimitCheck ( int nCurAreaX, int nCurAreaY, object oPC );
int SLimitCheck ( int nCurAreaX, int nCurAreaY, object oPC );
int ELimitCheck ( int nCurAreaX, int nCurAreaY, object oPC );
int WLimitCheck ( int nCurAreaX, int nCurAreaY, object oPC );
object oPC = GetEnteringObject(); //added this line to no effect
int GetIsDM(object oPC); //added this line to no effect
int GetIsDMPossessed(object oPC); //added this line to no effect
void main()
{ /// Begin User-Defined Variables ///
float fMaxAreaDim = 160.0f; // 10.0 per tile in one dimension. (Areas under 3x3 not recommended)
// Example: 16x16 areas would use 160.0f, 8x8 areas would use 80.0f, etc.
// *** NOTE: Linked areas *should* be square only! ***
float fLandingOffset = 8.0f; // Distance out from edge in destination Area that PC will land (8 to 10 recommended)
float fDiagTransSize = 10.0f; // Distance out from any corner to sense diagonal movement (8 to 15 recommended)
float fTransitionDelay = 2.5f; // Delay before zoning, used to prevent cheating by PC's (2.0 to 4.0 recommended)
int nDEBUG = TRUE; // Turns on feedback while zoning. Use for problem solving only, normal state is FALSE.
/// End User-Defined Variables ///
object oPC = GetEnteringObject();
// added for custom Outpost content
string sOldArea = GetTag(GetArea(oPC));
if ((oPC != OBJECT_INVALID) && (GetLocalInt(oPC,"m_nZoning") != TRUE))
{
if (GetLocalInt(GetLocalObject(oPC, "SpawnedBy"),"DontZone") == 1) return;
vector vPCVector = GetPosition(oPC); // PC's current Vector
float fPCFacing = GetFacingFromLocation(GetLocation(oPC)); // Direction PC is facing
float fNorthDist = fMaxAreaDim - vPCVector.y; // Distance from North edge
float fSouthDist = vPCVector.y; // Distance from South edge
float fEastDist = fMaxAreaDim - vPCVector.x; // Distance from East edge
float fWestDist = vPCVector.x; // Distance from West edge
float fLeast = fMaxAreaDim; // Initialize smallest found dist from any edge
object oArea; // Destination area
location lLoc; // Placeholder location for general use
int nNumber; // Placeholder number for general use
int nSuccess = FALSE; // Good zone located flag
int nDir2; // Fallback direction for diagonal movement
effect eZoneEffect3 = EffectVisualEffect(VFX_IMP_ACID_L); // ZoneIn effect for end-of-transition
int nDir; // Direction: N=1,S=2,E=3,W=4,NW=5,NE=6,SW=7,SE=8
// Loop through distances to find direction PC is moving, and set nDir to that direction
nDir = 1; // PC at NORTH edge
fLeast = fNorthDist;
if (fSouthDist <= fLeast)
{
nDir = 2; // PC at SOUTH edge
fLeast = fSouthDist;
}
if (fEastDist <= fLeast)
{
nDir = 3; // PC at EAST edge
fLeast = fEastDist;
}
if (fWestDist <= fLeast)
{
nDir = 4; // PC at WEST edge
fLeast = fWestDist;
}
if ((fSouthDist > (fMaxAreaDim-fDiagTransSize)) && (fWestDist < fDiagTransSize))
nDir = 5; // PC in NORTHWEST trigger area
else if ((fSouthDist > (fMaxAreaDim-fDiagTransSize)) && (fWestDist > (fMaxAreaDim-fDiagTransSize)))
nDir = 6; // PC in NORTHEAST trigger area
else if ((fSouthDist < fDiagTransSize) && (fWestDist < fDiagTransSize))
nDir = 7; // PC in SOUTHWEST trigger area
else if ((fSouthDist < fDiagTransSize) && (fWestDist > (fMaxAreaDim-fDiagTransSize)))
nDir = 8; // PC in SOUTHEAST trigger area
string sDestAreaX, sDestAreaY;
int nCurAreaX, nCurAreaY;
// start outpost custom content
object oOldArea = GetArea(oPC);
if (nDEBUG) PrintString(GetTag(oOldArea));
string sCurAreaTag = GetStringLowerCase(GetTag(oOldArea)); // X,Y,Z Tag of Current Area
int bDynamicArea = (GetStringLeft(sCurAreaTag, 4) == "dyna");
if (nDEBUG && bDynamicArea) PrintString("Entering dynamic area");
string sCurAreaX;
string sCurAreaY;
string sCurAreaZ;
if (bDynamicArea)
{
if (nDEBUG) PrintString("Leaving dynamic area");
nCurAreaX = GetLocalInt(oOldArea, "iX");
nCurAreaY = GetLocalInt(oOldArea, "iY");
if (nDEBUG) PrintString("area trans: " + IntToString(nCurAreaX) + IntToString(nCurAreaY));
sCurAreaX = "p" + IntToString(nCurAreaX);
sCurAreaY = "p" + IntToString(nCurAreaY);
sCurAreaZ = "p00";
}
else
// end outpost custom content (except for the brackets)
{
string sXYTag = GetStringLeft(sCurAreaTag,6); // Separate out X/Y from Z coordinate
sCurAreaX = GetStringLeft(sXYTag,3); // X-coordinate of current area (from Tag)
sCurAreaY = GetStringRight(sXYTag,3); // Y-coordinate of current area (from Tag)
sCurAreaZ = GetStringRight(sCurAreaTag,3); // Z-coordinate of current area (from Tag)
if (GetStringLeft(sCurAreaX,1) == "p")
{
nCurAreaX = StringToInt(GetStringRight(sCurAreaX,2));
if (nDEBUG) if (GetIsPC(oPC)) SendMessageToPC(oPC,"Current Area X coordinate is " + GetNumberPadding(nCurAreaX) + IntToString(abs(nCurAreaX)) + ".");
}
else
if (GetStringLeft(sCurAreaX,1) == "n")
{
nCurAreaX = (StringToInt(GetStringRight(sCurAreaX,2)) * (-1));
if (nDEBUG) if (GetIsPC(oPC)) SendMessageToPC(oPC,"Current Area X coordinate is " + GetNumberPadding(nCurAreaX) + IntToString(abs(nCurAreaX)) + ".");
}
if (GetStringLeft(sCurAreaY,1) == "p")
{
nCurAreaY = StringToInt(GetStringRight(sCurAreaY,2));
if (nDEBUG) if (GetIsPC(oPC)) SendMessageToPC(oPC,"Current Area Y coordinate is " + GetNumberPadding(nCurAreaY) + IntToString(abs(nCurAreaY)) + ".");
}
else
if (GetStringLeft(sCurAreaY,1) == "n")
{
nCurAreaY = (StringToInt(GetStringRight(sCurAreaY,2)) * (-1));
if (nDEBUG) if (GetIsPC(oPC)) SendMessageToPC(oPC,"Current Area Y coordinate is " + GetNumberPadding(nCurAreaY) + IntToString(abs(nCurAreaY)) + ".");
}
}
switch (nDir) // Calculate new Area Tag based on the direction they are moving, and move them
{
case 1: // Moving NORTH
{
if (NLimitCheck(nCurAreaX,nCurAreaY,oPC)==TRUE) return;
--nCurAreaY;
sDestAreaY = GetNumberPadding(nCurAreaY) + IntToString(abs(nCurAreaY));
oArea = GetObjectByTag(sCurAreaX + sDestAreaY + sCurAreaZ);
// Outpost custom stuff for dynamic areas
if (oArea == OBJECT_INVALID)
{
oArea = GetObjectByTag(PickDynamicArea(nCurAreaX, nCurAreaY,oPC,oOldArea,bDynamicArea));
if (GetIsObjectValid(oArea))
ExploreAreaForPlayer(oArea,oPC);
}
// end Outpost custom stuff
lLoc = Location(oArea,Vector(vPCVector.x,fLandingOffset),fPCFacing);
if (nDEBUG) if (GetIsPC(oPC)) SendMessageToPC(oPC,"Moving North:" + "\\nDestination Area X TAG is " + sCurAreaX + "." + "\\nDestination Area Y TAG is " + sDestAreaY + ".");
if ((oArea != OBJECT_INVALID) && (GetAreaFromLocation(lLoc) == oArea))
{
SetLocalInt(oPC,"m_nZoning",TRUE);
TransportEffect(oPC,fTransitionDelay);
if (GetIsPC(oPC)) FloatingTextStringOnCreature("Moving North...",oPC);
//outpost stuff
// if (GetIsPC(oPC)) DetachArea(sOldArea);
DelayCommand(fTransitionDelay,AssignCommand(oPC,JumpToLocation(lLoc)));
DelayCommand(fTransitionDelay,SetLocalInt(oPC,"m_nZoning",FALSE));
DelayCommand(fTransitionDelay,ApplyEffectAtLocation(DURATION_TYPE_INSTANT,eZoneEffect3,lLoc));
//MRC_TransitionMerchant(oPC, lLoc, fTransitionDelay);
}
break;
}
case 2: // Moving SOUTH
{
if (SLimitCheck(nCurAreaX,nCurAreaY,oPC)==TRUE) return;
++nCurAreaY;
sDestAreaY = GetNumberPadding(nCurAreaY) + IntToString(abs(nCurAreaY));
oArea = GetObjectByTag(sCurAreaX + sDestAreaY + sCurAreaZ);
// Outpost custom stuff for dynamic areas
if (oArea == OBJECT_INVALID)
{
oArea = GetObjectByTag(PickDynamicArea(nCurAreaX, nCurAreaY,oPC,oOldArea,bDynamicArea));
}
// end Outpost custom stuff
lLoc = Location(oArea,Vector(vPCVector.x,fMaxAreaDim - fLandingOffset),fPCFacing);
if (nDEBUG) if (GetIsPC(oPC)) SendMessageToPC(oPC,"Moving South:" + "\\nDestination Area X TAG is " + sCurAreaX + "." + "\\nDestination Area Y TAG is " + sDestAreaY + ".");
if ((oArea != OBJECT_INVALID) && (GetAreaFromLocation(lLoc) == oArea))
{
SetLocalInt(oPC,"m_nZoning",TRUE);
TransportEffect(oPC,fTransitionDelay);
if (GetIsPC(oPC)) FloatingTextStringOnCreature("Moving South...",oPC);
//outpost stuff
// if (GetIsPC(oPC)) DetachArea(sOldArea);
DelayCommand(fTransitionDelay,AssignCommand(oPC,JumpToLocation(lLoc)));
DelayCommand(fTransitionDelay,SetLocalInt(oPC,"m_nZoning",FALSE));
DelayCommand(fTransitionDelay,ApplyEffectAtLocation(DURATION_TYPE_INSTANT,eZoneEffect3,lLoc));
//MRC_TransitionMerchant(oPC, lLoc, fTransitionDelay);
}
break;
}
case 3: // Moving EAST
{
if (ELimitCheck(nCurAreaX,nCurAreaY,oPC)==TRUE) return;
++nCurAreaX;
sDestAreaX = GetNumberPadding(nCurAreaX) + IntToString(abs(nCurAreaX));
oArea = GetObjectByTag(sDestAreaX + sCurAreaY + sCurAreaZ);
// Outpost custom stuff for dynamic areas
if (oArea == OBJECT_INVALID)
{
oArea = GetObjectByTag(PickDynamicArea(nCurAreaX, nCurAreaY,oPC,oOldArea,bDynamicArea));
}
// end Outpost custom stuff
lLoc = Location(oArea,Vector(fLandingOffset,vPCVector.y),fPCFacing);
if (nDEBUG) if (GetIsPC(oPC)) SendMessageToPC(oPC,"Moving East:" + "\\nDestination Area X TAG is " + sDestAreaX + "." + "\\nDestination Area Y TAG is " + sCurAreaY + ".");
if ((oArea != OBJECT_INVALID) && (GetAreaFromLocation(lLoc) == oArea))
{
SetLocalInt(oPC,"m_nZoning",TRUE);
TransportEffect(oPC,fTransitionDelay);
if (GetIsPC(oPC)) FloatingTextStringOnCreature("Moving East...",oPC);
//outpost stuff
// if (GetIsPC(oPC)) DetachArea(sOldArea);
DelayCommand(fTransitionDelay,AssignCommand(oPC,JumpToLocation(lLoc)));
DelayCommand(fTransitionDelay,SetLocalInt(oPC,"m_nZoning",FALSE));
DelayCommand(fTransitionDelay,ApplyEffectAtLocation(DURATION_TYPE_INSTANT,eZoneEffect3,lLoc));
//MRC_TransitionMerchant(oPC, lLoc, fTransitionDelay);
}
break;
}
case 4: // Moving WEST
{
if (WLimitCheck(nCurAreaX,nCurAreaY,oPC)==TRUE) return;
--nCurAreaX;
sDestAreaX = GetNumberPadding(nCurAreaX) + IntToString(abs(nCurAreaX));
oArea = GetObjectByTag(sDestAreaX + sCurAreaY + sCurAreaZ);
// Outpost custom stuff for dynamic areas
if (oArea == OBJECT_INVALID)
{
oArea = GetObjectByTag(PickDynamicArea(nCurAreaX, nCurAreaY,oPC,oOldArea,bDynamicArea));
}
// end Outpost custom stuff
lLoc = Location(oArea,Vector(fMaxAreaDim - fLandingOffset,vPCVector.y),fPCFacing);
if (nDEBUG) if (GetIsPC(oPC)) SendMessageToPC(oPC,"Moving West:" + "\\nDestination Area X TAG is " + sDestAreaX + "." + "\\nDestination Area Y TAG is " + sCurAreaY + ".");
if ((oArea != OBJECT_INVALID) && (GetAreaFromLocation(lLoc) == oArea))
{
SetLocalInt(oPC,"m_nZoning",TRUE);
TransportEffect(oPC,fTransitionDelay);
if (GetIsPC(oPC)) FloatingTextStringOnCreature("Moving West...",oPC);
//outpost stuff
// if (GetIsPC(oPC)) DetachArea(sOldArea);
DelayCommand(fTransitionDelay,AssignCommand(oPC,JumpToLocation(lLoc)));
DelayCommand(fTransitionDelay,SetLocalInt(oPC,"m_nZoning",FALSE));
DelayCommand(fTransitionDelay,ApplyEffectAtLocation(DURATION_TYPE_INSTANT,eZoneEffect3,lLoc));
//MRC_TransitionMerchant(oPC, lLoc, fTransitionDelay);
}
break;
}
case 5: // Moving NORTHWEST
{
// check for limits of the map
if (NLimitCheck(nCurAreaX,nCurAreaY,oPC)==TRUE) return;
if (WLimitCheck(nCurAreaX,nCurAreaY,oPC)==TRUE) return;
// end limits
--nCurAreaX;
sDestAreaX = GetNumberPadding(nCurAreaX) + IntToString(abs(nCurAreaX));
--nCurAreaY;
sDestAreaY = GetNumberPadding(nCurAreaY) + IntToString(abs(nCurAreaY));
// if (GetIsValidTransArea(sDestAreaX + sDestAreaY + sCurAreaZ)) // If target Area is validated..
// {
oArea = GetObjectByTag(sDestAreaX + sDestAreaY + sCurAreaZ);
// Outpost custom stuff for dynamic areas
if (oArea == OBJECT_INVALID)
{
oArea = GetObjectByTag(PickDynamicArea(nCurAreaX, nCurAreaY,oPC,oOldArea,bDynamicArea));
}
// end Outpost custom stuff
lLoc = Location(oArea,Vector(fMaxAreaDim - fLandingOffset,fLandingOffset),fPCFacing);
if (nDEBUG) if (GetIsPC(oPC)) SendMessageToPC(oPC,"Destination Area validated, moving NorthWest:" + "\\nDestination Area X TAG is " + sDestAreaX + "." + "\\nDestination Area Y TAG is " + sDestAreaY + ".");
if (GetIsPC(oPC)) FloatingTextStringOnCreature("Moving NorthWest...",oPC);
// Outpost custom stuff for dynamic areas
// if (GetIsPC(oPC)) DetachArea(sOldArea);
DelayCommand(fTransitionDelay,AssignCommand(oPC,JumpToLocation(lLoc)));
DelayCommand(fTransitionDelay,SetLocalInt(oPC,"m_nZoning",FALSE));
DelayCommand(fTransitionDelay,ApplyEffectAtLocation(DURATION_TYPE_INSTANT,eZoneEffect3,lLoc));
//MRC_TransitionMerchant(oPC, lLoc, fTransitionDelay);
// }
// else
// {
// if (fNorthDist <= fWestDist)
// nDir2 = 1; // Set fallback direction indicator to North
// else nDir2 = 4; // Set fallback direction indicator to West
// if (nDir2 == 1) // Try to move them North since it was closer edge..
// {
// if (nDEBUG) if (GetIsPC(oPC)) SendMessageToPC(oPC,"Destination Area NOT validated, trying North..");
// ++nCurAreaX;
// sDestAreaX = GetNumberPadding(nCurAreaX) + IntToString(abs(nCurAreaX));
// if (GetIsValidTransArea(sDestAreaX + sDestAreaY + sCurAreaZ))
// {
// oArea = GetObjectByTag(sDestAreaX + sDestAreaY + sCurAreaZ);
// lLoc = Location(oArea,Vector(vPCVector.x,fLandingOffset),fPCFacing);
// nSuccess = TRUE;
// if (nDEBUG) if (GetIsPC(oPC)) SendMessageToPC(oPC,"North is valid and will be used:" + "\\nDestination Area X TAG is " + sDestAreaX + "." + "\\nDestination Area Y TAG is " + sDestAreaY + ".");
// if (GetIsPC(oPC)) FloatingTextStringOnCreature("Moving North...",oPC);
// }
// if (nSuccess == FALSE) // Try to move them West since North Failed..
// {
// if (nDEBUG) if (GetIsPC(oPC)) SendMessageToPC(oPC,"North Area NOT validated, trying West...");
// --nCurAreaX;
// ++nCurAreaY;
// sDestAreaX = GetNumberPadding(nCurAreaX) + IntToString(abs(nCurAreaX));
// sDestAreaY = GetNumberPadding(nCu
#2
Posté 13 février 2013 - 10:22
#3
Posté 13 février 2013 - 10:34
I unfortunately can not remember if this solved the problem... but one thing that will be helpful to do is to change the trigger type to Transition or the like. Another useful thing to do is to have the transition trigger target a waypoint.
Both of those changes enabled me to solve the problem of creatures not following PCs across transitions.
I have forgotten what this did for DMs as I haven't run any events in that module since August.
#4
Posté 13 février 2013 - 10:40
#5
Posté 13 février 2013 - 10:48
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
////// ALL-IN-ONE SEAMLESS AREA TRANSITIONER (for Neverwinter Nights) //////
////// Date: July 19, 2002 - Version 1.1 //////
////// Created by: Jaga Te'lesin (jaga-nwn@earthlink.net) //////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
////// Copyright Notice //////
////// You may use this script for personal use however you like. But if you redistribute you *must* //////
////// leave all code untouched and with all comments intact. //////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
////// For detailed instructions: //////
////// Please see the readme file that comes with the standard .zip distribution of this script. //////
////// It contains detailed installation and configuration instructions. A current version of this //////
////// script and the accompanying demo module can be found at: //////
////// http://home.earthlin... //////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include "op_dynamicareas"
#include "op_inc_navmsgs"
const int nKS_WBORDER = 47;
const int nKS_NBORDER = 51;
const int nGS_EBORDER = 57;
const int nGS_SBORDER = 47;
const int nTW_NBORDERX = 38;
const int nTW_WLIMIT = 20;
const int nTW_SBORDER = 57;
const int nHP_NBORDER = 40;
const int nHP_SBORDERX = 61;
const int nHP_ELIMIT = 80;
const int nHP_NLIMIT = 20;
const int nTW_SLIMIT = 80;
const string sNWMESSAGE = "The wide river and the tall mountains loom before you; you cannot go further north.";
const string sWKSMESSAGE = "The tall peaks of the Kora Shan loom before you; you cannot go further east.";
const string sTWWMESSAGE = "Due to module limitations, you may not go further west.";
const string sHPEMESSAGE = "Due to module limitations, you may not go further east.";
const string sEKSMESSAGE = "The sodden bog and the tall mountains loom before you; you may not go further south.";
const string sEGSMESSAGE = "The towering peaks of the Glittering Spires loom before you; you cannot go further west.";
const string sHPNMESSAGE = "Due to module limitations, you may not go further north.";
const string sTWSMESSAGE = "Due to module limitations, you may not go further south.";
void TransportEffect ( object oTarget , float fDuration );
string GetNumberPadding ( int nNumber );
int GetIsValidTransArea ( string sAreaTag );
int NLimitCheck ( int nCurAreaX, int nCurAreaY, object oPC );
int SLimitCheck ( int nCurAreaX, int nCurAreaY, object oPC );
int ELimitCheck ( int nCurAreaX, int nCurAreaY, object oPC );
int WLimitCheck ( int nCurAreaX, int nCurAreaY, object oPC );
object oPC = GetEnteringObject(); //added this line to no effect
int GetIsDM(object oPC); //added this line to no effect
int GetIsDMPossessed(object oPC); //added this line to no effect
void main()
{ /// Begin User-Defined Variables ///
float fMaxAreaDim = 160.0f; // 10.0 per tile in one dimension. (Areas under 3x3 not recommended)
// Example: 16x16 areas would use 160.0f, 8x8 areas would use 80.0f, etc.
// *** NOTE: Linked areas *should* be square only! ***
float fLandingOffset = 8.0f; // Distance out from edge in destination Area that PC will land (8 to 10 recommended)
float fDiagTransSize = 10.0f; // Distance out from any corner to sense diagonal movement (8 to 15 recommended)
float fTransitionDelay = 2.5f; // Delay before zoning, used to prevent cheating by PC's (2.0 to 4.0 recommended)
int nDEBUG = TRUE; // Turns on feedback while zoning. Use for problem solving only, normal state is FALSE.
/// End User-Defined Variables ///
object oPC = GetEnteringObject();
// added for custom Outpost content
string sOldArea = GetTag(GetArea(oPC));
if ((oPC != OBJECT_INVALID) && (GetLocalInt(oPC,"m_nZoning") != TRUE))
{
if (GetLocalInt(GetLocalObject(oPC, "SpawnedBy"),"DontZone") == 1) return;
vector vPCVector = GetPosition(oPC); // PC's current Vector
float fPCFacing = GetFacingFromLocation(GetLocation(oPC)); // Direction PC is facing
float fNorthDist = fMaxAreaDim - vPCVector.y; // Distance from North edge
float fSouthDist = vPCVector.y; // Distance from South edge
float fEastDist = fMaxAreaDim - vPCVector.x; // Distance from East edge
float fWestDist = vPCVector.x; // Distance from West edge
float fLeast = fMaxAreaDim; // Initialize smallest found dist from any edge
object oArea; // Destination area
location lLoc; // Placeholder location for general use
int nNumber; // Placeholder number for general use
int nSuccess = FALSE; // Good zone located flag
int nDir2; // Fallback direction for diagonal movement
effect eZoneEffect3 = EffectVisualEffect(VFX_IMP_ACID_L); // ZoneIn effect for end-of-transition
int nDir; // Direction: N=1,S=2,E=3,W=4,NW=5,NE=6,SW=7,SE=8
// Loop through distances to find direction PC is moving, and set nDir to that direction
nDir = 1; // PC at NORTH edge
fLeast = fNorthDist;
if (fSouthDist <= fLeast)
{
nDir = 2; // PC at SOUTH edge
fLeast = fSouthDist;
}
if (fEastDist <= fLeast)
{
nDir = 3; // PC at EAST edge
fLeast = fEastDist;
}
if (fWestDist <= fLeast)
{
nDir = 4; // PC at WEST edge
fLeast = fWestDist;
}
if ((fSouthDist > (fMaxAreaDim-fDiagTransSize)) && (fWestDist < fDiagTransSize))
nDir = 5; // PC in NORTHWEST trigger area
else if ((fSouthDist > (fMaxAreaDim-fDiagTransSize)) && (fWestDist > (fMaxAreaDim-fDiagTransSize)))
nDir = 6; // PC in NORTHEAST trigger area
else if ((fSouthDist < fDiagTransSize) && (fWestDist < fDiagTransSize))
nDir = 7; // PC in SOUTHWEST trigger area
else if ((fSouthDist < fDiagTransSize) && (fWestDist > (fMaxAreaDim-fDiagTransSize)))
nDir = 8; // PC in SOUTHEAST trigger area
string sDestAreaX, sDestAreaY;
int nCurAreaX, nCurAreaY;
// start outpost custom content
object oOldArea = GetArea(oPC);
if (nDEBUG) PrintString(GetTag(oOldArea));
string sCurAreaTag = GetStringLowerCase(GetTag(oOldArea)); // X,Y,Z Tag of Current Area
int bDynamicArea = (GetStringLeft(sCurAreaTag, 4) == "dyna");
if (nDEBUG && bDynamicArea) PrintString("Entering dynamic area");
string sCurAreaX;
string sCurAreaY;
string sCurAreaZ;
if (bDynamicArea)
{
if (nDEBUG) PrintString("Leaving dynamic area");
nCurAreaX = GetLocalInt(oOldArea, "iX");
nCurAreaY = GetLocalInt(oOldArea, "iY");
if (nDEBUG) PrintString("area trans: " + IntToString(nCurAreaX) + IntToString(nCurAreaY));
sCurAreaX = "p" + IntToString(nCurAreaX);
sCurAreaY = "p" + IntToString(nCurAreaY);
sCurAreaZ = "p00";
}
else
// end outpost custom content (except for the brackets)
{
string sXYTag = GetStringLeft(sCurAreaTag,6); // Separate out X/Y from Z coordinate
sCurAreaX = GetStringLeft(sXYTag,3); // X-coordinate of current area (from Tag)
sCurAreaY = GetStringRight(sXYTag,3); // Y-coordinate of current area (from Tag)
sCurAreaZ = GetStringRight(sCurAreaTag,3); // Z-coordinate of current area (from Tag)
if (GetStringLeft(sCurAreaX,1) == "p")
{
nCurAreaX = StringToInt(GetStringRight(sCurAreaX,2));
if (nDEBUG) if (GetIsPC(oPC)) SendMessageToPC(oPC,"Current Area X
coordinate is " + GetNumberPadding(nCurAreaX) +
IntToString(abs(nCurAreaX)) + ".");
}
else
if (GetStringLeft(sCurAreaX,1) == "n")
{
nCurAreaX = (StringToInt(GetStringRight(sCurAreaX,2)) * (-1));
if (nDEBUG) if (GetIsPC(oPC)) SendMessageToPC(oPC,"Current Area X
coordinate is " + GetNumberPadding(nCurAreaX) +
IntToString(abs(nCurAreaX)) + ".");
}
if (GetStringLeft(sCurAreaY,1) == "p")
{
nCurAreaY = StringToInt(GetStringRight(sCurAreaY,2));
if (nDEBUG) if (GetIsPC(oPC)) SendMessageToPC(oPC,"Current Area Y
coordinate is " + GetNumberPadding(nCurAreaY) +
IntToString(abs(nCurAreaY)) + ".");
}
else
if (GetStringLeft(sCurAreaY,1) == "n")
{
nCurAreaY = (StringToInt(GetStringRight(sCurAreaY,2)) * (-1));
if (nDEBUG) if (GetIsPC(oPC)) SendMessageToPC(oPC,"Current Area Y
coordinate is " + GetNumberPadding(nCurAreaY) +
IntToString(abs(nCurAreaY)) + ".");
}
}
switch (nDir) // Calculate new Area Tag based on the direction they are moving, and move them
{
case 1: // Moving NORTH
{
if (NLimitCheck(nCurAreaX,nCurAreaY,oPC)==TRUE) return;
--nCurAreaY;
sDestAreaY = GetNumberPadding(nCurAreaY) + IntToString(abs(nCurAreaY));
oArea = GetObjectByTag(sCurAreaX + sDestAreaY + sCurAreaZ);
// Outpost custom stuff for dynamic areas
if (oArea == OBJECT_INVALID)
{
oArea = GetObjectByTag(PickDynamicArea(nCurAreaX, nCurAreaY,oPC,oOldArea,bDynamicArea));
if (GetIsObjectValid(oArea))
ExploreAreaForPlayer(oArea,oPC);
}
// end Outpost custom stuff
lLoc = Location(oArea,Vector(vPCVector.x,fLandingOffset),fPCFacing);
if (nDEBUG) if (GetIsPC(oPC)) SendMessageToPC(oPC,"Moving North:" +
"\\nDestination Area X TAG is " + sCurAreaX + "." + "\\nDestination Area Y
TAG is " + sDestAreaY + ".");
if ((oArea != OBJECT_INVALID) && (GetAreaFromLocation(lLoc) == oArea))
{
SetLocalInt(oPC,"m_nZoning",TRUE);
TransportEffect(oPC,fTransitionDelay);
if (GetIsPC(oPC)) FloatingTextStringOnCreature("Moving North...",oPC);
//outpost stuff
// if (GetIsPC(oPC)) DetachArea(sOldArea);
DelayCommand(fTransitionDelay,AssignCommand(oPC,JumpToLocation(lLoc)));
DelayCommand(fTransitionDelay,SetLocalInt(oPC,"m_nZoning",FALSE));
DelayCommand(fTransitionDelay,ApplyEffectAtLocation(DURATION_TYPE_INSTANT,eZoneEffect3,lLoc));
//MRC_TransitionMerchant(oPC, lLoc, fTransitionDelay);
}
break;
}
case 2: // Moving SOUTH
{
if (SLimitCheck(nCurAreaX,nCurAreaY,oPC)==TRUE) return;
++nCurAreaY;
sDestAreaY = GetNumberPadding(nCurAreaY) + IntToString(abs(nCurAreaY));
oArea = GetObjectByTag(sCurAreaX + sDestAreaY + sCurAreaZ);
// Outpost custom stuff for dynamic areas
if (oArea == OBJECT_INVALID)
{
oArea = GetObjectByTag(PickDynamicArea(nCurAreaX, nCurAreaY,oPC,oOldArea,bDynamicArea));
}
// end Outpost custom stuff
lLoc = Location(oArea,Vector(vPCVector.x,fMaxAreaDim - fLandingOffset),fPCFacing);
if (nDEBUG) if (GetIsPC(oPC)) SendMessageToPC(oPC,"Moving South:" +
"\\nDestination Area X TAG is " + sCurAreaX + "." + "\\nDestination Area Y
TAG is " + sDestAreaY + ".");
if ((oArea != OBJECT_INVALID) && (GetAreaFromLocation(lLoc) == oArea))
{
SetLocalInt(oPC,"m_nZoning",TRUE);
TransportEffect(oPC,fTransitionDelay);
if (GetIsPC(oPC)) FloatingTextStringOnCreature("Moving South...",oPC);
//outpost stuff
// if (GetIsPC(oPC)) DetachArea(sOldArea);
DelayCommand(fTransitionDelay,AssignCommand(oPC,JumpToLocation(lLoc)));
DelayCommand(fTransitionDelay,SetLocalInt(oPC,"m_nZoning",FALSE));
DelayCommand(fTransitionDelay,ApplyEffectAtLocation(DURATION_TYPE_INSTANT,eZoneEffect3,lLoc));
//MRC_TransitionMerchant(oPC, lLoc, fTransitionDelay);
}
break;
}
case 3: // Moving EAST
{
if (ELimitCheck(nCurAreaX,nCurAreaY,oPC)==TRUE) return;
++nCurAreaX;
sDestAreaX = GetNumberPadding(nCurAreaX) + IntToString(abs(nCurAreaX));
oArea = GetObjectByTag(sDestAreaX + sCurAreaY + sCurAreaZ);
// Outpost custom stuff for dynamic areas
if (oArea == OBJECT_INVALID)
{
oArea = GetObjectByTag(PickDynamicArea(nCurAreaX, nCurAreaY,oPC,oOldArea,bDynamicArea));
}
// end Outpost custom stuff
lLoc = Location(oArea,Vector(fLandingOffset,vPCVector.y),fPCFacing);
if (nDEBUG) if (GetIsPC(oPC)) SendMessageToPC(oPC,"Moving East:" +
"\\nDestination Area X TAG is " + sDestAreaX + "." + "\\nDestination Area Y
TAG is " + sCurAreaY + ".");
if ((oArea != OBJECT_INVALID) && (GetAreaFromLocation(lLoc) == oArea))
{
SetLocalInt(oPC,"m_nZoning",TRUE);
TransportEffect(oPC,fTransitionDelay);
if (GetIsPC(oPC)) FloatingTextStringOnCreature("Moving East...",oPC);
//outpost stuff
// if (GetIsPC(oPC)) DetachArea(sOldArea);
DelayCommand(fTransitionDelay,AssignCommand(oPC,JumpToLocation(lLoc)));
DelayCommand(fTransitionDelay,SetLocalInt(oPC,"m_nZoning",FALSE));
DelayCommand(fTransitionDelay,ApplyEffectAtLocation(DURATION_TYPE_INSTANT,eZoneEffect3,lLoc));
//MRC_TransitionMerchant(oPC, lLoc, fTransitionDelay);
}
break;
}
case 4: // Moving WEST
{
if (WLimitCheck(nCurAreaX,nCurAreaY,oPC)==TRUE) return;
--nCurAreaX;
sDestAreaX = GetNumberPadding(nCurAreaX) + IntToString(abs(nCurAreaX));
oArea = GetObjectByTag(sDestAreaX + sCurAreaY + sCurAreaZ);
// Outpost custom stuff for dynamic areas
if (oArea == OBJECT_INVALID)
{
oArea = GetObjectByTag(PickDynamicArea(nCurAreaX, nCurAreaY,oPC,oOldArea,bDynamicArea));
}
// end Outpost custom stuff
lLoc = Location(oArea,Vector(fMaxAreaDim - fLandingOffset,vPCVector.y),fPCFacing);
if (nDEBUG) if (GetIsPC(oPC)) SendMessageToPC(oPC,"Moving West:" +
"\\nDestination Area X TAG is " + sDestAreaX + "." + "\\nDestination Area Y
TAG is " + sCurAreaY + ".");
if ((oArea != OBJECT_INVALID) && (GetAreaFromLocation(lLoc) == oArea))
{
SetLocalInt(oPC,"m_nZoning",TRUE);
TransportEffect(oPC,fTransitionDelay);
if (GetIsPC(oPC)) FloatingTextStringOnCreature("Moving West...",oPC);
//outpost stuff
// if (GetIsPC(oPC)) DetachArea(sOldArea);
DelayCommand(fTransitionDelay,AssignCommand(oPC,JumpToLocation(lLoc)));
DelayCommand(fTransitionDelay,SetLocalInt(oPC,"m_nZoning",FALSE));
DelayCommand(fTransitionDelay,ApplyEffectAtLocation(DURATION_TYPE_INSTANT,eZoneEffect3,lLoc));
//MRC_TransitionMerchant(oPC, lLoc, fTransitionDelay);
}
break;
}
case 5: // Moving NORTHWEST
{
// check for limits of the map
if (NLimitCheck(nCurAreaX,nCurAreaY,oPC)==TRUE) return;
if (WLimitCheck(nCurAreaX,nCurAreaY,oPC)==TRUE) return;
// end limits
--nCurAreaX;
sDestAreaX = GetNumberPadding(nCurAreaX) + IntToString(abs(nCurAreaX));
--nCurAreaY;
sDestAreaY = GetNumberPadding(nCurAreaY) + IntToString(abs(nCurAreaY));
// if (GetIsValidTransArea(sDestAreaX + sDestAreaY + sCurAreaZ)) // If target Area is validated..
// {
oArea = GetObjectByTag(sDestAreaX + sDestAreaY + sCurAreaZ);
// Outpost custom stuff for dynamic areas
if (oArea == OBJECT_INVALID)
{
oArea = GetObjectByTag(PickDynamicArea(nCurAreaX, nCurAreaY,oPC,oOldArea,bDynamicArea));
}
// end Outpost custom stuff
lLoc = Location(oArea,Vector(fMaxAreaDim - fLandingOffset,fLandingOffset),fPCFacing);
if (nDEBUG) if (GetIsPC(oPC)) SendMessageToPC(oPC,"Destination Area
validated, moving NorthWest:" + "\\nDestination Area X TAG is " +
sDestAreaX + "." + "\\nDestination Area Y TAG is " + sDestAreaY + ".");
if (GetIsPC(oPC)) FloatingTextStringOnCreature("Moving NorthWest...",oPC);
// Outpost custom stuff for dynamic areas
// if (GetIsPC(oPC)) DetachArea(sOldArea);
DelayCommand(fTransitionDelay,AssignCommand(oPC,JumpToLocation(lLoc)));
DelayCommand(fTransitionDelay,SetLocalInt(oPC,"m_nZoning",FALSE));
DelayCommand(fTransitionDelay,ApplyEffectAtLocation(DURATION_TYPE_INSTANT,eZoneEffect3,lLoc));
//MRC_TransitionMerchant(oPC, lLoc, fTransitionDelay);
// }
// else
// {
// if (fNorthDist <= fWestDist)
// nDir2 = 1; // Set fallback direction indicator to North
// else nDir2 = 4; // Set fallback direction indicator to West
// if (nDir2 == 1) // Try to move them North since it was closer edge..
// {
// if (nDEBUG) if (GetIsPC(oPC)) SendMessageToPC(oPC,"Destination Area NOT validated, trying North..");
// ++nCurAreaX;
// sDestAreaX = GetNumberPadding(nCurAreaX) + IntToString(abs(nCurAreaX));
// if (GetIsValidTransArea(sDestAreaX + sDestAreaY + sCurAreaZ))
// {
// oArea = GetObjectByTag(sDestAreaX + sDestAreaY + sCurAreaZ);
// lLoc = Location(oArea,Vector(vPCVector.x,fLandingOffset),fPCFacing);
// nSuccess = TRUE;
//
if (nDEBUG) if (GetIsPC(oPC)) SendMessageToPC(oPC,"North is valid and
will be used:" + "\\nDestination Area X TAG is " + sDestAreaX + "." +
"\\nDestination Area Y TAG is " + sDestAreaY + ".");
// if (GetIsPC(oPC)) FloatingTextStringOnCreature("Moving North...",oPC);
// }
// if (nSuccess == FALSE) // Try to move them West since North Failed..
// {
// if (nDEBUG) if (GetIsPC(oPC)) SendMessageToPC(oPC,"North Area NOT validated, trying West...");
// --nCurAreaX;
// &
#6
Posté 13 février 2013 - 10:53
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
////// Copyright Notice //////
////// You may use this script for personal use however you like. But if you redistribute you *must* //////
////// leave all code untouched and with all comments intact. //////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
That is why I haven't distributed my changes to this script. Eventually I'll rewrite it and post my improved version.
But more importantly I'd be careful about reposting it. Its not that big of a deal, as that is not a real copyright. BUT it does indicate the author's wishes that we not repost altered forms of their script.
Modifié par henesua, 13 février 2013 - 10:54 .
#7
Posté 14 février 2013 - 09:07
It is basically the genetic trigger problem Thayan mentions. Since it would take days to change all the triggers, I'm just going to have to stick with as is.
ShadowM, thanks, that works, although all triggers do not always appear. However since the DM possessed can get through, it is no big deal to create a bird or something and cross. Will put this in the DM guide I am making for the module.
Cheers again for your help folks
#8
Posté 14 février 2013 - 10:00
#9
Posté 14 février 2013 - 10:04
#10
Posté 14 février 2013 - 10:32
#11
Posté 14 février 2013 - 04:32
edit one of the area transition triggers in an area
after editing right click on it and update its blueprint
then right click the blueprint and update instances
#12
Posté 15 février 2013 - 01:58
GhostOfGod wrote...
Hmm. The script is a bit hard to read in it's current format and it also just kinda gets cut off at the end there. But from what I can see so far is that most of your debugging code is checking GetIsPC(oPC) so DMs won't see any of the debug code.
This is wrong. DM avatars return TRUE for GetIsPC.
Funky
#13
Posté 15 février 2013 - 10:39
FunkySwerve wrote...
GhostOfGod wrote...
Hmm. The script is a bit hard to read in it's current format and it also just kinda gets cut off at the end there. But from what I can see so far is that most of your debugging code is checking GetIsPC(oPC) so DMs won't see any of the debug code.
This is wrong. DM avatars return TRUE for GetIsPC.
Funky
Oh boy. See what happens when you get away from NWN for too long, forget everything, and then you come back and think you know what your talking about.
Modifié par GhostOfGod, 15 février 2013 - 10:40 .





Retour en haut







