ID:271056
 
how do u make a NPC re-spawn 1 minute after u killed him. I've tried a repop and everything but it doesnt work lol.
Just use the Del() command, look it up.

mob
monster
New()
//all the things that happen when he is created\
you should know this. Ex: walkaround(src)

Del() //this is what you need.
..() //call the deletion proc
sleep(30) //sleep 3 seconds
new/mob/monster() //i'm not sure where you want to locate\
him, but you should know how to do that.
In response to Avren (#1)
Wrong: Once src has been deleted, all running procedures depended on him will cease to exist. You should find an alternative.
In response to Avren (#1)
This is my current code:
mob
ennemies
Rat
icon = 'Rat.dmi'
name = "Infected Rat"
hp = 10
ATK = 3
var/mob/character/Player
New()
. = ..()
spawn()
move()
proc/move()
while(src)
var/player_found = 0
for(Player in oview(8,src))
step_towards(src,Player)
player_found = 1
break
if(player_found != 1)
step_rand(src)
sleep(10)
sleep(5)

Bump(mob/M)
if(istype(M,/mob/character))
attack(M)
proc/attack(mob/M)
var/damage = rand(1,ATK)
M.hp -= damage
M <<"You are being attacked by [src]!"
src.level_up()
M.death_check(src)

Del() //this is what you need.
..() //call the deletion proc
sleep(30) //sleep 3 seconds
new/mob/ennemies/Rat() //i'm not sure where you want to locate him, but you should know how to do that.

I have no errors at all but the problem is they still don't spawn after 3 seconds.
PS: the rats are spreaded on map so there are like 10 of them so its a little problem with the locate on the last line.
In response to DivineO'peanut (#2)
Well, he almost had it right:
Del() //is called when the mob is deleted (but not yet)
var/oloc=src.loc
spawn(30) new src.type(oloc) //I forgot the workaround method for this
..()


When you call ..(), it calls the parents proc.. which has the actual deletion of the object, so when you called the ..() first, it deleted the mob thus the rest weren't called.

Alternatively, you could make it relocate after it "dies"
Del()
src.z = 0//it goes to THE VOID
sleep(30)
src.restore_stats()
src.loc=initial(src.loc)
if(!z)del src //if it has no initial location [eg: not placed on map), it is deleted


- GhostAnime
In response to GhostAnime (#4)
Could this work?
mob
ennemies
Rat
icon = 'Rat.dmi'
name = "Infected Rat"
hp = 10

mob
verb
attack(mob/M in oview(1))
if(M.hp <= 0)
M.hp-=1
if(M.hp >= 0)
M.loc = locate(1,1,1)
sleep(600)
M.loc = locate(1,1,2)
M.hp+=10

It will just teleport them to a new spot on the map for 1 minute.
In response to Revojake (#5)
Revojake wrote:
Could this work?
mob
> ennemies
> Rat
> icon = 'Rat.dmi'
> name = "Infected Rat"
> hp = 10
>
> mob
> verb
> attack(mob/M in oview(1))
> if(M.hp <= 0)
> M.hp-=1
> if(M.hp >= 0)
> M.loc = locate(1,1,1)
> sleep(600)
> M.loc = locate(1,1,2)
> M.hp+=10

It will just teleport them to a new spot on the map for 1 minute.
*faints*
You might want to look at that again.....
Also, you should probably have separate DeathCheck() and Die() procs, possibly a TakeDamage() one as well..