ID:144106
 
Code:
mob/var
LVL = 1 //level
EXP = 0 //"min exp"
EXPN=100//"exp needed"
GEXP = 0//exp that monster gives
gain = 0//enables monsters to give exp

ob/proc
Death() //what happens when something "dies"
if(HP<=0) //hp must be below zero to "die"
view() << "[src] is destroyed by [usr]."
if(gold>=1) // makes it so gold is only dropped if they have it
usr.gold += src.gold
usr << "You get [gold] gold from [src]!"
if(src.gain==1) //if mob gives exp...
src.EXP += src.GEXP
usr << "You gain [GEXP] experience points!"
usr.Levelup()
del src
mob/proc
Levelup()
if(usr.EXP<=usr.EXPN)
src<<"You have reached the next level!"
src.LVL++
src.EXP=(src.EXP-EXPN)//problem is here
src.EXPN=src.EXPN*1.6
else
return


Problem description:

Okay the problem is that my code keeps miscalculating how to reset the Player's experience. If I would take out the problem line of code it automatically sets the player's experience back to zero, which I don't understand where I told it to do that (although it's a nice sentiment). I've been trying to get it so that the player's experience will "overlap" into their next level.

For example. Bob gains 100 EXP and reaches the next level so his experience after he levels up should be 0 (100EXP-100EXPN). Nick gains 105 experience and reaches the next level, his experience should now be 5 (105EXP-100EXPN).
//just set exp to 0
mob/proc
Levelup()
//You want EXP to be GREATER than or equal to EXPN. Otherwise you'll gain a level unless you exceed EXPN in one kill.
if(usr.EXP>=usr.EXPN)
src<<"You have reached the next level!"
src.LVL++
src.EXP=0//set EXP to 0. You're making this more complicated than it is.
//The next line was tabbed too far...
src.EXPN=src.EXPN*1.6
In response to Vermolius
Vermolius wrote:
>             src.EXPN=src.EXPN*1.6
>



That last line can be improved.

            src.EXPN=round(src.EXPN*1.6)//To avoid decimals


Or if you want them...

            src.EXPN*=1.6 //Compact, easy version
In response to RedlineM203
Thanks for the greater than sign. That's what I get for trying to code at 1am T_T. I found another mistake though.

    Death() //what happens when something "dies"
if(HP<=0) //hp must be below zero to "die"
view() << "[src] is destroyed by [usr]."
if(gold>=1) // makes it so gold is only dropped if they have it
usr.gold += src.gold
usr << "You get [gold] gold from [src]!"
if(src.gain==1) //if mob gives exp...
src.EXP += src.GEXP //Why would I add EXP to the dead monster?
usr << "You gain [GEXP] experience points!"
usr.Levelup()
del src


I changed that to usr.EXP and fixed the > operator and my code worked :>.
In response to RadianceKnight
Try using defining M and get rid of some of the usr...
In response to RedlineM203
eh.. He didn't ask for that but I'm sure it's nice that someone pointed it out to him.
In response to Vermolius
It does make me happy :D. Right now I'm steadily working through the DM guide and coding stuff at the same time to review and gain experience. It's one less thing I'll need to know