Re: [Code]Race Specific Spells

From: Rasmus Roenlev (raro94ab@STUDENT.ECON.CBS.DK)
Date: 09/09/97


On Sun, 31 Aug 1997, 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.

Well, I'm in the process of re-coding my mud. I had races implemented,
where the only thing they really had, was a possibility to have permanent
affects. This could be like an AFF_INFRAVISION type flag. This worked
well, but it made the reason to implement races a little questionable.

So, I sat down and thought a little about the races and the skill system
in general. In spell.h you'll see the following structure;

struct spell_info_type {
   byte min_position;   /* Position for caster   */
   int mana_min;        /* Min amount of mana used by a spell (highest lev) */
   int mana_max;        /* Max amount of mana used by a spell (lowest lev) */
   int mana_change;     /* Change in mana used by spell from lev to lev */

   int min_level[NUM_CLASSES];
   int routines;
   byte violent;
   int targets;         /* See below for use with TAR_XXX  */
};

As you can see there's an 'int min_level[NUM_CLASSES]' array. So, what I
did what to apply the following changes to the struct, it now looks like
this;

struct spell_info_type {
   byte min_position;   /* Position for caster   */
   int  mana;           /* Amount of mana used by a spell */

   struct class_type {
     byte       min_level;
     u_byte     alignment;
   } class[NUM_CLASSES];

   struct race_type {
     byte       min_level;
     u_byte     alignment;
   } race[NUM_RACES];

   int routines;
   byte violent;
   int targets;         /* See below for use with TAR_XXX  */
};

This hasn't been compiled yet, so I'm not sure if the structs in the
struct are declared correctly, but I thought it would make for a more
logical 'adressing' of the race and class fields.
Anyway, what I did was, to add a struct for the classes and one for the
races at the size of the available classes and races. I also added an
alignment specific field, so I can make the skills alignment dependent,
but that's a whole different storry :)
In any case this enables you to rebuild your guildmaster spec-proc and
have your skills checked for use in spell_parser.c as usual.

I guess I could continue popping code into this mail, but unless someone
specificly requests it I think I'll stop here. It should give you a
general idea of how I started out the project. Oh yes. I also made the
following function in spell_parser.c:


void race_spell_level(int spell, int race_num, byte alignment, int level)
{
  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_num < 0 || race_num >= NUM_RACES) {
    sprintf(buf, "SYSERR: assigning '%s' to illegal race %d",
            skill_name(spell), race_num);
    log(buf);
    bad = 1;
  }

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

  if (!bad) {
    spell_info[spell].race[race_num].min_level = level;
    spell_info[spell].race[race_num].alignment = alignent;
  }
}

It's actually more or less a copy'n'change from the spell_level function
made by Jeremy that's called from class.c when the class skills are set
up. Just make it so that you have the same sort of thing for your race
that calls this, and you're set up to check the races vs. skills with your
guildmaster spec-proc after a few changes :)

Ok, changing to something a little different.

ObjJeremyElson:       :)

Just a little note here. I deleted all the mana_min, mana_max and
mana_change variables and made only one 'mana'! in the spell_info
structure. This should actually be considered to be implemented in
CircleMUD's base distribution.
It was actually a coincidence that made me do it. But it was something
that had nagged me for a long time. You level a character and not only
does his mana increase if he's a spellcaster the raw cost for the spells
(s)he casts also get lower. In effect this actually makes the character
even more powerfull, since the amount of, let's say heal (s)he can cast
gets larger than the increase in mana, since the mana_change also gets
into effect.
Now I mentioned this to some ppl. and they told me, that this was a left
over from DikuMUD, where you didn't get any mana increase when you
leveled. In that system I can see the idea of the mana_change meaning you
will be able to cast more heals with the fixed amount of mana. But in
CircleMUD it seems a little questionable...

What are peoples (and especially Jeremy Elsons) insight on this ?

Regards,
Rasmus

d.
--
     Rasmus Ronlev DOEK'94      WWW: http://www.econ.cbs.dk/~raro94ab
     Student instructor         MUD: exiled.mud.circlemud.org 5000
                                         207.1.218.76 5000
        B.Sc. in Computer Science and Business Administration.
    Student M.Sc. in Computer Science and Business Administration.


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