ID:156677
 
I am trying to make a game where you kill zombies and get Experience, I have a code for experience But i never recieve the Experience Here is the code LevelUp and DeathCheck

proc
DeathCheck()
if(M.HP <= 0)
del(M)
usr.EXP += M.EXPG
world<<"You killed the [src]"
else
return

proc/GainLevel()//This is the procedue to the end of the attack verb
if(usr.EXP>=usr.MEXP)//This checks to see if the usrs exp is = or > Than the Max Exp
usr.level+=1//This adds one level to the usrs level stat
usr.EXP=0//This brings there Exp down to 0
usr.MEXP+=20//This adds 20 to the persons max exp for them to gain a level
usr.HP += 5//This gains the usrs Hp up by 5
usr.MHP += 5 //This does the same as the Hp thing but with the max hp
usr << "Your Hp has increased"//This just tells them there hp has increased
usr.attack += rand(3)//This adds 3 to the usrs strength
usr << "Your Str has increased by 3"//This tells the usrs that there str went up by 3
usr<<"You have gained a level. You now need [usr.MEXP] Exp to gain another level."

I never recieve any experience, also EXPG is experience given

here is the list i tried to make

ZCheck()
if src.name = "Zombie"
EXPG = 2

if src.name = "Fat_Zombie"
EXPG = 5

if src.name = "Red_Demon"
EXPG = 15

if src.name = "Black_Demon"
EXPG = 30

Kkirk15 wrote:
I am trying to make a game where you kill zombies and get Experience, I have a code for experience But i never recieve the Experience Here is the code LevelUp and DeathCheck

proc
DeathCheck()
if(M.HP <= 0)
del(M)
usr.EXP += M.EXPG
world<<"You killed the [src]"
else
return

proc/GainLevel()//This is the procedue to the end of the attack verb
if(usr.EXP>=usr.MEXP)//This checks to see if the usrs exp is = or > Than the Max Exp
usr.level+=1//This adds one level to the usrs level stat
usr.EXP=0//This brings there Exp down to 0
usr.MEXP+=20//This adds 20 to the persons max exp for them to gain a level
usr.HP += 5//This gains the usrs Hp up by 5
usr.MHP += 5 //This does the same as the Hp thing but with the max hp
usr << "Your Hp has increased"//This just tells them there hp has increased
usr.attack += rand(3)//This adds 3 to the usrs strength
usr << "Your Str has increased by 3"//This tells the usrs that there str went up by 3
usr<<"You have gained a level. You now need [usr.MEXP] Exp to gain another level."

I never recieve any experience, also EXPG is experience given

here is the list i tried to make

ZCheck()
if src.name = "Zombie"
EXPG = 2

if src.name = "Fat_Zombie"
EXPG = 5

if src.name = "Red_Demon"
EXPG = 15

if src.name = "Black_Demon"
EXPG = 30

No EXP var, only EXPG
WOAH.. DUDE... your code is backtofront left and right up and down wtf...

How do you expect to take a value from M if you deleted M?
Never use USR in procs.
Dont define procs as global procs if there dedicated to a mob like you did...

and use DM codes in the future.

furthermore you never define M in that deathcheck so im surprised it even compiled.
mob/proc/LevelUps(mob/E)
src.exp += E.expgain
if(src.exp >= src.maxexp)
var/funkycheck = 0
if(src.exp > src.maxexp) //so exp can carry over to new lev
funkycheck = src.exp-src.maxexp
src.lev++ //adds one level
src.exp = funkycheck
//do your stat gains and your max exp highering
else
src.exp = funkycheck
src.lev++
//do your stat stuff and max xp gainers.

/* that should handle leveling in a short form for you. E is the enemy so you can pull the exp */

mob/proc/Deathcheck()
if(src.hp <= 0)
if(src.client)
//that above checks if its player so you dont delete players
else
del(src)
else
return

mob/proc/Attack(mob/E in view)
//im not giving you the entire attack code cause im lazy but read this carefully
//do your attack then run
src.LevelUps(E) //this will tell the level up proc that mob is there and
//you can pull its exp easily there


Meh im tired and i scrapped that together for a newbie so if its wrong meh
Your problem is your references. I really don't know how you're managing to kill zombies because if M is the reference to the zombie your world message would be non-existent or incorrect (depending on how you're calling DeathCheck()), and if src is the reference then the zombie isn't being deleted. What you'll want to do is add an argument to DeathCheck() for the person attacking, and always call DeathCheck() from the person getting attacked.

mob
verb
Attack(mob/victim in oview(1)) // Demo on how to call DeathCheck().
// Attacking stuff.
victim.DeathCheck(src) // Sending the verb user as an argument.
// Notice that it is called from the zombie.

proc
DeathCheck(mob/killer) // verb user back in this line.
if(src.HP <= 0)
world << "[killer] has killed [src]"
killer.EXP += src.EXPG
killer.LevelCheck()
if(!src.client) // If it's not a player
del src // delete whatever died.

LevelCheck()
if(src.EXP >= src.MEXP)
src << "You gained a level!"
src.lvl += 1
src.EXP = 0 // src.EXP -= MEXP to keep the remainder.
src.MEXP += 20


So if you were attacking a zombie with this, here's how it would go down as far as references are concerned. In the Attack verb your character would be src (because the verb called belongs to you) and the zombie would be victim (because he's in oview(1)). When you call DeathCheck(), you call it from the zombie so he becomes src in that proc (it's his proc) and your character becomes killer because we sent it as an argument to the killer parameter. Then finally, we call your characters LevelCheck() proc so your character is src in there again. Since we didn't need the zombie anymore, we didn't send it as an argument or setup a parameter for it.