act_move.c

muddy/src/act_move.c · 193.4 KB

From the archive astrum.tar.bz2

Download the archive   « Back to the archive contents

/* $Id: act_move.c,v 1.666 2004/09/20 10:49:46 shrike Exp $ */

/************************************************************************************
 *    Copyright 2004 Astrum Metaphora consortium                                    *
 *                                                                                  *
 *    Licensed under the Apache License, Version 2.0 (the "License");               *
 *    you may not use this file except in compliance with the License.              *
 *    You may obtain a copy of the License at                                       *
 *                                                                                  *
 *    http://www.apache.org/licenses/LICENSE-2.0                                    *
 *                                                                                  *
 *    Unless required by applicable law or agreed to in writing, software           *
 *    distributed under the License is distributed on an "AS IS" BASIS,             *
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.      *
 *    See the License for the specific language governing permissions and           *
 *    limitations under the License.                                                *
 *                                                                                  *
 ************************************************************************************/

 /************************************************************************************
 *     ANATOLIA 2.1 is copyright 1996-1997 Serdar BULUT, Ibrahim CANPUNAR           *
 *     ANATOLIA has been brought to you by ANATOLIA consortium                      *
 *       Serdar BULUT {Chronos}         bulut@rorqual.cc.metu.edu.tr                *
 *       Ibrahim Canpunar  {Asena}      canpunar@rorqual.cc.metu.edu.tr             *
 *       Murat BICER  {KIO}             mbicer@rorqual.cc.metu.edu.tr               *
 *       D.Baris ACAR {Powerman}        dbacar@rorqual.cc.metu.edu.tr               *
 *     By using this code, you have agreed to follow the terms of the               *
 *     ANATOLIA license, in the file Anatolia/anatolia.licence                      *
 ***********************************************************************************/

/************************************************************************************
 *  Original Diku Mud copyright (C) 1990, 1991 by Sebastian Hammer,                 *
 *  Michael Seifert, Hans Henrik St{rfeldt, Tom Madsen, and Katja Nyboe.            *
 *                                                                                  *
 *  Merc Diku Mud improvments copyright (C) 1992, 1993 by Michael                   *
 *  Chastain, Michael Quan, and Mitchell Tse.                                       *
 *                                                                                  *
 *  In order to use any part of this Merc Diku Mud, you must comply with            *
 *  both the original Diku license in 'license.doc' as well the Merc                *
 *  license in 'license.txt'.  In particular, you may not remove either of          *
 *  these copyright notices.                                                        *
 *                                                                                  *
 *  Much time and thought has gone into this software and you are                   *
 *  benefitting.  We hope that you share your changes too.  What goes               *
 *  around, comes around.                                                           *
 ************************************************************************************/

/************************************************************************************
*       ROM 2.4 is copyright 1993-1995 Russ Taylor                                  *
*       ROM has been brought to you by the ROM consortium                           *
*           Russ Taylor (rtaylor@pacinfo.com)                                       *
*           Gabrielle Taylor (gtaylor@pacinfo.com)                                  *
*           Brian Moore (rom@rom.efn.org)                                           *
*       By using this code, you have agreed to follow the terms of the              *
*       ROM license, in the file Rom24/doc/rom.license                              *
*************************************************************************************/

/************************************************************************************
 * Copyright (c) 1998 fjoe <fjoe@iclub.nsu.ru>                                      *
 * All rights reserved.                                                             *
 *                                                                                  *
 * Redistribution and use in source and binary forms, with or without               *
 * modification, are permitted provided that the following conditions               *
 * are met:                                                                         *
 * 1. Redistributions of source code must retain the above copyright                *
 *    notice, this list of conditions and the following disclaimer.                 *
 * 2. Redistributions in binary form must reproduce the above copyright             *
 *    notice, this list of conditions and the following disclaimer in the           *
 *    documentation and/or other materials provided with the distribution.          *
 *                                                                                  *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND           *
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE            *
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE       *
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE          *
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL       *
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS          *
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)            *
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT       *
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY        *
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF           *
 * SUCH DAMAGE.                                                                     *
 ************************************************************************************/


#include <sys/types.h>
#if !defined (WIN32)
#include <sys/time.h>
#endif
#include <stdio.h>
#include <string.h>
#include "merc.h"
#include "update.h"
#include "mob_prog.h"
#include "obj_prog.h"
#include "fight.h"

extern bool check_recovery   (CHAR_DATA *ch, CHAR_DATA *victim);
extern bool check_roll       (CHAR_DATA *);
extern bool check_jammer     (CHAR_DATA *);
extern bool check_perception (CHAR_DATA *, CHAR_DATA *);
extern bool check_mirror_image (CHAR_DATA *, CHAR_DATA *);
extern bool check_dodge    (CHAR_DATA *ch, CHAR_DATA *victim);
extern bool is_safe_rspell_nom (int level, CHAR_DATA* victim);


char *  const   dir_name    []      =
    {
        "north", "east", "south", "west", "up", "down"
    };

const   int rev_dir     []      =
    {
        2, 3, 0, 1, 5, 4
    };

const   int movement_loss   [SECT_MAX]  =
    {
        1, 2, 2, 3, 4, 6, 4, 1, 6, 10, 6
    };

DECLARE_DO_FUN(do_look      );
DECLARE_DO_FUN(do_yell      );
DECLARE_DO_FUN(do_wear      );

void agent_net_printf(CHAR_DATA *ch, CHAR_DATA *victim, int condition);

/*
 * Local functions.
 */
int fish_number(int type);
int find_door   (CHAR_DATA *ch, char *arg);
int     find_exit   (CHAR_DATA *ch, char *arg);
bool    has_key     (CHAR_DATA *ch, int key);
int mount_success   (CHAR_DATA *ch, CHAR_DATA *mount, int canattack);
bool    move_char_org   (CHAR_DATA *ch, int door, bool follow, bool is_charge);

void move_char(CHAR_DATA *ch, int door, bool follow)
{
    move_char_org(ch, door, follow, FALSE);
}

