PDA

View Full Version : "advanced" spawn script


Mindtwistah
07-25-2007, 08:57 AM
Is it possible to make a spawn script that you can deactivate by another script?

For example if I put a spawn script for an NPC on the OnEnter on a module, and when I kill the NPC I trigger a script that deactivates the spawn script.

Qui-Gon Glenn
07-25-2007, 03:47 PM
I'm a rook, but I don't think you need a second script for this.... you just need to set a local or global boolean, and have its value set by death of the NPC in question.

stoffe
07-25-2007, 04:15 PM
I'm a rook, but I don't think you need a second script for this.... you just need to set a local or global boolean, and have its value set by death of the NPC in question.

That's usually how it's done, though you'd set the variable directly after the character has been spawned. Otherwise you'd get a new copy of the character every time the player leaves and re-enters the area, or every time a savegame is loaded in the area (depending on how the spawn script is set up). Usually you only want a character to spawn once.

So you just wrap the spawning part of the OnEnter script in a check, like:


if (!GetLocalBoolean(OBJECT_SELF, 40)) {
SetLocalBoolean(OBJECT_SELF, 40);

/// Spawning code here...
}