ID:148787
 
Im trying to make a leveling system from scratch (without tutorial assistance) but when I compile my level proc the error 'error: if :extra args' comes up... Meh, if you see what the problem is tell me

Okay, the proc 'LvlCheck1()' is called...

if(usr.level == 1, exp <= next_lvl)
world << "[usr] has gained a level!"
usr.next_lvl += 100
usr.exp = 0
usr.exp_give += 10
usr.level += 1
usr.Max_PL += 50
usr.HP += 500
else
usr:LvlCheck2()

So if your not Level 1, it calls LvlCheck2()... So on and so forth

I would like to kindly suggest creating a level system which does not require separate code for each level unless you plan on customizing almost every level.

Usual speech: Don't use usr in procs. It is not safe. It looks like the level checking procs belong to the mobs. Use src.

As for what you actually asked for, a comma is not part of a boolean expression. Look up the && and || operators. (I'm sorry. I'd take the time to tell you which to use, but... <= made sleep deprived brain go woozy... must sleep while eyes swirl.)
Try using this instead.
proc
Levelup()
if (exp == nextexp)
world << "[usr] has gained a level!"
HP += 10
def += 1
atk += 1
lvl += 1
nextexp += 50

And then in your attack code put
usr:Levelup()

and make sure you have the vars exp and nextexp on your player mob section.
In response to Hazman
Hazman wrote:
Try using this instead.
proc
Levelup()
if (exp == nextexp)
world << "[usr] has gained a level!"

NO! No no no no.

Do not use usr indiscriminately in procs. This should be src, since it belongs to the mob who's leveling up.

And then in your attack code put
usr:Levelup()

That's only correct if the attack happens to be carried out by a verb, so usr is guaranteed to be the attacker. Most sophisticated battle systems won't work that way. And even if that's the case, then for crying out loud make this an all-mobs proc or cast usr to the specific type you want so you don't end up using the : operator--that's just shoddy code.

Lummox JR
Hey there.

Try this out for your leveling system, I know it is basic, it is also untested so if you have problems please state and I will fix it.

So, here is the leveling system with a few addons.

mob/proc/LevelUp()
if(src.exp >= src.nextexp)
world << "[src] has just gained a level!"
src.next_lvl += 100
src.exp = 0
src.give_exp += 10
src.level +=1
src.Max_PL += 50
src.HP += 500
else ..()

mob/proc/StatCheck()
if(src.HP > src.Max_HP) src.HP = src.Max_HP //This makes sure the players HP is not greater than their Max HP.
if(src.PL > src.Max_PL) src.PL = src.Max_PL //This makes sure the players PL is not greater than their Max PL.
if(src.PL < 0) src.PL = 0 //This makes sure that the players PL doesn't go below zero.


Don't forget to add src.StatCheck() at the very end of your mob/Stat() section in your game.

Hope that helps you out.

--Lee
In response to Mellifluous
src.next_lvl should be src.nextexp there.