bool move_char_org(CHAR_DATA *ch, int door, bool follow, bool is_charge)
{
    CHAR_DATA *fch;
    CHAR_DATA *fch_next;
    CHAR_DATA *mount;
    ROOM_INDEX_DATA *in_room;
    ROOM_INDEX_DATA *to_room;
    EXIT_DATA *pexit;
    bool room_has_pc;
    OBJ_DATA *obj;
    OBJ_DATA *obj_next;
    int act_flags;

    if (RIDDEN(ch) && !IS_NPC(ch->mount))
        return move_char_org(ch->mount,door,follow, is_charge);

    if (IS_AFFECTED(ch, AFF_WEB)
            || (MOUNTED(ch) && IS_AFFECTED(ch->mount, AFF_WEB)))
    {
        WAIT_STATE(ch, PULSE_VIOLENCE);
        if (number_percent() < str_app[IS_NPC(ch) ?
                                       20 : get_curr_stat(ch,STAT_STR)].tohit * 5)
        {
            affect_strip(ch, gsn_web);
            REMOVE_BIT(ch->affected_by, AFF_WEB);
            char_act("When you attempt to leave the room, you break the webs holding you tight.", ch);
            act_puts("$n struggles against the webs which hold $gn{him} in place, and break it.", ch, NULL, NULL, TO_ROOM, POS_RESTING);
        }
        else
        {
            char_act("You attempt to leave the room, but the webs hold you tight.", ch);
            act_puts("$n struggles vainly against the webs which hold $gn{him} in place.", ch, NULL, NULL, TO_ROOM, POS_RESTING);
            return FALSE;
        }
    }

    if (door < 0 || door >= MAX_DIR)
    {
        bug("Do_move: bad door %d.", door);
        return FALSE;
    }

    if (IS_AFFECTED(ch, AFF_HIDE | AFF_FADE)
            && !IS_AFFECTED(ch, AFF_SNEAK))
    {
        REMOVE_BIT(ch->affected_by, AFF_HIDE);
        char_act("You step out of shadows.", ch);
        act_puts("$n steps out of shadows.", ch, NULL, NULL, TO_ROOM, POS_RESTING);
    }

    if (IS_AFFECTED(ch, AFF_TRAP))
    {
        REMOVE_BIT(ch->affected_by, AFF_TRAP);
        char_act("You blew your cover.", ch);
        act_puts("$n blews the cover.", ch, NULL, NULL, TO_ROOM, POS_RESTING);
    }

    if (IS_AFFECTED(ch, AFF_EARTHFADE))
    {
        affect_bit_strip(ch, TO_AFFECTS, AFF_EARTHFADE);
        WAIT_STATE(ch, PULSE_VIOLENCE * 2);
        act("You fade to your neutral form.", ch, NULL, NULL, TO_CHAR);
        act("Earth forms $n in front of you.",ch, NULL, NULL, TO_ROOM);
    }

    if (IS_AFFECTED(ch, AFF_CAMOUFLAGE))
    {
        int chance;

        if ((chance = get_skill(ch, gsn_camouflage_move)) == 0)
        {
            REMOVE_BIT(ch->affected_by, AFF_CAMOUFLAGE);
            char_act("You step out from your cover.", ch);
            act_puts("$n steps out of the cover.", ch, NULL, NULL, TO_ROOM, POS_RESTING);
        }
        else if (number_percent() < chance)
            check_improve(ch, gsn_camouflage_move, TRUE, 5);
        else
        {
            REMOVE_BIT(ch->affected_by, AFF_CAMOUFLAGE);
            char_act("You step out from your cover.", ch);
            act_puts("$n steps out of the cover.", ch, NULL, NULL, TO_ROOM, POS_RESTING);
            check_improve(ch, gsn_camouflage_move, FALSE, 5);
        }
    }

    /*
     * Exit trigger, if activated, bail out. Only PCs are triggered.
     */

    if (!IS_NPC(ch)
            && (p_exit_trigger( ch, door, PRG_MPROG )
                || p_exit_trigger( ch, door, PRG_OPROG )
                || p_exit_trigger( ch, door, PRG_RPROG )))
        return FALSE;

    in_room = ch->in_room;
    if ((pexit = in_room->exit[door]) == NULL
            || (to_room = pexit->to_room.r) == NULL
            || (!IS_NPC(ch) && !can_see_room(ch, pexit->to_room.r)))
    {
        char_act("Alas, you cannot go that way.", ch);
        return FALSE;
    }

    if (IS_ROOM_AFFECTED(in_room, RAFF_RANDOMIZER) && !is_charge)
    {
        int d0;
        while (1)
        {
            d0 = number_range(0, MAX_DIR-1);
            if ((pexit = in_room->exit[d0]) == NULL
                    || (to_room = pexit->to_room.r) == NULL
                    || !can_see_room(ch, pexit->to_room.r))
                continue;
            door = d0;
            break;
        }
    }

    if (IS_SET(pexit->exit_info, EX_CLOSED)
            && (!(IS_AFFECTED(ch, AFF_PASS_DOOR)
                  || IS_SET(ch->plr_flags, PLR_GHOST))
                || IS_SET(pexit->exit_info, EX_NOPASS))
            && !IS_TRUSTED(ch, ANGEL))
    {
        if (IS_AFFECTED(ch, AFF_PASS_DOOR)
                && IS_SET(pexit->exit_info, EX_NOPASS))
        {
            act_puts("You failed to pass through the $d.",
                     ch, NULL, pexit->keyword, TO_CHAR, POS_RESTING);
            act_puts("$n tries to pass through the $d, but $gn{he} failes",
                     ch, NULL, pexit->keyword, TO_ROOM, POS_RESTING);
        }
        else
            act_puts("The $d is closed.", ch, NULL, pexit->keyword, TO_CHAR, POS_RESTING);
        return FALSE;
    }

    if (IS_AFFECTED(ch, AFF_CHARM)
            && ch->master != NULL
            && in_room == ch->master->in_room)
    {
        char_act("What? And leave your beloved master?", ch);
        return FALSE;
    }

    if (IS_ROOM_AFFECTED(in_room, RAFF_ESPIRIT)
            && !IS_ROOM_AFFECTED(to_room, RAFF_ESPIRIT)
            && is_affected(ch, gsn_evil_spirit))
    {
        act_puts("Evil spirit holds you in the place.", ch, NULL, NULL, TO_CHAR, POS_RESTING);
        act("Evil spirit holds $n in the place.", ch, NULL, NULL, TO_ROOM);
        return FALSE;
    }

    if (ch->size > pexit->size)
    {
        act_puts("This passage is too small for you.", ch, NULL, NULL, TO_CHAR, POS_RESTING);
        return FALSE;
    }

    if (!check_war_move (ch, to_room, FALSE))
        return FALSE;

    if ((count_used_space(to_room) + ch->size) > to_room->space)
    {
        act_puts("There too little place for you.",
                 ch, NULL, NULL, TO_CHAR, POS_RESTING);
        return FALSE;
    }

    if (room_is_private(to_room))
    {
        char_act("That room is private right now.", ch);
        return FALSE;
    }

    if (MOUNTED(ch))
    {
        if (MOUNTED(ch)->position < POS_FIGHTING)
        {
            char_act("Your mount must be standing.", ch);
            return FALSE;
        }
        if (!mount_success(ch, MOUNTED(ch), FALSE))
        {
            char_act("Your mount subbornly refuses to go that way.", ch);
            return FALSE;
        }
    }

    if (!IS_NPC(ch))
    {
        int move;

        if (!IS_IMMORTAL(ch) && IS_PUMPED(ch)
                && IS_SET(to_room->room_flags, ROOM_PEACE))
        {
            char_act("You feel too bloody to go in there now.", ch);
            return FALSE;
        }

        if (!MOUNTED(ch)
                &&  ch->position > POS_RESTING
                &&  ch->pcdata->condition[COND_DRUNK] > (number_percent() >> 1)
                &&  number_bits(3) == 1)
        {
            char_act("You are trying to do a step, but stumble and fall.", ch);
            act("$n is trying to do a step, but stumbles and falls.", ch, NULL, NULL, TO_NOTVICT);
            ch->position = POS_RESTING;
            return FALSE;
        }

        if (in_room->sector_type == SECT_AIR || to_room->sector_type == SECT_AIR)
        {
            if (MOUNTED(ch))
            {
                if (!IS_AFFECTED(MOUNTED(ch), AFF_FLYING))
                {
                    char_act("Your mount can't fly.", ch);
                    return FALSE;
                }
            }
            else if (!(IS_AFFECTED(ch, AFF_FLYING)
                       || IS_SET(ch->plr_flags, PLR_GHOST))
                     && !IS_IMMORTAL(ch))
            {
                char_act("You can't fly.", ch);
                return FALSE;
            }
        }

        if ((in_room->sector_type == SECT_WATER_NOSWIM
                || to_room->sector_type == SECT_WATER_NOSWIM)
                && (MOUNTED(ch) && !IS_AFFECTED(MOUNTED(ch),AFF_FLYING)))
        {
            char_act("You can't take your mount there.", ch);
            return FALSE;
        }

        if ((in_room->sector_type == SECT_WATER_NOSWIM
                || to_room->sector_type == SECT_WATER_NOSWIM)
                && (!MOUNTED(ch) && !IS_AFFECTED(ch, AFF_FLYING)
                    && !IS_AFFECTED(ch, AFF_SWIM)
                    && !IS_SET(ch->plr_flags, PLR_GHOST)
                    && !IS_IMMORTAL(ch)))
        {
            OBJ_DATA *obj;
            bool found = FALSE;

            /*
             * Look for a boat.
             */
            for (obj = ch->carrying; obj != NULL; obj = obj->next_content)
            {
                if (obj->pIndexData->item_type == ITEM_BOAT)
                {
                    found = TRUE;
                    break;
                }
            }
            if (!found)
            {
                char_act("You need a boat to go there.", ch);
                return FALSE;
            }
        }

        move = (movement_loss[UMIN(SECT_MAX-1, in_room->sector_type)]
                + movement_loss[UMIN(SECT_MAX-1, to_room->sector_type)])/2;

        if (is_affected(ch, gsn_thumbling))
            move *= 2;
        else
        {
            if (IS_AFFECTED(ch,AFF_FLYING)
                    || IS_AFFECTED(ch,AFF_HASTE))
                move /= 2;

            if (IS_AFFECTED(ch,AFF_SLOW))
                move *= 2;
        }

        if (!MOUNTED(ch) && ch->move < move)
        {
            char_act("You are too exhausted.", ch);
            return FALSE;
        }

        if (!MOUNTED(ch)
                && (ch->in_room->sector_type == SECT_DESERT || IS_WATER(ch->in_room)))
            WAIT_STATE(ch, 2+IS_AFFECTED(ch,AFF_SLOW)?2:0);
        else
            WAIT_STATE(ch, 1+IS_AFFECTED(ch,AFF_SLOW)?1:0);

        if (!MOUNTED(ch))
            ch->move -= move;
    }

    if (IS_ROOM_AFFECTED(in_room, RAFF_PROTECTION))
    {
        act ("You destroy the circle of protection guarded the room.", ch, NULL, NULL, TO_CHAR);
        act ("$n destroys the circle of protection guarded the room.", ch, NULL, NULL, TO_ROOM);
        affect_strip_room (in_room, sn_lookup ("circle of protection"));
    }

    if (IS_ROOM_AFFECTED(to_room, RAFF_PROTECTION))
    {
        int sn;
        AFFECT_DATA* paf;

        if ((sn = sn_lookup ("circle of protection")) != -1)
        {
            if ((paf = affect_find (to_room->affected, sn)) != NULL)
            {
                if (!is_safe_rspell_nom (paf->level, ch))
                {
                    // here we will deal with circle of protection
                    char_act("Powerful circle blocks your way.", ch);
                    WAIT_STATE (ch, PULSE_VIOLENCE);
                    if (--paf->modifier <= 0)
                    {
                        act ("You destroy the circle of protection guarded the room.", ch, NULL, NULL, TO_CHAR);
                        if (to_room->people != NULL)
                            act ("Someone destroys the circle of protection guarded the room.", to_room->people, NULL, NULL, TO_ALL);
                        affect_strip_room (to_room, sn);
                    }
                    return FALSE;
                }
            }
            else
                bug ("Bad paf for circle of protection", 0);
        }
        else
            bug ("Bad sn for circle of protection", 0);
    }

    if (!IS_AFFECTED(ch, AFF_SNEAK)
            && !IS_AFFECTED(ch, AFF_CAMOUFLAGE)
            && ch->invis_level < LEVEL_HERO)
        act_flags = TO_ROOM;
    else
        act_flags = TO_ROOM | ACT_NOMORTAL;

    if (!IS_NPC(ch)
            && ch->in_room->sector_type != SECT_INSIDE
            && ch->in_room->sector_type != SECT_CITY
            && number_percent() < get_skill(ch, gsn_quiet_movement)
            && !is_charge)
    {
        act(MOUNTED(ch) ? "$n leaves, riding on $N." :
            IS_AFFECTED(ch, AFF_FLYING) ? "$n flies away." : "$n leaves.",
            ch, NULL, MOUNTED(ch), act_flags);
        check_improve(ch,gsn_quiet_movement,TRUE,1);
    }
    else if (is_charge)
    {
        act("$n spurs $gn{his} $N, leaving $t.",
            ch, dir_name[door], ch->mount,  TO_ROOM | ACT_TRANS);
    }
    else
    {
        act(MOUNTED(ch) ? "$n leaves $t, riding on $N." :
            IS_AFFECTED(ch, AFF_FLYING) ? "$n flies away $t." :
            "$n leaves $t.",
            ch, dir_name[door], MOUNTED(ch), act_flags | ACT_TRANS);
    }

    if (IS_AFFECTED(ch, AFF_CAMOUFLAGE)
            &&  to_room->sector_type != SECT_FOREST
            &&  to_room->sector_type != SECT_MOUNTAIN
            &&  to_room->sector_type != SECT_HILLS)
    {
        REMOVE_BIT(ch->affected_by, AFF_CAMOUFLAGE);
        char_act("You step out from your cover.", ch);
        act_puts("$n steps out of the cover.", ch, NULL, NULL, TO_ROOM, POS_RESTING);
    }

    // room record for tracking
    if (!IS_NPC (ch) && ch->in_room)
        room_record (ch->name, in_room, door);

    // fishing stuff
    if ((IS_SET (ch->in_room->room_flags, ROOM_SALTWATER_FISH)
            || IS_SET (ch->in_room->room_flags, ROOM_FRESHWATER_FISH))
            && (IS_SET (ch->comm, COMM_FISHING) || IS_SET (ch->comm, COMM_FISH_ON)))
    {
        REMOVE_BIT (ch->comm, COMM_FISHING);
        REMOVE_BIT (ch->comm, COMM_FISH_ON);
        act("You pack up your fishing gear and move on.",
            ch , NULL, NULL, TO_CHAR);
    }

    mount = MOUNTED (ch);

    // move char from the source room
    // this removes riding flag from char
    char_from_room (ch);

    if (!IS_AFFECTED (ch, AFF_SNEAK)
            && ch->invis_level < LEVEL_IMMORTAL)
        act_flags = TO_ROOM ;
    else
        act_flags = TO_ROOM | ACT_NOMORTAL ;

    // move char to the destination room
    char_to_room (ch, to_room);

    if (!is_charge)
        act((mount && ch->mount) ? "$n has arrived, riding $N." : IS_AFFECTED (ch, AFF_FLYING) ? "$n has flown in." : "$n has arrived.", ch, NULL, mount, act_flags);

    if (!JUST_KILLED (ch))
        do_look (ch, "auto");

    // move horse to the room (this part has been moved to char_to_room ())
    // ch->mount can be resetted in raffects.c
    if (mount && ch->mount == mount)
    {
        char_from_room (mount);
        char_to_room   (mount, to_room);
        ch->riding     = TRUE ;
        mount->riding  = TRUE ;
    }
    else if (mount)
    {
        char_from_room (mount);
        char_to_room   (mount, to_room);
        ch->riding     = FALSE ;
        mount->riding  = FALSE ;
    }
    else
        ch->mount = NULL ;

    if (in_room == to_room) /* no circular follows */
        return TRUE ;

    if (!follow)
        for (fch = in_room->people ; fch != NULL ; fch = fch_next)
        {
            fch_next = fch->next_in_room ;

            if (fch->master != ch || fch->position != POS_STANDING
                    || !can_see_room (fch, to_room))
                continue ;

            if (IS_SET (ch->in_room->room_flags, ROOM_LAW) && IS_NPC (fch)
                    && IS_SET (fch->pIndexData->act, ACT_AGGRESSIVE))
            {
                act_puts("You can't bring $N into the city.", ch, NULL, fch, TO_CHAR, POS_DEAD);
                act("You aren't allowed in the city.", fch, NULL, NULL, TO_CHAR);
                continue ;
            }

            act_puts("You follow $N.", fch, NULL, ch, TO_CHAR, POS_DEAD);
            move_char (fch, door, TRUE);
        }

    if (JUST_KILLED (ch))
        return(is_charge && ch->mount == NULL ? FALSE : TRUE);

    room_has_pc = FALSE ;

    for (fch = to_room->people ; fch != NULL ; fch = fch_next)
    {
        fch_next = fch->next_in_room ;

        if (!IS_NPC (fch))
        {
            room_has_pc = TRUE ;
            break ;
        }
    }

    if (!room_has_pc)
        return(is_charge && ch->mount == NULL ? FALSE : TRUE);

    for (fch = to_room->people ; fch != NULL ; fch = fch_next)
    {
        fch_next = fch->next_in_room ;

        // greet progs for items carried by people in room
        for (obj = fch->carrying ; obj != NULL ; obj = obj_next)
        {
            obj_next = obj->next_content ;
            oprog_call (OPROG_GREET, obj, ch, NULL);
        }
    }

    // entry programs for items
    for (obj = ch->carrying ; obj != NULL ; obj = obj_next)
    {
        obj_next = obj->next_content ;
        oprog_call (OPROG_ENTRY, obj, NULL, NULL);
    }

    /*
     * If someone is following the char, these triggers get activated
     * for the followers before the char, but it's safer this way...
     */
    if (IS_NPC (ch) && HAS_TRIGGER_MOB (ch, TRIG_ENTRY) && !IS_AFFECTED(ch, AFF_CHARM))
        p_percent_trigger (ch, NULL, NULL, NULL, NULL, NULL, TRIG_ENTRY);

    if (!IS_NPC(ch))
    {
        p_greet_trigger(ch, PRG_MPROG);
        p_greet_trigger(ch, PRG_OPROG);
        p_greet_trigger(ch, PRG_RPROG);
    }


    for (obj = ch->in_room->contents ; obj != NULL ; obj = obj_next)
    {
        obj_next = obj->next_content ;
        oprog_call (OPROG_GREET, obj, ch, NULL);
    }

    for (obj = ch->in_room->contents; obj; obj= obj->next_content)
    {
        if (obj->pIndexData->vnum == OBJ_VNUM_MINE)
        {
            act_puts("You have successfully found $p! Yes!!!", ch, obj, NULL, TO_CHAR, POS_DEAD);
            act("$n has successfully found $p! Yes!!!", ch, obj, NULL, TO_ROOM);
            if (number_percent() < (50 - get_curr_stat(ch, STAT_LCK)))
                do_get(ch, "mine");
        }
        if (obj->pIndexData->vnum == OBJ_VNUM_FUNPILL)
        {
            act_puts("You have successfully found $p! Yes!!!", ch, obj, NULL, TO_CHAR, POS_DEAD);
            act("$n has successfully found $p! Yes!!!", ch, obj, NULL, TO_ROOM);
            if (number_percent() < (get_curr_stat(ch, STAT_LCK) * 3))
                do_sacrifice(ch, "funpill");
            else
            {
                do_get(ch, "funpill");
                do_eat(ch, "funpill");
            }
        }
    }

    return(is_charge && ch->mount == NULL ? FALSE : TRUE);
}



DO_FUN(do_north)
{
    move_char(ch, DIR_NORTH, FALSE);
}



DO_FUN(do_east)
{
    move_char(ch, DIR_EAST, FALSE);
}



DO_FUN(do_south)
{
    move_char(ch, DIR_SOUTH, FALSE);
}



DO_FUN(do_west)
{
    move_char(ch, DIR_WEST, FALSE);
}



DO_FUN(do_up)
{
    move_char(ch, DIR_UP, FALSE);
}



DO_FUN(do_down)
{
    move_char(ch, DIR_DOWN, FALSE);
}



int find_exit(CHAR_DATA *ch, char *arg)
{
    int door;

    if (!str_cmp(arg, "n")
            || !str_cmp(arg, "north")
            || !str_cmp(arg, "Ó")
            || !str_cmp(arg, "ÓÅ×ÅÒ"))
    {
        door = 0;
    }
    else if (!str_cmp(arg, "e")
             || !str_cmp(arg, "east")
             || !str_cmp(arg, "×")
             || !str_cmp(arg, "ÓÅ×ÅÒ"))
    {
        door = 1;
    }
    else if (!str_cmp(arg, "s")
             || !str_cmp(arg, "south")
             || !str_cmp(arg, "À")
             || !str_cmp(arg, "ÀÇ"))
    {
        door = 2;
    }
    else if (!str_cmp(arg, "w")
             || !str_cmp(arg, "west")
             || !str_cmp(arg, "Ú")
             || !str_cmp(arg, "ÚÁÐÁÄ"))
    {
        door = 3;
    }
    else if (!str_cmp(arg, "u")
             || !str_cmp(arg, "up")
             || !str_cmp(arg, "××")
             || !str_cmp(arg, "××ÅÒÈ"))
    {
        door = 4;
    }
    else if (!str_cmp(arg, "d")
             || !str_cmp(arg, "down")
             || !str_cmp(arg, "Î")
             || !str_cmp(arg, "×Î")
             || !str_cmp(arg, "×ÎÉÚ")
             || !str_cmp(arg, "ÎÉÚ"))
    {
        door = 5;
    }
    else
    {
        act_puts("I see no exit $T here.", ch, NULL, arg, TO_CHAR, POS_DEAD);
        return -1;
    }

    return door;
}


