Re: [NEWBIE] [CODE] spell component discussion

From: John Evans (evansj@DATAWEST.NET)
Date: 06/04/98


On Thu, 4 Jun 1998, Mundi King wrote:

> i would like to get some ideas and feedback
> concerning the use of spell components,

I made it so that some objects would randomly appear in a mob's inventory
when the mob is loaded into the game. (25% chance for a random object
[randomly pulled from a list, that is] to load.) I used some of those
objects as spell components and used the following method to check for
component:

/*
 * Returns true if the character is holding the
 * vnum that is passed to it as a parameter.
 */
int has_component(struct char_data *ch, obj_num vnum)
{
  if (GET_EQ(ch, WEAR_HOLD))
    if (GET_OBJ_VNUM(GET_EQ(ch, WEAR_HOLD)) == vnum)
      return TRUE;
  return FALSE;
}

  case SPELL_PARALYZE:
    /* Check for component */
    if (!has_component(ch, 66)) {
      send_to_char("You aren't holding the proper component "
                   "for that spell.\r\n", ch);
      return;
    }

    /* Get rid of compnent. */
    extract_obj(unequip_char(ch, WEAR_HOLD));

    /* Saving throw and nat. resistance */
    if (mag_savingthrow(victim, SAVING_PARA) ||
        MOB_FLAGGED(victim, MOB_NOPARA)) {
      send_to_char(NOEFFECT, ch);
      return;
    }

    /* Setup the spell as per normal */
    af[0].bitvector = AFF_PARALYZE;
    af[0].duration = 2;
    accum_duration = FALSE;
    to_vict = "You have been paralyzed!!";
    to_char = "Your spell paralyzed $N and $E is helpless!";
    to_room = "$n's spell paralyzed $N and $E is helpless!";
  break;


Please note that obj_num is a typedef that I have setup in structs.h. In
stock code you would have a line like so:

typedef int     obj_num;

Hope this helps.

John Evans <evansj@datawest.net>
http://www.hi-line.net/~evansj/              telnet://spear.gator.net:1066

Any sufficiently advanced technology is indistinguishable from magic.
--Arthur C. Clarke


     +------------------------------------------------------------+
     | 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/15/00 PST