PDA

View Full Version : Making something spawn once through heartbeat tag?


Canderis
06-29-2009, 10:22 AM
If I put in a modified version of the OnHeartBeat to spawn something will it keep spawning or will it only spawn once? If it does spawn more than one how can I make it so it does only spawn once in that module?

Star Admiral
06-29-2009, 10:48 AM
You can add a conditional before spawning to check for the existence of the object, something like this:

void main() {
if( GetObjectByTag( "xxxxx" ) == OBJECT_INVALID ) {
// Spawn Stuff
}
}

xxxxx is the tag of the item you want to spawn.

- Star Admiral

Canderis
06-29-2009, 11:08 AM
The check didn't work they kept spawning. But at least they spawned. They didn't before...


if( GetObjectByTag( "p_t4m8" ) == OBJECT_INVALID ) {
// Spawn Stuff
CreateObject( OBJECT_TYPE_CREATURE, "p_t4m8", GetLocation(GetFirstPC()));
}
This is also only a part of the whole script, i decided not to post that cuz its the default heartbeat stuff.

EDIT: This is for k1

Star Admiral
06-29-2009, 11:26 AM
Did you make sure that the template resref and the tag of the creature you are spawning are the same?

- Star Admiral

Canderis
06-29-2009, 11:33 AM
Man.. I always miss the obvious...
EDIT: Now he dosn't spawn again when you enter another module.

Star Admiral
06-30-2009, 11:17 AM
I take it you want the creature to spawn once every time it enters a different module? Is it a custom module you are making, or a regular ingame one?

- Star Admiral

Canderis
06-30-2009, 11:25 AM
Both. Mostly ingame

Star Admiral
06-30-2009, 11:40 AM
Is the creature supposed to be a puppet of some sort? And does the creature not respawn when you re-enter a module you already visited, or does the creature not respawn when you enter all modules?

- Star Admiral

Canderis
06-30-2009, 11:42 AM
Yup i am experementing with making k1 puppets, he is still in the first module but he doesn't spawn into another module.

Star Admiral
06-30-2009, 11:54 AM
I'm not sure if its a script problem or not. Could you change the heartbeat script to something like this:

SendMessageToPC( GetFirstPC(), "I did not spawn." );
if( GetObjectByTag( "p_t4m8" ) == OBJECT_INVALID ) {
CreateObject( OBJECT_TYPE_CREATURE, "p_t4m8", GetLocation(GetFirstPC()));
SendMessageToPC( GetFirstPC(), "I spawned." );
}

Which of the two messages shows up in your feedback page?

- Star Admiral

Canderis
06-30-2009, 02:13 PM
In another module i get I did not spawn.