ID:163191
 
Is there an easy way to do this
There are plenty of respawn libraries, you should check them out some time. The key is to use the search function.
Well, if you want to respawn mobs that are on the map to begin with, there is a built in Respawn() command, which reloads all objects that were originally on the map.

Otherwise, a good way that I can think of is, make a procedure that spawns an object at a location (we'll find the object type and location from arguments), then call it when an object is deleted.

proc/respawn(type, location)
spawn(600) new type(location)

atom
var/liveforever = FALSE // not everything will respawn, of course
Del()
if (liveforever) respawn(type, loc)
..()

mob
something_that_lives_forever
liveforever = TRUE
power_rangers

// PS: TRUE == 1, FALSE == 0


Since the object is being killed, putting in something like a spawn() wouldn't be good (since the object will be dead before it gets a chance to run).

This way, it's run from an outside source, so it should run fine.

Anyway, as you should be able to tell, as long as an object is set to liveforever, when it is killed, respawn will create a replica (object of the same type) at the object's old location.

So, the mobs under something_that_lives_forever will always respawn when they are deleted.

Of course, it might be better to just keep track of their location when they're created, then run respawn and tell it to put the new mob there, but whatever.
In response to Keeth
thx your code works perfect exaclty as I wanted :D