This snippet was taken from www.grayarea.com/sneak.htm and MAY NOT be
posted on your web site. It MUST be linked back to the above URL for
download.


- First off you must create a pill object with no spells set
- Then in merc.h add:
#define OBJ_VNUM_PILL <the vnum of the pill you created>

- Also in merc.h add:
extern sh_int gsn_pillify;

- In db.c add:
sh_int gsn_pillify; 

- You must also add it in the skill_table in const.c, mine looks like:
- Actually it doesn't look like that but you can work from this :)

  {
        "pillify",           {  0,  0, 0, 0, 0 },        { 0, 0, 0, 0, 0},
        spell_null,             TAR_IGNORE,             POS_SLEEPING,
        &gsn_pillify,            SLOT( 0),       0,      25,
        "",                     "!Pillify!",           ""
  },


- If you do not have the function number_chance() add this:
- number_chance() is from Vassago's Quest code.

bool number_chance(int num)
{
    if (number_range(1,100) <= num) return TRUE;
    else return FALSE;
}


- If you do not have imprint_spell add this to act_obj.c:

void imprint_spell( int sn, int level, CHAR_DATA * ch, void *vo )
{
    static const int    sucess_rate[] = { 80, 25, 10 };

    char      buf [ MAX_STRING_LENGTH ];
    OBJ_DATA *obj = ( OBJ_DATA * ) vo;
    int       free_slots;
    int       i;
    int       mana;
    int       class;
    int       snlev = 0;

    for ( free_slots = i = 1; i < 4; i++ )
        if ( obj->value[i] != 0 )
            free_slots++;

    if ( free_slots > 3 )
    {
        act( "$p cannot contain any more spells.", ch, obj, NULL, TO_CHAR
);
        return;
    }

    mana = 40;
    mana += skill_table[sn].min_mana;
    if ( !IS_NPC( ch ) && ch->mana < mana )
    {
        send_to_char( "You don't have enough mana.\n\r", ch );
        return;
    }

    if ( number_percent( ) > ch->pcdata->learned[sn] )
    {
     send_to_char( "You lost your concentration.\n\r", ch );
        ch->mana -= mana / 2;
        return;
    }

    ch->mana -= mana;
    obj->value[free_slots] = sn;

    if ( number_percent( ) > sucess_rate[free_slots - 1] )
    {
        sprintf( buf, "The magic enchantment has failed: the %s
vanishes.\n\r",
                item_name( obj->item_type ) );
        send_to_char( buf, ch );
        extract_obj( obj );
        return;
    }


    free_string( obj->short_descr );
    sprintf( buf, "a %s of ", item_name( obj->item_type ) );
    for ( i = 1; i <= free_slots; i++ )
        if ( obj->value[ i ] != -1 )
        {
            strcat( buf, skill_table[ obj->value[ i ] ].name );
            ( i != free_slots ) ? strcat( buf, ", " ) : strcat( buf, "" );
    }
    obj->short_descr = str_dup( buf );

    sprintf( buf, "%s %s", obj->name, item_name( obj->item_type ) );
    free_string( obj->name );
    obj->name = str_dup( buf );
     for (class = 0;class < MAX_CLASS;class++) {
    if(skill_table[sn].skill_level[class] < snlev) {
    snlev = skill_table[sn].skill_level[class]; } }
    if(obj->level < snlev) {obj->level = snlev; }
    sprintf( buf, "You have imbued a new spell to the %s.\n\r",
            item_name( obj->item_type ) );
    send_to_char( buf, ch );

    return;
}


- put this in act_obj.c

void do_pillify( CHAR_DATA * ch,char *argument )
{
  OBJ_DATA  *pill;
  char       arg [ MAX_INPUT_LENGTH ];
  int        sn;

  if(IS_NPC(ch)) {
  send_to_char("You don't have any need for pills.\n\r",ch);
  return; }

  if(get_skill(ch,gsn_pillify) < 1) {
  send_to_char("Huh?\n\r",ch);
  return; }

  argument = one_argument( argument, arg );

    if ( arg[0] == '\0' )
    {
        send_to_char( "Make a pill out of what spell?\n\r", ch );
        return;
    }

  if ( ( sn = skill_lookup( arg ) ) < 0 )
    {
        send_to_char( "You don't know any spells by that name.\n\r", ch );
        return;
    }

  if(!number_chance(get_skill(ch,sn))) {
  send_to_char("You don't know that spell well enough to make a pill of it!\n\r",ch);
  return; }

  if ( skill_table[sn].target != TAR_CHAR_DEFENSIVE
        && skill_table[sn].target != TAR_CHAR_SELF )
    {
        send_to_char( "You cannot make a pill of that spell.\n\r", ch );
        return;
    }
  pill = create_object( get_obj_index( OBJ_VNUM_PILL ), 0 );
  if(!pill) {
  send_to_char("Could not find the pill object, please notify an IMP!\n\r",ch);
  return; }
  obj_to_char(pill,ch);
  send_to_char("You begin focusing your magical energy.\n\r",ch);
  act( "$n begins focusing their magical energy.", ch, NULL, NULL, TO_ROOM );
    WAIT_STATE( ch, skill_table[ gsn_pillify ].beats );
  act( "$p suddenly pops into existence.",ch, pill, NULL, TO_CHAR);
  act( "$p suddenly pops into existence.",ch, pill, NULL, TO_ROOM);
   if ( !IS_NPC( ch )
        && ( number_percent( ) > ch->pcdata->learned[gsn_pillify] ||
             number_percent( ) > ( ( get_curr_stat(ch,STAT_INT) - 13 ) * 5 +
                                   ( get_curr_stat(ch,STAT_WIS) - 13 ) * 3 ) ) )
    {
        act( "$p {Yexplodes {Rviolently{x!", ch, pill, NULL, TO_CHAR );
        act( "$p {Yexplodes {Rviolently{x!", ch, pill, NULL, TO_ROOM );
        extract_obj( pill );
        damage( ch, ch, ch->max_hit / 10, gsn_pillify, WEAR_NONE, DAM_ENERGY );
        check_improve(ch,gsn_pillify,FALSE,1);
        return;
    }

    pill->level       = ch->level / 2;
    pill->value[0]    = ch->level / 2;
    imprint_spell( sn, ch->level, ch, pill );
    check_improve(ch,gsn_pillify,TRUE,1);
    return;
}

- And that should do it.
