---------------
Redkoala MUD KNOCK Spell coded by Lord Siron of Redkoala MUD. 
To see the spell in action, telnet to redkoala.org port #8888.

To implement this spell into your codebase, You must check the
line under const     sh_int rev_dir [] = and make sure the #s
are the same as what is in your codebase. If the #'s are different,
change them to look like the other lines in your code. 

Also, EX_MAGICAL was added to our codebase as a toggable exit
flag for builders. This DOES NOT come with stock rom and to 
use it for stock rom, the portion pertaining to the EX_MAGICAL
flag must be removed. I ask that ya keep the small comment at
the beginning of the spell with it and email the name of your
mud and the port # which you are using the piece of code on.

Thank You,
Lord Siron
-----------------
<CUT HERE>

/* Redkoala MUD Knock Spell coded by Lord Siron. Version 1.00 */
void spell_knock ( int sn, int level, CHAR_DATA *ch, void *vo , int target)
{
    char arg[MAX_INPUT_LENGTH];
    int chance=0;
    int door;
    const       sh_int  rev_dir         []              =
        {
            2, 3, 0, 1, 5, 4, 9, 8, 7, 6
        };

    target_name = one_argument(target_name,arg);

    if (arg[0] == '\0')
    {
    send_to_char("Knock which door or direction.\n\r",ch);
    return;
    }

    if (ch->fighting)
    {
        send_to_char("Wait until the fight finishes.\n\r",ch);
        return;
    }

    if ( ( door = find_door( ch, arg ) ) >= 0 )
    {
        ROOM_INDEX_DATA *to_room;
        EXIT_DATA *pexit;
        EXIT_DATA *pexit_rev;

        pexit = ch->in_room->exit[door];
        if ( !IS_SET(pexit->exit_info, EX_CLOSED) )
            { send_to_char( "It's already open.\n\r",      ch ); return; }
        if ( !IS_SET(pexit->exit_info, EX_LOCKED) )
            { send_to_char( "Just try to open it.\n\r",     ch ); return; }
        if ( IS_SET(pexit->exit_info, EX_NOPASS) )
            { send_to_char( "A mystical shield protects the exit.\n\r",ch ); return; };
        if ( IS_SET(pexit->exit_info, EX_MAGICAL) )
            { send_to_char( "A mystical shield protects the exit from being      magically opened.\n\r",ch);return; }
    chance = ch->level / 5 + get_curr_stat(ch,STAT_INT) + get_skill(ch,sn) / 5;

    act("You cast knock on the $d, and try to open the $d!",
             ch,NULL,pexit->keyword,TO_CHAR);

    if (room_is_dark(ch->in_room))
                chance /= 2;

    /* now the attack */
    if (number_percent() < chance )
     {
        REMOVE_BIT(pexit->exit_info, EX_LOCKED);
        REMOVE_BIT(pexit->exit_info, EX_CLOSED);
        act( "$n knocks on the $d and opens the lock.", ch, NULL,
                pexit->keyword, TO_ROOM );
        send_to_char( "You successfully open the door.\n\r", ch );

        /* open the other side */
        if ( ( to_room   = pexit->u1.to_room            ) != NULL
        &&   ( pexit_rev = to_room->exit[rev_dir[door]] ) != NULL
        &&   pexit_rev->u1.to_room == ch->in_room )
        {
            CHAR_DATA *rch;
               REMOVE_BIT( pexit_rev->exit_info, EX_CLOSED );
            REMOVE_BIT( pexit_rev->exit_info, EX_LOCKED );
            for ( rch = to_room->people; rch != NULL; rch = rch->next_in_room )
                act( "The $d opens.", rch, NULL, pexit_rev->keyword, TO_CHAR );
        }
     }
    else
     {
        act("You couldn't magically open the $d!",
            ch,NULL,pexit->keyword,TO_CHAR);
        act("$n failed to magically open the $d.",
            ch,NULL,pexit->keyword,TO_ROOM);
     }
    return;
    }

  send_to_char("You can't see that here.\n\r",ch);
  return;
}
<END CUT>
