ID:819944
 
(See the best response by Kaiochao.)
Enemies
Code:
mob/Enemies
Wolf
icon='wolf.dmi'
icon_state=""
Name = "Wolf"
Level=10
Exp=30
MaxHP=50
Str=5
Def=7
Gold=5
Side = "Evil"
Alien
icon='alien.dmi'
icon_state=""
Name = "Alien"
Level=20
Exp=60
MaxHP=100
Str=20
Def=10
Gold=50
Side = "Evil"
New()
new /obj/AlienSuit(src)
..()



mob/Enemies/New()
src.HP=src.MaxHP
spawn(-1) src.CombatAI()
return ..()

mob/Enemies/proc/CombatAI()
while(src)
if(isDead == TRUE)
return
for(var/mob/player/M in oview())
if(src.isDead == TRUE)
return
if(get_dist(src,M)<=1)
src.dir=get_dir(src,M)
src.attack()
else
step_to(src,M)
break
sleep(rand(4,8))


Problem description: The object drops but when the enemy respawn they don't go up to me and attack

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

Respawn
mob/var/Respawn_Loc

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

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

You're not recalling CombatAI() in Respawn().
loading Story.dme
loading Skin.dmf
Procs.dm:29:error: src.CombatAI: undefined proc

Story.dmb - 1 error, 0 warnings (double-click on an error to jump to it)

I think the problem is that is for enemies only but how do i call it for the enemies in the respawn
mob/var/Respawn_Loc

mob/Enemies/proc/Respawn()
var/Old_Icon = icon
icon = null
density = 0
spawn(rand(600,1200)) // waits 60~120 seconds.
density = 1
src.CombatAI()
icon = Old_Icon
loc = Respawn_Loc
src.HP = src.MaxHP
Dead = 0
src.isDead = FALSE

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


Still not working i even switched the respawn to mob/enemies/proc/respawn
The problems are not the Object ones which is very weird
In response to Dr.Penguin
You still consider the enemy dead until after you call the proc, call the proc AFTER you set the isDead variable to FALSE.
In response to NNAAAAHH
Not the problem i think the problem is around here

mob/Enemies/proc/CombatAI()
while(src)
if(src.isDead == TRUE)
return
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
Best response
One problem I see there is abuse of usr. You might not have seen it, since it's not there, but the view() procs are evil in the way they have usr as the center by default.
// what you see:
oview()

// what I see:
oview(world.view, usr)

// what you need:
oview(src)
In response to Dr.Penguin
mob/var/Respawn_Loc
mob/Enemies/proc/Respawn()
var/Old_Icon = icon
icon = null
density = 0
spawn(rand(600,1200)) // waits 60~120 seconds.
density = 1
src.CombatAI() //Calls the proc before reseting isDead
icon = Old_Icon
loc = Respawn_Loc
src.HP = src.MaxHP
Dead = 0
src.isDead = FALSE //resets isDead to read the mob as living
mob/New()
..()
if(!client) Respawn_Loc = loc

mob/Enemies/proc/CombatAI()
while(src)
if(src.isDead == TRUE) //Checks if the mob is dead, if found to be TRUE, it stops the proc.
return
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))
This was solved thank you very much all of you.