Re: [Code]Race Specific Spells

From: Robert Sinland (rsinland@ERSKINE.POLARISTEL.NET)
Date: 08/31/97


J.T. wrote:
>
> I have been trying to get particular races to start with certain spells
> and skills like classes, I copied the code in spell_parser.c and set it
> up for races, added everything to races.c and spells.h, but it still
> won't work. Anyone got any ideas of what I am doing wrong or what I
> could do to make this work? I would appreciate any suggestions or ideas.
> Thanks in advance.
>
>      +------------------------------------------------------------+
>      | Ensure that you have read the CircleMUD Mailing List FAQ:  |
>      | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
>      +------------------------------------------------------------+


Here's how I did it for infravision.  You could maybe use some of this
as a starting point.


Infra for non-magic user non-humans

First, in utils.h add this

#define IS_RACE_INFRA(ch) (IS_ELF(ch) || IS_DROW(ch) || IS_GNOME(ch) ||
\
   IS_DWARF(ch) || IS_HALFELF(ch) || IS_HALFORC(ch))

 adjust for whatever your races are.

   In class.c

      case RACE_DROW:
      ch->real_abils.intel += 1;
      ch->real_abils.wis -= 1;
      ch->real_abils.dex += 1;
      SET_SKILL(ch, SPELL_INFRAVISION, 80);
      break;

        and so on.  This step might vary depending on how you imped the
race code
        if you need the whole function let me know

 in spell_parser.c

    in do_cast

       change

           if (GET_LEVEL(ch) < SINFO.min_level[(int) GET_CLASS(ch)]  ) {
    send_to_char("You do not know that spell!\r\n", ch);
    return;
  }

  to

    if (GET_LEVEL(ch) < SINFO.min_level[(int) GET_CLASS(ch)] && \
    !((IS_RACE_INFRA(ch)) && (spellnum == SPELL_INFRAVISION ))  ) {
    send_to_char("You do not know that spell!\r\n", ch);
    return;
  }



----------------------------------------------------------------------------
  higher up in int mag_manacost

  int mag_manacost(struct char_data * ch, int spellnum)
{
  int mana;

   if ( (IS_RACE_INFRA(ch)) && (spellnum == SPELL_INFRAVISION) ){
   mana =10;
   return mana;
   }else{

  mana = MAX(SINFO.mana_max - (SINFO.mana_change *
                    (GET_LEVEL(ch) - SINFO.min_level[(int) GET_CLASS(ch)])),
             SINFO.mana_min);
   }
  return mana;
}


  note, I did it that way so a level 1 drow warrior wouldn't have to
have 120 mana
 to cast a simple spell that just doesn't happen to be in the skill list
for warriors in
  class.c  There may be better ways to do this, but it was quick and
dirty :)


and, so it shows up in thier "spells" list, in do_spells
change it to look something like this...

ACMD(do_spells)
{
 extern char *spells[];
 extern struct spell_info_type spell_info[];
 int i;

 strcpy(buf, "You know of the following Spells:\r\n");
 strcpy(buf2, buf);

 for (i = 1; i < MAX_SPELLS+1; i++)
 {
  if (GET_LEVEL(ch) >= spell_info[i].min_level[(int) GET_CLASS(ch)] ||
IS_RACE_INFRA(ch)) {
   if (GET_SKILL(ch, i) > 0)
   {
    sprintf(buf, "%-20s %s\r\n", spells[i], how_good(GET_SKILL(ch,
    i))); strcat(buf2, buf);
   }
  }
 }
 page_string(ch->desc, buf2, 1);
}


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



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