Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
The Doomlad

Respawn Enemies in script

Recommended Posts

So I'm making a map and I want to have every enemy respawn in the level upon triggering a script. I've looked around but all I can find for respawning enemies is difficulty and I want to trigger it at a very specific point

Share this post


Link to post

Tag every monster in sequence (such as TID 20 to 60, if you were to have 40 monsters as an example). Don't skip any numbers. If needed, start at a really high number like 1000 so you don't mess with other numberings.

 

Write a script that uses a for loop that uses a counter that begins at the first TID number (like i = 20). Inside the loop, use Thing_Raise to bring them all back to life.

 

If you want them to actually re-spawn instead with a teleport effect, it gets a bit more complicated. Since you have a lot of monsters, you'll want to store all the SpawnIDs or actor class names in an array and use Thing_SpawnFacing or something to spawn them.

 

You will also need to consider what would happen if the script triggered before they all died, in which case you may need some additional checks such as GetActorProperty to check health to see if the monster is dead before trying to respawn it.

Share this post


Link to post
4 hours ago, Nevander said:

Tag every monster in sequence (such as TID 20 to 60, if you were to have 40 monsters as an example). Don't skip any numbers. If needed, start at a really high number like 1000 so you don't mess with other numberings.

 

Write a script that uses a for loop that uses a counter that begins at the first TID number (like i = 20). Inside the loop, use Thing_Raise to bring them all back to life.

 

If you want them to actually re-spawn instead with a teleport effect, it gets a bit more complicated. Since you have a lot of monsters, you'll want to store all the SpawnIDs or actor class names in an array and use Thing_SpawnFacing or something to spawn them.

 

You will also need to consider what would happen if the script triggered before they all died, in which case you may need some additional checks such as GetActorProperty to check health to see if the monster is dead before trying to respawn it.

Thanks. I think I'll go with the Thing_SpawnFacing Method. It may be more work but I want monsters spawning in the position they started in

Share this post


Link to post

One thing I forgot to mention, if you want them to spawn at their original spots and not where the corpse ends up, you will need a tagged MapSpot to go along with each monster to use in your loop or script, since the script doesn't know where the spots were unless tagged by MapSpots.

Share this post


Link to post
7 minutes ago, Nevander said:

One thing I forgot to mention, if you want them to spawn at their original spots and not where the corpse ends up, you will need a tagged MapSpot to go along with each monster to use in your loop or script, since the script doesn't know where the spots were unless tagged by MapSpots.

Yeah I tried Thing _SpawnFacing but it seems to not work well with new decorate script monsters so I'll probably go with the mapspot method

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×