ID:141192
 
Code:
mob
icon = 'person.dmi'
bug
icon = 'bug.dmi'
HP = 5
mxp = 1
def = 0
var
HP = 30
wealth = 0
level = 1
xp = 0
str = 3
mxp = 0
def = 3
proc
DeathCheck()
if (HP <= 0)
world << "[src] was killed by [usr]!"
del(src)
usr.xp += src.mxp
proc
LevelCheck()
if (xp == 2)
usr << "You leveled up! You are now level [level]!"
str += 1
xp -= 99
Del()
var/obj/gold/G = new(loc)
G.amount = rand(1,100)
..()
Login()
icon_state = gender
usr << "Welcome to Cypher Wars!"
world << "[usr] has logged in."
..()
verb
attack(mob/M as mob in oview(1))
if (M.HP <=0)
usr << "[M] is already dead!"
else
usr << "You attack [M]!"
oview() << "[usr] attacks [M]!"
//var/dmg = 1 //Testing Purposes
var/dmg=usr.str-M.def //Reg one
world << "[dmg] damage!"
M.HP -= dmg
M.DeathCheck()
usr.LevelCheck()
say(msg as text)
world << "[usr]: [msg]"
check()
usr << "You have [wealth] gold."
usr << "You are level [level]. You have [xp] xp. You have [str] strentgth."

Thats all that matters.
Problem description:
Okay, so i try to level up. I go kill a few bugs, but i still don't level up, and the check msg says i still have 0 xp. What can i do?
You're deleting the mob before finishing the whole proc. Deleting 'src' will cause it to stop totally.
In response to Mysame
Ahh, thanks
In response to Neos300
Also, I should've said, "your whole code is a piece of crap", but didn't have enough time. Now, though..

You need to pass arguments. src and usr are essentially the same thing in /mob/ procs. You need to pass arguments through the parenthesis. Passing an argument /mob/killer, for example, in your Deathcheck() proc, to have a reference to who killed the one dying, 'src'. 'Usr' in a proc, other than client procs, are normally a "no-no".

mob/proc/Deathcheck(mob/killer)
if(src.hp<0)
killer.exp+=rand(1,5)
del(src)

mob/verb/attack(mob/M in get_step(usr,usr.dir))
if(M&&ismob(M))
M.hp-=1
M.Deathcheck(usr) // Pass usr as argument
// he'll be referenced as the "killer" in your deathcheck proc.
In response to Mysame
Thanks for your suggestion. If you have more time, could please tell me why my code is crap in some other things? (I just started today so i'm a noob)