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
ID:156677
Aug 16 2010, 5:11 pm
|
|
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) 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 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. |
No EXP var, only EXPG