Hi, I’m wondering what to do for the EXP Formula, so whenever a player levels their XP capacity increases, e.g. Level 1 has a MaxXP of 50 to reach, then level 2 it increases to 75 and so on.

What formula should I use to calculate the MaxXP that needs to be reached per level?

There’s different formulas out there e.g.

MaxXP = PlayerLevel * 50 (I don’t know if this is good because imagine if a player is really high level)

I feel like a more linear formula would help if anyone could show how I can do so?

I think expressing levels as a function of time spent playing is a very good way to control the pacing of your game, especially if its an RPG like World of Warcraft or Runescape for example. If you do this then you have a basis for what your algorithm looks like. That’s a great starting point.

That said it’s not too difficult to come up with a decent algorithm. I typically like to create an algorithm that is can be determined with a single variable like level. Typically I also like to use logarithms to prevent exponential growth

Here’s one I came up with in just a minute or two.

local level = 1
local xp_for_level = math.ceil((level * (level / 12) * math.log((level + 1) ^ 2)) * 300)

With this, say you wanted a player to reach level 10 in an hour. Just take the total XP for the first 10 levels (41353 xp in my example) then divide by 60 to get what XP you should give at a minimum per minute to each player, assuming they’re doing something XP worthy. 41353 / 60 = 689.217 XP per minute. Now this shows that my algorithm really sucks, so you can make it better now!

can you explain to me the certain values in the algorithm ? for example what does the 12 represent and what does the ^ 2 represent, and what does the *300 represent, etc

I just sort of threw those in there to get a number that I felt looked nice at level 1 and level 100. They’re really just modifiers to make the number grow differently. You can play around with those or add more modifiers to make the algorithm generate the numbers you’re looking for.

how do you calculate the max_xp for each level for example lets say i wanted to make an xp system that could increase by more than 1 level how would i do that like lets say going up 5 levels

Assuming you’re setting the XP value to 0 + any extra after you level up each time?

I envision a set of functions like this:

local current_level = 1;
local current_xp = 40;
local function xp_needed_for_level(level: number)
return math.ceil((level * (level / 12) * math.log((level + 1) ^ 2)) * 300);
end
local function level_up()
local xp_for_level = xp_needed_for_level(current_level + 1);
local remaining_xp = current_xp - xp_for_level;
if (remaining_xp < 0) then
error('Cannot level up; not enough xp.');
return;
end
current_level += 1;
current_xp = 0;
award_xp(remaining_xp);
end
function award_xp(awarded_xp: number)
local xp_for_level = xp_needed_for_level(current_level + 1);
local xp = current_xp + awarded_xp;
if (xp >= xp_for_level) then
level_up();
end
end
award_xp(4000);