Re: races

From: Admin of The Keep (
Date: 10/13/96

On Sun, 13 Oct 1996, Brian Williams - Nashak wrote:

> I forgot what all you need to add to the code for races.. I had races a
> long time ago, but.. hey my memory is bad.. :P anyways.. could someone
> post the good old race.c, and a text of where to add everything?

  Never heard of race.c, myself, nor have I ever looked at any of the
  public releases of races; I just know how I do it...  The fun way... :)
  Short of my nifty race selection mode (anyone seen that?  heh, it's
  actually easier than many people think :)), it's fairly basic.

  I use a table instead of seperate strings, etc.  Like:

    struct race_data {
       char *name;
       char *abbrev;
       int mod_stats[6];

  For most MUDs this is an adequate representation of the use of races
  in the MUD...  Of course, it can get MUCH more complex (eg., my races
  have functions assigned to them, starting skills, etc., etc., etc.).
  Basically we have a format of:

    struct race_data Races[NUM_RACES] = {
      { "Human"		, "Hum", {  0,   0,   0,   0,   0,   0 } },
      { "Elf"		, "Elf", { -2,   2,   1,   1,  -2,   0 } }

  Presuming you have defined the following in 'structs.h':

    #define RACE_HUMAN		0
    #define RACE_ELF		1

    #define NUM_RACES		2

  Now you can make races modify stats (on my MUD races determine the roll
  of stats, max/min) by doing:

    ch->real_abils.str += Races[GET_RACE(ch)].mod_stats[0];
    ch-> += Races[GET_RACE(ch)].mod_stats[1];
    ch->real_abils.wis += Races[GET_RACE(ch)].mod_stats[2];
    ch->real_abils.dex += Races[GET_RACE(ch)].mod_stats[3];
    ch->real_abils.con += Races[GET_RACE(ch)].mod_stats[4];
    ch->real_abils.cha += Races[GET_RACE(ch)].mod_stats[5];

  Create your race selection code:

    -in "structs.h"-
    #define CON_QRACE			xx /* change 'xx' to first avail.
				            * nubmer */

    -in "interpreter.c" (I think?  I dunno, I moved nanny to a new file)-
    case CON_QRACE:
      for (x = 0; x < NUM_RACES; x++)
        if (is_abbrev(arg, Races[x].abbrev))
      if (x < 0 || x >= NUM_RACES) {
        send_to_char("That's an invalid race!\r\n", d->character);
        for (x = 0; x < NUM_RACES; x++) {
          sprintf(buf, "[%s] %s\r\n", Races[x].abbrev, Races[x].name);
          send_to_char(buf, d->character);
        SEND_TO_Q("Race: ", d);
      GET_RACE(ch) = x;

  You'll need to add support for display the races (as show just below
  "That's an invalid race!") to whatever con state you want to come
  before it and make CON_QRACE call the next con state, too.  Probably
  you'll want to add passing to CON_QRACE to CON_QSEX and then have
  CON_QRACE copy the code from the bottom of CON_QSEX that sends them
  to CON_QCLASS so you end up going from gender selection to race
  selection to class selection.

  BTW, you'll want to put:
    extern struct race_data Races[NUM_RACES];

  At the end of "structs.h" so that it's global to all files.

  "Forgive me father, for I am sin."

| Ensure that you have read the CircleMUD Mailing List FAQ: |
|   |

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