ID:149584
 
When an enemies dies how do you make it so the spawn in it's original place?
Buzzyboy wrote:
When an enemies dies how do you make it so the spawn in it's original place?

Search back several hundred days using the Search tool for a post by Shadowdarke on the same subject, that's how.
In response to Spuzzum
He never asked that. I even searched
In response to Buzzyboy
Buzzyboy wrote:
He never asked that. I even searched

He never asked that, you're right. He answered that, and it's probably the best code for it I've ever seen. ;-)

[edit] Since I don't know where it is either, however, I'll just repost it from my snippets list:

//Credit to: Shadowdarke (slightly modified by Spuzzum)
//Contributed by: Spuzzum

atom/movable
var
respawn = 200
turf/startloc

New(loc)
..(loc) // default new stuff
startloc = loc // store the starting loc for use later

Del()
if(startloc) Remake(src.type, src.startloc, src.respawn)
..() // default del stuff


proc/Remake(atom_type, loc, delay)
if(loc) // if we know where it started
if(delay != -1) spawn(delay) new atom_type(loc)


/* For objects that you can pick up, you might want to stick
"Remake(src.type, src.startloc, src.respawn)" (without the quotes,
of course) directly into the get verb, so that you don't need to
actually destroy the item for it to respawn.

If you don't want something to respawn, set its respawn time to -1. */



//Then just stick respawn times (in ticks) in the mob and obj declarations

/*
//For example:
mob/spider
respawn = 350 //35 seconds

mob/rat_boss
respawn = 6000 //10 minutes

obj/health_potion
respawn = 450 //45 seconds

obj/super_health_potion
respawn = 4500 //7 minutes and 30 seconds
*/


//Be careful with this. If you do global saving and an object doesn't
// exist at the time the server goes down, it will never come back.
//Most people don't do global saving, however, so this shouldn't apply to you.


There you go. Enjoy. =)
In response to Spuzzum
I can't find it though question or answer
In response to Buzzyboy
I edited my post to contain the snippet, since I couldn't find it either. =)
In response to Spuzzum
that won't work it's not going anywhere. is it because of the death check doesn't delete them?
In response to Buzzyboy
world/New()
status+="Beta"
spawn
while(1)
sleep(40)
for(var/obj in world)
for(var/mob/M in world)
sleep(100)
Repop()

this will respawn objects, and mobs as in monsters every 1 minuet, rather easy :)
- RaeKwon
In response to Buzzyboy
Buzzyboy wrote:
that won't work it's not going anywhere. is it because of the death check doesn't delete them?

Yep, that'd be why.
In response to RaeKwon
I have problems with each code.
for ShadowDarke's code it still won't respawn.
for Raekwon's it says " Warning! could not find matching colour entry for white
In response to Buzzyboy
Weird, try this.
world/New()
spawn
while(1)
sleep(300)
for(var/obj in world)
for(var/mob/M in world)
sleep(600)
Repop()

if it still does, its a BYOND bug, cause it doesnt for me.
- RaeKwon
In response to RaeKwon
Your indentation is wrong you have an empty for() loop.
In response to RaeKwon
same thing
In response to Nadrew
it works fine for me, i dont get any errors, in the months of codeing.
In response to RaeKwon
I tried making it a GM verb
and this it what it said
runtime error: Infinite loop suspected.
To avoid this safety check, set world.loop_checks=0
proc name: Repop (/proc/Repop)
usr: \[Master GM] Buzzyboy (/mob/newbie)
src: null
call stack:
In response to RaeKwon
Try this,it works fine for me.

world/New()
..()//!!!
spawn
while(1)
sleep(300)
for(var/obj in world)
for(var/mob/M in world)
sleep(600)
Repop()
world <<"(Repop)"


If it doesn't something is REALLY wrong.

-Kappa the Imp


In response to Kappa the Imp
Okay, please re-read his post. He said that he doesn't delete mobs when they die.

If he wants either of these systems to work, he has to delete the mobs when they die.


Of course, since he's not deleting mobs when they're killed, I don't see why he can't just add a variable like this:

mob/var/respawn = 300 //30 seconds

mob/var/turf/spawn_loc

mob/New(loc)
..(loc)
spawn_loc = loc

mob/Death() //or whatever proc
//do whatever
spawn(respawn) //after 'respawn' ticks,
src.loc = spawn_loc //return me to my spawn location
//and do whatever else you need to do to make me new again

You could try what I posted in Newbie Central on the same topic.

mob
Monster
var
startx
starty
startz
New()
src.startx=src.x
src.starty=src.y
src.startz=src.z
proc
DeathCheck()
if(src.health<=0)
new/mob/Monster(locate(src.startx,src.starty,src.startz))
del(src)

Give that a shot.