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

 * 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;

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

    /* 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);

    /* 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!";

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 <>              telnet://

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

     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | |

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