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 npc's from a script

Page: 1 of 1
 Bell
08-29-2004, 3:01 AM
#1
Hiya,
anyone ever have trouble with spawning an npc with the use command?

I have..

use ( "cin1del1" );

affect ( "cin1del1", /*@AFFECT_TYPE*/ FLUSH )
etc. etc.

where cin1del1 is the targetname of the npc i want to spawn.

It spawns, but thats it, the script does not continue. If i remove the targetname from the npc and and remove the "use" lines of the script, it spawns when the map loads and the script continues.

any suggestions?
 lassev
08-29-2004, 6:53 AM
#2
That is indeed true. You cannot spawn an NPC in the script and then immediately affect him. It's proven failure. If you need the NPC for a cinematic, you can prespawn the NPC a little earlier (for example when the player triggers some trigger before the room), in a temporary location, and then set his origin to the intended place. That's how I did it. Obviously you can also use a spawnscript, for they should always work.

So, the use("targetname") works fine enough, but there needs to be a significant period of time between the use and the affect.

This may feel like a nasty thing, but that's just how it is.
 Bell
08-29-2004, 12:34 PM
#3
ah Mr. Lassev as always thanks :)
you're a great help:cool:
 lassev
08-29-2004, 6:24 PM
#4
If you prespawn the NPCs before the cinematic, you might want to turn the invisible. Otherwise the player will see them with force sense. Although not directly harmful, but it'd be nevertheless a technical glitch. But invisibility solves that quite easily. And like I said, the prespawning is OK to do just a little before the cinematic, so the NPCs won't really eat FPS for any significant period of time.

For example, if the player needs to walk to a room, and when he steps into the room through the door, a cinematic will launch. You can place a trigger little before the door. The trigger will target the NPCs that will spawn in a small, unreachable box belowe floors. They have a spawnscript setting them invisible (and any other things you might need). The player won't notice anything, but when he reaches the room, and the cinematic starts, you can just set_origin those NPCs to the room and turn them visible.

Smooth and clean. Or you can just run the cinematic from the NPCs spawnscript, or possibly target the NPC entity to a script_runner, which will run the cinematic (haven't tested this last one but should potentially work).
 Bell
08-30-2004, 3:49 AM
#5
most excellent. worked like a charm thanks :cool:
Page: 1 of 1