Re: [Circle] race dependant spells

From: Daniel Koepke (dkoepke@california.com)
Date: 11/10/96


On Mon, 11 Nov 1996, Nic Suzor wrote:

> i thought about that, but it would mean that everyone would be able to
> practice those spells, and see them etc, but only ogres could cast... its a
> little messy, i was hoping for a cleaner way to do them...

To 'struct spell_info_type' (in spells.h) add: 

  bool races[NUM_RACES];
  bool race_dependant; /* automatically set by spell_race() */

Now add the following function to spell_parser.c:

  void spell_race(int spell, int race) {
    char buf[256];
    int bad = 0;

    if (spell < 0 || spell > TOP_SPELL_DEFINE) {
      sprintf(buf, "SYSERR: attempting assign to illegal spellnum %d", spell);
      log(buf);
      return;
    }

    if (race < 0 || race >= NUM_RACES) {
      sprintf(buf, "SYSERR: assigning '%s' to illegal race %d",
	      skill_name(spell), race);
      log(buf);
      bad = 1;
    }

    if (!bad) {
      spell_info[spell].races[race] = TRUE;
      spell_info[spell].race_dependant = TRUE;
    }
  }

Add the following lines to 'void spello()':

  for (i = 0; i < NUM_RACES; i++)
    spell_info[spell].races[i] = FALSE;
  spell_info[spell].race_dependant = FALSE;

The following macro will also be of some use:

  #define CAN_CAST(ch, s)	(GET_LEVEL(ch) >= LVL_IMMORT   || \
				 !spell_info[s].race_dependant || \
				 spell_info[s].races[GET_RACE(ch)]) 

Now in spec_procs.c, do the following (my new lines are marked with
a plus sign at the beginning; you'll need to remove those.  Any that
are not marked with the + are context lines to show you where to put
them), these changes occur somewhere around line 121.

    if (GET_LEVEL(ch) >= spell_info[i].min_level[(int) GET_CLASS(ch)])
+     if (CAN_CAST(ch)) {

Now in SPECIAL(guild), find the following line:

  if (skill_num < 1 ||

And change it to:

  if (skill_num < 1 || !CAN_CAST(ch) ||

You can do the same in do_cast if you want to present a special
message when someone tries to cast a spell their race is not
capable of casting; although since they can't learn the spell and
they can't see it in the practice list (unless they are immortal)
I suppose it doesn't really matter.


--
Daniel Koepke
dkoepke@california.com
Forgive me father, for I am sin.
Back after a brief excursion to Alaska.


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