my character has stats where if he kills an enemy . it reads whatever that person gets like this
if(usr.Exp == ExpNeed)
usr << "You Have Gained A Level"
usr.Exp = 0
usr.MHp += 5
usr.Level += 1
usr.Str += 2
usr.Def += 2
usr.ExpNeed += usr.ExpNeed + 20
everything works beautiful and the stats really work because it shows with the attacking, but the max exp is doubling it looks like
And with the number high , like if u start with 20 exp needed for next level, the 8th level it will have 620 needed for next level up.
Also with this problem, it looks like it stays that u only need 20 exp per level and that never goes up only the number (the variable isn't changing)
if anyone can help me with these 2 probs.. it would be greatly apprecitiated.
--DarkFireball
ID:149615
Mar 25 2002, 2:36 pm
|
|
In response to DarkFireball
|
|
Check out Nadrew's leveling system.
|
DarkFireball wrote:
my character has stats where if he kills an enemy . it reads whatever that person gets like thisHere's a tip. What if the user gets more Exp than needed? use: if(usr.Exp >= ExpNeed) usr << "You Have Gained A Level"Why not just do usr.ExpNeed += 20? |
In response to Nova2000
|
|
usr.ExpNeed += usr.ExpNeed + 20Why not just do usr.ExpNeed += 20? Because it wouldn't be the same thing. Say usr.ExpNeed is 100. usr.ExpNeed += [100] + 20 [100] += 100 + 20 100 += 120 = 220 usr.ExpNeed += 20 [100] += 20 = 120 |
In response to DarkFireball
|
|
DarkFireball wrote:
ok i got the words to go upp in the statspanel area for to show plus 20 experience, 20, 40, 60 etc, but the variable isnt changing so it takes 20 exp for every level to level up Here's the problem: You're using the ExpNeeded var to show what's left to go before you go to the next level, but then you're trying to double its old value from the last timed you leveled up. What you're really doubling is the current value, which will be 0 or less. If I read your code correctly, the line usr.ExpNeeded += usr.ExpNeeded+20 is intended to require 2x the old needed experience, plus another 20. However, the old needed experience is a value that's already gone; I believe you've subtracted from it every time you gained experience. So while you're trying to achieve a progression like 20, 60, 140, 300, etc., what you're really always getting is 20 because the line is interpreted at runtime as this: usr.ExpNeeded += 0 + 20 I believe what you need is either to keep a separate var, or use a formula. Separate var: usr.ExpForNextLevel += usr.ExpForNextLevel + 20 Formula (20, 60, 140, 300, 620...): usr.ExpNeeded = 20 * (2**usr.Level - 1) Probably a good idea in either case is to add Exp to ExpNeeded before you reset Exp to 0: usr.ExpNeeded = 20 * (2**usr.Level - 1) + usr.Exp That way if you overshoot on the experience, you'll have some of those points carry over toward the next level. You may not want to do it that way, but I think in most games it makes more sense. Lummox JR |
--DarkFireball