ID:151382
 
Do you guys think it would be more efficient to re-use the same mobs instead of creating new ones? Something like once the monster's HP is zero, teleport them to another location,like a holding pen in another z level, give the killer the exp, and then bring it back after a certain amount of time with full hp? Or is the difference negligible.
If you re-use mobs you need to make sure that you reset everything. If one of your attacks adds an overlay to the mob, when the mob dies (or when it respawns) you need to make sure the overlay is removed. Also, if you have any variables that are references to the enemy (ex: the player has a reference to the mob they're targeting), you need to be careful about what happens when the mob dies. If the mob is deleted the references become null automatically, not deleting the mob could cause problems.

It might be more efficient to re-use mobs, but it also introduces some potential problems. I suggest doing whatever is easier to you, as the developer, and only worry about efficiency when you run into performance problems.
The idea you are describing allows everything individual respawns based on when they died, as well as the possiblity to have different delays.

It sounds like the alternative method you are considering is to use world.Repop(), which means that ALL mobs have respawn at the same time. So if you spend 20 minutes clearing out a room full of enemies, and the repop happens 10 seconds after you kill the last one, you are screwed because they will ALL come back at once.

I personally prefer the first option, and it is what I put into one of my games. What I did is place most of the setup of the mob into its New() proc, including things like taking note of its initial spawn location, clearing out over/underlays, threat lists, setting the mobs health to equal its maxhealth value, etc.
When the mob dies, set its location to loc=locate(0,0,0) and then start a sleep() timer for the duration you want. After this sleep() is over, set the mobs location back to its original (which I made note of in the New() proc with values StartX, StartY, and StartZ) and then run src.New() to reset everything.

You'll also want to make sure that if the mobs have any sort of loops running to find enemies that you disable them while the mob is dead otherwise you are just wasting CPU for nothing.