int find_door(CHAR_DATA *ch, char *arg)
{
    EXIT_DATA *pexit;
    int door;

    if (!str_cmp(arg, "n")
            || !str_cmp(arg, "north")
            || !str_cmp(arg, "Ó")
            || !str_cmp(arg, "ÓÅ×ÅÒ"))
    {
        door = 0;
    }
    else if (!str_cmp(arg, "e")
             || !str_cmp(arg, "east")
             || !str_cmp(arg, "×")
             || !str_cmp(arg, "ÓÅ×ÅÒ"))
    {
        door = 1;
    }
    else if (!str_cmp(arg, "s")
             || !str_cmp(arg, "south")
             || !str_cmp(arg, "À")
             || !str_cmp(arg, "ÀÇ"))
    {
        door = 2;
    }
    else if (!str_cmp(arg, "w")
             || !str_cmp(arg, "west")
             || !str_cmp(arg, "Ú")
             || !str_cmp(arg, "ÚÁÐÁÄ"))
    {
        door = 3;
    }
    else if (!str_cmp(arg, "u")
             || !str_cmp(arg, "up")
             || !str_cmp(arg, "××")
             || !str_cmp(arg, "××ÅÒÈ"))
    {
        door = 4;
    }
    else if (!str_cmp(arg, "d")
             || !str_cmp(arg, "down")
             || !str_cmp(arg, "Î")
             || !str_cmp(arg, "×Î")
             || !str_cmp(arg, "×ÎÉÚ")
             || !str_cmp(arg, "ÎÉÚ"))
    {
        door = 5;
    }
    else
    {
        for (door = 0; door <= 5; door++)
        {
            if ((pexit = ch->in_room->exit[door]) != NULL
                    &&   IS_SET(pexit->exit_info, EX_ISDOOR)
                    &&   pexit->keyword != NULL
                    &&   is_name(arg, pexit->keyword))
                return door;
        }
        act_puts("I see no $T here.", ch, NULL, arg, TO_CHAR, POS_DEAD);
        return -1;
    }

    if ((pexit = ch->in_room->exit[door]) == NULL)
    {
        act_puts("I see no door $T here.", ch, NULL, arg, TO_CHAR, POS_DEAD);
        return -1;
    }

    if (!IS_SET(pexit->exit_info, EX_ISDOOR))
    {
        char_act("You can't do that.", ch);
        return -1;
    }

    return door;
}

DO_FUN(do_open)
{
    char arg[MAX_INPUT_LENGTH];
    OBJ_DATA *obj;
    int door;

    one_argument(argument, arg, sizeof(arg));

    if (arg[0] == '\0')
    {
        char_act("Open what?", ch);
        return;
    }

    if ((obj = get_obj_here(ch, arg)) != NULL)
    {
        /* open portal */
        if (obj->pIndexData->item_type == ITEM_PORTAL)
        {
            if (!IS_SET(obj->value[1], EX_ISDOOR))
            {
                char_act("You can't do that.", ch);
                return;
            }

            if (!IS_SET(obj->value[1], EX_CLOSED))
            {
                char_act("It's already open.", ch);
                return;
            }

            if (IS_SET(obj->value[1], EX_LOCKED))
            {
                char_act("It's locked.", ch);
                return;
            }

            REMOVE_BIT(obj->value[1], EX_CLOSED);
            act_puts("You open $p.", ch, obj, NULL, TO_CHAR, POS_DEAD);
            act("$n opens $p.", ch, obj, NULL, TO_ROOM);
            return;
        }

        /* 'open object' */
        if (obj->pIndexData->item_type != ITEM_CONTAINER)
        {
            act_puts("$p not a container.", ch, obj, NULL, TO_CHAR, POS_DEAD);
            return;
            //            char_act("üÔÏ ÎÅ ËÏÎÔÅÊÎÅÒ.", ch);
        }
        if (!IS_SET(obj->value[1], CONT_CLOSED))
        {
            act_puts("$p already open.", ch, obj, NULL, TO_CHAR, POS_DEAD);
            return;
            //            char_act("üÔÏ ÕÖÅ ÏÔËÒÙÔÏ.", ch); return;
        }
        if (!IS_SET(obj->value[1], CONT_CLOSEABLE))
        {
            act_puts("You can't do that with $p.", ch, obj, NULL, TO_CHAR, POS_DEAD);
            return;
            //            char_act("ôÙ ÎÅ ÍÏÖÅÛØ ÓÄÅÌÁÔØ ÜÔÏ.", ch); return;
        }
        if (IS_SET(obj->value[1], CONT_LOCKED))
        {
            act_puts("$p locked.", ch, obj, NULL, TO_CHAR, POS_DEAD);
            return;
            //            char_act("úÁÐÅÒÔÏ.", ch); return;
        }

        REMOVE_BIT(obj->value[1], CONT_CLOSED);
        act_puts("You open $p.", ch, obj, NULL, TO_CHAR, POS_DEAD);
        act("$n opens $p.", ch, obj, NULL, TO_ROOM);
        return;
    }

    if ((door = find_door(ch, arg)) >= 0)
    {
        /* 'open door' */
        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))
        {
            char_act("It's already open.", ch);
            return;
        }
        if ( IS_SET(pexit->exit_info, EX_LOCKED))
        {
            char_act("It's locked.", ch);
            return;
        }

        REMOVE_BIT(pexit->exit_info, EX_CLOSED);
        act("$n opens the $d.", ch, NULL, pexit->keyword, TO_ROOM);
        char_act("Ok.", ch);

        /* open the other side */
        if ((to_room   = pexit->to_room.r           ) != NULL
                &&   (pexit_rev = to_room->exit[rev_dir[door]]) != NULL
                &&   pexit_rev->to_room.r == ch->in_room)
        {
            ROOM_INDEX_DATA *in_room;

            REMOVE_BIT(pexit_rev->exit_info, EX_CLOSED);

            in_room = ch->in_room;
            ch->in_room = to_room;
            act("The $d opens.", ch, NULL, pexit_rev->keyword,
                TO_ROOM);
            ch->in_room = in_room;
        }
        return;
    }
}

DO_FUN(do_close)
{
    char arg[MAX_INPUT_LENGTH];
    OBJ_DATA *obj;
    int door;

    one_argument(argument, arg, sizeof(arg));

    if (arg[0] == '\0')
    {
        char_act("Close what?", ch);
        return;
    }

    if ((obj = get_obj_here(ch, arg)) != NULL)
    {
        /* portal stuff */
        if (obj->pIndexData->item_type == ITEM_PORTAL)
        {

            if (!IS_SET(obj->value[1],EX_ISDOOR)
                    || IS_SET(obj->value[1],EX_NOCLOSE))
            {
                char_act("You can't do that.", ch);
                return;
            }

            if (IS_SET(obj->value[1],EX_CLOSED))
            {
                char_act("It's already closed.", ch);
                return;
            }

            SET_BIT(obj->value[1],EX_CLOSED);
            act_puts("You close $p.", ch, obj, NULL, TO_CHAR, POS_DEAD);
            act("$n closes $p.", ch, obj, NULL, TO_ROOM);
            return;
        }

        /* 'close object' */
        if (obj->pIndexData->item_type != ITEM_CONTAINER)
        {
            act_puts("$p not a container.", ch, obj, NULL, TO_CHAR, POS_DEAD);
            return;
            //            char_act("üÔÏ ÎÅ ËÏÎÔÅÊÎÅÒ.", ch); return;
        }
        if (IS_SET(obj->value[1], CONT_CLOSED))
        {
            act_puts("$p already closed.", ch, obj, NULL, TO_CHAR, POS_DEAD);
            return;
            //            char_act("ôÕÔ ÕÖÅ ÚÁËÒÙÔÏ.", ch); return;
        }
        if (!IS_SET(obj->value[1], CONT_CLOSEABLE))
        {
            act_puts("You can't do that with $p.", ch, obj, NULL, TO_CHAR, POS_DEAD);
            return;
            //            char_act("ôÙ ÎÅ ÍÏÖÅÛØ ÓÄÅÌÁÔØ ÜÔÏÇÏ.", ch); return;
        }

        SET_BIT(obj->value[1], CONT_CLOSED);
        act_puts("You close $p.", ch, obj, NULL, TO_CHAR, POS_DEAD);
        act("$n closes $p.", ch, obj, NULL, TO_ROOM);
        return;
    }

    if ((door = find_door(ch, arg)) >= 0)
    {
        /* 'close door' */
        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))
        {
            char_act("It's already closed.", ch);
            return;
        }

        SET_BIT(pexit->exit_info, EX_CLOSED);
        act("$n closes $d.", ch, NULL, pexit->keyword, TO_ROOM);
        char_act("Ok.", ch);

        /* close the other side */
        if ((to_room   = pexit->to_room.r           ) != NULL
                &&   (pexit_rev = to_room->exit[rev_dir[door]]) != 0
                &&   pexit_rev->to_room.r == ch->in_room)
        {
            ROOM_INDEX_DATA *in_room;

            SET_BIT(pexit_rev->exit_info, EX_CLOSED);
            in_room = ch->in_room;
            ch->in_room = to_room;
            act("The $d closes.", ch, NULL, pexit_rev->keyword, TO_ROOM);
            ch->in_room = in_room;
        }
        return;
    }
}

/*
 * Added can_see check. Kio.
 */
/*
bool has_key(CHAR_DATA *ch, int key)
{
    OBJ_DATA *obj;

    for (obj = ch->carrying; obj; obj = obj->next_content)
        if (obj->pIndexData->vnum == key   &&  can_see_obj(ch, obj))
            return TRUE;

    return FALSE;
}

*/

bool has_key( CHAR_DATA *ch, int key )
{
    OBJ_DATA *obj;
    KEY_DATA *keys;

    for ( obj = ch->carrying; obj != NULL; obj = obj->next_content )
    {
      if ( obj->pIndexData->vnum == key &&  can_see_obj(ch, obj))
          return TRUE;
    }

    // look for the keyring in players inventory
    obj = find_keyring(ch);

    // no keyring found ?
    if (!obj) return FALSE;

    // loop thru the keys on keyring and see if there is a matching key
    for (keys = obj->keys; keys != NULL; keys = keys->next)
    {
      if ( keys->index->vnum == key )
      {
          char_act("After some searching of your keyring, you found a key that seems to fit the lock.", ch);
          return TRUE;
      }
    }

    // no keys found
    return FALSE;
}

bool has_key_ground(CHAR_DATA *ch, int key)
{
    OBJ_DATA *obj;

    for (obj = ch->in_room->contents; obj; obj = obj->next_content)
        if (obj->pIndexData->vnum == key
                &&  can_see_obj(ch, obj))
            return TRUE;

    return FALSE;
}

DO_FUN(do_lock)
{
    char arg[MAX_INPUT_LENGTH];
    OBJ_DATA *obj;
    int door;

    one_argument(argument, arg, sizeof(arg));

    if (arg[0] == '\0')
    {
        char_act("Lock what?", ch);
        return;
    }

    if ((obj = get_obj_here(ch, arg)) != NULL)
    {
        /* portal stuff */
        if (obj->pIndexData->item_type == ITEM_PORTAL)
        {
            if (!IS_SET(obj->value[1], EX_ISDOOR)
                    ||  IS_SET(obj->value[1], EX_NOCLOSE))
            {
                char_act("You can't do that.", ch);
                return;
            }
            if (!IS_SET(obj->value[1], EX_CLOSED))
            {
                char_act("It's not closed.", ch);
                return;
            }

            if (obj->value[4] < 0 || IS_SET(obj->value[1], EX_NOLOCK))
            {
                char_act("It can't be locked.", ch);
                return;
            }

            if (!has_key(ch, obj->value[4]))
            {
                char_act("You lack the key.", ch);
                return;
            }

            if (IS_SET(obj->value[1], EX_LOCKED))
            {
                char_act("It's already locked.", ch);
                return;
            }

            SET_BIT(obj->value[1], EX_LOCKED);
            act_puts("You lock $p.", ch, obj, NULL, TO_CHAR, POS_DEAD);
            act("$n locks $p.", ch, obj, NULL, TO_ROOM);
            return;
        }

        /* 'lock object' */
        if (obj->pIndexData->item_type != ITEM_CONTAINER)
        {
            act_puts("$p not a container.", ch, obj, NULL, TO_CHAR, POS_DEAD);
            return;
            //            char_act("üÔÏ ÎÅ ËÏÎÔÅÊÎÅÒ.", ch); return;
        }
        if (!IS_SET(obj->value[1], CONT_CLOSED))
        {
            act_puts("$p not closed.", ch, obj, NULL, TO_CHAR, POS_DEAD);
            return;
            //            char_act("úÄÅÓØ ÎÅ ÚÁËÒÙÔÏ.", ch); return;
        }
        if (obj->value[2] < 0)
        {
            act_puts("$p can't be locked.", ch, obj, NULL, TO_CHAR, POS_DEAD);
            return;
            //            char_act("üÔÏ ÎÅÌØÚÑ ÚÁÐÅÒÅÔØ.", ch); return;
        }
        if (!has_key(ch, obj->value[2]))
        {
            act_puts("You lack the key from $p.", ch, obj, NULL, TO_CHAR, POS_DEAD);
            return;
            //            char_act("õ ÔÅÂÑ ÎÅÔ ËÌÀÞÁ.", ch); return;
        }
        if (IS_SET(obj->value[1], CONT_LOCKED))
        {
            act_puts("$p already locked.", ch, obj, NULL, TO_CHAR, POS_DEAD);
            return;
            //            char_act("ôÕÔ ÕÖÅ ÚÁÐÅÒÔÏ.", ch); return;
        }

        SET_BIT(obj->value[1], CONT_LOCKED);
        act_puts("You lock $p.", ch, obj, NULL, TO_CHAR, POS_DEAD);
        act("$n locks $p.", ch, obj, NULL, TO_ROOM);
        return;
    }

    if ((door = find_door(ch, arg)) >= 0)
    {
        /* 'lock door' */
        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))
        {
            char_act("It's not closed.", ch);
            return;
        }
        if (pexit->key < 0)
        {
            char_act("It can't be locked.", ch);
            return;
        }
        if (!has_key(ch, pexit->key)
                && !has_key_ground(ch, pexit->key))
        {
            char_act("You lack the key.", ch);
            return;
        }
        if (IS_SET(pexit->exit_info, EX_LOCKED))
        {
            char_act("It's already locked.", ch);
            return;
        }

        SET_BIT(pexit->exit_info, EX_LOCKED);
        char_act("*Click*", ch);
        act("$n locks the $d.", ch, NULL, pexit->keyword, TO_ROOM);

        /* lock the other side */
        if ((to_room   = pexit->to_room.r           ) != NULL
                &&   (pexit_rev = to_room->exit[rev_dir[door]]) != 0
                &&   pexit_rev->to_room.r == ch->in_room)
        {
            ROOM_INDEX_DATA *in_room;

            SET_BIT(pexit_rev->exit_info, EX_LOCKED);

            in_room = ch->in_room;
            ch->in_room = to_room;
            act("The $d clicks.",
                ch, NULL, pexit_rev->keyword, TO_ROOM);
            ch->in_room  = in_room;
        }
        return;
    }
}

