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.

npc spawning?

Page: 1 of 1
 one_must_fall
08-06-2006, 5:19 PM
#1
Hi i need help with a spawn npc script. I have the script already, but how do i make it so the npc spawns when i kill a certain person? the tutorial covers spawning an npc when you enter an area but it doesn't cover spawning when a certain person dies.
 stoffe
08-06-2006, 5:34 PM
#2
Hi i need help with a spawn npc script. I have the script already, but how do i make it so the npc spawns when i kill a certain person? the tutorial covers spawning an npc when you enter an area but it doesn't cover spawning when a certain person dies.

You could make the OnDeath event AI script of the killed NPC spawn the other NPC. As an example, this modified OnDeath AI script would spawn a new NPC (at coordinates 1.0, 1.0, 1.0) that attacks the killer whenever the NPC it is assigned to is killed:


void main() {
vector loc;
loc.x = 1.0; // x coordinate in world
loc.y = 1.0; // y coordinate in world
loc.z = 1.0; // z coordinate (elevation) in world

object oSpawned = CreateObject(OBJECT_TYPE_CREATURE, "NPCResRef", Location(loc, 0.0));
AssignCommand(oSpawned, ActionAttack(GetLastKiller()));

ExecuteScript("k_ai_master", OBJECT_SELF, 1007);
}
 one_must_fall
08-06-2006, 6:18 PM
#3
wait, that script would make the person i spawn attack me if i kill someone? well, i'm doing a recrutment mod, and i need to make it so if i kill the new member instead of letting him join me, atton spawns outside of the room, runs in and starts a conversation with me. I don't want atton to be a hostile, still a friendly.
 stoffe
08-06-2006, 6:50 PM
#4
wait, that script would make the person i spawn attack me if i kill someone? well, i'm doing a recrutment mod, and i need to make it so if i kill the new member instead of letting him join me, atton spawns outside of the room, runs in and starts a conversation with me. I don't want atton to be a hostile, still a friendly.

It was merely an example of how it could be used, since I didn't know anything about your particular case. :)

You can replace everything in that script except the last line with what you have in your own script. As long as you keep the last line in the script (the ExecuteScript() line) it should work properly. Then you assign the script to the OnDeath script field in the UTC file for the NPC who should get killed.
Page: 1 of 1