Re: [Circle] [Races] [Newbie] Compile Error

From: Brian Williams - Nashak (bmw@efn.org)
Date: 11/15/96


Well, due to all these bugs, I will post to the list my race code, here is
my hand made race.doc for all of you who are tired of buggy one =)

-=-=-=-=-=-=-=-=-=-
     structs.h
-=-=-=-=-=-=-=-=-=-

Search for:
#define CLASS_GIANT       5

Below it, add:
#define RACE_UNDEFINED   -1 
#define RACE_HUMAN        0 
#define RACE_ELF          1 
#define RACE_GNOME        2 
#define RACE_DWARF        3 

#define NUM_RACES         4 

Search for:
#define CON_DELCNF2      16             /* Delete confirmation 2        */

Below it, add:
#define CON_QRACE        17             /* Race?                        */ 

Search for:
struct char_player_data {
   char *name;         /* PC / NPC s name (kill ...  )         */
   char *short_descr;  /* for NPC 'actions'                    */
   char *long_descr;   /* for 'look'                           */
   char *description;  /* Extra descriptions                   */
   char *title;        /* PC / NPC's title                     */
   byte sex;           /* PC / NPC's sex                       */
   byte class;         /* PC / NPC's class                     */

Below it, add:
   byte race;          /* PC / NPC's race                      */ 

Search for:
struct char_file_u {
   /* char_player_data */
   char name[MAX_NAME_LENGTH+1];
   char description[EXDSCR_LENGTH];
   char title[MAX_TITLE_LENGTH+1];
   byte sex;
   byte class;

Below it, add:
   byte race; 

-=-=-=-=-=-=-=-=-=-
      utils.h
-=-=-=-=-=-=-=-=-=-

Search for:
#define CLASS_ABBR(ch) (IS_NPC(ch) ? "--" : class_abbrevs[(int)GET_CLASS(ch)])

Below it, add:
#define RACE_ABBR(ch) (IS_NPC(ch) ? "--" : race_abbrevs[(int)GET_RACE(ch)])

Search for:
#define GET_CLASS(ch)   ((ch)->player.class)

Below it, add:
#define GET_RACE(ch)    ((ch)->player.race)  

-=-=-=-=-=-=-=-=-=-
races.c(MAKE NEW FILE)
-=-=-=-=-=-=-=-=-=-
#include "sysdep.h"
#include "conf.h"

#include "structs.h"
#include "interpreter.h"
#include "utils.h"

const char *race_abbrevs[] = {   
  "Hum",                         
  "Elf",                         
  "Gno",                         
  "Dwa",                         
  "\n"                           
};                               
                                 
const char *pc_race_types[] = {  
  "Human",                       
  "Elf",                         
  "Gnome",                       
  "Dwarf",                       
  "\n"                           
};                               

/* The menu for choosing a race in interpreter.c: */ 
const char *race_menu =                              
"\r\n"                                               
"Select a race:\r\n"                                 
"  [H]uman\r\n"                                      
"  [E]lf\r\n"                                        
"  [G]nome\r\n"                                      
"  [D]warf\r\n";                                     

/*
 * The code to interpret a race letter (used in interpreter.c when a 
 * new character is selecting a race).                               
 */                                                                  
int parse_race(char arg)                                             
{                                                                    
  arg = LOWER(arg);                                                  
                                                                     
  switch (arg) {                                                     
  case 'h':                                                          
    return RACE_HUMAN;                                               
    break;                                                           
  case 'e':                                                          
    return RACE_ELF;                                                 
    break;                                                           
  case 'g':                                                          
    return RACE_GNOME;                                               
    break;                                                           
  case 'd':                                                          
    return RACE_DWARF;                                               
    break;                                                           
  default:                                                           
    return RACE_UNDEFINED;                                           
    break;                                                           
  }                                                                  
}                                                                    

long find_race_bitvector(char arg)                                   
{                                                                    
  arg = LOWER(arg);                                                  
                                                                     
  switch (arg) {                                                     
    case 'h':                                                        
      return (1 << 0);                     
      break;                                                         
    case 'e':                                                        
      return (1 << 1);                                                      
      break;                                                         
    case 'g':                                                        
      return (1 << 2);                                                      
      break;                                                         
    case 'd':                                                        
      return (1 << 3);                                                      
      break;                                                         
    default:                                                         
      return 0;                                                      
      break;                                                         
  }                                                                  
}                                                                    

-=-=-=-=-=-=-=-=-=-
     class.c
-=-=-=-=-=-=-=-=-=-

Search for:
  case CLASS_WARRIOR:
    ch->real_abils.str = table[0];
    ch->real_abils.dex = table[1];
    ch->real_abils.con = table[2];
    ch->real_abils.wis = table[3];
    ch->real_abils.intel = table[4];
    ch->real_abils.cha = table[5];
    if (ch->real_abils.str == 18)
      ch->real_abils.str_add = number(0, 100);
    break;
  }

Below it, add:
  switch (GET_RACE(ch)) {                       
    case RACE_HUMAN:                              
      break;                                        
    case RACE_ELF:                                
      ch->real_abils.dex += 1; 
      ch->real_abils.intel += 1;
      ch->real_abils.con -= 1;
      ch->real_abils.str -= 1;
      break;                                        
    case RACE_GNOME:                              
      ch->real_abils.intel += 1;
      ch->real_abils.wis -= 1;
      break;                                        
    case RACE_DWARF:
      ch->real_abils.con += 1;                              
      ch->real_abils.intel -= 1;
      ch->real_abils.cha -= 1;
      break;                                        
    default:
      break;
   }                                              

-=-=-=-=-=-=-=-=-=-
    constants.c
-=-=-=-=-=-=-=-=-=-
Search for:
  "Self-Delete 2",

Below it, add:
  "Select race",                        

-=-=-=-=-=-=-=-=-=-
       db.c
-=-=-=-=-=-=-=-=-=-

Search for:
  GET_CLASS(ch) = st->class;

Below it, add:
  GET_RACE(ch) = st->race;              

Search for:
  st->class = GET_CLASS(ch);

Below it, add:
  st->race = GET_RACE(ch);              

-=-=-=-=-=-=-=-=-=-
   interpreter.c
-=-=-=-=-=-=-=-=-=-

Search for:
  extern const char *class_menu;

Below it, add:
  extern const char *race_menu;   

Search for:
  int parse_class(char arg);

Below it, add:
  int parse_race(char arg);     

Search for:
  SEND_TO_Q(class_menu, d);
  SEND_TO_Q("Class: ", d);
  STATE(d) = CON_QCLASS;
  break;

Change it to:
  SEND_TO_Q(race_menu, d);
  SEND_TO_Q("Race: ", d);
  STATE(d) = CON_QRACE;
  break;

Below it, add:
  case CON_QRACE:
    load_result = parse_race(*arg);
    if (load_result == RACE_UNDEFINED) {
      SEND_TO_Q("\r\nThat's not a race.\r\nRace: ", d);
      return;
    } else
      GET_RACE(d->character) = load_result;