DO_FUN(do_unlock)
{
    char arg[MAX_INPUT_LENGTH];
    OBJ_DATA *obj;
    int door;

    one_argument(argument, arg, sizeof(arg));

    if (arg[0] == '\0')
    {
        char_act("Unlock what?", ch);
        return;
    }

    if ((obj = get_obj_here(ch, arg)) != NULL)
    {
        /* portal stuff */
        if (obj->pIndexData->item_type == ITEM_PORTAL)
        {
            if (IS_SET(obj->value[1],EX_ISDOOR))
            {
                char_act("You can't do that.", ch);
                return;
            }

            if (!IS_SET(obj->value[1],EX_CLOSED))
            {
                char_act("It's not closed.", ch);
                return;
            }

            if (obj->value[4] < 0)
            {
                char_act("It can't be unlocked.", ch);
                return;
            }

            if (!has_key(ch, obj->value[4]))
            {
                char_act("You lack the key.", ch);
                return;
            }

            if (!IS_SET(obj->value[1], EX_LOCKED))
            {
                char_act("It's already unlocked.", ch);
                return;
            }

            REMOVE_BIT(obj->value[1], EX_LOCKED);
            act_puts("You unlock $p.", ch, obj, NULL, TO_CHAR, POS_DEAD);
            act("$n unlocks $p.", ch, obj, NULL, TO_ROOM);
            return;
        }

        /* 'unlock object' */
        if (obj->pIndexData->item_type != ITEM_CONTAINER)
        {
            act_puts("$p not a container.", ch, obj, NULL, TO_CHAR, POS_DEAD);
            return;
            //            char_act("üÔÏ ÎÅ ËÏÎÔÅÊÎÅÒ.", ch); return;
        }
        if (!IS_SET(obj->value[1], CONT_CLOSED))
        {
            act_puts("$p not closed.", ch, obj, NULL, TO_CHAR, POS_DEAD);
            return;
            //            char_act("ôÕÔ ÎÅ ÚÁËÒÙÔÏ.", ch); return;
        }
        if (obj->value[2] < 0)
        {
            act_puts("$p can't be unlocked.", ch, obj, NULL, TO_CHAR, POS_DEAD);
            return;
            //            char_act("ôÕÔ ÎÅ ÚÁÐÅÒÔÏ.", ch); return;
        }
        if (!has_key(ch, obj->value[2]))
        {
            act_puts("You lack the key from $p.", ch, obj, NULL, TO_CHAR, POS_DEAD);
            return;
            //            char_act("õ ÔÅÂÑ ÎÅÔ ËÌÀÞÁ.", ch); return;
        }
        if (!IS_SET(obj->value[1], CONT_LOCKED))
        {
            act_puts("$p already unlocked.", ch, obj, NULL, TO_CHAR, POS_DEAD);
            return;
            //            char_act("ôÕÔ ÎÅ ÚÁÐÅÒÔÏ.", ch); return;
        }

        REMOVE_BIT(obj->value[1], CONT_LOCKED);
        act_puts("You unlock $p.", ch, obj, NULL, TO_CHAR, POS_DEAD);
        act("$n unlocks $p.", ch, obj, NULL, TO_ROOM);
        return;
    }

    if ((door = find_door(ch, arg)) >= 0)
    {
        /* 'unlock door' */
        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))
        {
            char_act("It's not closed.", ch);
            return;
        }
        if (pexit->key < 0)
        {
            char_act("It can't be unlocked.", ch);
            return;
        }
        if (!has_key(ch, pexit->key) &&
                !has_key_ground(ch, pexit->key))
        {
            char_act("You lack the key.", ch);
            return;
        }
        if (!IS_SET(pexit->exit_info, EX_LOCKED))
        {
            char_act("It's already unlocked.", ch);
            return;
        }

        REMOVE_BIT(pexit->exit_info, EX_LOCKED);
        char_act("*Click*", ch);
        act("$n unlocks the $d.", ch, NULL, pexit->keyword, TO_ROOM);

        /* unlock the other side */
        if ((to_room   = pexit->to_room.r           ) != NULL
                &&   (pexit_rev = to_room->exit[rev_dir[door]]) != NULL
                &&   pexit_rev->to_room.r == ch->in_room)
        {
            ROOM_INDEX_DATA *in_room;

            REMOVE_BIT(pexit_rev->exit_info, EX_LOCKED);

            in_room = ch->in_room;
            ch->in_room = to_room;
            act("The $d clicks.",
                ch, NULL, pexit_rev->keyword, TO_ROOM);
            ch->in_room = in_room;
        }
        return;
    }
}

DO_FUN(do_pick)
{
    char arg[MAX_INPUT_LENGTH];
    CHAR_DATA *gch;
    OBJ_DATA *obj;
    int door;
    int chance;
    //FIXME: EVENT *e;

    if ((chance = get_skill(ch, gsn_pick)) == 0)
    {
        char_act("Huh?", ch);
        return;
    }

    one_argument(argument, arg, sizeof(arg));

    if (arg[0] == '\0')
    {
        char_act("Pick what?", ch);
        return;
    }

    if (IS_SET(muddy_mode, MUDDY_EVENTS))
        create_char_event(ch, evn_char_test, 10);//Test nafig

    if (MOUNTED(ch))
    {
        char_act("You can't pick while mounted.", ch);
        return;
    }

    WAIT_STATE(ch, SKILL(gsn_pick)->beats);

    /* look for guards */
    for (gch = ch->in_room->people; gch; gch = gch->next_in_room)
    {
        if (IS_NPC(gch)
                && IS_AWAKE(gch)
                && ch->level + 5 < gch->level)
        {
            act("$N is standing too close to lock.", ch, NULL, gch, TO_CHAR);
            return;
        }
    }

    if (!IS_NPC(ch) && number_percent() > chance)
    {
        char_act("You failed.", ch);
        check_improve(ch, gsn_pick, FALSE, 2);
        return;
    }

    if ((obj = get_obj_here(ch, arg)) != NULL)
    {
        /* portal stuff */
        if (obj->pIndexData->item_type == ITEM_PORTAL)
        {
            if (!IS_SET(obj->value[1],EX_ISDOOR))
            {
                char_act("You can't do that.", ch);
                return;
            }

            if (!IS_SET(obj->value[1],EX_CLOSED))
            {
                char_act("It's not closed.", ch);
                return;
            }

            if (obj->value[4] < 0)
            {
                char_act("It can't be unlocked.", ch);
                return;
            }

            if (IS_SET(obj->value[1],EX_PICKPROOF))
            {
                char_act("You failed.", ch);
                return;
            }

            REMOVE_BIT(obj->value[1],EX_LOCKED);
            act_puts("You pick the lock on $p.", ch, obj, NULL, TO_CHAR, POS_DEAD);
            act("$n picks the lock on $p.", ch, obj, NULL, TO_ROOM);
            check_improve(ch, gsn_pick, TRUE, 2);
            return;
        }

        /* 'pick object' */
        if (obj->pIndexData->item_type != ITEM_CONTAINER)
        {
            act_puts("$p not a container.", ch, obj, NULL, TO_CHAR, POS_DEAD);
            return;
            //            char_act("üÔÏ ÎÅ ËÏÎÔÅÊÎÅÒ.", ch); return;
        }
        if (!IS_SET(obj->value[1], CONT_CLOSED))
        {
            act_puts("$p not closed.", ch, obj, NULL, TO_CHAR, POS_DEAD);
            return;
            //            char_act("ôÕÔ ÏÔËÒÙÔÏ.", ch); return;
        }
        if (obj->value[2] < 0)
        {
            act_puts("$p can't be unlocked.", ch, obj, NULL, TO_CHAR, POS_DEAD);
            return;
            //            char_act("üÔÏ ÎÅÌØÚÑ ÏÔÐÅÒÅÔØ.", ch); return;
        }
        if (!IS_SET(obj->value[1], CONT_LOCKED))
        {
            act_puts("$p already unlocked.", ch, obj, NULL, TO_CHAR, POS_DEAD);
            return;
            //            char_act("ôÕÔ ÎÅ ÚÁÐÅÒÔÏ.", ch); return;
        }
        if (IS_SET(obj->value[1], CONT_PICKPROOF))
        {
            char_act("You failed.", ch);
            return;
        }

        REMOVE_BIT(obj->value[1], CONT_LOCKED);
        act_puts("You pick the lock on $p.", ch, obj, NULL, TO_CHAR, POS_DEAD);
        act("$n picks the lock on $p.", ch, obj, NULL, TO_ROOM);
        check_improve(ch, gsn_pick, TRUE, 2);
        return;
    }

    if ((door = find_door(ch, arg)) >= 0)
    {
        /* 'pick door' */
        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) && !IS_IMMORTAL(ch))
        {
            char_act("It's not closed.", ch);
            return;
        }
        if (pexit->key < 0 && !IS_IMMORTAL(ch))
        {
            char_act("It can't be picked.", ch);
            return;
        }
        if (!IS_SET(pexit->exit_info, EX_LOCKED))
        {
            char_act("It's already unlocked.", ch);
            return;
        }
        if (IS_SET(pexit->exit_info, EX_PICKPROOF) && !IS_IMMORTAL(ch))
        {
            char_act("You failed.", ch);
            return;
        }

        REMOVE_BIT(pexit->exit_info, EX_LOCKED);
        char_act("*Click*", ch);
        act("$n picks the $d.", ch, NULL, pexit->keyword, TO_ROOM);
        check_improve(ch, gsn_pick, TRUE, 2);

        /* pick the other side */
        if ((to_room   = pexit->to_room.r           ) != NULL
                &&   (pexit_rev = to_room->exit[rev_dir[door]]) != NULL
                &&   pexit_rev->to_room.r == ch->in_room)
            REMOVE_BIT(pexit_rev->exit_info, EX_LOCKED);
    }
}

DO_FUN(do_stand)
{
    OBJ_DATA *obj = NULL;

    if (argument[0] != '\0')
    {
        if (ch->position == POS_FIGHTING)
        {
            char_act("Maybe you should finish fighting first?", ch);
            return;
        }
        obj = get_obj_list(ch,argument,ch->in_room->contents);
        if (obj == NULL)
        {
            char_act("You don't see that here.", ch);
            return;
        }
        if (obj->pIndexData->item_type != ITEM_FURNITURE
                || (!IS_SET(obj->value[2],STAND_AT)
                    && !IS_SET(obj->value[2],STAND_ON)
                    && !IS_SET(obj->value[2],STAND_IN)))
        {
            char_act("You can't seem to find a place to stand.", ch);
            return;
        }
        if (ch->on != obj && count_users(obj) >= obj->value[0])
        {
            act_puts("There's no room to stand on $p.",
                     ch, obj, NULL, TO_ROOM, POS_DEAD);
            return;
        }
    }
    switch (ch->position)
    {
    case POS_SLEEPING:
        if (IS_AFFECTED(ch, AFF_SLEEP))
        {
            char_act("You can't wake up!", ch);
            return;
        }

        if (obj == NULL)
        {
            char_act("You wake and stand up.", ch);
            act("$n wakes and stands up.", ch, NULL, NULL, TO_ROOM);

            ch->on = NULL;
        }
        else if (IS_SET(obj->value[2],STAND_AT))
        {
            act_puts("You wake and stand at $p.", ch, obj, NULL, TO_CHAR, POS_DEAD);
            act("$n wakes and stands at $p.", ch, obj, NULL, TO_ROOM);

        }
        else if (IS_SET(obj->value[2],STAND_ON))
        {
            act_puts("You wake and stand on $p.", ch, obj, NULL, TO_CHAR, POS_DEAD);
            act("$n wakes and stands on $p.", ch, obj, NULL, TO_ROOM);
        }
        else
        {
            act_puts("You wake and stand in $p.", ch, obj, NULL, TO_CHAR, POS_DEAD);
            act("$n wakes and stands in $p.", ch, obj, NULL, TO_ROOM);
        }

        ch->position = POS_STANDING;
        do_look(ch,"auto");
        break;

    case POS_RESTING:
    case POS_SITTING:
        if (obj == NULL)
        {
            char_act("You stand up.", ch);
            act("$n stands up.", ch, NULL, NULL, TO_ROOM);
            ch->on = NULL;
        }
        else if (IS_SET(obj->value[2],STAND_AT))
        {
            act_puts("You stand at $p.", ch, obj, NULL, TO_CHAR, POS_DEAD);
            act("$n stands at $p.", ch, obj, NULL, TO_ROOM);
        }
        else if (IS_SET(obj->value[2],STAND_ON))
        {
            act_puts("You stand on $p.", ch, obj, NULL, TO_CHAR, POS_DEAD);
            act("$n stands on $p.", ch, obj, NULL, TO_ROOM);
        }
        else
        {
            act_puts("You stand in $p.", ch, obj, NULL, TO_CHAR, POS_DEAD);
            act("$n stands in $p.", ch, obj, NULL, TO_ROOM);
        }
        ch->position = POS_STANDING;
        break;

    case POS_STANDING:
        char_act("You are already standing.", ch);
        break;

    case POS_FIGHTING:
        char_act("You are already fighting!", ch);
        break;
    }

    if (IS_HARA_KIRI(ch))
    {
        char_act("You feel your blood heats your body.", ch);
        REMOVE_BIT(ch->plr_flags, PLR_HARA_KIRI);
    }
}

