PDA

View Full Version : Calculating level



filthy_freak_
9th March 2014, 06:04
Hey,

I'm trying calculate a level based on total kills/xp using the Quadratic equation.

Example:
Level 1 = 50 (+50)
Level 2 = 150 (+100)
Level 3 = 300 (+150)
Level 4 = 500 (+200)

I have found the equations to do this (http://stackoverflow.com/questions/6954874/php-game-formula-to-calculate-a-level-based-on-exp) but i'm not sure how to translate that into the cod2 engine.

Can anyone give me an example that would work?

RobsoN
9th March 2014, 09:16
This should work:


level.rank[0] = 0;
max_rank = 20;

for(i = 1; i <= max_rank; i++)
{
level.rank[i] = level.rank[i-1] + 50*i
}


level.rank[RANK_VALUE] = shows you how many XP need for this rank.

IzNoGoD
9th March 2014, 09:42
lvl = 0;
xp_gain = 0
xp_increase = 50;
xp_level = 0;
while(xp_prev_level < self.xp)
{
xp_gain += xp_increase;
xp_level += xp_gain;
lvl++;
}

easy

filthy_freak_
9th March 2014, 10:27
This should work:


level.rank[0] = 0;
max_rank = 20;

for(i = 1; i <= max_rank; i++)
{
level.rank[i] = level.rank[i-1] + 50*i
}


level.rank[RANK_VALUE] = shows you how many XP need for this rank.

Working perfectly, thanks!