Re: Multi-Classes

From: Tim R. Yohn (yohnt@southwind.net)
Date: 06/08/96


On Sat, 8 Jun 1996, Mud wrote:

> I would like to look at those files as well if you don't mind :)

Heh... this is starting to get funny... That message was a mistake and
wasn't supposed to go to the list but since it did... here ya go... :)

Any questions send them this way I'll see what I can do...  This is only
the race stuff and if your interested in languages it's a little more
detailed (changes to do_say, and a new do_speak)...

I'll even add some comments so you can see some useless stuff that's only
good on my mud :)

I'll include a copy of my race.c here (It's not too big... :):
---------------------------------------------------------------------------
/* ************************************************************************
*   File: act.race.c                                    Part of CircleMUD *
*  Usage: Player-level race commands                                      *
*                                                                         *
*  All rights reserved.  See license.doc for complete information.        *
************************************************************************ */

#include "conf.h"
#include "sysdep.h"


#include "structs.h"
#include "utils.h"
#include "comm.h"
#include "interpreter.h"
#include "handler.h"
#include "db.h"
#include "screen.h"

/* extern variables */
extern struct room_data *world;
extern struct descriptor_data *descriptor_list;
extern struct char_data *character_list;

/* This dosn't do anything but make the hometown in 'do_who' show up as a
word instead of a number :) */

const char *pc_hometown[] = {
  "!RESERVED!",
  "Midgaard"
};

const char *pc_race_types[] = {
  "Human",
  "Elven",
  "Dwarven",
  "Gnome"
};

const char *race_abbrevs[] = {
  "Hu",
  "El",
  "Dw",
  "Gn"
};

const char *race_menu =
"\r\n"
"Select Race:\r\n"
"  [H]uman\r\n"
"  [E]lven\r\n"
"  [D]warven\r\n"
"  [G]nome\r\n";

const char *race_title[] = {
  "the Human",
  "the Elf",
  "the Dwarf",
  "the Gnome"
};

int parse_race(char arg)
{
  arg = LOWER(arg);

  switch(arg) {
  case 'h':
    return RACE_HUMAN;
    break;
  case 'e':
    return RACE_ELF;
    break;
  case 'd':
    return RACE_DWARF;
    break;
  case 'g':
    return RACE_GNOME;
    break;
  default:
    return RACE_UNDEFINED;
    break;
  }
}

/* I havn't implemented any code that uses this yet but I made a copy of
the class.c's find_class_bitvector for future use... */

long find_race_bitvector(char arg)
{
  arg = LOWER(arg);

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

void do_start_race(struct char_data *ch) {
 
  switch( GET_RACE(ch) ) {

  case RACE_HUMAN:
    SET_LANG(ch, LNG_COMMON, 1);        /* These just initalize what race*/ 
    SET_LANG(ch, LNG_ELVEN, 0);         /* has what languages. Curently*/
    SET_LANG(ch, LNG_DWARVEN, 0);       /* some of these are pointless.*/
    SET_NATIVE_LANG(ch, LNG_COMMON);    /* and you shouldn't have to set*/
    break;                              /* the languages to 0 they should*/
                                        /* already be 0 unless set to 1.*/
  case RACE_ELF:

    SET_LANG(ch, LNG_COMMON, 1);         
    SET_LANG(ch, LNG_ELVEN, 1);
    SET_LANG(ch, LNG_DWARVEN, 0);
    SET_NATIVE_LANG(ch, LNG_ELVEN);
    ch->real_abils.in = (ch->real_abils.in + 10); 
    ch->real_abils.st = (ch->real_abils.st - 10);
  /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
  /* These can be used to set bonuses for stats.  But I guess that's
pretty obvious.  Note: stats are diffrent on my system so these will need
to be changed :) */
    break;

  case RACE_DWARF:
    SET_LANG(ch, LNG_COMMON, 1);
    SET_LANG(ch, LNG_DWARVEN, 1);
    SET_LANG(ch, LNG_ELVEN, 0);
    SET_NATIVE_LANG(ch, LNG_DWARVEN);
    ch->real_abils.co = (ch->real_abils.co + 1);
    ch->real_abils.st = (ch->real_abils.st + 1);
    ch->real_abils.in = (ch->real_abils.in - 1);
    ch->real_abils.me = (ch->real_abils.me - 1);    
    break;

  case RACE_GNOME:
    SET_LANG(ch, LNG_COMMON, 1);
    SET_LANG(ch, LNG_GNOMISH, 1);
    SET_LANG(ch, LNG_ELVEN, 0);
    SET_NATIVE_LANG(ch, LNG_DWARVEN);
    ch->real_abils.in = (ch->real_abils.in + 1);
    ch->real_abils.me = (ch->real_abils.me - 1);    
    break;



  }
  ch->aff_abils = ch->real_abils;
  SET_CURRENT_LANG(ch, GET_NATIVE_LANG(ch));
  /* This wll just set the curent language to the native language, we
don't want people speaking '!RESERVED!' :) */
}
--------------------------------------------------------------------------

Ok, that's pretty straight forward.  Like I said our race system stems off
of our language system so some of that will be pointless :).

Some points of note (I'm taking it your an experianced coder so I'm not
gonna include all the files :):

You need a define for RACE_HUMAN, RACE_ELF... in structs.h... You'll also
wanna throw some macros in utils.h for GET_RACE(ch) (I can't provide
macros because my pfile has been changed so it's not gonna work on a
stock (or semi-stock) mud.).

And of course you need to add somewhere in the interpreter.c's nanny()
function a place to select your race.  It's almost an exact duplicate of
the class (see the menu at the top of the race.c above :) menu and is
called from nanny() just the same (I belive it has to be done before class
to work corectly, or other code in nanny has to be changed.  This also
requires adding another CON state (don't fogret to add a text description
of the CON_QRACE (or whatever you call it) into constants.c)

And if you have any questions (I just woke up and threw this together so
if you don't understand it sorry :) just ask.  It'd probably be better to
ask me directly since it is my code and I don't profess to be the worlds
greatest coder so some of it my not be the greatest.

Laters...

--
yohnt@southwind.net
Lost?



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