ID:263249
 
Code:
    verb                                                    //an action
attack(mob/M as mob in oview(1))
if (M.HP <= 0) //if M's HP are at or below 0...
usr << "[M] is already dead!"
else //otherwise...
usr << "You attack [M]!"
oview() << "[usr] attacks [M]!"
var/damage = rand(1,10)
world << "[damage] damage!"
M.HP -= damage
M.DeathCheck()
proc
DeathCheck() //checks to see if an attack is deadly
if (HP <= 0) //if the defender's HP is low enough...
world << "[src] was killed by [usr]!" //do the death messaging
M.EXP += rand (1,25)
var //This starts a variable list
HP = 100 //MAkes a verb called HP and sets it to 100
EXP = 0
MaxEXP = 1000
equip = 0
damage = 8
MP = 10
Level = 1 //scince this is somthing to get u started this will end the var list
wealth
Stat() //starts a stat panel
statpanel("Stats") //names the pannel stats
stat("HP:",HP) //stat makes the new stat then ("HP:",makes the "name" of it HP , sppersates and then you put the var HP
stat("MP:",MP)
stat("EXP:",EXP)
stat("Exp to next:",MaxEXP)
stat("Level:",Level)
statpanel("Inventory") //MAkes a new stat panel called inventory
stat(contents)


Problem description:
When i compile the line that reads:
                M.EXP += rand (1,25)

is said to have an undefiened var, please can you tell me what im doing wrong? Thanks

usr abuse to the maximum combined with no idea what 'usr' and 'src' and 'M' is in that Deathcheck proc.

You didn't define M, usr isn't safe there, and in no way did you pass the killer. And the killer should always be passed as an argument, mind you.
In response to Mysame
Mysame wrote:
usr abuse to the maximum combined with no idea what 'usr' and 'src' and 'M' is in that Deathcheck proc.

You didn't define M, usr isn't safe there, and in no way did you pass the killer. And the killer should always be passed as an argument, mind you.

I don't see no <code>usr</code> abuse. o.o;

HAVE I GONE BLIND?!?1/
In response to DivineO'peanut
Deathcheck.
In response to Mysame
Oh... Right... Didn't notice, lol.

Sowwies.
In response to DivineO'peanut
I have another problem:

obj
book
icon = 'book.dmi'
icon_state = "Book"
density = 1
verb
ReadBook()
if (usr.HP <= 0)
usr << "[usr] is worn out!"
else
set src in view(1)
usr << "[usr] starts reading"
sleep(20)
usr.EXP += 10
usr.MaxMP += 5
usr.HP -= 10
usr << "[usr] stops reading"
if (usr.EXP>=100)
world << "[usr] levels up!"
usr.Level += 1


How can i make it that whenever some levels up, thre MaxEXP goes up by 100

Thanks
In response to Master Scar
MaxExp+=100
In response to National Guardsmen
Were do i put it?
In response to Master Scar
Right under "usr.Level += 1" or better yet, make a generalized proc...

hope ytou noticed that EXP in that book ALWAYS goes by 100 instead of maxEXP... unless you changed it by now but I doubt it

- GhostAnime
In response to GhostAnime
I get undefined vars when i put it there

    var
HP = 100
MaxHP = 100
EXP = 0
MaxEXP = 100
equip = 0
damage = 8
tkyes
tkobj
MP = 10
MaxMP = 10
Level = 1
wealth


But havnt i defined it here?
In response to Master Scar
Well the only thing I guess that could trigger that error than is:

1) You called the wrong parent type (eg: obj.MaxEXP rather than mob.MaxEXP or you but it under the wrong var)

2) You mistyped/capped something (coding is extremely picky)

- GhostAnime
In response to GhostAnime
Dont worry my friend gave me a code he made.