Re: [code] GET_CLASS for multiclassing...

From: peter dahlgren (
Date: 11/10/02

>I'm level 30 warrior. I change to Mage. Do you somehow save my warrior
>level, or do I just start from scratch as a level 0 mage with some
>weapon skills ? When I reach level 11 as a mage, I decide I wish to
>become a cleric. Will I just forget my mage spells ? If I decide to
>be a thief, too, will I be able to cast any spells at all ? What if
>I decided to go the other way and started as a thief ? Can I backstab ?

Well, i have made up GET_CLASS_LEVEL(ch, i) aswell, this will replace the use of GET_LEVEL(ch) in spell checks and such... GET_CLASS_LEVEL(ch, i) use the same [i] as GET_CLASS

>> and, how do i make it set all values to -1 except the first class...?

>In init_char, loop through the class array and set the class, like this:

>#define NUM_MULTICLASSES 6 /* for easier expansion if need be */
>int i;
>for (i = 0; i < NUM_MULTICLASSES; i++)

thanx, i'll do that :) but init_char is called after class is chosen, or so it says, so i made it int i = 1 instead to work from one pos above [0], if you get what i mean...

>Then, when the player has chosen a class, just set the first class:

>GET_CLASS(ch, 0) = ;

>Later on, and I guess you've discovered already, the most advanced
>bit of coding in this endavour goes into the 'gain' part.

yeah, i figured, i wanted to use search_cur_class to find the current position in the array for the player to gain mana, move and such, exp tables will be the same for all classes, some penalties will be added later.

>if (GET_LEVEL(ch) < SINFO.min_level[(int) GET_CLASS(ch)]) {
>send_to_char(ch, "You do not know that spell!\r\n");

>Transform this to work with an array:

>int i, can_cast = FALSE;
>for (i = 0; i < NUM_MULTICLASSES; i++) {
>/* save cpu time */
>if (GET_LEVEL(ch) > SINFO.min_level[(int) GET_CLASS(ch, i)])
>can_cast = TRUE;
>if (!can_cast) {
>send_to_char(ch, "You do not know that spell!\r\n");

With the GET_CLASS_LEVEL(ch, i), should i put that in instead of GET_LEVEL(ch) there?

>As you can see, I'm stubbornly refusing to work with magic numbers.
>Putting 'raw' numbers into your code will make it harder for you
>to debug later, as well as making it near impossible for others
>to understand if we're asked to help.

i'll change those immedietly, i just experimented a little, i didn't think of the defines :)

oh, one more thing, if a player leaves the mage class at level 15 to work on warrior, he can't go back to mage, he'll always be mage 15/warrior 30 for example

and one more thing, GET_LEVEL(ch) will still exist as it does now, for exp tables use and such...

but do_advance and do_set level is kinda messed up with this, if the player is advanced, the class level goes up in the same rate as level... but if he's demoted, to prevent negative class levels, i need to put in a function that removes classes from the array if the class level goes below 0...

one more thing, to make it easier for you to see... when a player chooses to change class to level up, he gains that class, but it is level 0, and gains 1 level the next time he gains one level...


Gratis e-mail resten av livet på:

   | FAQ: |
   | Archives: |
   | Newbie List:   |

This archive was generated by hypermail 2b30 : 06/25/03 PDT