This question may already have been asked, but, nonetheless, what would an example formula be for getting the current level from the total amount of EXP a player has? As in the variable that's known is the EXP, the one I'm trying to get from the formula is the current level.
\$\begingroup\$
\$\endgroup\$
4
-
\$\begingroup\$ You want to find a good level <=> EXP formula? As in, how much EXP should I get to get to lv2, lv3, ..., lv56, ..., lvN? \$\endgroup\$Vaillancourt– Vaillancourt ♦2015-10-15 01:38:16 +00:00Commented Oct 15, 2015 at 1:38
-
\$\begingroup\$ I want an example of a Total EXP > Level formula, as in - finding what level the character is from the total EXP they have. \$\endgroup\$Quadryc– Quadryc2015-10-15 01:42:08 +00:00Commented Oct 15, 2015 at 1:42
-
\$\begingroup\$ Why do you need this? I would suggest you find the exp/level curve from popular games/MMOs if this fits your needs (Diablo III paragon, WoW, etc..). \$\endgroup\$Vaillancourt– Vaillancourt ♦2015-10-15 01:51:23 +00:00Commented Oct 15, 2015 at 1:51
-
4\$\begingroup\$ one, two, three, four; here \$\endgroup\$Exerion– Exerion2015-10-15 06:32:49 +00:00Commented Oct 15, 2015 at 6:32
Add a comment
|
1 Answer
\$\begingroup\$
\$\endgroup\$
There isn't really a best way to do this, so I'll give you one way it could be done. Assuming you had experience represented as a number you would want to:
- Define an experience curve you're going to want to use. Normally subsequent levels take increasing amounts of experience to reach.
- In your game have a map data structure that maps an experience value to a given level based on your curve.
- Find the map key closest to but not over the current experience value. Display the mapped level as your current level.
Example experience curve.
var experience_curve = {};
experience_curve['0'] = 1;
experience_curve['100'] = 2;
experience_curve['300'] = 3;
experience_curve['700'] = 4;
experience_curve['2100'] = 5;
Bonus: To display progress towards the next level.
- Find the map key closest to but not over the current experience value
- Subtract the key found in 1. from the next map key, this is how much total xp is needed for the next level.
- Subtract 1. from the player's current experience value, this is how much progress has been made into the next level.
- Divide 3. by 2. and you now have the percentage of how far you are into the level.