Welcome to the Builder Academy

Question Need advice on restricting class choice based on race

More
24 Mar 2018 22:40 - 24 Mar 2018 22:46 #7792 by JTP
load_result = parse_class(*arg);
if (load_result == CLASS_UNDEFINED || !classRaceAllowed[GET_RACE(d->character)][load_result]) {
Last edit: 24 Mar 2018 22:46 by JTP.
The following user(s) said Thank You: Nibiru

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

More
25 Mar 2018 00:32 #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.

More
25 Mar 2018 13:37 #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
26 Mar 2018 18:59 #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:
Code:
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.

More
27 Mar 2018 17:12 #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
28 Mar 2018 22:18 #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
Code:
GET_CLASS(d->character) = load_result;

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

Time to create page: 0.336 seconds