yep you are right, i was going to do that last. Already have a system in place similar to that to reset encounter triggers if there are no players on the last map. However it looks like you missed my last edit. I have two areas total that will use this script. So if i change const string WP_REF = "wp_skip_bf1_"
to
const string WP_REF1 = "wp_skip_bf1_";
const string WP_REF2 = "wp_skip_bf2_";
and then use this later on in the script:
object oWP;
if( GetTag(OBJECT_SELF) == "skip_bforest1" )
{oWP = GetObjectByTag(WP_REF1 + sWP);}
else if( GetTag(OBJECT_SELF) == "skip_bforest2" )
{oWP = GetObjectByTag(WP_REF2 + sWP);}
That should use different sets of waypoint strings depending on the area right? just want to limit the amount of scripts that our module has to have. AV3 is ginormous for only 1 server.
Thanks again Kato :-)
Final Script looks like this.
-----
const string TREE_REF = "x3_plc_tree"; // the trees base ref
const string WP_REF1 = "wp_skip_bf1_"; // the waypoints base ref for map 1
const string WP_REF2 = "wp_skip_bf2_"; // the waypoints base ref for map 2
const int MAX_TREES = 50; // the max number of spawns
void main()
{
object oEntering = GetEnteringObject();
if(!GetIsPC(oEntering) || GetIsDM(oEntering)) return;
int nNumPCs = GetLocalInt(OBJECT_SELF, "NumPCs")+1;
SetLocalInt(OBJECT_SELF, "NumPCs", nNumPCs);
if(nNumPCs > 1) return;
int nWP = 0, nSpawned = 0;
while(++nWP <= 100 && nSpawned < MAX_TREES) // replace 100 with the number of waypoints if different
{
if(Random(2))
{
string sWP = IntToString(nWP);
string sTree = IntToString(Random(19)); // 19 existing tree refs from 0 to 18 for each size
int nRandSize = Random(3)+1;
string sSize = "l";
if(nRandSize == 1) sSize = "s";
else if(nRandSize == 2) sSize = "m";
switch(GetStringLength(sWP))
{
case 1: sWP = "00" + sWP; break;
case 2: sWP = "0" + sWP; break;
default: break;
}
switch(GetStringLength(sTree))
{
case 1: sTree = "00" + sTree; break;
case 2: sTree = "0" + sTree; break;
default: break;
}
object oWP;
if( GetTag(OBJECT_SELF) == "skip_bforest1" )
{oWP = GetObjectByTag(WP_REF1 + sWP);}
else if( GetTag(OBJECT_SELF) == "skip_bforest2" )
{oWP = GetObjectByTag(WP_REF2 + sWP);}
CreateObject(OBJECT_TYPE_PLACEABLE, TREE_REF + sSize + sTree, GetLocation(oWP));
nSpawned++;
}
}
}
This is the current OnExit script to handle resetting the encounters
-----
void main()
{
object oPC = GetExitingObject();
object oArea = OBJECT_SELF;
int iSomeoneThere = FALSE;
object oInArea = GetFirstObjectInArea(oArea);
//Only reset the encounters if the area has no players in it
while ( oInArea != OBJECT_INVALID)
{
if ( GetIsPC(oInArea) & oInArea != oPC)
{
iSomeoneThere = TRUE;
}
oInArea = GetNextObjectInArea(oArea);
}
if (!iSomeoneThere)
{
string sAreaNo = GetStringRight(GetTag(oArea), 2);
int i;
for(i = 1; i < 6; i++)
{
string sSpwnNo = "0" + IntToString(i);
object oSpawn = GetObjectByTag( "skip_bfspawn" + sAreaNo + sSpwnNo );
SetLocalInt(oSpawn, "iCanTrigger", 1);
}
}
}
Modifié par SKIPPNUTTZ, 21 novembre 2011 - 10:33 .