Jump to content

Home

spawning npc's from a script


Bell

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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).

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...