05 Nov, 2013, Grieffels wrote in the 1st comment:
Votes: 0
Ok, basically im going to set my TNL up from a table instead of points/points chosen.

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?
05 Nov, 2013, Nathan wrote in the 2nd comment:
Votes: 0
I know that I'm not that familiar with Diku/Rom, etc, but this seems kind of vague. TNL is experience to reach the next level, yes?

I take it you are doing some kind of on the fly struct initialization there in that "table" bit?

If the experience for reaching the next level isn't always the same and isn't some calculation, you could use a array of size 100 (0-99) and just store the required amount to reach that level in the slot (i.e. if level 5 takes 10000 total experience then TNL[5] = 10000;). If it can be calculated or is exponential just use a formula instead of stored data.

for (i = ch->level; i < 99; i++)  { 
ch->exp = classexp_table .tnl;
}


What is this code supposed to do? Why are you starting with a character's level and incrementing up until you reach 99 and storing, presumably a value from the "table" as their experience?
05 Nov, 2013, plamzi wrote in the 3rd comment:
Votes: 0
Here's a start (untested):

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;
}


You can tweak the curve slightly by changing "factor", and heavily by removing or adding "* j"s.
05 Nov, 2013, quixadhal wrote in the 4th comment:
Votes: 0
Are you trying to get rid of the "level" element entirely, and just have it use the experience table?

If so, and assuming your table is always sorted…

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;
}


EDIT: Oh, that's right… ROM doesn't do cumulative EXP, does it? The above would be for each level saying what total XP you need (like DikuMUD).

You could just keep an accumulator and invert the loop:

IE:
total += classexp_table[i].tnl;
and then compare against that instead of the table itself.
05 Nov, 2013, Grieffels wrote in the 5th comment:
Votes: 0
I'm just trying to get rid of how it grabs how much till you level and use a table based setup.
This way, it'll grab what level they are, find it, pull from the table, what int tnl is compared
to what exp they've gained. There are several pieces to this in ROM.
05 Nov, 2013, Nathan wrote in the 6th comment:
Votes: 0
You may want to typedef 'struct classexp_type' to just be 'classexp_type':

typedef struct classexp_type { 
int charlevel;
int tnl;
} classexp_type;


So that your other code can be:

const classexp_type classexp_table[MAX_PLAYER_LEVEL] =  {
{1,1000},
{2, 3000},
{3, 1000},
{4, 4000}
};


^ assuming the above is valid C.

So, like this?:

int level = 0;
int xp = 0;

for( level = 0; level < (ch->level); level++ ) {
xp += classexp_table[level].tnl;
}

return classexp_table[level + 1] - xp;


Of course the above assumes a progression like this:

Lvl XP
0 0
1 1000 (L:0 + 1000)
2 4000 (L:1 + 3000)
3 10000 (L:2 + 6000)
4 19000 (L:3 + 9000)
5 31000 (L:4 + 12000)

where the next levels xp to level includes the previous quantity.

or just stick to a plain old integer indexed int array, as noted before, where the index/key is the level and the stored value is the total experience to reach that level.
0.0/6