ID:2199888
 
(See the best response by Zecronious.)
Code:
mob/proc/LevelupSword()//       SWORD LEVELING
if(src.maxswordskill>=20000)
src << "You have reached the limit of your Sword-weilding ability!"
return 0
else if((src.level*3)<=(src.maxswordskill+src.maxthrowingskill))
src<<"You must increase your over-all level before training this skill further!"
return 0
else
if(src.swordexp>=src.swordexpnext)
src.JutsuCheck()
src.maxswordskill++
src.swordskill = src.maxswordskill
src.swordexp=0
src.swordexpnext+=7.5
if(src.swordexpnext>=7500)
src.swordexpnext=7500
src<<"<font color = red><font size =1><b>You have increased your Sword Skill to [src.maxswordskill]!</font></small></b>"


The problem im having is even if i put a cap on the sword leveling it will go past 20,000..I'm not sure if I'm missing something here.. please help.. Thanks.

How far over 20,000 is it going?

Also, be careful. You actually have another problem you might not know about yet. What happens if a player gets enough exp from a single attack he levels up twice? This will only level him once.
In response to Zecronious
if(src.maxswordskill>=20000)

Im trying to make it so that once they reach 20,000 they cannot go any further...


The player hits swords stumps to gain these levels I use another coding for Mob leveling.
In response to Stikk0
You said it's going over 20,000. By how much is it going over? 20,001? 20,002 ?
In response to Zecronious
Yeah it keeps going past 20k. Even if i set it to cap at 20k the amount continues to go past it
In response to Stikk0
Best response
Man, do I need to ask a third time? By how much? Are people able to go over by 1, more than one? Infinitely?
You're adding maxswordskill before calling LevelupSword(). So regardless of what the amount is, it's going to add that and then calculate if it's over 20k. So you'll always be able to go past 20k. Add the value you were going to increase maxswordskill as an argument passed into LevelupSword() and then calculate, if it is going to go past 20k just set it at 20k and end LevelupSword(). If it's not going to go past 20k continue on.


1. Did Something to earn EXP.
2. Get maxswordskill-earned and call LevelupSword(maxswordskill earned value)
3. Is maxswordskill + maxswordskill-earned >= 20k? Cool, set maxswordskill to 20k and end. If not, add maxswordskill-earned to max-swordskill and continue on with LevelupSword().
4. Done.
just add a
if(swordskill>=2000)
swordskill=2000

and add that to anything that will give sword skill and it will stop going over
Actually, switch() would probably be a much more efficient way to handle this.
Ill try both ways and let you know thank you
    if(src.swordskill>=10000)
src<<"You have reached the level cap."
return

i think thats it right but your problem is with the level.

mob/proc/LevelupSword()//       SWORD LEVELING
if(src.maxswordskill>=20000)
src << "You have reached the limit of your Sword-weilding ability!"
return 0
else if((src.level*2)<=(src.maxswordskill+src.maxthrowingskill))//this is where you problem is chance itto 2 and see what happens
src<<"You must increase your over-all level before training this skill further!"
return 0
else
if(src.swordexp>=src.swordexpnext)
src.JutsuCheck()
src.maxswordskill++
src.swordskill = src.maxswordskill
src.swordexp=0
src.swordexpnext+=15
if(src.swordexpnext>=7500)
src.swordexpnext=7500
src<<"<font color = red><font size =1><b>You have increased your Sword Skill to [src.maxswordskill]!</font></small></b>"
src.maxswordskill = min(src.maxswordskill+1, 20000)


I also suggest you to take this out
        src << "You have reached the limit of your Sword-weilding ability!"

It just spams the player's output screen for no reason. Then again, it's your game. Just giving my opinion.
There's a bigger design issue here, which is that I assume you have different exp and skill vars for each possible skill, and this code is repeated in many places. That's a great recipe for a bug.

I would suggest switching to a system where you use datums to keep track of skills. Create the datum as needed for each mob that needs it (but don't simply create it for all mobs, because some like NPCs don't need it).

skill
var/name
var/level=1, maxlevel=100
var/xp=0, xpnext=50

proc/AddXP(amount, mob/owner)
while(xp >= xpnext && level < maxlevel)
xp -= xpnext
xpnext = round(xpnext * 1.5), 1)
++level
++.
if(.)
owner << "Your [name] skill is now at level [level]."

