ID:145094
 
Code:
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))
M.DeathCheck(M) use that..
In response to A.T.H.K
thanks for making it worse
In response to CYN
Its your fault for not learning to code properly..
In response to A.T.H.K
its your fault for crappeh solution :O
In response to CYN
You fault for not knowing how to spell in plain english :P

src.DeathCheck(M) try that then lol
In response to A.T.H.K
thats what it was to begin with...
In response to CYN
Look agian

usr.attacking = 0
M.DeathCheck() // heres the problem...
In response to A.T.H.K
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
DeathCheck(src,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>"

proc
DeathCheck(S,B)//S is the attacker, B is the defender
var/mob/A = S
var/mob/D = B
if(D.PL <= 0)
if(D != S)
world<<"<font size = 1><font color = black><b>[D] has been knocked out by [A]</b></font>"
A<<"<font size = 1><font color = black><b>[D] has been knocked out by [A]</b></font>"
D<<"<font size = 1><font color = red><b>You have been knocked out by [src]</b></font>"
A.kills++
D.Dead = 1
D.move = 0
D.Deaths++
D.loc = locate(1,1,2)
D.move = 1
else
world<<"<font color = red><small><b>Recent Death: <font color = white>[D] has killed himself!"
D.Dead = 1
D.move = 0
D.Deaths++
D.loc = locate(1,1,2)
D.move = 1</sm>
In response to Rickoshay
And yet agian you will still get the error whilst using attack type 1...

                                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() // DOES NOT COMPUTE!!