ID:142528
 
Code:
mob
proc
regeneration()
set background = 1
spawn(20)
if(usr.Chakra<=usr.Mchakra)
usr.Chakra+=rand(usr.Str/2)
usr.exp+=10
if(usr.exp>=usr.mexp)
usr.exp=0
usr.Level+=1
usr.mexp*=2
usr.Str+=15
usr.Chakra+=60
usr.Def+=15
usr.expupp()
if(usr.Chakra>=usr.Mchakra)
usr.Chakra=usr.Mchakra


else if(usr.Hp<=usr.Mhp) //or else heal.
usr.Hp+=rand(usr.Str/2)
usr.exp+=10
if(usr.exp>=usr.mexp)
usr.exp=0
usr.Level+=1
usr.mexp*=2
usr.Str+=15
usr.Chakra+=60
usr.Def+=15
usr.expupp()

if(usr.Hp>=usr.Mhp)
usr.Hp=usr.Mhp


Problem description:

hey guys, my problem is that i want it so that once u have full hp and chakra , the persons exp stops raising. because as of now even if the person isnt regenerating and has full hp and chakra the exp still goes up, help is appreciated
if(src.HP == src.maxHP && src.chakra == src.maxchakra) //Checks if src(because usr is invalid) has max HP and chakra
src << "You are fully rejuvinated." //Dude, you're not weak! :D
return 0 //Ends the proc
In response to Darkmag1c1an11
Might want to use >= instead of == in case they gain more than one HP at a time.
mob/proc/levelcheck()
if(exp >= mexp)
exp = 0
Level += 1
//blah blah blah, what's this expupp() proc anyway?
expupp()

mob/proc/regeneration()
spawn(20)
if(hp <= maxhp)
hp += whatever
exp += whatever
levelcheck()
if(mana <= maxmana)
mana += whatever
exp += whatever
levelcheck()


You really have a knack for making things much more complicated than they need to be.
In response to Garthor
Garthor wrote:
mob/proc/levelcheck()
> if(exp >= mexp)
> exp = 0


You get screwed if you've accumulated a large amount of exp (or even just a little bit above mexp, then that bit is lost). Fix:
LevelCheck()
while(exp >= mexp)
exp -= mexp
LevelUp()
In response to Kaioken
Or just call the proc before you set it to 0.
In response to Sokkiejjj
Or say something that makes sense and understand the post you're replying to? The code is quite self-explanatory.