DO_FUN(do_rest)
{
    OBJ_DATA *obj = NULL;

    if (ch->position == POS_FIGHTING)
    {
        char_act("You are already fighting!", ch);
        return;
    }

    if (MOUNTED(ch))
    {
        char_act("You can't rest while mounted.", ch);
        return;
    }

    if (RIDDEN(ch))
    {
        char_act("You can't rest while being ridden.", ch);
        return;
    }

    if (IS_AFFECTED(ch, AFF_SLEEP))
    {
        char_act("You are already sleeping.", ch);
        return;
    }

    /* okay, now that we know we can rest, find an object to rest on */
    if (argument[0] != '\0')
    {
        obj = get_obj_list(ch,argument,ch->in_room->contents);
        if (obj == NULL)
        {
            char_act("You don't see that here.", ch);
            return;
        }
    }
    else
        obj = ch->on;

    if (obj != NULL)
    {
        if (obj->pIndexData->item_type != ITEM_FURNITURE
                ||  (!IS_SET(obj->value[2],REST_ON) &&
                     !IS_SET(obj->value[2],REST_IN) &&
                     !IS_SET(obj->value[2],REST_AT)))
        {
            char_act("You can't rest on that.", ch);
            return;
        }

        if (obj != NULL && ch->on != obj
                &&  count_users(obj) >= obj->value[0])
        {
            act_puts("There's no more room on $p.", ch, obj, NULL, TO_CHAR, POS_DEAD);
            return;
        }

        ch->on = obj;
        if (HAS_TRIGGER_OBJ(obj, TRIG_SIT))
            p_percent_trigger( NULL, obj, NULL, ch, NULL, NULL, TRIG_SIT );
    }

    switch (ch->position)
    {
    case POS_SLEEPING:
        if (obj == NULL)
        {
            char_act("You wake up and start resting.", ch);
            act("$n wakes up and starts resting.",
                ch, NULL, NULL, TO_ROOM);

        }
        else if (IS_SET(obj->value[2],REST_AT))
        {
            act_puts("You wake up and rest at $p.",
                     ch, obj, NULL, TO_CHAR, POS_DEAD);
            act("$n wakes up and rests at $p.",
                ch, obj, NULL, TO_ROOM);
        }
        else if (IS_SET(obj->value[2],REST_ON))
        {
            act_puts("You wake up and rest on $p.",
                     ch, obj, NULL, TO_CHAR, POS_DEAD);
            act("$n wakes up and rests on $p.",
                ch, obj, NULL, TO_ROOM);
        }
        else
        {
            act_puts("You wake up and rest in $p.",
                     ch, obj, NULL, TO_CHAR, POS_DEAD);
            act("$n wakes up and rests in $p.",
                ch, obj, NULL, TO_ROOM);
        }
        ch->position = POS_RESTING;
        break;

    case POS_RESTING:
        char_act("You are already resting.", ch);
        break;

    case POS_STANDING:
        if (obj == NULL)
        {
            char_act("You rest.", ch);
            act("$n sits down and rests.", ch, NULL, NULL, TO_ROOM);
        }
        else if (IS_SET(obj->value[2], REST_AT))
        {
            act_puts("You sit down at $p and rest.", ch, obj, NULL, TO_CHAR, POS_DEAD);
            act("$n sits down at $p and rests.", ch, obj, NULL, TO_ROOM);
        }
        else if (IS_SET(obj->value[2], REST_ON))
        {
            act_puts("You sit down on $p and rest.", ch, obj, NULL, TO_CHAR, POS_DEAD);
            act("$n sits down on $p and rests.", ch, obj, NULL, TO_ROOM);
        }
        else
        {
            act_puts("You sit down in $p and rest.", ch, obj, NULL, TO_CHAR, POS_DEAD);
            act("$n sits down in $p and rests.", ch, obj, NULL, TO_ROOM);
        }
        ch->position = POS_RESTING;
        break;

    case POS_SITTING:
        if (obj == NULL)
        {
            char_act("You rest.", ch);
            act("$n rests.", ch, NULL, NULL, TO_ROOM);
        }
        else if (IS_SET(obj->value[2],REST_AT))
        {
            act_puts("You rest at $p.", ch, obj, NULL, TO_CHAR, POS_DEAD);
            act("$n rests at $p.", ch, obj, NULL, TO_ROOM);
        }
        else if (IS_SET(obj->value[2],REST_ON))
        {
            act_puts("You rest on $p.", ch, obj, NULL, TO_CHAR, POS_DEAD);
            act("$n rests on $p.", ch, obj, NULL, TO_ROOM);
        }
        else
        {
            act_puts("You rest in $p.", ch, obj, NULL, TO_CHAR, POS_DEAD);
            act("$n rests in $p.", ch, obj, NULL, TO_ROOM);
        }
        ch->position = POS_RESTING;
        break;
    }

    if (IS_HARA_KIRI(ch))
    {
        char_act("You feel your blood heats your body.", ch);
        REMOVE_BIT(ch->plr_flags, PLR_HARA_KIRI);
    }
}

DO_FUN(do_sit)
{
    OBJ_DATA *obj = NULL;

    if (ch->position == POS_FIGHTING)
    {
        char_act("Maybe you should finish fighting first?", ch);
        return;
    }

    if (MOUNTED(ch))
    {
        char_act("You can't sit while mounted.", ch);
        return;
    }

    if (RIDDEN(ch))
    {
        char_act("You can't sit while being ridden.", ch);
        return;
    }

    if (IS_AFFECTED(ch, AFF_SLEEP))
    {
        char_act("You are already sleeping.", ch);
        return;
    }

    /* okay, now that we know we can sit, find an object to sit on */
    if (argument[0] != '\0')
    {
        obj = get_obj_list(ch,argument,ch->in_room->contents);
        if (obj == NULL)
        {
            char_act("You don't see that here.", ch);
            return;
        }
    }
    else
        obj = ch->on;

    if (obj != NULL)
    {
        if (obj->pIndexData->item_type != ITEM_FURNITURE
                ||  (!IS_SET(obj->value[2],SIT_ON)
                     &&   !IS_SET(obj->value[2],SIT_IN)
                     &&   !IS_SET(obj->value[2],SIT_AT)))
        {
            char_act("You can't sit on that.", ch);
            return;
        }

        if (obj != NULL &&  ch->on != obj &&  count_users(obj) >= obj->value[0])
        {
            act_puts("There's no more room on $p.", ch, obj, NULL, TO_CHAR, POS_DEAD);
            return;
        }

        ch->on = obj;

        if (HAS_TRIGGER_OBJ(obj, TRIG_SIT))
            p_percent_trigger( NULL, obj, NULL, ch, NULL, NULL, TRIG_SIT );
    }

    switch (ch->position)
    {
    case POS_SLEEPING:
        if (obj == NULL)
        {
            char_act("You wake and sit up.", ch);
            act("$n wakes and sits up.", ch, NULL, NULL, TO_ROOM);
        }
        else if (IS_SET(obj->value[2],SIT_AT))
        {
            act_puts("You wake and sit at $p.", ch, obj, NULL, TO_CHAR, POS_DEAD);
            act("$n wakes and sits at $p.", ch, obj, NULL, TO_ROOM);
        }
        else if (IS_SET(obj->value[2],SIT_ON))
        {
            act_puts("You wake and sit on $p.", ch, obj, NULL, TO_CHAR, POS_DEAD);
            act("$n wakes and sits on $p.", ch, obj, NULL, TO_ROOM);
        }
        else
        {
            act_puts("You wake and sit in $p.", ch, obj, NULL, TO_CHAR, POS_DEAD);
            act("$n wakes and sits in $p.", ch, obj, NULL, TO_ROOM);
        }

        ch->position = POS_SITTING;
        break;

    case POS_RESTING:
        if (obj == NULL)
            char_act("You stop resting.", ch);
        else if (IS_SET(obj->value[2],SIT_AT))
        {
            act_puts("You sit at $p.", ch, obj, NULL, TO_CHAR, POS_DEAD);
            act("$n sits at $p.", ch, obj, NULL, TO_ROOM);
        }
        else if (IS_SET(obj->value[2],SIT_ON))
        {
            act_puts("You sit on $p.", ch, obj, NULL, TO_CHAR, POS_DEAD);
            act("$n sits on $p.", ch, obj, NULL, TO_ROOM);
        }
        else
        {
            act_puts("You sit in $p.", ch, obj, NULL, TO_CHAR, POS_DEAD);
            act("$n sits in $p.", ch, obj, NULL, TO_ROOM);
        }
        ch->position = POS_SITTING;
        break;

    case POS_SITTING:
        char_act("You are already sitting down.", ch);
        break;

    case POS_STANDING:
        if (obj == NULL)
        {
            char_act("You sit down.", ch);
            act("$n sits down on the ground.", ch, NULL, NULL, TO_ROOM);
        }
        else if (IS_SET(obj->value[2], SIT_AT))
        {
            act_puts("You sit down at $p.", ch, obj, NULL, TO_CHAR, POS_DEAD);
            act("$n sits down at $p.", ch, obj, NULL, TO_ROOM);
        }
        else if (IS_SET(obj->value[2],SIT_ON))
        {
            act_puts("You sit down on $p.", ch, obj, NULL, TO_CHAR, POS_DEAD);
            act("$n sits down on $p.", ch, obj, NULL, TO_ROOM);
        }
        else
        {
            act_puts("You sit down in $p.", ch, obj, NULL, TO_CHAR, POS_DEAD);
            act("$n sits down in $p.", ch, obj, NULL, TO_ROOM);
        }
        ch->position = POS_SITTING;
        break;
    }

    if (IS_HARA_KIRI(ch))
    {
        char_act("You feel your blood heats your body.", ch);
        REMOVE_BIT(ch->plr_flags, PLR_HARA_KIRI);
    }
}

DO_FUN(do_sleep)
{
    OBJ_DATA *obj = NULL;

    if (MOUNTED(ch))
    {
        char_act("You can't sleep while mounted.", ch);
        return;
    }

    if (RIDDEN(ch))
    {
        char_act("You can't sleep while being ridden.", ch);
        return;
    }

    if (is_affected (ch, gsn_insomnia))
    {
        char_act("But you can't sleep!", ch);
        return;
    }

    if (ch->class == CLASS_VAMPIRE)
    {
        if ( weather_info.sunlight != SUN_LIGHT && weather_info.sunlight != SUN_RISE)
        {
            act("Vampire sleeps at daytime!", ch, NULL, NULL, TO_CHAR);
            return;
        }
    }
    else if (IS_UNDEAD(ch))
    {
        act("You are undead and can't sleep.", ch, NULL, NULL, TO_CHAR);
        return;
    }
    switch (ch->position)
    {
    case POS_SLEEPING:
        char_act("You are already sleeping.", ch);
        break;

    case POS_RESTING:
    case POS_SITTING:
    case POS_STANDING:
        if (argument[0] == '\0' && ch->on == NULL)
        {
            char_act("You go to sleep.", ch);
            act("$n goes to sleep.", ch, NULL, NULL, TO_ROOM);
        }
        else
        { /* find an object and sleep on it */
            if (argument[0] == '\0')
                obj = ch->on;
            else
                obj = get_obj_list(ch, argument, ch->in_room->contents);

            if (obj == NULL)
            {
                char_act("You don't see that here.", ch);
                return;
            }

            if (obj->pIndexData->item_type != ITEM_FURNITURE
                    || (!IS_SET(obj->value[2], SLEEP_ON)
                        && !IS_SET(obj->value[2],SLEEP_IN)
                        && !IS_SET(obj->value[2],SLEEP_AT)))
            {
                char_act("You can't sleep on that.", ch);
                return;
            }

            if (ch->on != obj &&  count_users(obj) >= obj->value[0])
            {
                act_puts("There's no room on $p for you.",
                         ch, obj, NULL, TO_CHAR, POS_DEAD);
                return;
            }

            ch->on = obj;

            if (HAS_TRIGGER_OBJ(obj, TRIG_SIT))
                p_percent_trigger( NULL, obj, NULL, ch, NULL, NULL, TRIG_SIT );

            if (IS_SET(obj->value[2], SLEEP_AT))
            {
                act_puts("You go to sleep at $p.", ch, obj, NULL, TO_CHAR, POS_DEAD);
                act("$n goes to sleep at $p.", ch, obj, NULL, TO_ROOM);
            }
            else if (IS_SET(obj->value[2], SLEEP_ON))
            {
                act_puts("You go to sleep on $p.", ch, obj, NULL, TO_CHAR, POS_DEAD);
                act("$n goes to sleep on $p.", ch, obj, NULL, TO_ROOM);
            }
            else
            {
                act_puts("You go to sleep in $p.", ch, obj, NULL, TO_CHAR, POS_DEAD);
                act("$n goes to sleep in $p.", ch, obj, NULL, TO_ROOM);
            }
        }
        ch->position = POS_SLEEPING;
        break;

    case POS_FIGHTING:
        char_act("You are already fighting.", ch);
        break;
    }
}

DO_FUN(do_wake)
{
    char arg[MAX_INPUT_LENGTH];
    CHAR_DATA *victim;

    one_argument(argument, arg, sizeof(arg));
    if (arg[0] == '\0')
    {
        do_stand(ch, argument);
        return;
    }

    if (!IS_AWAKE(ch))
    {
        char_act("You are asleep yourself!", ch);
        return;
    }

    if ((victim = get_char_room(ch, arg)) == NULL)
    {
        char_act("They aren't here.", ch);
        return;
    }

    if (IS_AWAKE(victim))
    {
        act_puts("$N is already awake.", ch, NULL, victim, TO_CHAR, POS_DEAD);
        return;
    }

    if (IS_AFFECTED(victim, AFF_SLEEP))
    {
        act_puts("You can't wake $gN{him}!", victim, NULL, ch, TO_VICT, POS_DEAD);
        return;
    }

    act_puts("$n wakes you.", ch, NULL, victim, TO_VICT, POS_SLEEPING);
    do_stand(victim, str_empty);
    return;
}

DO_FUN(do_sneak)
{
    AFFECT_DATA af;
    int     chance;

    if ((chance = get_skill(ch, gsn_sneak)) == 0)
    {
        char_act("Huh?", ch);
        return;
    }

    if (MOUNTED(ch))
    {
        char_act("You can't sneak while mounted.", ch);
        return;
    }

    char_act("You attempt to move silently.", ch);
    affect_strip(ch, gsn_sneak);

    if (IS_AFFECTED(ch, AFF_SNEAK))
        return;

    if (number_percent() < chance)
    {
        check_improve(ch, gsn_sneak, TRUE, 3);
        af.where     = TO_AFFECTS;
        af.type      = gsn_sneak;
        af.level     = LVL(ch);
        af.duration  = LVL(ch);
        af.location  = APPLY_NONE;
        af.modifier  = 0;
        af.bitvector = AFF_SNEAK;
        affect_to_char(ch, &af);
    }
    else
        check_improve(ch, gsn_sneak, FALSE, 3);
}

