Note: LucasForums Archive Project
The content here was reconstructed by scraping the Wayback Machine in an effort to restore some of what was lost when LF went down. The LucasForums Archive Project claims no ownership over the content or assets that were archived on archive.org.

This project is meant for research purposes only.

Spawning based on globals

Page: 1 of 1
 TimBob12
11-16-2010, 2:09 PM
#1
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
 harIII
11-16-2010, 2:38 PM
#2
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); }
}
 TimBob12
11-17-2010, 2:01 PM
#3
They still didn't show up.

I am gonna check to see whether the global is working or not.
 harIII
11-17-2010, 3:21 PM
#4
Make sure that the global is set to true, that's what the script is set up to do so far.
Page: 1 of 1