Avaz 1 Posted April 1, 2016 So I'm trying to design a leveling/xp system for an MP game mode, and i'm having issues figuring out how to do a scaling xp requirement for the next level, and also some general questions as i'm sure I could be doing this in a more optimal way. What i'm trying to do is similar to most games, you have a certain amount of experience to reach the next level, and the amount of experience required to level up increases slightly each time you level up, so level 2 = 100xp, level 3 = 150xp, level 5 = 225xp for example. The part I'm not sure with is actually figuring out how to calculate the amount of experience required for the next level, based on your own level. The amount of experience the player receives for different actions such as killing a player will be the same regardless of the level as well. When creating this system its also worth mentioning that stats will save to a database, or to the players profile, so at the moment I am saving the players total experience, and the players level. This is my first question I guess, I'm currently going with saving the players total experience/level, but i'm wondering if I should instead reset the experience to 0 as the level increases, as I imagine it would be easier that way? So far I have a script which is called to add experience to the player, and I'm currently checking if the player levels up in the same script. This is where my main issue is, as i'm unsure of what sort of calculation I should use to figure out the xp requirement for the next level, based on the players current level. I will also be displaying the experience on something like a progress bar so something like 1200/1500xp. I don't see this being difficult if the players current experience is reset to 0 each time they level up, but if its not reset to 0 and the only var is total experience I can see it being more complicated, which Is why I asked about it in the first place. Any help/feedback would be appreciated, thanks. Share this post Link to post Share on other sites
donelsarjo 60 Posted April 1, 2016 What i'm trying to do is similar to most games, you have a certain amount of experience to reach the next level, and the amount of experience required to level up increases slightly each time you level up, so level 2 = 100xp, level 3 = 150xp, level 5 = 225xp for example. The part I'm not sure with is actually figuring out how to calculate the amount of experience required for the next level, based on your own level. The amount of experience the player receives for different actions such as killing a player will be the same regardless of the level as well. use ln(XP) to calculate the level. When creating this system its also worth mentioning that stats will save to a database, or to the players profile, so at the moment I am saving the players total experience, and the players level. This is my first question I guess, I'm currently going with saving the players total experience/level, but i'm wondering if I should instead reset the experience to 0 as the level increases, as I imagine it would be easier that way? nope same difficulty if you check the function above. So far I have a script which is called to add experience to the player, and I'm currently checking if the player levels up in the same script. This is where my main issue is, as i'm unsure of what sort of calculation I should use to figure out the xp requirement for the next level, based on the players current level. I will also be displaying the experience on something like a progress bar so something like 1200/1500xp. I don't see this being difficult if the players current experience is reset to 0 each time they level up, but if its not reset to 0 and the only var is total experience I can see it being more complicated, which Is why I asked about it in the first place. maybe KilledEH: level = floor (ln(xp)) if (currlevel != level) then currlevel = level call fn_fancyeffect else do other stuff if it would be so selfexplainatory we would have a lot more sa matras running around :P Share this post Link to post Share on other sites
pedeathtrian 100 Posted April 1, 2016 use ln(XP) to calculate the level. This is cruel, assuming that The amount of experience the player receives for different actions such as killing a player will be the same regardless of the level as well. Most games use square root curve, that is level = floor(k * sqrt (exp)), where k is some constant. Given nth level, required expn = (n / k)2 And k is just 1 divided by square root of amount of exp required for 1st level-up: k = sqrt(1 / exp1) I assumed you start with level 0, which is most like not the case. For starting with level 1 replace n with n-1 where needed: level = floor(1+ k * sqrt (exp)); expn = ((n-1) / k)2 Let's say you start with level 1 and 100 exp points required to gain 2nd level. Then k = 0.1. Required exp for levels 2,3,4,10: exp2 = ((2-1) / 0.1)2 = 100; exp3 = ((3-1) / 0.1)2 = 400; exp4 = ((4-1) / 0.1)2 = 900; exp10 = ((10-1) / 0.1)2 = 8100; Assuming player has 450 points of experience, his level will be: level(450) = floor(1+ 0.1 * sqrt (450)) = floor (1+2.121) = 3; 2 Share this post Link to post Share on other sites
Avaz 1 Posted April 1, 2016 Thanks for the information guys, helps a lot. One thing I would like to ask though pedeathtrian if you wouldn't mind, would you track/save the current xp and lifetime xp separately? As i'm wanting the player to start each level at 0/whatever xp, I imagine it will be easier to keep track of current xp and reset it to 0 each time the player levels up. Share this post Link to post Share on other sites
pedeathtrian 100 Posted April 2, 2016 Thanks for the information guys, helps a lot. One thing I would like to ask though pedeathtrian if you wouldn't mind, would you track/save the current xp and lifetime xp separately? As i'm wanting the player to start each level at 0/whatever xp, I imagine it will be easier to keep track of current xp and reset it to 0 each time the player levels up. I'd save only total player exp since all other parameters can be calculated from it. They simply does not contain any new information. So you can store total exp, but show (calculated) progress for only next level-up. Let's continue example from previous post. Player has 450 points of experience (50 points ahead of level 3). Their level is calculated to be 3. Exp for levels 3 and 4 are 400 and 900 respectively (500 points for level-up). So you show 50/500. The only value to store is 450. Share this post Link to post Share on other sites
kennyleif 20 Posted September 6, 2017 Did you get a system functioning? Share this post Link to post Share on other sites
J0K3R 5 93 Posted September 7, 2017 Try this, not my work. Cant remember where I got it from. https://drive.google.com/open?id=0B7f7inkZ9lkaQkNSdFJ0cGZRaWM 1 Share this post Link to post Share on other sites
Larrow 2823 Posted September 9, 2017 On 9/7/2017 at 7:34 PM, kaysio said: Try this, not my work. Cant remember where I got it from. https://drive.google.com/open?id=0B7f7inkZ9lkaQkNSdFJ0cGZRaWM That was mine. Original post can be found HERE. 2 Share this post Link to post Share on other sites