What script is there for TSL to make enemies keep respawning? Like on the mod planet Sirat where zombies kept respawning.
What script is there for TSL to make enemies keep respawning? Like on the mod planet Sirat where zombies kept respawning.
If you want the same enemies to come over and over you can either make a script that resurrects and heals the existing enemies shortly after they die, or you can make a script that spawns a new enemy when an one dies. Both of these can be accomplished by giving the endless NPCs a custom OnDeath event script.
A simple such script could look like this for KOTOR 2:
void main() {
if (!GetLocalBoolean(OBJECT_SELF, 87)) {
vector vCoordinates;
vCoordinates.x = 0.0; // X coordinate in world to spawn new NPC
vCoordinates.y = 0.0; // Y coordinate in world to spawn new NPC
object oNew = CreateObject(OBJECT_TYPE_CREATURE, "NameOfUTCfile", Location(vCoordinates, 0.0));
ExecuteScript("k_ai_master", oNew, 1003);
SpeakString("GEN_I_AM_DEAD", TALKVOLUME_SILENT_TALK);
SpeakString("GEN_ATTACK_MY_TARGET", TALKVOLUME_SILENT_TALK);
}
}
Set 0.0 to the X coordinate and 0.0 to the Y coordinate within the area where you want the respawning NPC to appear, and NameOfUTCfile to the name of the UTC template to create the new NPC from. Then compile the script and put its name in the "OnDeath" field on the Scripts tab in the UTC editor.
This way the player would be confronted by a never-ending wave of NPCs, but there would only be the same number of them as was originally placed there at any given time. To give a bit more variety you'll probably want to make a unique UTC template for each of the initial batch and give them their own copy of the script with different coordinates and respawn UTC template set.