      SEND_TO_Q(class_menu, d);
      SEND_TO_Q("Class: ", d);
      STATE(d) = CON_QCLASS;
      break;

-=-=-=-=-=-=-=-=-=-
   act.wizard.c
-=-=-=-=-=-=-=-=-=-

Search for:
ACMD(do_set)
{
  int i, l;
  struct char_data *vict = NULL, *cbuf = NULL;
  struct char_file_u tmp_store;
  char field[MAX_INPUT_LENGTH], name[MAX_INPUT_LENGTH], val_arg[MAX_INPUT_LENGTH]
  int on = 0, off = 0, value = 0;
  char is_file = 0, is_mob = 0, is_player = 0;
  int player_i = 0;
  int parse_class(char arg);

Below it, add:
  int parse_race(char arg);

Search for:
   { "cha",             LVL_GRGOD,      BOTH,   NUMBER },

Below it, add:
   { "race",            LVL_GRGOD,      PC,     MISC },

Search for:
  case 47:
    if (IS_NPC(vict) || GET_LEVEL(vict) >= LVL_GRGOD)
      RANGE(3, 25);
    else
      RANGE(3, 18);
    vict->real_abils.cha = value;
    affect_total(vict);
    break;

Below it, add:
  case 48:
    if ((i = parse_race(*val_arg)) == RACE_UNDEFINED) {
      send_to_char("That is not a race.\r\n", ch);
      return;
    }
    GET_RACE(vict) = i;
    break;

-=-=-=-=-=-=-=-=-=-
     Makefile
-=-=-=-=-=-=-=-=-=-

Search for:
	objsave.o olc.o shop.o spec_assign.o spec_procs.o spell_parser.o \

Change it to:
	objsave.o olc.o races.o shop.o spec_assign.o spec_procs.o \
	spell_parser.o \

Search for:
random.o: random.c
	$(CC) -c $(CFLAGS) random.c

Below it, add:
races.o: races.c sysdep.h conf.h structs.h interpreter.h utils.h
	$(CC) -c $(CFLAGS) races.c

^^^^^^^^
***MAKE SURE THIS IS A <TAB> OR ELSE THE MAKEFILE WILL PRODUCE ERRORS!!!!!***


That's all you need. Simple, eh? Hope this helps... - Nashak


On Fri, 15 Nov 1996, Bri - Circle List wrote:

> > When trying to compile a pretty bare mud except for OasisOLC and a recently
> > to the letter added races system (From races.doc) I get this:
> I've been seeing a lot of messages complaining of bugs in races.doc.. the
> original creator may wanna recheck his/her code. I coded races myself..
> they're not too hard, just pretty much copy class code over to race
> variables and put one of the spares to race_value. Of course, some
> modifications need to be made, but it's not too hard..
> 
> Bri
> 
> +-----------------------------------------------------------+
> | Ensure that you have read the CircleMUD Mailing List FAQ: |
> |   http://cspo.queensu.ca/~fletcher/Circle/list_faq.html   |
> +-----------------------------------------------------------+
> 

            XXXXXXXXXXXXX             ////////////
           //XXXXXXXXXXX\\           ////////////
          ////XXXXXXXXX\\\\         ////////////
         //////XXXXXXX\\\\\\       ////////////
        ////////XXXXX\\\\\\\\     ////////////
       //////////XXX\\\\\\\\\\   ////////////
      //////////// \\\\\\\\\\\\ ////////////
     ////////////   \\\\\\\\\\XXX//////////           Brian Williams
    ////////////     \\\\\\\\XXXXX/////ashak          bmw@efn.org
   ////////////       \\\\\\XXXXXXX//////             mud.penguin.net 4000
  ////////////         \\\\XXXXXXXXX////
 ////////////           \\XXXXXXXXXXX//
////////////             XXXXXXXXXXXXX 


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



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