ID:1229046
 
After killing the enemy npc [del(src)] how do I make them respawn on the map?




Easy! If the NPC dies by a proc instead of doing del(src) you just do a restore health proc use it on him and then go back to his place. You can also use the Repop() proc but it would probably lag the server... Let me show you an exemple

mob/var
MaxHealth=10
Health=10
level=1
exp=0
mexp=100

mob
proc
Death(mob/M)
if(istype(src,/mob/AI/Redguy))
M.spawned()
src.Health = src.MaxHealth
src.loc=locate(1,1,1)//Place he was before

mob
AI
Redguy
Health=100
MaxHealth=100

mob
proc
spawned()
src.loc=locate(1,1,1)//person's spawn
src.Health=src.MaxHealth
src.LevelCheck()

mob
proc
LevelCheck()
if(src.exp>=src.mexp)
src.level+=1


Something like that, but then again I didn't test it.
mob
proc
Death(mob/M)
if(istype(src,/mob/AI/Redguy))
M.spawned()
src.Health = src.MaxHealth
src.loc=locate(1,1,1)//Place he was before


Everything looks great ^^ I'm just curious about what if I make 30+ of the same npc will I need to set src.loc=locate(?,?,?) for each of them?
Yes. Or if(istype(src,mob/AI)) (Which would do all the AI, I believe)

mob
proc
Death(mob/M)
if(istype(src,/mob/AI))
M.spawned()
src.Health = src.MaxHealth
src.loc=locate(1,1,1)//Place he was before
mob/var
MaxHealth=10
Health=10
level=1
exp=0
mexp=100
spawnpoint=null
mob
New()
..()
spawnpoint=src.loc//where ever they are on the map during runtime is their spawn

mob
proc
Death(mob/M)
if(istype(src,/mob/AI/Redguy))
M.spawned()
src.Health = src.MaxHealth
src.loc=src.spawnpoint//Place he was before

mob
AI
Redguy
Health=100
MaxHealth=100

mob
proc
spawned()
src.loc=src.spawnpoint//person's spawn
src.Health=src.MaxHealth
src.LevelCheck()


This would be easier to do, I didn't test though
Ah, one more question though. How do I make spawning delays for the AI's after they die?
In response to Mitz001
Create a variable such as spawn_delay for each NPC then do spawn(src.spawn_delay) before restoring them.
In response to Albro1
or she/he could do the normal sleep proc xD
In response to Haiji
You could, however, if you wanted to change anything about that mob between the time that you call the sleep and when it ends, you can't. Sleep halts everything about the mob until it's over. Spawn just waits for a certain amount of time, letting other things work like normal.