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
ID:148787
Sep 30 2002, 12:53 am
|
|
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. 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 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() 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.
|
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.)