mob
verb
Attack(mob/M in get_step(usr,usr.dir))
var/attacktype = rand(1,2)
if(usr.rest == 0 && usr.attacking == 0)
if(usr.Stamina >= 5)
if(usr.Sleep > 2)
if(usr.attackzone == 1 && M.attackzone == 1)
var/evaded = rand(1,M.Evade)
usr.attacking = 1
usr.Sleep -= 0.3
if(evaded == 5)
usr<<"<font color = orange><font size = 1><b>[M] blocked your attack</b></font>"
else
if(attacktype == 1)
var/pdamage = max(2, usr.Armstr - M.Endurance)
flick("Punch",usr)
usr<<"<font color = orange><font size = 1><b>You punch [M] for [pdamage] damage</b></font>"
M<<"<font color = orange><font size = 1><b>[usr] punches you for [pdamage] damage</b></font>"
usr.Stamina -= rand(2,4)
M.HP -= pdamage
spawn(20 - usr.Speed)
usr.attacking = 0
M.DeathCheck()
if(attacktype == 2)
var/kdamage = max(3, usr.Legstr - M.Endurance)
flick("Kick",usr)
usr<<"<font color = orange><font size = 1><b>You kick [M] for [kdamage] damage</b></font>"
usr<<"<font color = orange><font size = 1><b>[usr] kicks you for [kdamage] damage</b></font>"
usr.Stamina -= rand(2,6)
M.HP -= kdamage
spawn(20 - usr.Speed)
usr.attacking = 0
src.DeathCheck(M)
else
usr<<"<font color = blue><font size = 1><b>You must be in a battle area to attack</b></font>"
else
usr<<"<font color = blue><font size = 1><b>You need to sleep</b></font>"
else
usr<<"<font color = blue><font size = 1><b>You need to rest</b></font>"
mob
proc
DeathCheck(mob/M)
if(M.HP <= 0)
world<<"<font size = 1><font color = black><b>[M] has been knocked out by [src]</b></font>"
M<<"<font size = 1><font color = red><b>You have been knocked out by [src]</b></font>"
M.HP = M.MHP
M.loc = locate(5,5,1)
Problem description:
It carries out the deathcheck fine but it doesn't restore M.HP to M.MHP sometimes and it says stuff like Cyn kicks you for 162 damage even though I attacked someone else and it gives me this runtime error
runtime error: Cannot read null.HP
proc name: DeathCheck (/mob/proc/DeathCheck)
usr: Rickoshay (/mob)
src: Cyn (/mob)
call stack:
Cyn (/mob): DeathCheck(null)
Rickoshay (/mob): Attack(Cyn (/mob))