ID:267763
 
Ive imputted a leveling system into my game but the exp just goes over the limit and doesnt do anything please help .
You could either do a world loop, which isn't very accurate and could cause major lag. Or with a bit mroe effort and coding, you could put something like : if(src.XP>=src.MaxXp) after everything that could give the player experience.

~Ease~

<font size = -3>Everything is at ease with Ease</font>
In response to Ease
mob
proc
Levelup()
if(src.exp>=src.Max_exp)
src.level++
src.exp=0
src.Max_exp*=2
src<<"You gained a level!"
src.Statup()
else
..()
mob
proc
Statup()
src.strength+=1
src.Max_HP+=20
src.HP=src.Max_HP
src<<"Your stats increase!"

What you gave me just gives me a load of errors this is what I have for a leveling system
In response to Dragon-wars
Well you could of told me you had made procs for it already :P

Just put src.Levelup() after all the things that could affect their EXP.

~Ease~

<font size = -3>Everything is at ease with Ease</font>
In response to Ease
That doesnt make any difference to it .
It still just goes over the level limit
In response to Dragon-wars
When you go up a level, do you reset the experience back to zero, aswell as raising the required experience?
In response to Lazyboy
Yes
In response to Dragon-wars
mob
proc
Levelup()
if(src.exp>=src.Max_exp)
src.level += 1
src.exp = 0
src.Max_exp *= 2
src << "You gained a level!"
src.Statup()
else
..()
mob
proc
Statup()
src.strength += 1
src.Max_HP += 20
src.HP = src.Max_HP
src << "Your stats increase!"

your code works properly make sure that whatever your hitting has the usr.Levelup()to check the exp.
In response to Lauren
It doesn't seem to matter what I do with the code it just keeps going over the max_exp i think it's more a bug than a code problem but someone moved it into newbie central .
In response to Dragon-wars
It worked for that code did.
In response to Lauren
The leveling system works but i can code a monster to just give exp and it still wont make it level up .
In response to Dragon-wars
mob
NPC
Headthrower
name = "Head thrower"
icon = 'Head.dmi'
HP = 10
Max_HP = 10
strength = 2
exp_give = 5
exp = 5
src.Levelup()
money_give = 5
var/mob/PC/P
New()
. = ..()
spawn()
Wander()
proc/Wander()
while(src)
var/Found = FALSE
for(P in oview(5))
step_towards(src,P)
Found = TRUE
break
if(Found != TRUE)
step_rand(src)
sleep(10)
sleep(5)
Bump(mob/M)
if(istype(M,/mob/PC))
Attack(M)
proc/Attack(mob/M)
flick("Head_Attack",src)
sleep(2)
var/damage = rand(1,strength)
M.HP -= damage
view(src) << "[src] attacks [M]!"
view(src) << "[damage] damage!"
M.Death()


This is a sample monster the spaces are a bit wrong on this but this i s what i code them like cud this be whats wrong .
In response to Lauren
Lauren wrote:
your code works properly make sure that whatever your >hitting has the usr.Levelup()to check the exp.

...If thats in a proc, that should be src.Levelup(), You should find Lummox JRs post on byondscape.
In response to Wanabe
That doesn't seem to work I've tried it but it still goes over .
In response to Dragon-wars
please help me with this if ne1 knows how to solve it i need help ive put my game on byond 2 find and look at if you can help .
Its called headthowers domain if you need the whole coding i could email me .
In response to Dragon-wars
Dragon-wars wrote:
mob
NPC
Headthrower
name = "Head thrower"
icon = 'Head.dmi'
HP = 10
Max_HP = 10
strength = 2
exp_give = 5
exp = 5
<s>src.Levelup()</s>//don't want this here, put it in the code where you actually hit the thing