From: "Patrick J. Dughi" <dughi@imaxx.net>
Subject: Innate Spells

Trying to figure out some way to give races innate abilities, i decided to
make innate spells.  Here's the pieces of actually working code that i
took a few minutes to piece together.  first though - here's how it works.
Circle already allows for innate spells, just have their duration under 0.
(0 duration comes to 1 hour of game time).  To make any spell innate then,
just set the duration on a spell to -1. And of course, you wouldn't want
that spell to be removed by ordinary circumstances... The  below code does
all that, and works too.

>>>>Begin Code<<<<

in magic.c: function mag_affects() look for:
 bool accum_affect = FALSE, accum_duration = FALSE;

 change it to this:

  bool accum_affect = FALSE, accum_duration = FALSE, is_innate = FALSE;

lower on down the function, look for:

  /*
   * If the victim is already affected by this spell, and the spell does
   * not have an accumulative effect, then fail the spell.
   */
  if (affected_by_spell(victim,spellnum) && !(accum_duration||accum_affect)) {
    send_to_char(NOEFFECT, ch);
    return;
  }

add this to the bottom of it:

 /*
  *  If the victim has that spell affect set innate, then make sure that the
  *  spell is treated like the above, which fails the spell.
  */
    for (aff = victim->affected; aff && !is_innate; aff = aff->next) {
        if (spellnum == aff->type && aff->duration == -1)
          is_innate=TRUE;
    }

    if (affected_by_spell(victim,spellnum) && is_innate) {
      send_to_char(NOEFFECT, ch);
      return;
    }

 New file: act.wizard.c, in do_stat_char(), look for
    
        sprintf(buf, "SPL: (%3dhr) %s%-21s%s ", aff->duration + 1,
              CCCYN(ch, C_NRM), spells[aff->type], CCNRM(ch, C_NRM));
  
 and change it to
     if (aff->duration <  0)
        sprintf(buf, "SPL: (innate) %s%-21s%s ",
              CCCYN(ch, C_NRM), spells[aff->type], CCNRM(ch, C_NRM));
      else
        sprintf(buf, "SPL: (%3dhr) %s%-21s%s ", aff->duration + 1,
              CCCYN(ch, C_NRM), spells[aff->type], CCNRM(ch, C_NRM));

  then, add the actual innate function:

ACMD(do_innate) {
  struct char_data *victim;
  struct affected_type *aff=NULL;
  int found=FALSE;

  half_chop(argument, arg, buf);

  if (!buf) {
    if(subcmd==SCMD_SINNATE)
      send_to_char("You must specify WHICH spell you'd like to make innate.\r\n",ch);
    else
      send_to_char("You must specify WHICH spell you'd like to remove innate from.\r\n",ch);
    return;
  }

  if (!(victim = get_player_vis(ch, arg, 0))) {
    send_to_char(NOPERSON, ch);
    return;
  }

  /* lets make sure the spell exists. */
  if (victim->affected) {
    for (aff = victim->affected; aff && !found; aff = aff->next) {
        if  (is_abbrev(buf,spells[aff->type]))
           found=TRUE;
    }
  }

  if (!found)  {
    send_to_char("That person is not affected by that spell.Sorry.\r\n",ch);
    return;
  }

  if (subcmd == SCMD_SINNATE)

/* this searches  out all instances of named spell - after  all, spells
like bless cause  several affects, you'd  have to  make them all
innate  */

    for (aff = victim->affected; aff; aff = aff->next) {
        if  (is_abbrev(buf,spells[aff->type]))
         aff->duration=-1;          /* well, -1 is innate neh? never goes away*/
    }
  else
         /* really, this  is  unaffect, with a specific target*/
    for (aff = victim->affected; aff; aff = aff->next) {
      if  (is_abbrev(buf,spells[aff->type]))
        affect_remove(victim,aff);
    }
  send_to_char(OK,ch);
}

and then of course, add the commands to  interpreter..
in interpreter.h add
#define SCMD_SINNATE 0
#define SCMD_RINNATE 1

where ever  you'd like, and in interpreter.c, add the  lines
ACMD(do_innate);
   up with  the function declarations, and 
{ "rinnate"  , POS_DEAD    , do_innate   , LVL_IMPL, SCMD_RINNATE},
{ "sinnate"  , POS_DEAD    , do_innate   , LVL_IMPL, SCMD_SINNATE},
   somewhere in that command table  mass.


and here's how to use it:
cast a spell on some character.
type 
sinnate <character> <spellname>

thats it.
to  remove a spell from a  characer  type
rinnate <character> <spellname>

You might want to make it so that immortals can cast TAR_SELF spells at
others........... (its even simpler than the above sludge)

                                                     PjD
