for (i = ch->level; i < 99; i++) {
ch->exp = classexp_table .tnl;
}
int j, factor = 24;
classexp_table[0].tnl = 0;
for (j = 1; j <= MAX_PLAYER_LEVEL; j++) {
classexp_table[j].tnl = factor * j * j * j * j;
}
int player_level( CHAR_DATA *ch ) {
int i;
for(i = MAX_PLAYER_LEVEL-1; i >= 0; i–) {
if(ch->exp >= classexp_table[i].tnl )
return i+1;
}
return 1;
}
total += classexp_table[i].tnl;and then compare against that instead of the table itself.
typedef struct classexp_type {
int charlevel;
int tnl;
} classexp_type;
const classexp_type classexp_table[MAX_PLAYER_LEVEL] = {
{1,1000},
{2, 3000},
{3, 1000},
{4, 4000}
};
int level = 0;
int xp = 0;
for( level = 0; level < (ch->level); level++ ) {
xp += classexp_table[level].tnl;
}
return classexp_table[level + 1] - xp;
I have the structure setup in merc.h
struct classexp_type
{
int charlevel;
int tnl;
};
I have my table in another file. I'm just going to list 4 levels even though there are 99.
const struct classexp_type classexp_table [MAX_PLAYER_LEVEL] =
{
{1,1000},
{2, 3000},
{3, 1000},
{4, 4000}
};
How would I start with getting it to work? I know where all the calls for the points and ch->exp are
so the problem now is making it so each time the character levels, it does the check, pulls what level
the char is from the table and uses that level of tnl.
for (i = ch->level; i < 99; i++)
{
ch->exp = classexp_table .tnl;
}
I spaced because it wont register for some reason if I dont space it here.
I know this isn't correct but it's close. Anyone care to help me with this?