That snippet includes an exponential rather than linear experience curve, because linear curves make very little sense, and has a saner max level.

As a general rule in all game design, if your level numbers can get as high as 20000, there is no way to balance anything properly. The lower range all stats can get, the easier time you'll have maintaining balance and keeping play fun, especially in multiplayer.
As a general rule in all game design, if your level numbers can get as high as 20000, there is no way to balance anything properly.

Citation needed.
In response to FKI
FKI wrote:
As a general rule in all game design, if your level numbers can get as high as 20000, there is no way to balance anything properly.

Citation needed.

Au contraire. The difficulty in balancing when you're dealing with numbers that differ by several orders of magnitude is obvious. Level 1 vs. level 20000 is going to look a lot different, if level has a direct impact on gameplay.

The only times I've seen high levels work reasonably well are when the level doesn't contribute much at all to the chance of winning a battle--at least past a certain point. There's a game I play that used to cap its level at 1000 (it recently dropped that cap), but once you've passed 100 you're really gaining very little; your stats stop increasing except at some 100x milestones, and you only gain a marginal increase to the chance of a bonus in each round. You also get some benefits from having played longer, where around the game world you may have accrued certain bonuses--but those bonuses are small, and while they do add up they don't get to the point where it's impossible for mid-level players to compete--although good luck to a newbie going after them. The difference between 500 and 1000 is largely about those side bonuses, and they don't add up to a ton.

Also look at a game like Skyrim. In the original game, prior to legendary skills, levels were capped at 81. There are upper limits on the strength of weapons, armor, etc.; those are in the double digits.

In Roguelike games--which are known to be extremely challenging--your core stats (not including HP) are always in the teens at best.

In every game you need a consistently decent level of challenge to keep things interesting. It's okay (even good) for the player to reach a point where they're dominating for a little while, and even to see formerly scary foes as insignificant--but if the challenge goes away for good, so does the fun. With stats that differ by many orders of magnitude, that's an exponentially harder design goal to meet--and if maintaining challenge isn't a design goal, you're doing game design all wrong.
Ah, I can agree then. Last post:

There's a game I play that used to cap its level at 1000 (it recently dropped that cap) [...]

What's the name of this game? I'd like to look more into their character progression.
In response to FKI
FKI wrote:
There's a game I play that used to cap its level at 1000 (it recently dropped that cap) [...]

What's the name of this game? I'd like to look more into their character progression.

It's called Gems of War; it's a casual freemium game. It's a match-3 with six colors and skulls, and the six colors represent different types of mana that your characters (4 of them) can gain to set off spells. It's a spiritual successor to Puzzle Quest: Challenge of the Warlords and is made by the same team. The game mixes match-3 with a card collection mechanic, where the cards are troops that can fight for you.

Progress is quite high during the first 100 levels. You gain stats frequently early on. Every time you level up, you get to increase the mastery of one type of mana (from a choice of two), and mastery increases the chance of a mana surge (double mana) from making a gem match. At level 100 you gain 1 to your magic stat, which impacts your hero character if they're a part of your team, and there are some other gains at 200, 300, 500, etc. IIRC, there's a magic gain at 1000 too but I haven't reached that yet.

Gems of War is a pretty interesting case study in how to keep a game fresh and interesting. When I joined the game things were very simple, and your options were limited. You had PVP which only gave you so much for benefits, quests and challenges in each kingdom--but you run out of those eventually--and the arena minigame where you try to win 8 rounds, with at most one loss, against other players where each of you has your hero and three other semi-random troops. Their first big update added a treasure hunt minigame, where you have a limited number of turns to build bigger treasures and can either keep your turn or get an extra with 4 or 5+ gem matches, respectively. They later added trait stones, which can be used to fill in three pre-defined traits (in order, and getting progressively more expensive) on your troops. Then they revamped PVP completely, making it a more interesting and challenging experience. They added an Explore option on each kingdom so you could play against interesting computer teams and try to earn specific trait stones. They updated player guilds to make them a lot better.

As of a few weeks ago, they changed their weekly events so that different troops get skill bonuses and you can earn rewards for using one of the week's new troops in battle or exploring or doing treasure hunts. Every week now is a different challenge, which makes the game a lot more interesting and also encourages people to change up their PVP teams--which were tending to stagnate around certain proven combos.

I rather suspect the design crew there takes a lot of their cues from MTG, because they listened to players and looked for ways to shake up the status quo.