ID:1389973
 
(See the best response by Lummox JR.)
Code:


Problem description:

So me and my crew been working on the Soul Eater game off an on, an right now I'm at a stump in the coding. I been trying to find resources, videos and ect, on how to properly code in a experience system where players gain exp from a pve and pvp format, what some players call hands on training where players have to kill npcs and other players to gain experience. Similar to GOA and Rise of the Pirates style of training, It would be very appreciated if I could get some assistance on how to.

Search the forums for "leveling". This question is asked repeatedly.
Best response
I highly recommend taking Ter13's advice to search, but just to get you started, this is the basic way:

mob/var
level = 1
xp = 0
xp_next = 20
xp_value = 1 // what this monster is worth to the killer

mob/proc/DeathCheck(mob/killer)
if(hp <= 0)
if(killer) killer.LevelCheck(xp_value)
// this should do del(src) or move to null for a monster
// in a player, override it for more complex behavior like respawning
Die()

mob/proc/LevelCheck(gain=0)
xp += gain
var/oldlevel = level
while(xp >= xp_next)
++level
// add code to raise stats here

xp -= xp_next
// each level requires 50% more XP
xp_next = round(xp_next * 1.5, 1)
if(level > oldlevel)
src << "Welcome to level [level]!"

That's about all there is to a simple leveling system. Usually they follow an exponential curve like that.

One word of warning: When you do search the forums for more info on this, you'll occasionally run into people with bad programming habits who get this stuff backwards. They may make the death check proc belong to the killer rather than the victim, and put usr everywhere. If you see usr in any of these procs, someone has done something very wrong; it should be avoided outside of verbs.
Thanks to both you guys and I did find some resources in the forum an I found some references and this is what I put into the leveling coding of my game.

mob/proc/levelup()
if(experience>=max_experience)
experience=0
level++
max_experience+=1000
src<<"You've gained a level"
stamina+=[10,35]
resonance+=[10,35]
skill_point+=6
return