Leveling Characters

(1/1)

**Richard Marks**:

Balancing your character's growth is a difficult task, and this is one method that I've used in the past.

Experience Points Needed to Level Up = G

Current Experience Points = X

Current Experience Level = L

Rate of Growth = R

The Growth Formula is

G = X * L ^ log(R) / log(2)

My example below uses a rate of growth of 1.739 (arbitrary number that I chose to use after lots of testing)

The index * 75 part is the current experience multiplier.

Each level the character's level is multiplied by 75 to get the current experience.

Code:

#define MAXIMUM_CHARACTER_LEVEL 100

unsigned long nextLevel[MAXIMUM_CHARACTER_LEVEL];

void InitializeLevelingRequirements()

{

for (int index = 0; index < MAXIMUM_CHARACTER_LEVEL; index++)

{

nextLevel[index] = static_cast<unsigned long>((index * 75) * powf(index, (logf(1.739f) / logf(2))));

}

}

Now some code to see if we have leveled up (call this at the end of a battle)

Code:

void LevelUp()

{

if (currentLevel < MAXIMUM_CHARACTER_LEVEL - 1)

{

if (currentExperience >= nextLevel[currentLevel + 1])

{

// level up!

// increase your character's stats how you want to

}

}

}

**Richard Marks**:

For the curious, here are the values for the code above:

Code:

Level 1: The XP needed to gain Level 2 is 75

Level 2: The XP needed to gain Level 3 is 260 a difference of 185

Level 3: The XP needed to gain Level 4 is 540 a difference of 280

Level 4: The XP needed to gain Level 5 is 907 a difference of 367

Level 5: The XP needed to gain Level 6 is 1355 a difference of 448

Level 6: The XP needed to gain Level 7 is 1880 a difference of 525

Level 7: The XP needed to gain Level 8 is 2481 a difference of 601

Level 8: The XP needed to gain Level 9 is 3155 a difference of 674

Level 9: The XP needed to gain Level 10 is 3899 a difference of 744

Level 10: The XP needed to gain Level 11 is 4713 a difference of 814

Level 11: The XP needed to gain Level 12 is 5594 a difference of 881

Level 12: The XP needed to gain Level 13 is 6541 a difference of 947

Level 13: The XP needed to gain Level 14 is 7554 a difference of 1013

Level 14: The XP needed to gain Level 15 is 8631 a difference of 1077

Level 15: The XP needed to gain Level 16 is 9771 a difference of 1140

Level 16: The XP needed to gain Level 17 is 10974 a difference of 1203

Level 17: The XP needed to gain Level 18 is 12238 a difference of 1264

Level 18: The XP needed to gain Level 19 is 13563 a difference of 1325

Level 19: The XP needed to gain Level 20 is 14948 a difference of 1385

Level 20: The XP needed to gain Level 21 is 16392 a difference of 1444

Level 21: The XP needed to gain Level 22 is 17895 a difference of 1503

Level 22: The XP needed to gain Level 23 is 19457 a difference of 1562

Level 23: The XP needed to gain Level 24 is 21076 a difference of 1619

Level 24: The XP needed to gain Level 25 is 22752 a difference of 1676

Level 25: The XP needed to gain Level 26 is 24486 a difference of 1734

Level 26: The XP needed to gain Level 27 is 26275 a difference of 1789

Level 27: The XP needed to gain Level 28 is 28120 a difference of 1845

Level 28: The XP needed to gain Level 29 is 30020 a difference of 1900

Level 29: The XP needed to gain Level 30 is 31976 a difference of 1956

Level 30: The XP needed to gain Level 31 is 33986 a difference of 2010

Level 31: The XP needed to gain Level 32 is 36050 a difference of 2064

Level 32: The XP needed to gain Level 33 is 38168 a difference of 2118

Level 33: The XP needed to gain Level 34 is 40340 a difference of 2172

Level 34: The XP needed to gain Level 35 is 42565 a difference of 2225

Level 35: The XP needed to gain Level 36 is 44842 a difference of 2277

Level 36: The XP needed to gain Level 37 is 47173 a difference of 2331

Level 37: The XP needed to gain Level 38 is 49555 a difference of 2382

Level 38: The XP needed to gain Level 39 is 51989 a difference of 2434

Level 39: The XP needed to gain Level 40 is 54476 a difference of 2487

Level 40: The XP needed to gain Level 41 is 57013 a difference of 2537

Level 41: The XP needed to gain Level 42 is 59602 a difference of 2589

Level 42: The XP needed to gain Level 43 is 62241 a difference of 2639