DO_FUN(do_hide)
{
    int chance;
    flag32_t sector;

    if ((chance = get_skill(ch, gsn_hide)) == 0)
    {
        char_act("Huh?", ch);
        return;
    }

    if (MOUNTED(ch))
    {
        char_act("You can't hide while mounted.", ch);
        return;
    }

    if (RIDDEN(ch))
    {
        char_act("You can't hide while being ridden.", ch);
        return;
    }

    if (IS_AFFECTED(ch, AFF_FAERIE_FIRE))
    {
        char_act("You cannot hide while glowing.", ch);
        return;
    }

    char_act("You attempt to hide.", ch);

    sector = ch->in_room->sector_type;
    if (sector == SECT_FOREST
            || sector == SECT_HILLS
            || sector == SECT_MOUNTAIN)
        chance += 15;
    else if (sector == SECT_CITY)
        chance -= 15;

    if (number_percent() < chance)
    {
        SET_BIT(ch->affected_by, AFF_HIDE);
        check_improve(ch, gsn_hide, TRUE, 3);
    }
    else
    {
        REMOVE_BIT(ch->affected_by, AFF_HIDE);
        check_improve(ch, gsn_hide, FALSE, 3);
    }
}

DO_FUN(do_camouflage)
{
    int     sn;
    int     chance;
    flag32_t     sector;

    if ((sn = sn_lookup("camouflage")) < 0
            ||  (chance = get_skill(ch, sn)) == 0)
    {
        char_act("You don't know how to camouflage yourself.", ch);
        return;
    }

    if (MOUNTED(ch))
    {
        char_act("You can't camouflage while mounted.", ch);
        return;
    }

    if (RIDDEN(ch))
    {
        char_act("You can't camouflage while being ridden.", ch);
        return;
    }

    if (IS_AFFECTED(ch, AFF_FAERIE_FIRE))
    {
        char_act("You can't camouflage yourself while glowing.", ch);
        return;
    }

    sector = ch->in_room->sector_type;
    if (sector != SECT_FOREST
            && sector != SECT_HILLS
            && sector != SECT_MOUNTAIN)
    {
        char_act("There's no cover here.", ch);
        act("$n tries to camouflage $gn{himself} against the lone leaf on the ground.",
            ch, NULL, NULL, TO_ROOM);
        return;
    }

    char_act("You attempt to camouflage yourself.", ch);
    WAIT_STATE(ch, SKILL(sn)->beats);

    if (IS_AFFECTED(ch, AFF_CAMOUFLAGE))
        REMOVE_BIT(ch->affected_by, AFF_CAMOUFLAGE);

    if (IS_NPC(ch) || number_percent() < chance)
    {
        SET_BIT(ch->affected_by, AFF_CAMOUFLAGE);
        check_improve(ch, sn, TRUE, 1);
    }
    else
        check_improve(ch, sn, FALSE, 1);
}

DO_FUN(do_trap)
{
    int chance;

    if ((chance = get_skill(ch, gsn_trap)) == 0)
    {
        char_act("Huh?", ch);
        return;
    }

    if (IS_PUMPED(ch))
    {
        char_act("You can't trap while pumped.", ch);
        return;
    }

    if (MOUNTED(ch))
    {
        char_act("You can't trap while mounted.", ch);
        return;
    }

    if (RIDDEN(ch))
    {
        char_act("You can't trap while being ridden.", ch);
        return;
    }

    if (IS_AFFECTED(ch, AFF_FAERIE_FIRE))
    {
        char_act("You can't trap while glowing.", ch);
        return;
    }

    if (IS_AFFECTED(ch, AFF_TRAP))
    {
        char_act("You are in trap!", ch);
        return;
    }

    if (number_percent() < chance)
    {
        SET_BIT(ch->affected_by, AFF_TRAP);
        char_act("You trap.", ch);
        check_improve(ch, gsn_trap, TRUE, 3);
    }
    else
    {
        REMOVE_BIT(ch->affected_by, AFF_TRAP);
        char_act("You attempt to trap.", ch);
        check_improve(ch, gsn_trap, FALSE, 3);
    }
}

/*
 * Contributed by Alander
 */
DO_FUN(do_visible)
{
    if (IS_AFFECTED(ch, AFF_SLEEP))
    {
        char_act("óÎÁÞÁÌÁ ×ÙÓÐÉÓØ.", ch);
        return;
    }
    if (IS_AFFECTED(ch, AFF_HIDE | AFF_FADE | AFF_TRAP))
    {
        char_act("You step out of shadows.", ch);
        REMOVE_BIT(ch->affected_by, AFF_HIDE | AFF_FADE | AFF_TRAP);
        act_puts("$n steps out of shadows.", ch, NULL, NULL, TO_ROOM, POS_RESTING);
    }

    if (is_affected(ch, gsn_stealth))
    {
        affect_strip(ch, gsn_stealth);
        char_act("ôÙ ÂÏÌØÛÅ ÎÅ ÓËÒÙÔÅÎ.", ch);
    }

    if (IS_AFFECTED(ch, AFF_CAMOUFLAGE))
    {
        char_act("You step out from your cover.", ch);
        REMOVE_BIT(ch->affected_by, AFF_CAMOUFLAGE);
        act_puts("$n steps out of the cover.", ch, NULL, NULL, TO_ROOM, POS_RESTING);
    }

    if (IS_AFFECTED(ch, AFF_INVIS | AFF_IMP_INVIS))
    {
        char_act("You fade into existence.", ch);
        affect_bit_strip(ch, TO_AFFECTS, AFF_INVIS | AFF_IMP_INVIS);
        REMOVE_BIT(ch->affected_by, AFF_INVIS | AFF_IMP_INVIS);
        act("$n fades into existence.", ch, NULL, NULL, TO_ROOM);
    }

    if (IS_AFFECTED(ch, AFF_EARTHFADE))
    {
        affect_bit_strip(ch, TO_AFFECTS, AFF_EARTHFADE);
        WAIT_STATE(ch, PULSE_VIOLENCE * 2);
        act("You fade to your neutral form.", ch, NULL, NULL, TO_CHAR);
        act("Earth forms $n in front of you.", ch, NULL, NULL, TO_ROOM);
    }
}

DO_FUN(do_recall)
{
    ROOM_INDEX_DATA *location;

    if (IS_NPC(ch))
    {
        char_act("Only players can recall.", ch);
        return;
    }

    if (ch->level >= 10)
    {
        char_act("Recall is for only levels below 10.", ch);
        return;
    }

    if (ch->desc)
    {
        if (IS_PUMPED(ch))
        {
            char_act("You are too pumped to pray now.", ch);
            return;
        }
        location = get_recall(ch);
    }
    else
        location = get_random_recall();

    act("$n prays for transportation!", ch, NULL, NULL, TO_ROOM);

    if (location == NULL)
    {
        char_act("You are completely lost.", ch);
        return;
    }

    if (ch->in_room == location)
        return;

    if (IS_SET(ch->in_room->room_flags, ROOM_NORECALL)
            || IS_AFFECTED(ch, AFF_CURSE)
            || IS_RAFFECTED(ch->in_room, RAFF_CURSE))
    {
        char_act("The gods have forsaken you.", ch);
        return;
    }

    ch->move /= 2;
    act("$n disappears.", ch, NULL, NULL, TO_ROOM);
    char_from_room(ch);
    char_to_room(ch, location);
    act("$n comes up for the room.", ch, NULL, NULL, TO_ROOM);
    if (!JUST_KILLED(ch))
        do_look(ch, "auto");

    if (ch->pet != NULL)
    {
        act("$n disappears.", ch->pet, NULL, NULL, TO_ROOM);
        char_from_room(ch->pet);
        char_to_room(ch->pet, location);
        act("$n comes up for the room.", ch->pet, NULL, NULL, TO_ROOM);
        if (!JUST_KILLED(ch->pet))
            do_look(ch->pet, "auto");
    }
}

DO_FUN(do_train)
{
    CHAR_DATA *mob;
    int stat = - 1;
    char *pOutput = NULL;
    int cost, temp = 0;
    race_t *r;
    class_t *cl;


    if (IS_NPC(ch))
        return;

    if ((cl = class_lookup(ch->class)) == NULL)
    {
        log_printf("do_train", "%s: unknown class %d",
                   ch->name, ch->class);
        return;
    }

    r = RACE(ORG_RACE(ch));
    //  r = RACE(ch->race);

    /*
     * Check for trainer.
     */
    for (mob = ch->in_room->people; mob; mob = mob->next_in_room)
        if (IS_NPC(mob)
                && IS_SET(mob->pIndexData->act, ACT_PRACTICE | ACT_TRAIN | ACT_GAIN))
            break;

    if (mob == NULL)
    {
        char_act("You can't do that here.", ch);
        return;
    }

    if (argument[0] == '\0')
    {
        act_puts("You have $j training sessions.",
                 ch, (const void *) ch->train, NULL, TO_CHAR, POS_DEAD);
        argument = "foo";
    }

    cost = 1;

    if (!str_cmp(argument, "str"))
    {
        stat        = STAT_STR;
        pOutput     = "strength";
    }
    else if (!str_cmp(argument, "int"))
    {
        stat        = STAT_INT;
        pOutput     = "intelligence";
    }
    else if (!str_cmp(argument, "wis"))
    {
        stat        = STAT_WIS;
        pOutput     = "wisdom";
    }
    else if (!str_cmp(argument, "dex"))
    {
        stat        = STAT_DEX;
        pOutput     = "dexterity";
    }
    else if (!str_cmp(argument, "con"))
    {
        stat        = STAT_CON;
        pOutput     = "constitution";
    }
    else if (!str_cmp(argument, "cha"))
    {
        stat        = STAT_CHA;
        pOutput     = "charisma";
    }
    else if (!str_cmp(argument, "lck"))
    {
        stat        = STAT_LCK;
        pOutput     = "luck";
    }
    else if (!str_cmp(argument, "hp"))
        cost = 3;
    else if (!str_cmp(argument, "mana"))
        cost = 2;
    else if (!str_cmp(argument, "move"))
        cost = 2;
    else
    {
        act_puts3("You can train:$t$T$U", ch,
                  (ch->perm_stat[STAT_STR] < get_max_train(ch,STAT_STR)) ?
                  " str," : str_empty,
                  (ch->perm_stat[STAT_INT] < get_max_train(ch,STAT_INT)) ?
                  " int," : str_empty,
                  (ch->perm_stat[STAT_WIS] < get_max_train(ch,STAT_WIS)) ?
                  " wis," : str_empty,
                  TO_CHAR | ACT_NOLF, POS_DEAD);
        act_puts3("$t$T$U", ch,
                  (ch->perm_stat[STAT_DEX] < get_max_train(ch,STAT_DEX)) ?
                  " dex," : str_empty,
                  (ch->perm_stat[STAT_CON] < get_max_train(ch,STAT_CON)) ?
                  " con," : str_empty,
                  (ch->perm_stat[STAT_CHA] < get_max_train(ch,STAT_CHA)) ?
                  " cha," : str_empty,
                  TO_CHAR | ACT_NOLF, POS_DEAD);
        act_puts("$t hit points, mana or move.", ch,
                 (ch->perm_stat[STAT_LCK] < get_max_train(ch,STAT_LCK)) ?
                 " lck," : str_empty, NULL, TO_CHAR, POS_DEAD);

        if (FALSE)
            act("You have nothing left to train!", ch, NULL, NULL, TO_CHAR);

        return;
    }

    if (!str_cmp("hp", argument))
    {
        if ( cost > ch->train )
        {
            char_act("You don't have enough training sessions.", ch);
            return;
        }

        temp = (get_curr_stat(ch,STAT_CON) + r->pcdata->hp_bonus + cl->hp_rate) * ch->level + ch->pcdata->quest_hp_gained;

        if (ch->pcdata->perm_hit < temp)
        {
            ch->train -= cost;
            ch->pcdata->perm_hit += 10;
            ch->pcdata->perm_hit = UMIN(ch->pcdata->perm_hit, temp);
            ch->max_hit += 10;
            ch->hit += 10;
            act("Your health increases.",ch,NULL,NULL,TO_CHAR);
            act("$n's health increases.",ch,NULL,NULL,TO_ROOM);
        }
        else
        {
            act("Your hit points are at maximum!", ch, NULL, NULL, TO_CHAR);
        }
        return;
    }

    if (!str_cmp("mana",argument))
    {
        if ( cost > ch->train )
        {
            char_act("You don't have enough training sessions.", ch);
            return;
        }

        temp = (get_curr_stat(ch,STAT_INT) + get_curr_stat(ch,STAT_WIS) +
                r->pcdata->mana_bonus + cl->mana_rate) * ch->level + ch->pcdata->quest_mana_gained;

        if (ch->pcdata->perm_mana < temp)
        {
            ch->train -= cost;
            ch->pcdata->perm_mana += 10;
            ch->pcdata->perm_mana = UMIN (ch->pcdata->perm_mana, temp);
            ch->max_mana += 10;
            ch->mana += 10;
            act("Your mana increases.",ch,NULL,NULL,TO_CHAR);
            act("$n's mana increases.",ch,NULL,NULL,TO_ROOM);
        }
        else
        {
            act("Your mana is at maximum!", ch, NULL, NULL, TO_CHAR);
        }
        return;
    }

    if (!str_cmp("move",argument))
    {
        if ( cost > ch->train )
        {
            char_act("You don't have enough training sessions.", ch);
            return;
        }

        temp = ((get_curr_stat(ch,STAT_CON) + get_curr_stat(ch,STAT_DEX)) / 4) * ch->level;

        if (ch->pcdata->perm_move < temp)
        {
            ch->train -= cost;
            ch->pcdata->perm_move += 10;
            ch->pcdata->perm_move = UMIN (ch->pcdata->perm_move, temp);
            ch->max_move += 10;
            ch->move += 10;
            act("Your moves increase.", ch, NULL, NULL, TO_CHAR);
            act("$n's moves increase.", ch, NULL, NULL, TO_ROOM);
        }
        else
        {
            act("Your moves are at maximum!", ch, NULL, NULL, TO_CHAR);
        }
        return;
    }

    if (ch->perm_stat[stat] >= get_max_train(ch,stat))
    {
        act_puts("Your $T is already at maximum.", ch, NULL, pOutput, TO_CHAR, POS_DEAD);
        return;
    }

    if (ch->train < 1)
    {
        char_act("You don't have enough training sessions.", ch);
        return;
    }

    ch->train--;
    ch->perm_stat[stat] += 1;
    act_puts("Your $T increases!", ch, NULL, pOutput, TO_CHAR | ACT_TRANS, POS_DEAD);
    act("$n's $T increases!", ch, NULL, pOutput, TO_ROOM | ACT_TRANS);
}

