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.

one time creature spawn..tsl

Page: 1 of 1
 newbiemodder
04-09-2010, 12:22 PM
#1
I have this script for spawning a creature on the onenter script for my .are file:

void main() {
CreateObject(OBJECT_TYPE_CREATURE, "n_xyz", Location(Vector(6.00,-62.06,11.02), 0.0));

object oNPC = GetObjectByTag("xyz");
object oItem = CreateItemOnObject("mask", oNPC);
AssignCommand(oNPC, ActionEquipItem(oItem, INVENTORY_SLOT_HEAD, TRUE));

}


I only want the creature to spawn the first time you enter the module. I assume I need to establish a local variable/boolean. How do I modify this script to do that. Just fyi, the spawned npc will be killed in battle after entering the first time.
 harIII
04-09-2010, 12:40 PM
#2
You can do it with local variables/booleans are the easiest. I personally like to use booleans since I can see all the variables that I'm working with. So you need to open globalcat.2da file and add a new boolean at the bottom.

Then you need to change your script to something like this:


void main () {

if (GetGlobalBoolean("boolean name") == TRUE) {
CreateObject(OBJECT_TYPE_CREATURE, "n_xyz", Location(Vector(6.00,-62.06,11.02), 0.0));

object oNPC = GetObjectByTag("xyz");
object oItem = CreateItemOnObject("mask", oNPC);
AssignCommand(oNPC, ActionEquipItem(oItem, INVENTORY_SLOT_HEAD, TRUE));

SetGlobalBoolean("same boolean name", FALSE); }
}


You must somehow make the boolean say True, they always start out as false. Then attack this script to the onEnter field in the .are file. At that point the npc is spawned and then the boolean is set back to False so that when you re-enter the module, you don't see two npcs.

Yell at me if this doesn't do what you want, good luck chief.
 DarthStoney
04-09-2010, 1:40 PM
#3
Try this it will check and see of the creature exists in the module before spawning him so it will only create him once.
void main() {
object object1 = GetObjectByTag("creatures tag", 0);
if ((!GetIsObjectValid(object1))) {
CreateObject(OBJECT_TYPE_CREATURE, "n_xyz", Location(Vector(6.00,-62.06,11.02), 0.0));

object oNPC = GetObjectByTag("xyz");
object oItem = CreateItemOnObject("mask", oNPC);
AssignCommand(oNPC, ActionEquipItem(oItem, INVENTORY_SLOT_HEAD, TRUE));

}
 newbiemodder
04-09-2010, 10:04 PM
#4
Thanks guys....I got it working.
Page: 1 of 1