ID:148340
 
Ok heres the scoop

I have the following code

mob
Login()
usr.loc = locate(/turf/start)
usr.HP = 10
usr.MP = 0
usr.Str = 5
usr.Def = 2
usr.Lvl = 1
usr.maxhp = 10
usr<< " Welcome To Combat Test By RagnarofBurland. This test makes use of Deadrons character Handling and The creatures are regenerated every 7 'days'"
Time()

mob/player
icon = 'mob.dmi'
icon_state = "bartender"

verb
Attack(M as mob in oview(1))
set category = "Combat"
if (istype(M, /mob/monster))
var/damage = rand(1,Str)
usr<<"You attacked for [damage] damage"
M<<"Your Attacked by [usr] for [damage]"
M.HP -= damage
DeathCheck()
else
usr<<"You can't attack other people and Townsfolk"

mob/monster/troll1
name = "Ogre"
icon = 'mob.dmi'
icon_state = "troll"
HP = 6
MP = 0
Def = 2
Str = 5
Lvl = 1

mob/monster/Whisp
name = "Wisp"
icon = 'mob.dmi'
icon_state = "ghost"
HP = 6
MP = 0
Def = 2
Str = 2
Lvl = 1
luminosity = 1


mob
var
HP
MP
Str
Def
Lvl
maxhp

mob/monster
var
HP
MP
Str
Def
Lvl
maxhp


proc/DeathCheck(M/mob)
if (M.HP <= 0)
usr << "you defeat [M]"
del M








Now in the DeathCheck proc and in the combat verb where it suntracts damage I keep getting

M.HP:undefined var
M.HP:undefined var

I was just wondering what the problem is because as var as I can tell I defined the HP for all characters. So could anyone help me?
Switch the definition ... (M/mob) to (mob/M)
In response to Unowuero
thank you but that still doesn't clear up the error in the combat verb
RagnarofBurland wrote:

mob
Login()
usr.loc = locate(/turf/start)
usr.HP = 10
usr.MP = 0
usr.Str = 5
usr.Def = 2
usr.Lvl = 1
usr.maxhp = 10
usr<< " Welcome To Combat Test By RagnarofBurland. This test makes use of Deadrons character Handling and The creatures are regenerated every 7 'days'"
Time()

Don't use usr in Login(), use src.

mob
var
HP
MP
Str
Def
Lvl
maxhp

mob/monster
var
HP
MP
Str
Def
Lvl
maxhp


This is redundant. Children inherit the properties of their parents. mob/monster has all the variables that mob has, ontop of what it defines for itself. You only need to declare these on for mob.

proc/DeathCheck(M/mob)
if (M.HP <= 0)
usr << "you defeat [M]"
del M







That is not correct syntax. It needs to be DeathCheck(mob/M), not M/mob. Once again, you should shy away from usr here. Make DeathCheck() a mob proc, and have the argument be the defeater.
In response to Alathon
ok so can we rephrase have the arguement be the defeater. I understood the rest and even why it's wrong just not that last we bit. And apparently M.HP in the attack verb is still "Undefined according to DM"


verb
Attack(M as mob in oview(1))
set category = "Combat"
if (istype(M, /mob/monster))
var/damage = rand(1,Str)
src<<"You attacked for [damage] damage"
M<<"Your Attacked by [usr] for [damage]"
---->>> (ERROR) M.HP -= damage
DeathCheck()
In response to RagnarofBurland
verb
Attack(mob/M as mob in oview(1))
set category = "Combat"
if (istype(M, /mob/monster))
var/damage = rand(1,Str)
src<<"You attacked for [damage] damage"
M<<"Your Attacked by [usr] for [damage]"
---->>> (ERROR) M.HP -= damage
DeathCheck()

Try that
In response to Maz
I'll try that when I get home. Thanks Maz
In response to RagnarofBurland
RagnarofBurland wrote:
I'll try that when I get home. Thanks Maz

Well it worked Maz But my deathcheck keeps returning this deathcheck runtime error

runtime error: Cannot read null.HP
proc name: DeathCheck (/proc/DeathCheck)
usr: RagnarofBurland (/mob/player)
src: null
call stack:
DeathCheck(null)
RagnarofBurland (/mob/player): Attack(Wisp (/mob/monster/Whisp)

and this would be the Deathcheck in question

proc
DeathCheck(mob/M as mob in oview(1))
if (M.HP <= 0)
src << "you defeat [M]"
del M

Gosh I need help

In response to RagnarofBurland
Well that's obvious. M is null. Thus, you're not passing M into DeathChecK(), or M is not in oview(1). Take out the "as mob in oview(1)" part, then make sure you're passing an argument into it.