Need advice on restricting class choice based on race

  • Nibiru
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
More
10 months 1 week ago #7227 by Nibiru
I'm running TBA 3.68 on windows 10.
I've added races using the snippet posted for an earlier version of TBA as a guide.
Now I want to restrict class choices based on race. What is the best way to accomplish this? I'm decent at hand patching but when it comes to creating something new I'm still very weak. If someone has done this this and can give me a brief outline of what you did I should be able to use it as a starting point. I've tried modifying class.c by setting up a case for each race but ran into issues getting the choices to display during character creation, this solution also did not prevent someone from choosing a class that is not permitted for the selected race.

Nibiru

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

More
10 months 1 week ago #7230 by WhiskyTest
I have a sneaky suspicion this was included in the D20 mud releases, but it seems the links are broken :(
If your google-fu is on point you might be able to track down source code for it.

Or someone else here might have a valid link?..

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

More
10 months 1 week ago #7233 by JTP
Im using:
int class_ok_race[NUM_RACES][NUM_CLASSES] = {
  /*            M, C, T, W */
  /* Human */ { Y, Y, Y, Y },
  /* Elf   */ { Y, Y, Y, N },
  /* Gnome */ { Y, Y, N, Y },
  /* Dwarf */ { N, Y, N, Y }
};

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

  • Nibiru
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
More
9 months 4 weeks ago #7278 by Nibiru
Thank you for the suggestion to use a table and take a look at the D20 versions. I downloaded one of the D20 versions (Rasputin) and the class.c file seems to have the solution I'm looking for. Other than interpreter.c, are there any other files I should take a close look at prior to patching the relevant sections from the rasputin version of class.c into the tba3.68 version of class.c?

Nibiru

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

More
9 months 4 weeks ago - 9 months 4 weeks ago #7279 by thomas
It's mostly those two - class.c for the definitions, interpreter.c for the usage.

Edit: and of course, the relevant .h files.
Last edit: 9 months 4 weeks ago by thomas.

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

  • Nibiru
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
More
6 months 3 weeks ago #7791 by Nibiru
I've got this partially in however I'm running into issue getting con_qclass to use my table.
I suspect I'm using the wrong syntax:
This is what I've done:
I created a table using JTP's suggestion in class.c
I added int class_ok_race[NUM_RACES][NUM_CLASSES]; in the list of external function prototypes in interpreter.h


I tried using the lines in interpreter.c from CWG rasputin for this function as a guideline but the few times I was able to get the code to recompile, the table was not used or everything was an invalid class.

So how do I rewrite this function to use the table I created?

case CON_QCLASS:
load_result = parse_class(*arg);
if (load_result == CLASS_UNDEFINED) {
write_to_output(d, "\r\nThat's not a class.\r\nClass: ");
return;
} else
GET_CLASS(d->character) = load_result;

Nibiru

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

More
6 months 3 weeks ago - 6 months 3 weeks ago #7792 by JTP
load_result = parse_class(*arg);
if (load_result == CLASS_UNDEFINED || !classRaceAllowed[GET_RACE(d->character)][load_result]) {
Last edit: 6 months 3 weeks ago by JTP.
The following user(s) said Thank You: Nibiru

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

  • Nibiru
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
More
6 months 3 weeks ago #7795 by Nibiru
Thank you,
Took a bit of fiddling but that worked. Just need to verify I didn't break anything and I can move this from test to live in the morning.

Nibiru

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

  • Nibiru
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
More
6 months 3 weeks ago #7798 by Nibiru
And I broke something:

The menu seems to be working, as it will only let you choose permitted race/class combinations, however this information is not getting written to the playerfiles.

When I create a test character either nothing is written in for class and the character is class 1 by default(The field for class is not created) or only class 1 is written to the playerfile.

If I use the set command I can set the correct class and it writes properly to the playerfile.

Any thoughts as to what I should look at next?
The files I made changes in are class.c, class.h, interpreter.c , interpreter.h and in an attempt to fix I added #include class.h to players.c

Nibiru

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

More
6 months 3 weeks ago #7810 by Chime
I did this as a work-around placeholder to accomplish the same basic idea. Charali, Hillish and Daravi can't be the Gentry or Nobility class, so if one of the three picked a restricted class it it sets them to the appropriate class instead:
if (IS_CHARALI(ch) && (IS_GENTRY(ch) || IS_NOBILITY(ch)))
  {GET_CLASS(ch) = 1;}
  send_to_char(ch, "Charali cannot be Gentry or Nobility. Class set to Freeman.")
  if (IS_HILLISH(ch) && (IS_GENTRY(ch) || IS_NOBILITY(ch)))
  {GET_CLASS(ch) = 1;}
  send_to_char(ch, "Hillmen cannot be Gentry or Nobility. Class set to Freeman.")
  if (IS_DARAVI(ch) && (IS_GENTRY(ch) || IS_NOBILITY(ch)))
  {GET_CLASS(ch) = 1;}
  send_to_char(ch, "Daravi cannot be Gentry or Nobility. Class set to Freeman.")

This is probably not an ideal or even intelligent way of handling it, but it's low impact. The only change required was in init_char.

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

  • Nibiru
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
More
6 months 3 weeks ago #7813 by Nibiru
Thank you Chime,
I like the simplicity of your suggestion, however I need to get the table I set up functioning for ease in making changes when I implement NPC races.

Nibiru

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

More
6 months 3 weeks ago #7823 by thomas

Nibiru wrote: And I broke something:

The menu seems to be working, as it will only let you choose permitted race/class combinations, however this information is not getting written to the playerfiles.


I think you might be missing the
GET_CLASS(d->character) = load_result;

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

  • Nibiru
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
More
6 months 2 weeks ago #7856 by Nibiru
That did the trick. :)
Thank you to everyone who gave advice.

Nibiru

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

Time to create page: 1.635 seconds