ID:789756
 
(See the best response by LordAndrew.)
Code:
mob
var
isDead = FALSE

proc
attack()
flick("Attack",src)
//for(var/mob/Enemies/S in world)
for(var/mob/M in get_step(src,src.dir))
if(M != src) // you could also edit this in the future, so it doesn't attack people allied to you, etc etc.
var/Damage=rand(0,src.Str-M.Def)
if(Damage <= 0)
Damage = rand(1,5) //To ensure that you never do 0 or negative damage.
view(M)<<"[src] hit [M] for [Damage] Damage!"
M.TakeDamage(Damage,src)

DeathCheck()


//takeDamage(damage, mob/attacker)
TakeDamage(var/Damage,var/mob/Attacker)
src.HP-=Damage
src.DeathCheck(Attacker)


DeathCheck(mob/attacker)

player
DeathCheck(mob/attacker)
if(src.HP <= 0)
if(isDead == TRUE)
return
view()<<"<b><font color=red>[attacker] killed [src]!</font></b>"// when user dies
src.HP = src.MaxHP
src.MP = src.MaxMP
src.Stamina = src.MaxStamina
attacker.Kills += 1 // If the killer isn't a NPC, it gets a kill.
src.Deaths += 1 // If the person killed isn't a NPC, it gets a death.
src.loc = locate(9,3,1)// where user spawns after
//if(src.PenguinTownSpawn) src.loc = locate(7,5,2)
//if(src.blood) src.loc = locate(38,69,1)

Enemies
DeathCheck(mob/attacker)
if(src.HP <= 0)
attacker<<"<b><font color=red>You killed [src] for [src.Exp] exp and for [src.Gold] Gold" // Enemy dies
attacker.Exp += src.Exp
attacker.LevelCheck()
isDead = TRUE
attacker.Gold += src.Gold // You should change it, the person'll always receive 2 gold from any kind of NPC.
src.Respawn()


Problem description: It doesnt let it respawn

mob/var/Respawn_Loc

mob/proc/Respawn()
del src
var/Old_Icon = icon
icon = null
density = 0
spawn(rand(60,120)) // waits 60~120 seconds.
density = 1
icon = Old_Icon
loc = Respawn_Loc
Dead = 0

mob/New()
..()
if(!client) Respawn_Loc = loc


Best response
You're calling del src right off the bat in Respawn(), which means everything below it will never happen. Judging by how you're handling respawning, you shouldn't be using del src in the first place.
i took it off and when i kill the mob


proc name: DeathCheck (/mob/Enemies/DeathCheck)
usr: TheJoker (/mob/Enemies/TheJoker)
src: TheJoker (/mob/Enemies/TheJoker)
call stack:
TheJoker (/mob/Enemies/TheJoker): DeathCheck(null)
TheJoker (/mob/Enemies/TheJoker): attack()
TheJoker (/mob/Enemies/TheJoker): CombatAI()
TheJoker (/mob/Enemies/TheJoker): New(Grass (6,5,1) (/turf/Grass))
mob/Enemies/New()
src.HP=src.MaxHP
spawn(-1) src.CombatAI()
return ..()

mob/Enemies/proc/CombatAI()
if(isDead == TRUE)
return
while(src)
for(var/mob/player/M in oview())
if(get_dist(src,M)<=1)
src.dir=get_dir(src,M)
src.attack()
else
step_to(src,M)
break
sleep(rand(4,8))
In response to Dr.Penguin (#2)
Ah, I see. You're calling DeathCheck() in attack(), which you shouldn't be. The reason for the error is because you called it without an argument, which means it got to the part where it needed to output to attacker. Since one doesn't exist, it crashed.
So i take off deathcheck() Right?
In response to Dr.Penguin (#5)
Yes.