From: Brett Helgeson <varagol@netcom.com>
Subject: Races.doc for 2.20 code
Many, many thanks to Lupo for sharing the code with me - it saved
me much time, and gave me a good, stable base. Without further ado, here
it is:
Here comes what I've done for races. It's just basic stuff, I'll perhaps
improve it later, but It's a good starting point:
1- in structs.h, I've added:
#define RACE_HUMAN 0
#define RACE_DWARF 1
#define RACE_ELF 2
#define RACE_HOBBIT 3
#define RACE_TROLL 4
In the char_specials2_data, instead of
ubyte spare0;
I've put
ubyte race;
2- in utils.h,
#define GET_RACE(ch) ((ch)->specials2.race)
3- in constants.c,
I've added:
const char *pc_race_type[] = {
"Humans",
"Dwarves",
"Elves",
"Hobbits",
"Trolls",
"\n"
};
and
const int race_apply[5][5] = {
{0,0,0,0,0},
{0,0,0,-1,+1},
{0,0,0,+1,-1},
{-1,0,0,+1,0},
{+2,-1,-1,0,0}
};
This one is for affecting stats (str int wis dex con)
and
const int race_phy_apply[5][2] = {
{0,0},
{-70,-50},
{-20,-40},
{-100,-100},
{30,50}
};
affects races height and weight ...
3- in interpreter.c,
Add question about choosing race (see how it's done for classes, and just
do the same ).
You'll surely need to add #define CON_QRACE 18 in structs.h
4- in act.wizard.c,
in roll_abilities, here is what I've done:
case CLASS_WARRIOR:
ch->abilities.str = table[0];
ch->abilities.dex = table[1];
ch->abilities.con = table[2];
ch->abilities.wis = table[3];
ch->abilities.intel = table[4];
break;
}
/* Races Modifications (Ludo) */
ch->abilities.str = ch->abilities.str + race_apply[GET_RACE(ch)][0];
ch->abilities.intel = ch->abilities.intel + race_apply[GET_RACE(ch)][1];
ch->abilities.wis = ch->abilities.wis + race_apply[GET_RACE(ch)][2];
ch->abilities.dex = ch->abilities.dex + race_apply[GET_RACE(ch)][3];
ch->abilities.con = ch->abilities.con + race_apply[GET_RACE(ch)][4];
if (ch->abilities.str>18) {ch->abilities.str=18;ch->abilities.str_add = number(0, 100);};
if (ch->abilities.intel>18) ch->abilities.intel=18;
if (ch->abilities.wis>18) ch->abilities.wis=18;
if (ch->abilities.dex>18) ch->abilities.dex=18;
if (ch->abilities.con>18) ch->abilities.con=18;
ch->tmpabilities = ch->abilities;
}
5- in dc.c,
in init_char,
if (ch->player.sex == SEX_MALE) {
ch->player.weight = number(120, 180);
ch->player.height = number(160, 200);
} else {
ch->player.weight = number(100, 160);
ch->player.height = number(150, 180);
}
/* modifications according to the race */
ch->player.weight=ch->player.weight + race_phy_apply[GET_RACE(ch)][1];
ch->player.height=ch->player.height + race_phy_apply[GET_RACE(ch)][0];
Thanks to Ludo for sharing.