Re: [CODe] races again and WHO command

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


Change the 1 << 5.. << 6 << 7 << 8 to << 1 << 2 << 3 << 4... because race
bitvectors look for a different number.. they look for RACE_.. not
CLASS_.. so the races would think that there were no races.. because they
were looking for a race with the number being 5 6 7 8... instead of 1 2 3
4.... anyways.. hope I helped.. if you want to add races.. here is my
race.doc that I made.. =):
-=-=-=-=-=-=-=-=-=-
     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



		 	   |-\ \            / /
			    \ \ \          /<
			     \ \-|        /  \
                              ..... asha .....
				bmw@efn.org
			      mud.penguin.net
				    4000

On Tue, 22 Oct 1996, Peter Hartman wrote:

> Well this time i got the who to work in alongside with races .  HOWVER
> this is  the  catch22: all charcters are now level one (as in no wizards
> as in i cant make myself as wizard)...  first I'll say what i did to
> class.c to get it to work and nuke all players and maybe someone will
> have an idea.
> 
> /*
>  * bitvectors (i.e., powers of two) for each class, mainly for use in
>  * do_who and do_users.  Add new classes at the end so that all classes
>  * use sequential powers of two (1 << 0, 1 << 1, 1 << 2, 1 << 3, 1 << 4,
>  * 1 << 5, etc.
>  */
> 
> long find_class_bitvector(char arg)
> {
>   arg = LOWER(arg);
> 
>   switch (arg) {
>     case 'm':
>       return (1 << 0);
>       break;
>     case 'c':
>       return (1 << 1);
>       break;
>     case 't':
>       return (1 << 2);
>       break;
>     case 'w':
>       return (1 << 3);
>       break;
>     case 'b':
>       return (1 << 4);
>       break;
>     default:
>       return 0;
>       break;
>   }
> }
> 
> /* [WART] */
> long find_race_bitvector(char arg)
> {
>   arg = LOWER(arg);
>   
>   switch (arg) {
>     case 'h':
>       return (1 << 5);
>       break;
>     case 'e':
>       return (1 << 6);
>       break;
>     case 'g':
>       return (1 << 7);
>       break;
>     case 'f':
>       return (1 << 8);
>       break;
>     default:
>       return 0;
>       break;
>   }
> }
> 
> 
> In the long find_race_bitvector the races.doc said to make it 'h':
> return 1 :: e return 2 :: g return 4 :: and f return 8 but this resulted
> in NO WHO or USERS command.   So i made it like it is.  Is this the
> source of the prob?  as in have i fixed it? 
> Now if i have fixed it (so that i CAN do a WHO and CAN have races at
> same time) how do i get atleast one account system admin (or wizard)
> status?  Thanks for ANY help :-).  I appreciate this emailing list for
> its service!  
> 
> wart <hartman@kuntrynet.com>
> +-----------------------------------------------------------+
> | Ensure that you have read the CircleMUD Mailing List FAQ: |
> |   http://cspo.queensu.ca/~fletcher/Circle/list_faq.html   |
> +-----------------------------------------------------------+
> 

+-----------------------------------------------------------+
| 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