Thank you for the reply!
I understand, I guess I am missing something, but here are my scripts. I trimmed it down to where the problem is arising. the SetupTriggers() will be the focus here. The trigger script is afterwards.
The first time I check the module and enter the area, it correctly finds the trigger and tells me its local variable is set to 1. The trigger correctly sets up the ambush’s at the markers
How ever, the second time I load the module, The areas OnEnter script still tells me that the variables are correctly set to 1, how ever when I enter the trigger, it tells me the “active” local var is 0.
Its very odd. Maybe has to do when I create another area in the module? Its mind boggling
//The OnEnter area script
void SetupTriggers();
void CloseDoors();
void LockDoors(int a,int b);
void SetupEncounters(int e);
void SetupContainers(int c);
void DestroyObjects();
void main()
{
object oPC = GetEnteringObject();
if(!GetIsPC(oPC))
return;
int r = GetLocalInt(OBJECT_SELF,"reset");
//object oEnc = GetFirstObjectInArea(OBJECT_SELF);
//string sTreasure = "x0_tres_anylow";
//location lLoc = GetLocation(oEnc);
int c = GetLocalInt(OBJECT_SELF,"waypoints");
int e = GetLocalInt(OBJECT_SELF,"encounters");
int s = GetLocalInt(OBJECT_SELF,"silverdoor");
int b = GetLocalInt(OBJECT_SELF,"bossdoor");
//if r == 1 -> find all objects eith enc, set active
if(r == 1 && GetIsPC(oPC))
{
DestroyObjects();
SetupTriggers();
SetupEncounters(e);
SetupContainers(c);
LockDoors(s,b);
SetLocalInt(OBJECT_SELF,"reset", 0);
}
}
void SetupTriggers()
{
object oPC = GetEnteringObject();
string sType = "";
object oArea = GetArea(OBJECT_SELF);
if(GetStringLeft(GetTag(oArea),3) == "Und")
sType = "trig_ambush_und";
else sType = "trig_ambush_und";
object oTrigger = GetObjectByTag(sType);
if(GetIsObjectValid(oTrigger))
{
SetLocalInt(oTrigger, "active", 1);
SendMessageToPC(oPC,"Trigger activated: " +IntToString(GetLocalInt(oTrigger, "active")));//DEBUG
}
SendMessageToPC(oPC,"SECOND CALL: " +IntToString(GetLocalInt(oTrigger, "active")));//DEBUG
}
//The script attached to the trigger object OnEnter
void main()
{
object oPC = GetEnteringObject();
object oWP = GetObjectByTag("ambush_marker",0);
string sTag = "ambush_marker";
string sType = "";
location lLoc = GetLocation(oWP);
int iActive = GetLocalInt(OBJECT_SELF,"active");
SendMessageToPC(oPC,"Value of active is: " + IntToString(iActive));//DEBUG
int iMarkers = GetLocalInt(OBJECT_SELF,"markers");
int iDiff = GetLocalInt(OBJECT_SELF, "difficulty");
int r = Random(10);
int i = 0;
if(iActive == 1)
{
SendMessageToPC(oPC,"Entered for active block");//DEBUG
for(i = 0; i < iMarkers; i++)
{
SendMessageToPC(oPC,"Entered the for loop");//DEBUG
oWP = GetNearestObjectByTag(sTag, OBJECT_SELF, i);
lLoc = GetLocation(oWP);
if(GetIsObjectValid(oWP))
{
if(iDiff == 1)//easy
{
if(r <= 5)
sType = "amb_und_easy";
else
sType = "amb_und_easy2";
}
else if(iDiff == 2)//normal
{
if(r<=5)
sType = "amb_und_med";
else
sType = "amb_und_med2";
}
else if(iDiff == 3)//hard
{
sType = "amb_und_hard";
}
}
CreateObject(OBJECT_TYPE_PLACEABLE,sType, lLoc, FALSE);
SendMessageToPC(oPC,"Ambush created");//DEBUG
}
SetLocalInt(OBJECT_SELF,"active",0) ;
}
}