DO_FUN(do_track)
{
    ROOM_HISTORY_DATA *rh;
    EXIT_DATA *pexit;
    static char *door[] = { "north","east","south","west","up","down",
                            "that way"};
    int d;
    int chance;

    if ((chance = get_skill(ch, gsn_track)) == 0)
    {
        char_act("There are no train tracks here.", ch);
        return;
    }

    if (JUST_KILLED(ch))
        return;

    WAIT_STATE(ch, SKILL(gsn_track)->beats);
    act("$n checks the ground for tracks.", ch, NULL, NULL, TO_ROOM);

    if (number_percent() < chance)
    {
        if (IS_NPC(ch))
        {
            ch->status = 0;
            if (ch->last_fought != NULL
                    &&  !IS_SET(ch->pIndexData->act, ACT_NOTRACK))
                add_mind(ch, ch->last_fought->name);
        }

        for (rh = ch->in_room->history; rh != NULL; rh = rh->next)
            if (is_name(argument, rh->name))
            {
                check_improve(ch, gsn_track, TRUE, 1);
                if ((d = rh->went) == -1)
                    continue;
                act("$T's tracks lead $t.", ch, door[d], rh->name, TO_CHAR | ACT_TRANS);
                if ((pexit = ch->in_room->exit[d]) != NULL
                        &&  IS_SET(pexit->exit_info, EX_ISDOOR)
                        &&  pexit->keyword != NULL)
                    doprintf(do_open, ch, "%s", door[d]);
                if (IS_NPC (ch) || IS_SET (ch->comm, COMM_TRACK))
                    move_char(ch, rh->went, FALSE);
                return;
            }
    }

    char_act("You don't see any tracks.", ch);

    if (IS_NPC(ch))
        ch->status = 5; /* for stalker */

    check_improve(ch, gsn_track, FALSE, 1);
}

void do_vampire(CHAR_DATA* ch, const char* argument)
{
    AFFECT_DATA af;
    int level, duration, damroll_mod;
    int chance;

    if (IS_SET(ch->form, FORM_VAMPIRE))
    {
        char_act("But you are already vampire. Kill them! Kill them!", ch);
        return;
    }

    if ((chance = get_skill(ch, gsn_vampire)) == 0)
    {
        char_act("You try to show yourself even more ugly.", ch);
        return ;
    }

    if (chance < 100)
    {
        char_act("Go and ask the questor. He'll help you.", ch);
        return ;
    }

    if (weather_info.sunlight == SUN_LIGHT
            ||  weather_info.sunlight == SUN_RISE)
    {
        char_act("You should wait for the evening or night to transform to a vampire.", ch);
        return ;
    }

    level = LVL(ch);
    duration = level / 10 + 5 ;

    if (LVL(ch) < 50)
        damroll_mod = LVL(ch);
    else if (LVL(ch) < 80)
        damroll_mod = LVL(ch) * 2;
    else
        damroll_mod = LVL(ch) * 3;

    af.type      = gsn_vampire ;
    af.level     = level       ;
    af.duration  = duration    ;

    // negative immunity
    af.where     = TO_RESIST   ;
    af.location  = APPLY_NONE  ;
    af.modifier  = 40;
    af.bitvector = DAM_NEGATIVE ;
    affect_to_char (ch, &af);

    // vampires vulnerabilities
    af.where     = TO_RESIST  ;
    af.location  = APPLY_NONE ;
    af.modifier  = -40 ;
    af.bitvector = DAM_HOLY   ;
    affect_to_char (ch, &af);

    af.where     = TO_RESIST  ;
    af.location  = APPLY_NONE ;
    af.modifier  = -40 ;
    af.bitvector = DAM_SILVER ;
    affect_to_char (ch, &af);

    // haste
    af.where     = TO_AFFECTS ;
    af.location  = APPLY_DEX  ;
    af.modifier  = number_range (5, 10);
    af.bitvector = AFF_HASTE  ;
    affect_to_char (ch, &af);

    // giant strength
    af.location  = APPLY_STR ;
    af.modifier  = number_range (10, 15);
    af.bitvector = 0 ;
    affect_to_char (ch, &af);

    // hit point
    af.where     = TO_AFFECTS ;
    af.location  = APPLY_HIT;
    af.modifier  = damroll_mod * 2;
    af.bitvector = 0;
    affect_to_char(ch, &af);

    // size
    af.where     = TO_FORM    ;
    af.location  = APPLY_SIZE ;
    af.modifier  = 3;
    af.bitvector = FORM_UNDEAD | FORM_VAMPIRE ;
    affect_to_char (ch, &af);

    // damroll
    af.where     = TO_AFFECTS    ;
    af.location  = APPLY_DAMROLL ;
    af.modifier  = damroll_mod   ;
    af.bitvector = AFF_FLYING | AFF_DETECT_INVIS | AFF_DETECT_IMP_INVIS ;
    affect_to_char (ch, &af);

    char_act("You feel yourself getting greater and greater.", ch);
    act_puts("You cannot recognize $n anymore.", ch, NULL, NULL, TO_ROOM, POS_RESTING);
}

DO_FUN(do_soulswitch)
{
    /* GM : îÅ ÓÔÁÌ ÐÅÒÅ×ÏÄÉÔØ. äÕÍÁÀ áÚÅÒÏÔÕ ÂÕÄÅÔ ÐÒÉÑÔÎÏ ÄÏÄÅÌÁÔØ ÎÁÞÁÔÏÅ.
        char arg[MAX_INPUT_LENGTH];
        CHAR_DATA *victim;

        if (!IS_NPC(ch) || (ch->pIndexData->vnum != MOB_VNUM_SOUL))
        {
        char_act("ôÅÂÅ ÍÁÌÏ ÜÔÏÇÏ ÔÅÌÁ?..", ch);
        return;
        }

        one_argument(argument, arg, sizeof(arg));
        if (arg[0] == '\0')
        {
        char_act("÷ÓÅÌÉÔØÓÑ × ËÏÇÏ?", ch);
        return;
        }
        if ((victim = get_char_room(ch, arg)) == NULL)
        {
        char_act("ôÁËÉÈ ÔÕÔ ÎÅÔ..", ch);
        return;
        }
        if (victim == ch)
        {
        char_act("ôÙ ×Ù×ÏÒÁÞÉ×ÁÅÛØÓÑ ÎÁÉÚÎÁÎËÕ, ÎÏ ÎÉÞÅÇÏ ÎÅ ÐÒÏÉÓÈÏÄÉÔ..", ch);
        return;
        }

        if (IS_NPC(victim))
        {
        if (!IS_CLAN_GUARD(victim) && victim->level <= LEVEL_HERO)
        {
            act_puts("ôÙ ×ÓÅÌÑÅÛØÓÑ × $N!", ch, NULL, victim, TO_CHAR, POS_DEAD);
            ch->desc->character = victim;
            victim->desc = ch-> desc;
            ch->desc = NULL;
            victim->comm = ch->comm;
            victim->lines = ch->lines;
            extract_char(ch, TRUE);
            return;
        }
        else
        {
            char_act("ôÙ ÎÅ ÍÏÖÅÛØ ×ÓÅÌÉÔØÓÑ × ÜÔÏ ÓÕÝÅÓÔ×Ï.", ch);
            return;
        }
        }
        if (victim->desc == NULL && victim != ch->desc->original)
        {
        char_act("ôÙ ÎÅ ÍÏÖÅÛØ ×ÓÅÌÉÔØÓÑ × ÞÁÒÏ× ÂÅÚ Ó×ÑÚÉ (lostlink).", ch);
        return;
        }


        if ((victim != ch->desc->original) && (victim->desc->snoop_by != NULL))
        {
        char_act("ëÔÏ-ÔÏ ÕÖÅ ÔÁÍ ÓÉÄÉÔ..", ch);
        return;
        }
    */
    /*ÕÂÉ×ÁÅÍ ÄÕÈÁ-ÎÅÐÉÓÀ É ×ÏÚ×ÒÁÝÁÅÍ ÞÁÒÕ ÄÅÓËÒÉÐÔÏÒ */
    /*
        ch->desc->character             = ch->desc->original;
        ch->desc->original              = NULL;
        ch->desc->character->desc       = ch->desc;
    */
    /*ch->desc                        = NULL;*/
    /*    if (victim == ch->desc->character)
        {
        char_act("ôÙ ×ÅÒÎÕÌÓÑ × Ó×ÏÅ ÔÅÌÏ....", victim);
        ch->desc = NULL;
        extract_char(ch, TRUE);
        return;
        }
        else
        {
        if (victim->level > LEVEL_HERO || saves_spell(victim->level,victim, DAM_NEGATIVE))
        {
            char_act("ôÅÂÅ ÎÅ ÕÄÁÌÏÓØ ÓÌÏÍÉÔØ ÓÏÐÒÏÔÉ×ÌÅÎÉÅ ÞÕÖÏÊ ÄÕÛÉ!.", ch->desc->character);
            char_act("ôÙ ÐÏÌÎÏÓÔØÀ ÏÂÅÓÓÉÌÅÎ!", ch);
            do_look(ch->desc->character, "auto");
            ch->desc->character->mana = 0;
            ch->desc->character->move = 0;
            ch->desc = NULL;
            extract_char(ch, TRUE);
            return;
        }
        else
        {
            TOGGLE_BIT(ch->desc->character->plr_flags, PLR_SOUL);
            act("ôÙ ÍÅÄÌÅÎÎÏ ÐÒÏÎÉËÁÅÛØ × ÓÏÚÎÁÎÉÅ $N.",
                ch->desc->character, NULL, victim, TO_CHAR);
            victim->desc->snoop_by = ch->desc->character->desc;
            ch->desc = NULL;
            extract_char(ch, TRUE);
            return;
        }
        }
    */
}

DO_FUN(do_resoul)
{
    /* GM : á ×ÏÏÂÝÅ ÜÔÏ ÄÏÌÖÎÏ ÂÙÔØ ÔÕÔ? é ÐÅÒÅ×ÅÓÔÉ ÎÅ ÚÁÂÕÄØ.
        CHAR_DATA *soul;
        DESCRIPTOR_DATA *d;

        if (IS_NPC(ch) && ch->desc != NULL)
        {
        char_act("ô×ÏÊ ÄÕÈ ×ÙÓËÁÌØÚÙ×ÁÅÔ ÉÚ ÔÅÓÎÏÇÏ ÔÅÌÁ.", ch);
        soul = create_mob(get_mob_index(MOB_VNUM_SOUL));
        char_to_room(soul,ch->in_room);
        ch->desc->character = soul;
        soul->desc = ch->desc;
        ch->desc = NULL;
        soul->comm = ch->comm;
        soul->lines = ch->lines;
        do_look(soul, "auto");
        return;
        }

        if (!IS_NPC(ch) && IS_SET(ch->plr_flags, PLR_SOUL))
        {
        char_act("ô×ÏÑ ÄÕÛÁ × ÍÇÎÏ×ÅÎÉÅ ÏËÁ ÐÏËÉÄÁÅÔ ÞÕÖÏÅ ÔÅÌÏ É ÔÙ ÓÎÏ×Á ÞÕ×ÓÔ×ÕÅÛØ ó÷ïå!.", ch);
        for (d = descriptor_list; d != NULL; d = d->next)
            if (d->snoop_by == ch->desc)
                d->snoop_by = NULL;
        REMOVE_BIT(ch->plr_flags, PLR_SOUL);
        do_look(ch, "auto");
        return;
        }
        char_act("Huh?", ch);
    */
}


DO_FUN(do_vbite)
{
    char arg[MAX_INPUT_LENGTH];
    CHAR_DATA *victim;
    int chance;

    one_argument(argument, arg, sizeof(arg));

    if ((chance = get_skill(ch, gsn_vampiric_bite)) == 0)
    {
        char_act("You don't know how to bite creatures.", ch);
        return;
    }

    if (!IS_SET(ch->form, FORM_VAMPIRE))
    {
        char_act("You must transform vampire before biting.", ch);
        return;
    }

    if (arg[0] == '\0')
    {
        char_act("Bite whom?", ch);
        return;
    }

    WAIT_STATE(ch, SKILL(gsn_vampiric_bite)->beats);

    if ((victim = get_char_room(ch, arg)) == NULL)
    {
        char_act("They aren't here.", ch);
        return;
    }

    if (victim->position != POS_SLEEPING)
    {
        char_act("They must be sleeping.", ch);
        return;
    }

    if (IS_NPC(ch) && !IS_NPC(victim))
        return;

    if (victim == ch)
    {
        char_act("How can you sneak upon yourself?", ch);
        return;
    }

    if (victim->fighting != NULL)
    {
        char_act("You can't bite a fighting person.", ch);
        return;
    }

    if (is_safe(ch, victim))
        return;

    if (victim->hit < (8 * victim->max_hit / 10) && (IS_AWAKE(victim)))
    {
        act_puts("$N is hurt and suspicious ... doesn't worth up.",
                 ch, NULL, victim, TO_CHAR, POS_DEAD);
        return;
    }

    if (current_time-victim->last_fight_time < 200 && IS_AWAKE(victim))
    {
        act_puts("$N is hurt and suspicious ... doesn't worth up.",
                 ch, NULL, victim, TO_CHAR, POS_DEAD);
        return;
    }

    if (!IS_AWAKE(victim)
            && (IS_NPC(ch)
                || number_percent() < ((chance * 7 / 10) + (2 * (LVL(ch) - LVL(victim))) )))
    {
        check_improve(ch,gsn_vampiric_bite,TRUE,1);
        one_hit(ch, victim, gsn_vampiric_bite, WEAR_WIELD);
    }
    else
    {
        check_improve(ch, gsn_vampiric_bite, FALSE, 1);
        damage(ch, victim, 0, gsn_vampiric_bite, DAM_NONE, DAMF_SHOW);
    }
    if (!IS_NPC(victim) && victim->position==POS_FIGHTING)
    {
        act_yell(victim, "Help! $i tried to bite me!", ch, "yells in panic");
        agent_net_printf(victim, ch, ANET_ATTACK);
    }
}

