ID:144930
 
Code:mob/var
Hp
player
Mp


mob/enemies
icon='enemies.dmi'

Mettaur
name = "Mettaur"
icon_state = "mettaur"
Hp = 55
Mp = 55
player = 0
var/mob/you/P
New()
. = ..()
spawn()
Wander()
proc/Wander()
while(src)
if(P in oview(5)) //if a Player comes in 5 steps pf him
step_towards(src,P) //Chase him!
for(P in oview(1)) //here you can define some stuff
break //if you want your NPC to shoot make it so
for(P in oview(2)) //these are saying if the Player is within 1,2,3,4 blocks do nothing
break
for(P in oview(3))
break
for(P in oview(4))
break
else
step_rand(src) //if no NPC is 5 blocks or less away walk around
sleep(10) //stop for 1 second
for(P in oview(5)) //.......
break
sleep(5)
spawn(5)
Wander()//Wonder again...
Bump(mob/M)
if(M.player == 1) //If the NPC bumps you
Fight(M)//Fight You!
else
return

proc/Fight(mob/M)
var/damage = rand(1,5)
M.hp -= damage
M << "[src] attacks you for [damage] damage!!"
src<<"You attack [M] for [damage] damage!!"
Dcheck()


mob
proc/Dcheck(mob/M) //Death Check
if(M.Hp <= 0) //If M's hp is less that or equal to 0
M<<"You died!" //tell M they died
M.Hp = M.maxhp //Make M's health be 50
M.loc = locate(1,1,1) //Start M at 1,1,1
if(M.player == 0)
del(M)



Problem description:

um i kinda messed up my code for death check and when i try to put it back to normal this runtime error comes up

runtime error: Cannot read null.Hp
proc name: Dcheck (/mob/proc/Dcheck)
usr: Mettaur (/mob/enemies/Mettaur)
src: Mettaur (/mob/enemies/Mettaur)
call stack:
Mettaur (/mob/enemies/Mettaur): Dcheck(null)
Mettaur (/mob/enemies/Mettaur): Fight(Dazz513 (/mob/you))
Mettaur (/mob/enemies/Mettaur): Bump(Dazz513 (/mob/you))
Mettaur (/mob/enemies/Mettaur): Wander()
Mettaur (/mob/enemies/Mettaur): New(the floor (87,18,1) (/turf/floor))
You're not passing an argument to "Dcheck", though you are defining it. Thus, the defined argument is null, because it's not passed.
Your Dcheck() proc is backwards. In a death check, src must always be the victim. If it needs to know the killer, use the argument for that.

For future reference, please put your code inside the <dm> tags. That's why they're there.

Lummox JR