Jump to content

Home

Spawning based on globals


TimBob12

Recommended Posts

Hi there,

I am currently working on a mod (http://www.lucasforums.com/showthread.php?t=205833)

and am having a problem.

 

I am trying to spawn a placeable and an NPC but I only want to spawn them if a global bool is set to true.

 

Currently I have this script set in the OnOpen event of a corpse that sets the variable:

 

void main()
{
 SetGlobalBoolean("STOLE_CORPSE_FOUND", TRUE);
} 

 

And using my limited C++ knowledge i have had a go at creating a conditional spawn script

 

void main()
{
// ST: Check if it's the player entering the trigger, and that it hasn't already fired 
if (!GetLocalBoolean(OBJECT_SELF, 40) && (GetEnteringObject() == GetFirstPC())) { 

// ST: Make sure the trigger only fires once. 
SetLocalBoolean(OBJECT_SELF, 40, TRUE); 

int iResult;

 iResult = (GetGlobalBoolean("STOLE_CORPSE_FOUND") );

if (iResult == TRUE)
{



         object oNPC1 = CreateObject(OBJECT_TYPE_CREATURE, "twilek", Location(Vector(194.69,64.87,3.75), 180.0));


         object oP1 = CreateObject(OBJECT_TYPE_PLACEABLE, "safe_box", Location(Vector(221.11,93.16,3.75), 180.0));


}


           }


    ExecuteScript("k_ptat17_enter_old", OBJECT_SELF); 	

}

 

Even after opening the corpse the container and NPC don't appear.

 

Also I extracted the enter script for "tat_m17aa" but when I extracted it, it was called this:

"k_ptat17_enter"

I take it this is the same as tat_m17aa as i was aiming for anchorhead.

 

Yeah so any help with this would be massively appreciated.

 

Thanks :D

 

Tim

Link to comment
Share on other sites

Try this, I replaced the properties of my script with those of yours so it should work as is. Just make sure that you turn the condition to false after it has been triggered because that means, in this case, that every time you enter the module it will spawn the twilek and the box.

void main() {

 

if (GetGlobalBoolean("STOLE_CORPSE_FOUND") == TRUE) {

 

object oNPC1 = CreateObject(OBJECT_TYPE_CREATURE, "twilek", Location(Vector(194.69,64.87,3.75), 180.0));

object oP1 = CreateObject(OBJECT_TYPE_PLACEABLE, "safe_box", Location(Vector(221.11,93.16,3.75), 180.0));

SetGlobalBoolean("STOLE_CORPSE_FOUND", FALSE); }

}

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...