Re: [CODE] Race help

From: ;P (siv@CYBERENET.NET)
Date: 03/15/98


>     else if(load_result == RACE_HELP) {
>       page_string(d, race_help, 1);
>       SEND_TO_Q(race_menu, d);
>       STATE(d) = CON_QRACE;
>       break;
>     }

i've done something similar..i doubt it's the best way, but it does
exactly what i want..at the race menu, when someone types just '?' they
get a single help screen that shows the stat bonuses for the races (and
acts as a secondary menu)..if the player types '?<letter>' they get the
help file for that race..here's my code from interpreter.c and my
parse_race..that should give you an idea..

class.c:

int parse_race(char *arg, struct descriptor_data *d)
{
  int help_no = -1;
  *arg = LOWER(*arg);

  switch (*arg) {
  case 'a':
    return RACE_HUMAN;
    break;
  case 'b':
    return RACE_ELF;
.
.
[races snipped]
.
.
    break;
  case 'p':
    return RACE_FAIRY;
    break;
  case 'q':
    return RACE_YETI;
    break;
  case '?':
    *(arg + 1) = LOWER(*(arg + 1));
    switch (*(arg + 1)) {
      case 'a':
        sprintf(buf, "human");
        break;
      case 'b':
        sprintf(buf, "elf");
        break;
.
.
[races snipped]
.
.
        sprintf(buf, "fairy");
        break;
      case 'q':
        sprintf(buf, "yeti");
        break;
      default:
        return RACE_HELP;
    }
    break;
  default:
    return RACE_UNDEFINED;
    break;
  }

  help_no = find_help(buf);
  if (help_no > 1)
    SEND_TO_Q(help_table[help_no].entry, d);
  else {
    sprintf(buf1, "There is no help available on '%s'\r\n", buf);
    SEND_TO_Q(buf1, d);
  }

  return VIEWING_RACE_HELP;

}

interpreter.c:
  case CON_QRACE:
    load_result = parse_race(arg, d);
    if (load_result == RACE_UNDEFINED) {
      SEND_TO_Q("\r\nThat is not an option.\r\n", d);
      SEND_TO_Q(race_menu, d);
      SEND_TO_Q("\r\nRace: ", d);
    } else if (load_result == RACE_HELP) {
      SEND_TO_Q(race_help, d);
      SEND_TO_Q("\r\nRace: ", d);
    } else if (load_result == VIEWING_RACE_HELP) {
      STATE(d) = CON_V_RACE_HELP;
      SEND_TO_Q("\r\nPress Return When Finished.", d);
    } else {
      GET_RACE(d->character) = load_result;

      SEND_TO_Q("\r\nWhat is your class?", d);
      SEND_TO_Q(class_menu, d);
      SEND_TO_Q("\r\nClass: ", d);
      STATE(d) = CON_QCLASS;
    }
    break;

  case CON_V_RACE_HELP:
    SEND_TO_Q("\r\nWhat is your race?", d);
    SEND_TO_Q(race_menu, d);
    SEND_TO_Q("\r\nRace: ", d);
    STATE(d) = CON_QRACE;
    break;


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST