ID:195122
 
//Title: Sample Level-Based System
//Credit to: Jtgibson
//Contributed by: Jtgibson


//This is a sample of the basic foundation of a level-based
// system. This system uses a "progressive demands" experience
// system, which means that the experience requirement for your
// next level will continually increase. This is distinct from
// a "constant demand" experience system, where the experience
// you get changes depending on the level of the monsters you
// beat compared to your own experience, and you must get a fixed
// amount of experience to gain a level (e.g. you need to get
// 1000 experience points to level up, but orks will only be worth
// 1 experience point by the time you're level 50).


mob
var
exp = 0
exp_next = 1000
level = 1

max_hp = 20

proc
AddExp(experience = 0)
exp += experience

//Uses 'while' to allow multiple level-ups
// in case of tons of experience points.
while(exp >= exp_next)
GainLevel()

/* Alternate Implementation:
//Allow only one level up at a time.
if(exp >= exp_next)
exp = exp_next
GainLevel() */


GainLevel()
//INCREASE LEVEL
level++

//INCREASE EXPERIENCE REQUIRED FOR NEXT LEVEL
// (Change the formula as desired!)
exp_next += round((level * 0.75) * 1000)

//ADD/INCREASE STATS HERE
max_hp += rand(1,3)

//ANNOUNCE SUCCESS
world << "<b>[src] gained a level!</b>"
src << "<b>You are now level <font color=\"red\">[level]</font>!</b>"