Level 43: The XP needed to gain Level 44 is 64932 a difference of 2691

Level 44: The XP needed to gain Level 45 is 67672 a difference of 2740

Level 45: The XP needed to gain Level 46 is 70463 a difference of 2791

Level 46: The XP needed to gain Level 47 is 73304 a difference of 2841

Level 47: The XP needed to gain Level 48 is 76194 a difference of 2890

Level 48: The XP needed to gain Level 49 is 79134 a difference of 2940

Level 49: The XP needed to gain Level 50 is 82123 a difference of 2989

Level 50: The XP needed to gain Level 51 is 85162 a difference of 3039

Level 51: The XP needed to gain Level 52 is 88249 a difference of 3087

Level 52: The XP needed to gain Level 53 is 91385 a difference of 3136

Level 53: The XP needed to gain Level 54 is 94570 a difference of 3185

Level 54: The XP needed to gain Level 55 is 97802 a difference of 3232

Level 55: The XP needed to gain Level 56 is 101083 a difference of 3281

Level 56: The XP needed to gain Level 57 is 104412 a difference of 3329

Level 57: The XP needed to gain Level 58 is 107789 a difference of 3377

Level 58: The XP needed to gain Level 59 is 111214 a difference of 3425

Level 59: The XP needed to gain Level 60 is 114685 a difference of 3471

Level 60: The XP needed to gain Level 61 is 118204 a difference of 3519

Level 61: The XP needed to gain Level 62 is 121771 a difference of 3567

Level 62: The XP needed to gain Level 63 is 125384 a difference of 3613

Level 63: The XP needed to gain Level 64 is 129044 a difference of 3660

Level 64: The XP needed to gain Level 65 is 132751 a difference of 3707

Level 65: The XP needed to gain Level 66 is 136504 a difference of 3753

Level 66: The XP needed to gain Level 67 is 140304 a difference of 3800

Level 67: The XP needed to gain Level 68 is 144150 a difference of 3846

Level 68: The XP needed to gain Level 69 is 148041 a difference of 3891

Level 69: The XP needed to gain Level 70 is 151979 a difference of 3938

Level 70: The XP needed to gain Level 71 is 155963 a difference of 3984

Level 71: The XP needed to gain Level 72 is 159993 a difference of 4030

Level 72: The XP needed to gain Level 73 is 164068 a difference of 4075

Level 73: The XP needed to gain Level 74 is 168188 a difference of 4120

Level 74: The XP needed to gain Level 75 is 172354 a difference of 4166

Level 75: The XP needed to gain Level 76 is 176565 a difference of 4211

Level 76: The XP needed to gain Level 77 is 180821 a difference of 4256

Level 77: The XP needed to gain Level 78 is 185122 a difference of 4301

Level 78: The XP needed to gain Level 79 is 189467 a difference of 4345

Level 79: The XP needed to gain Level 80 is 193858 a difference of 4391

Level 80: The XP needed to gain Level 81 is 198293 a difference of 4435

Level 81: The XP needed to gain Level 82 is 202772 a difference of 4479

Level 82: The XP needed to gain Level 83 is 207296 a difference of 4524

Level 83: The XP needed to gain Level 84 is 211864 a difference of 4568

Level 84: The XP needed to gain Level 85 is 216476 a difference of 4612

Level 85: The XP needed to gain Level 86 is 221133 a difference of 4657

Level 86: The XP needed to gain Level 87 is 225833 a difference of 4700

Level 87: The XP needed to gain Level 88 is 230577 a difference of 4744

Level 88: The XP needed to gain Level 89 is 235365 a difference of 4788

Level 89: The XP needed to gain Level 90 is 240196 a difference of 4831

Level 90: The XP needed to gain Level 91 is 245071 a difference of 4875

Level 91: The XP needed to gain Level 92 is 249990 a difference of 4919

Level 92: The XP needed to gain Level 93 is 254951 a difference of 4961

Level 93: The XP needed to gain Level 94 is 259956 a difference of 5005

Level 94: The XP needed to gain Level 95 is 265004 a difference of 5048

Level 95: The XP needed to gain Level 96 is 270096 a difference of 5092

Level 96: The XP needed to gain Level 97 is 275230 a difference of 5134

Level 97: The XP needed to gain Level 98 is 280407 a difference of 5177

Level 98: The XP needed to gain Level 99 is 285627 a difference of 5220

Level 99: The XP needed to gain Level 100 is 290889 a difference of 5262

Navigation

[0] Message Index