DO_FUN(do_bash_door)
{
    char arg[MAX_INPUT_LENGTH];
    CHAR_DATA *gch;
    int chance;
    int damage_bash,door;
    int beats;

    ROOM_INDEX_DATA *to_room;
    EXIT_DATA *pexit;
    EXIT_DATA *pexit_rev;

    one_argument(argument, arg, sizeof(arg));

    if ((chance = get_skill(ch, gsn_bash_door)) == 0)
    {
        char_act("Bashing? What's that?", ch);
        return;
    }

    if (MOUNTED(ch))
    {
        char_act("You can't bash doors while mounted.", ch);
        return;
    }

    if (RIDDEN(ch))
    {
        char_act("You can't bash doors while being ridden.", ch);
        return;
    }

    if (arg[0] == '\0')
    {
        char_act("Bash wich door or direction?", ch);
        return;
    }

    if (ch->fighting)
    {
        char_act("Wait until the fight finishes.", ch);
        return;
    }

    /* look for guards */
    for (gch = ch->in_room->people; gch; gch = gch->next_in_room)
        if (IS_NPC(gch)
                && IS_AWAKE(gch) && ch->level + 5 < gch->level)
        {
            act_puts("$N is standing too close to door.",
                     ch, NULL, gch, TO_CHAR, POS_DEAD);
            return;
        }

    if ((door = find_door(ch, arg)) < 0)
        return;

    pexit = ch->in_room->exit[door];

    if (!IS_SET(pexit->exit_info, EX_CLOSED))
    {
        char_act("It's already open.", ch);
        return;
    }

    if (!IS_SET(pexit->exit_info, EX_LOCKED))
    {
        char_act("Just try to open it.", ch);
        return;
    }

    if (IS_SET(pexit->exit_info, EX_NOPASS))
    {
        char_act("A mystical shield protects exit.", ch);
        return;
    }

    chance -= 90;

    /* modifiers */

    /* size and weight */
    //    chance += get_carry_weight(ch) / 100;
    chance += ch->size * 2;

    /* stats */
    chance += get_curr_stat(ch, STAT_STR);

    if (IS_AFFECTED(ch, AFF_FLYING))
        chance -= 10;

    act_puts("You slam into $d, and try to break $d!",
             ch, NULL, pexit->keyword, TO_CHAR, POS_DEAD);
    act("$n slams into $d, and tries to break it!",
        ch, NULL, pexit->keyword, TO_ROOM);

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

    beats = SKILL(gsn_bash_door)->beats;
    /* now the attack */
    if (number_percent() < chance)
    {
        check_improve(ch, gsn_bash_door, TRUE, 1);

        REMOVE_BIT(pexit->exit_info, EX_LOCKED);
        REMOVE_BIT(pexit->exit_info, EX_CLOSED);
        act("$n bashes the $d and breaks the lock.",
            ch, NULL, pexit->keyword, TO_ROOM);
        char_act("You successed to open the door.", ch);

        /* open the other side */
        if ((to_room = pexit->to_room.r) != NULL
                && (pexit_rev = to_room->exit[rev_dir[door]]) != NULL
                && pexit_rev->to_room.r == ch->in_room)
        {
            ROOM_INDEX_DATA *in_room;

            REMOVE_BIT(pexit_rev->exit_info, EX_CLOSED);
            REMOVE_BIT(pexit_rev->exit_info, EX_LOCKED);

            in_room = ch->in_room;
            ch->in_room = to_room;
            act("$n bashes the $d and breaks the lock.",
                ch, NULL, pexit->keyword, TO_ROOM);
            ch->in_room = in_room;
        }

        check_improve(ch, gsn_bash_door, TRUE, 1);
        WAIT_STATE(ch, beats);
    }
    else
    {
        char_act("You fall flat on your face!", ch);
        act_puts("$n falls flat on $gn{his} face.",
                 ch, NULL, NULL, TO_ROOM, POS_RESTING);
        check_improve(ch, gsn_bash_door, FALSE, 1);
        ch->position = POS_RESTING;
        WAIT_STATE(ch, beats * 3 / 2);
        damage_bash = ch->damroll + number_range(4, 4 + ch->size + chance / 5);
        damage(ch, ch, damage_bash, gsn_bash_door, DAM_BASH, DAMF_SHOW);
    }
}

DO_FUN(do_blink)
{
    char arg[MAX_INPUT_LENGTH];

    if (get_skill(ch, gsn_blink) == 0)
    {
        char_act("Huh?", ch);
        return;
    }

    argument = one_argument(argument, arg, sizeof(arg));

    if (arg[0] == '\0')
    {
        act_puts("Your current blink status: $t.",
                 ch, IS_SET(ch->plr_flags, PLR_BLINK) ? "ON" : "OFF", NULL, TO_CHAR | ACT_TRANS, POS_DEAD);
        return;
    }

    if (!str_cmp(arg, "ON") || !str_cmp(arg, "×ËÌ"))
    {
        SET_BIT(ch->plr_flags, PLR_BLINK);
        char_act("Now, your current blink status is ON.", ch);
        return;
    }

    if (!str_cmp(arg, "OFF")
            || !str_cmp(arg, "×ÙËÌ"))
    {
        REMOVE_BIT(ch->plr_flags, PLR_BLINK);
        char_act("Now, your current blink status is OFF.", ch);
        return;
    }

    act_puts("What's that? Is $t a status?", ch, arg, NULL, TO_CHAR, POS_DEAD);
}

DO_FUN(do_kidnap)
{
    char arg[MAX_INPUT_LENGTH];
    AFFECT_DATA af;
    ROOM_INDEX_DATA *pRoomIndex;
    CHAR_DATA *victim;
    int chance;
    int i;
    bool r_found = FALSE;

    if ((chance = get_skill(ch, gsn_kidnap)) == 0)
    {
        char_act("Huh?", ch);
        return;
    }

    argument = one_argument(argument, arg, sizeof(arg));

    if (ch->fighting != NULL)
    {
        char_act("Wait until the fight finishes.", ch);
        return;
    }
    if (arg[0] == '\0')
    {
        char_act("Kidnap whom?", ch);
        return;
    }
    else if ((victim = get_char_room(ch, arg)) == NULL)
    {
        WAIT_STATE(ch, SKILL(gsn_kidnap)->beats);
        char_act("They aren't there.", ch);
        return;
    }
    WAIT_STATE(ch, SKILL(gsn_kidnap)->beats);

    if (is_safe(ch, victim))
        return;

    if (IS_SET(ch->in_room->room_flags, ROOM_BATTLE_ARENA))
    {
        char_act("You can't kidnap on Battle Arena!", ch);
        return;
    }

    if (victim->fighting != NULL)
    {
        char_act("You can't kidnap fighting victim.", ch);
        return;
    }
    if (victim == ch)
    {
        char_act("That's pointless.", ch);
        return;
    }

    if (ch->mana < 70)
    {
        char_act("You don't have enough power.", ch);
        return;
    }

    if (is_affected(ch, gsn_kidnap))
    {
        char_act("This skill is used too recently.", ch);
        return;
    }


    ch->mana -= 70;
    //     chance /=2; //âÁÚÏ×ÙÊ 50% // commented by Aseroth
    if (IS_AWAKE(victim))
        chance /= 2; //ÅÓÌÉ ÎÅ ÓÐÉÔ ÔÏ 25%
    chance += URANGE(0, (get_curr_stat(ch, STAT_DEX)-20)*2, 10); //ÂÏÌØÛÅ ÅÓÌÉ ÌÏ×ÏË
    chance -= URANGE(0, (get_curr_stat(victim, STAT_DEX)-20)*2, 10); //ÍÅÎØÛÅ ÅÓÌÉ ÌÏ×ÏË ÐÒÏÔÉ×ÎÉË

    if (IS_SET(victim->in_room->room_flags, ROOM_NORECALL))
        chance = 0;

    if (IS_IMMORTAL(victim) && (ch->level < victim->level))
        chance = 0;

    // åÓÌÉ ÛÁÎÓÁ ÎÅÔÕ -- ×ÙÈÏÄÉÍ ÓÒÁÚÕ, ÛÏÐ ÎÅ ÓÞÉÔÁÔØ ÌÉÛÎÅÇÏ

    if (number_percent() > chance
            || (IS_NPC(victim)
                && ((IS_SET(victim->pIndexData->act, ACT_QUESTOR))
                    || (IS_SET(victim->pIndexData->act, ACT_PRACTICE))
                    || (IS_SET(victim->pIndexData->act, ACT_TRAIN))
                    || (IS_SET(victim->pIndexData->act, ACT_HEALER))
                    || (IS_SET(victim->pIndexData->act, ACT_CHANGER))
                    || (IS_SET(victim->pIndexData->act, ACT_AREA_GUARD))
                    || (IS_SET(victim->pIndexData->act, ACT_CLAN_GUARD)))))
    {
        check_improve(ch, gsn_kidnap, FALSE, 1);
        act("You trying kidnap $N, but failed.",
            ch, NULL, victim, TO_CHAR);
        act("$n trying kidnap you!",
            ch, NULL, victim, TO_VICT);
        act("$n trying kidnap $N, but failed.",
            ch, NULL, victim, TO_NOTVICT);
        if (!IS_AWAKE(victim))
            return;
        damage(ch, victim, 0, gsn_kidnap, DAM_NONE, TRUE);
        return;
    }
    else
    {
        check_improve(ch, gsn_kidnap, TRUE, 1);
        for (i = 0; i < 5000 ; i++)
        {
            if ((pRoomIndex = get_room_index(number_range(ch->in_room->area->min_vnum, ch->in_room->area->max_vnum))) == NULL)
                continue;
            /*        if ((ch->in_room->vnum < 500 || ch->in_room->vnum > 600)
                    &&  (pRoomIndex->vnum > 500 && pRoomIndex->vnum < 600))
                    continue;*/
            if (can_see_room(ch,pRoomIndex)
                    && !room_is_private(pRoomIndex)
                    && !IS_SET(pRoomIndex->room_flags, ROOM_NOSUMMON)
                    && !IS_SET(pRoomIndex->room_flags, ROOM_IMP_ONLY)
                    && !IS_SET(pRoomIndex->room_flags, ROOM_GODS_ONLY)
                    && ch->in_room->area == pRoomIndex->area)
            {
                r_found = TRUE;
                break;
            }
        }
        // ÎÅ ÎÁÊÄÅÎÁ ËÏÍÎÁÔÁ -- õöáó!! Ñ ÎÅ ×ÅÒÀ
        if (!r_found)
        {
            char_act("Hmm.. you just don't know that to do with this body!", ch);
            bug("do_kidnap: room in %d not found!! muttafucka!!", ch->in_room->area->vnum);
            return;
        }

        af.where     = TO_AFFECTS;
        af.type      = gsn_kidnap;
        af.level     = ch->level;
        af.duration  = 0;
        af.location  = 0;
        af.modifier  = 0;
        af.bitvector = 0;
        affect_to_char(ch, &af);


        act("$n snatch $N.",
            ch, NULL, victim, TO_NOTVICT);
        act("$n throws something under legs and disappear with $N in smoke.",
            ch, NULL, victim, TO_NOTVICT);
        act("You snatch $N and disappear.",
            ch, NULL, victim, TO_CHAR);
        act("$n kidnap you!",
            ch, NULL, victim, TO_VICT);
        char_from_room(victim);
        char_from_room(ch);
        char_to_room(ch, pRoomIndex);
        char_to_room(victim, pRoomIndex);
        act("$n and $N suddenly come up from the smoke.",ch, NULL, victim, TO_NOTVICT);
    }
    do_look(ch, "auto");
    if (!IS_AWAKE(victim))
        return;
    do_look(victim, "auto");
    multi_hit(victim, ch, TYPE_UNDEFINED);
}

DO_FUN(do_vanish)
{
    ROOM_INDEX_DATA *pRoomIndex;
    int chance;
    int sn;
    int i;
    bool found;

    if ((sn = sn_lookup("vanish")) < 0
            ||  (chance = get_skill(ch, sn)) == 0)
    {
        char_act("Huh?", ch);
        return;
    }

    if (ch->mana < 25)
    {
        char_act("You don't have enough power.", ch);
        return;
    }
    ch->mana -= 25;
    WAIT_STATE(ch, SKILL(sn)->beats);

    if (number_percent() > chance)
    {
        char_act("You failed.", ch);
        check_improve(ch, sn, FALSE, 1);
        return;
    }

    if (ch->in_room == NULL
            || IS_SET(ch->in_room->room_flags, ROOM_NORECALL)
            || IS_RAFFECTED(ch->in_room, RAFF_PREVENT))
    {
        char_act("You failed.", ch);
        return;
    }

    found = FALSE;
    for (i = 0; i < 50 ; i++)
    {
        if ((pRoomIndex = get_room_index(number_range(ch->in_room->area->min_vnum, ch->in_room->area->max_vnum))) == NULL)
            continue;
        if ((ch->in_room->vnum < 500 || ch->in_room->vnum > 600)
                && (pRoomIndex->vnum > 500 && pRoomIndex->vnum < 600))
            continue;
        if (can_see_room(ch,pRoomIndex)
                && !room_is_private(pRoomIndex)
                && !IS_SET(pRoomIndex->room_flags, ROOM_NOSUMMON)
                && !IS_SET(pRoomIndex->room_flags, ROOM_IMP_ONLY)
                && !IS_SET(pRoomIndex->room_flags, ROOM_GODS_ONLY)
                && ch->in_room->area == pRoomIndex->area)
        {
            found = TRUE;
            break;
        }
    }

    act_puts("$n throws down a small globe.", ch, NULL, NULL, TO_ROOM, POS_RESTING);
    check_improve(ch, sn, TRUE, 1);

    if (!found)
    {
        char_act("You failed.", ch);
        return;
    }

    if (!IS_NPC(ch) && ch->fighting != NULL && number_bits(1) == 1)
    {
        char_act("You failed.", ch);
        return;
    }

    act_puts("$n is gone!", ch, NULL, NULL, TO_ROOM, POS_RESTING);

    char_from_room(ch);
    char_to_room(ch, pRoomIndex);
    act_puts("$n appears from nowhere.", ch, NULL, NULL, TO_ROOM, POS_RESTING);
    do_look(ch, "auto");
    stop_fighting(ch, TRUE);
}

DO_FUN(do_fade)
{
    int chance;
    if ((chance=get_skill(ch, gsn_fade)) == 0)
    {
  

Showing the first 100 KB of 193.4 KB. Download the archive for the full file.

Site Stats

Snippets: 1791
Codebases: 571