Welcome to the Builder Academy

Question New Level System Idea

More
12 Nov 2012 00:33 #1025 by dfeigel71
Being a newbie coder, and still in my first semester of computer science, and am still learning the basics of programming. I really don't know a lot about C at this time but am working to learn it. So that being said I am not afraid to ask for a little help when unsure of anything. So here is what I would like to do, and what I have done. Maybe someone could be helpful on this enough to get me started in the right direct, but don't have to write the whole code for it if you prefer not to.

What I have done so far to my code. Added 12 races total. Change the classes from stock to a whole new 13 different class selections. Increased the max levels to 125 mortal levels.

Now, what I really don't want to do, is have to write exp tables for each level. Instead I would like to have this handled with a case switch function for each class/race combo.

I would just like to make a down and dirty but easy level system overall using the following formula.

(lvl * base * (lvl + 5) + (lvl * 125 * racemultiplier))


To explain the formula for those that might be unsure of what I am talking about:

lvl: the current level of the character.

base: this number will change dependent on what level range the character is at. For example level 1 to 9 will have a base multiplier of 250. Level 10 to 19 will have a base multiplier of 500, level 20 to 29 will have a multiplier of 1000, ect and ect.

racemultiplier: This will be a variable dependent on the race/class the player chooses. For example it would make sense to have a dwarf barbarian so we will give them a multiplier of 1, but it wouldn't make sense to have a pixie barbarian so they would get a higher multiplier of 13 due to the 13 races. The variable will all depend on what race you choose, so you could end up with a racemultiplier anywhere from 1 to 13.


Any help, or if you think you can whip up a basic code snippet that I may be able to edit and use for this problem, would be greatly appreciated.


Thank you in advance,

Dustin

Please Log in or Create an account to join the conversation.

More
12 Nov 2012 13:38 #1029 by Gahan
Replied by Gahan on topic Re: New Level System Idea
This is what I've done:

I've added a function; int exp_to_level(struct char_data *ch);

For what you need, you might not need to pass the entire character structure, but my system is relatively complex. You might be able to just pass an int for (GET_LEVEL(ch) and GET_RACE(ch)).

Here, you would do something like:
Code:
int exp_for_level(int ch_level, int ch_race) { int base = (put in your base value, or pick it from a struct); int expforlevel = 0; ch_level++; // make sure you're checking exp to level for next level expforlevel = (ch_level * base * (ch_level + 5) + (ch_level * 125 * racemultiplier[ch_race])); return (expforlevel); }

Now all you have to do from here on in, is anytime you want the value, is run that function and and it will tell you. You can go one step further, and take the expforlevel and have Your players current exp banked against it (which is what i do), so calculation = expforlevel - GET_EXP(ch) (this would require you to pass more of the character structure through the function though).

I hope this helps, let me know if you need any further clarification. After all it is like 8AM here, heh.

Please Log in or Create an account to join the conversation.

Time to create page: 0.239 seconds