/
mudd/docs/html/
mudd/world/
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "mud.h"

extern bool noibm;
extern bool kk;
extern bool mb;
extern bool dbs;


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

const int blood_number[] =
{
1, 2, 4, 8, 16, 32
};

const short revdir[] =
{
  2, 3, 0, 1, 5, 4
};




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

char *const dir_letter[] =
{
  "n", "e", "s", "w", "u", "d"
};




char *const dir_rev[] =
{
  "the south", "the west", "the north", "the east", "below", "above"
};

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



char *
get_direction (char *arg)
{
  switch (LOWER (arg[0]))
    {
    case 'n':
      return "north";
    case 's':
      return "south";
    case 'e':
      return "east";
    case 'w':
      return "west";
    case 'u':
      return "up";
    case 'd':
      return "down";
    }
  return "anywhere";
}

char *
ans_uppercase (const char *txt)
{
  static char buf[STD_LENGTH];
  char *str;
  char *point;
  buf[0] = '\0';
  if (txt == "")
    {
      return buf;
    }
  if (!txt || txt[0] == '\0')
    {
      return buf;
    }
  str = (char *) txt;
  point = buf;
  if (isalpha (txt[0]))
    {
      sprintf (buf, txt);
      buf[0] = UPPER (buf[0]);
      return buf;
    }
  if (strlen (txt) > 5 && isalpha (txt[1]))
    {
      sprintf (buf, txt);
      buf[1] = UPPER (buf[1]);
      return buf;
    }
  if (strlen (txt) > 5 && isalpha (txt[2]) && txt[2] != 'm')
    {
      sprintf (buf, txt);
      buf[2] = UPPER (buf[2]);
      return buf;
    }
  if (strlen (txt) > 5 && isalpha (txt[3]) && txt[3] != 'm')
    {
      sprintf (buf, txt);
      buf[3] = UPPER (buf[3]);
      return buf;
    }
  sprintf (buf, txt);
  while (*point)
    {
      while (*point != 'm' && *point)
	point++;
      if (!*point)
	return buf;
      point++;
      if (isalpha (*point))
	{
	  *point = UPPER (*point);
	  return buf;
	}
    }
  return buf;
}


TRACK_DATA *
new_track (void *thing, ROOM_DATA * room, int came_from, int going_to)
{
  TRACK_DATA *trk;
  char *t;
  trk = (TRACK_DATA *) mem_alloc ((sizeof (*trk)));
  t = thing;
  if (*t == K_CHAR)
    {
      if (IS_PLAYER((CHAR_DATA *)thing))
	trk->who = ((ONLINE *) ((CHAR_DATA *)thing)->pcdata->online_spot);
      else
	trk->who = (CHAR_DATA *) thing;
    }
  else if (*t == K_ROOM)
    {
      trk->who = (ROOM_DATA *) thing;
    }
  else
    {
      free_m (trk);
      return NULL; 
    }
  trk->timer = sectors[room->sector_type].track_timer + number_range(0,2); 
  trk->dir = came_from + 10* going_to;
  trk->next = room->tracks;
  room->tracks = trk;
  return trk;
}



void
do_rawclear (CHAR_DATA * ch)
{
  char ddd[500];
  if (IS_MOB (ch) || ch->desc == NULL)
    return;
  sprintf (ddd, "\x1B[2J\x1B[0m\x1B[1;%dr", ch->pcdata->pagelen);
  write_to_descriptor2 (ch->desc, ddd, 0);
  return;
}

void
do_clear (CHAR_DATA * ch, char *argy)
{
  char ddd[500];
  DEFINE_COMMAND ("cls", do_clear, POSITION_DEAD, 0, LOG_NORMAL, "Clears the screen; defaults window size to pagelen. ANSI")

    if (IS_MOB (ch) || ch->desc == NULL)
    return;
  	sprintf (ddd, "\x1B[2J\x1B[0m\x1B[1;%dr", ch->pcdata->pagelen);
  	write_to_descriptor2 (ch->desc, ddd, 0);

  return;
}

void
do_enter (CHAR_DATA * ch, char *argy)
{
  char arg[SML_LENGTH];
  SINGLE_OBJECT *obj;
  CHAR_DATA *fch;
  ROOM_DATA *dest;
  DEFINE_COMMAND ("enter", do_enter, POSITION_STANDING, 0, LOG_NORMAL,"Allows you to enter an enterable objject.");
  if (!ch || !ch->in_room) return;
  one_argy (argy, arg);
  if (ch == NULL || ch->in_room == NULL) return;
  if ((fch = FIGHTING(ch)) != NULL)
    {
      send_to_char("Not while fighting!\n\r", ch);
      return;
    }
  for(fch = ch->in_room->people; fch != NULL;fch=fch->next_in_room)
    {
      if (ch == FIGHTING(fch))
	{
	  send_to_char("Not while fighting!\n\r", ch);
	  return;
	}
    }
  if (RIDING(ch) != NULL)
    {
      send_to_char("How do you expect to enter something when you are riding a mount.\n\r", ch);
      return;
    }
  if (MOUNTED_BY(ch) != NULL)
    {
      send_to_char("How do you expect to enter something when you are being ridden?\n\r", ch);
      return;
    }
  if ((obj = get_obj_here (ch, arg, SEARCH_ROOM_FIRST)) == NULL)
    {
      send_to_char ("There is nothing like that to enter.\n\r", ch);
      return;
    }
  if (!obj || obj->in_room == NULL || obj->carried_by != NULL)
    {
      send_to_char("That object is not in the room.\n\r", ch);
      return;
    }
  if ((obj->pIndexData->item_type != ITEM_FURNITURE))
    {
      send_to_char ("How do you expect to enter that?\n\r", ch);
      return;
    }
  else
    {
      I_FURNITURE *furn = (I_FURNITURE *) obj->more;
      if (!IS_SET (furn->type, FURN_EXIT))
	{
	  send_to_char ("How do you expect to enter that?\n\r", ch);
	  return;
	}
      if ((dest = get_room_index (furn->to_room_vnum)) == NULL)
	{
	  send_to_char ("It doesn't lead anywhere.\n\r", ch);
	  return;
	}
      act ("$n enters $p\e[0m.", ch, obj, NULL, TO_ROOM);
      act ("You enter $p\e[0m.", ch, obj, NULL, TO_CHAR);
      if (furn->portal_flags == 1)
	{
	  send_to_char ("You feel a strange force ripping at you...\n\r", ch);
	  strip_nonworn (ch);
	}
      char_from_room (ch);
      char_to_room (ch, dest);
      do_look (ch, "auto");
      act ("$n enters from $p\e[0m.", ch, obj, NULL, TO_ROOM);
    }
  return;
}


bool
find_vehicle (CHAR_DATA * ch, int sector_type)
{
  if (IS_MOB(ch)) return TRUE;
  if ((sector_type == SECT_WATER_SWIM ||
       sector_type == SECT_WATER_NOSWIM) &&
      !IS_SET(ch->act, PLR_HAS_BOAT))
    return FALSE;
  
  else if (sector_type == SECT_MOUNTAIN && 
      !IS_SET(ch->act, PLR_HAS_MTN_BOOTS))
    return FALSE;
  else if (sector_type == SECT_UNDERWATER && 
      !IS_SET(ch->act, PLR_HAS_SCUBA) && 
      !IS_AFF(ch, WATER_BREATH))
    return FALSE;
  else if (sector_type == SECT_SNOW &&
      !IS_SET(ch->act, PLR_HAS_SNOWSHOES))
    return FALSE;
  return TRUE;
}



bool check_super = TRUE;

bool
move_char (CHAR_DATA * ch, int door)
{
  static int depth = 0;
  int i, n;
  char to_sector;
  CHAR_DATA *fch;
  CHAR_DATA *fch_next;
  ROOM_DATA *in_room;
  ROOM_DATA *curr_room;
  ROOM_DATA *to_room = NULL;
  ROOM_DATA *troom = NULL;
  CHAR_DATA *viewer;
  TRACK_DATA *trk;
  SOCIETY_DATA *soc;
  bool yelled = FALSE;
  void *track_thing;
  char buf2[STD_LENGTH];
  char buf[STD_LENGTH];
  EXIT_DATA *pexit;
  bool fndd = FALSE;
  bool flagone = FALSE;
  bool flagtwo = FALSE;
  SINGLE_OBJECT *ob;
  SINGLE_OBJECT *obt;
  bool canmove = TRUE;
  int weightmult = 0;
  bool fleeing = FALSE;
  bool ballista_push = FALSE;
  int followers = 0;
  int move = 0;
  if (ch->in_room == NULL || ch->position < POSITION_SLEEPING)
    return FALSE;
  in_room = ch->in_room;
 
  if (door > 18)
    {
      door -= 20;
      fleeing = TRUE;
    }
  else
    {
      if (FIGHTING(ch))
	return FALSE;
      for (fch = ch->in_room->people; fch != NULL; fch = fch->next_in_room)
	{
	  if (FIGHTING (fch) == ch)
	    {
	      send_to_char ("You are in the middle of combat!\n\r", ch);
	      return FALSE;
	    }
	}
      
    }
  if (door > 9)
    {
      door -= 10;
      ballista_push = TRUE;
    }
  
  
  if (ch->desc)
    ch->desc->repeat = 0;
  if (FIGHTING (ch) != NULL && ch->position == POSITION_CASTING)
    return FALSE;
  if (door < 0 || door > 5)
    {
      bug ("Do_move: bad door %d.", door);
      return 0;
    }
  if (MOUNTED_BY (ch) != NULL && MOUNTED_BY (ch)->position != POSITION_STANDING)
    {
      if (LEADER (ch) != NULL && LEADER (ch) != ch)
	{
	  char buffy[100];
	  sprintf (buffy, "%s was not standing and couldn't follow!", NAME (ch));
	  group_notify (buffy, ch);
	}
      return FALSE;
    }
  if (RIDING (ch) != NULL && RIDING (ch)->position < POSITION_STANDING)
    {
      send_to_char ("Your ride doesn't want to move right now.\n\r", ch);
      return 0;
    }
  if (ch->position < POSITION_STANDING)
    {
      if (LEADER (ch) != NULL && LEADER(ch) != ch && ch->position < POSITION_MEDITATING)
	{
	  char buffy[100];
	  sprintf (buffy, "%s couldn't follow!", NAME (ch));
	  group_notify (buffy, ch);
	}
      if (ch->position == POSITION_MEDITATING)
	{
	  act ("You must stop meditating before you try to move!", ch, NULL, NULL, TO_CHAR);
	  return FALSE;
	}
      if (ch->position == POSITION_FALLING && door==DIR_UP) 
	{
	  act("You are heading in quite the opposite direction!",ch,NULL,ch,TO_CHAR);
	  return FALSE;
	}
      if (ch->position == POSITION_FALLING && door==DIR_DOWN) 
	{
	  act("You are heading in that direction already!",ch,NULL,ch,TO_CHAR);
	  return FALSE;
	}
      if (ch->position == POSITION_BASHED)
	{
	  act ("You have just been bashed to the ground! How can you move?!", ch, NULL, NULL, TO_CHAR);
	  return FALSE;
	}
      if (ch->position == POSITION_GROUNDFIGHTING)
	{
	  act ("You are on the ground, fighting! How can you move?!", ch, NULL, NULL, TO_CHAR);
	  return FALSE;
	}
    }
  if (IS_PLAYER (ch) && (ch->pcdata->condition[COND_DRUNK] > 15 || IS_HURT(ch, CONFUSE)) && number_range(1,7) == 2)
    door = number_range (0, 5);
  if ((pexit = in_room->exit[door]) == NULL)
    {
      send_to_char("You can't go any farther in that direction.\n\r", ch);
      return 0;
    }
  if ((to_room = pexit->to_room) == NULL)
    {
      if (pexit->d_info && 
	  pexit->d_info->description[0] != ' ' &&
          pexit->d_info->description != "" && 
	  pexit->d_info->description[0] != '\0')
	{
	  send_to_char (pexit->d_info->description, ch);
	  return 0;
	}
      send_to_char ("You can't go any further in that direction.\n\r", ch);
      return 0;
    }
  to_sector = to_room->sector_type;
  if (pexit->d_info 
      && IS_SET (pexit->d_info->exit_info, EX_CLOSED | EX_ISWALL)
      && !IS_SET(ch->act, PLR_HOLYWALK))
    {
      if (IS_SET (pexit->d_info->exit_info, EX_HIDDEN | EX_ISWALL))
	{
	  send_to_char ("You can't go any further in that direction.\n\r", ch);
	  return 0;
	}
      else if (!IS_AFF(ch, FOGGY))
	{
	  act ("The $T is closed.", ch, NULL, pexit->d_info->keyword, TO_CHAR);
	  return 0;
	}
    }
  if (IS_PLAYER(ch) && !IS_SET (ch->act, PLR_HOLYWALK))
    {
      if (ch->pcdata->speedwalk > 80  && ch->position != POSITION_RUNNING)
	{
	  send_to_char("You are too tired from moving so much!\n\r", ch);
	  if (ch->desc)
	    ch->desc->inbuf[0] = '\0';
	  ch->pcdata->speedwalk = 2*PULSE_VIOLENCE +1;
	  WAIT_STATE(ch, 2*PULSE_VIOLENCE);
	  return FALSE;
	}
      for (ob = ch->in_room->contents; ob != NULL; ob = ob->next_content)
	{
	  if (ob->pIndexData->item_type != ITEM_TRASH)
	    continue;
	  if (ob->pIndexData->value[door] == 0)
	    continue;
	  if (ob->pIndexData->value[6] == 0) continue;
	  switch (ob->pIndexData->value[6])
	    {
	    case 1:
	      if (ob->pIndexData->value[7] < LEVEL (ch))
		canmove = FALSE;
	      break;
	    case 2:
	      if (ob->pIndexData->value[7] != ch->pcdata->race)
		canmove = FALSE;
	      break;
	    case 3:
	      if (ob->pIndexData->value[7] != clan_number (ch))
		canmove = FALSE;
	      break;
	    case 4:
	      if (ob->pIndexData->value[7] != clan_number_2 (ch))
		canmove = FALSE;
	      break;
	    case 5:
	      if ((ch->pcdata->donated == 0 || ob->pIndexData->value[7] > ch->pcdata->donated))
		canmove = FALSE;
	      break;
	    case 6:
	      if (ob->pIndexData->value[7] > 0)
		{
		  canmove = FALSE;
		  for (obt = ch->carrying; obt != NULL; obt = obt->next_content)
		    {
		      if (obt->pIndexData->vnum == ob->pIndexData->value[7])
			{
			  canmove = TRUE;
			  break;
			}
		    } 
		}
	      break;
	    case 7:
	      if (ob->pIndexData->value[7] > LEVEL (ch))
		canmove = FALSE;
	      break;
	    }
	}
      if (!canmove)
	{
	  send_to_char("A strange force prevents you from going in that direction!\n\r", ch);
	  return FALSE;
	}
      for (fch = ch->in_room->people; fch != NULL; fch = fch_next)
	{
	  fch_next = fch->next_in_room;
	  if (IS_PLAYER(fch) || !fch->pIndexData->guard ||
	      !IS_SET(fch->pIndexData->guard->guarding_door, 
		     blood_number[door]) ||
	      !can_see(ch, fch)) 
	    continue;
	  if (IS_SET (fch->pIndexData->act3, ACT3_WALL))
	    { 
	      if (!IS_SET (fch->act, ACT_ATTITUDE))
		{
		  send_to_char ("You can't go any further in that direction.\n\r", ch);
		  return FALSE;
		}
	      else
		{
		  act ("$n didn't appreciate that. It attacks!", fch, NULL, NULL, TO_ROOM);
		  multi_hit (fch, ch, TYPE_UNDEFINED);
		  return FALSE;
		}
	    }
	  if (IS_SET(fch->pIndexData->act3, ACT3_GUARD_DOOR))
	    {
	      if (IS_SET (fch->act, ACT_ATTITUDE))
		{
		  do_say (fch, "You'll have to get by me first!");
		  multi_hit (fch, ch, TYPE_UNDEFINED);
		}
	      else
		{
		  do_say (fch, "I can't let you by.");
		}
	      return 0;
	    }
	  if (IS_SET(fch->pIndexData->act3, ACT3_GUARD_DOOR_ALIGN) && 
	      DIFF_ALIGN(ch, fch))
	    {
	      char t[80];
	      sprintf (t, "%ss may not pass!", align_info[ch->pcdata->alignment].name);
	      do_say (fch, t);
	      return FALSE;
	    }
	  if (fch->pIndexData->guard->guarding_clan != 0 && 
	      (clan_number (ch)) != fch->pIndexData->guard->guarding_clan)
	    {
	      do_say (fch, "You must be a member of our clan to enter!");
	      return FALSE;
	    }
	  if (fch->pIndexData->guard->guarding_sect != 0 && 
	      (clan_number_2 (ch)) != fch->pIndexData->guard->guarding_sect)
	    {
	      do_say (fch, "You must be a member of our sect to enter!");
	      return FALSE;
	    }
	}
    }
  if ((fch = RIDING (ch)) != NULL)
    {
      if (fch->move == 50)
	send_to_char ("Your mount is beginning to get tired.\n\r", ch);
      if (fch->move == 25)
	send_to_char ("Your mount is very tired, and will need to rest soon.\n\r", ch);
      if (fch->move < 15)
	send_to_char ("Your mount is nearly fainting from exhaustion.\n\r", ch);
      if (fch->move < 7)
	{
	  send_to_char ("Your mount is too exhausted.\n\r", ch);
	  return 0;
	}
      if (to_sector == SECT_SNOW)
	{
	  if (fch->move > 12)
	    fch->move -= 11;
	  else
	    fch->move = 1;
	}
      fch->move -= 3;
    }
  if (IS_MOB (ch))
    {
      if (ch->pIndexData->mobtype != MOB_FISH)
        {
          if (!IS_AFF(ch, FLYING) && (to_sector > SECT_SAVANNAH &&
             to_sector < SECT_CLOUDS))
             return FALSE;
        }
      else
        {
          if (to_sector < SECT_WATER_SWIM || to_sector > SECT_UNDERWATER)
             return FALSE;
        }
      if (IS_HURT (ch, CHARM)
	  && MASTER (ch) != NULL
	  && in_room == MASTER (ch)->in_room)
	{
	  send_to_char ("What? And leave your beloved master?\n\r", ch);
	  return 0;
	}
      if (MOUNTED_BY(ch) == NULL && 
	  ((IS_SET (ch->pIndexData->act3, ACT3_STAYROAD) &&
	    to_sector != SECT_ROAD) ||
	   (IS_SET (ch->act, ACT_STAYOFFROAD) &&
	    to_sector == SECT_ROAD)))
	return FALSE;
    }
  else
    {
      if (!IS_OPEN (to_room->area) && !IS_IMMORTAL (ch))
	{
	  send_to_char ("That area has not been opened to mortals yet!\n\r", ch);
	  return 0;
	}
      if (LEVEL (ch) > 100 && LEVEL (ch) < 108 && IS_OPEN (to_room->area))
	{
	  send_to_char ("That is not a region you can explore right now.. sorry.\n\r", ch);
	  return 0;
	}
      if (!IS_SET(ch->act, PLR_HOLYWALK) &&
	  (to_sector > SECT_SAVANNAH) && (to_sector < SECT_ICE))
	{
	  if ( !IS_AFF(ch, FLYING) &&
	       (to_sector == SECT_AIR || to_sector == SECT_CLOUDS))
	    {
	      send_to_char("You're not flying!\n\r", ch);
	      return 0;
	    }
	  if (to_sector == SECT_MOUNTAIN && !IS_SET(ch->act, PLR_HAS_MTN_BOOTS))
	    {
	      send_to_char("It's too steep for you to climb unaided.\n\r", ch);
	      return 0;
	    }
	  if (to_sector == SECT_UNDERWATER && 
	      !IS_SET(ch->act, PLR_HAS_SCUBA) &&
	      !IS_AFF(ch, WATER_BREATH))
	    {
	      send_to_char("You need to be able to breathe water to go there.\n\r", ch);
	      return 0;
	    }
	  if (to_sector == SECT_WATER_NOSWIM && 
	      !IS_SET(ch->act, PLR_HAS_BOAT))
	    {
	      send_to_char("The water is too rough for you to be out here without a boat!\n\r", ch);
	      return 0;
	    }
	  if (to_sector == SECT_WATER_SWIM &&
	      !IS_SET(ch->act, PLR_HAS_BOAT) &&
	      (!IS_AFF (ch, FLYING) ||
	       IS_SET (to_room->room_flags, ROOM_INDOORS | ROOM_UNDERGROUND)) &&
	      !check_skill (ch, gsn_swim))
	    {
	      send_to_char("You try to swim but your skill is not great enough!\n\r", ch);
	      ch->move -= 5;
	      return FALSE;
	    }
	}
    }
  move = (sectors[in_room->sector_type].moves + 
	  sectors[to_sector].moves)/2;
  if (to_sector == SECT_SNOW)
    {
      if (RIDING(ch) != NULL)
	send_to_char("Your mount has an extremely tough time trudging through the snow.\n\r", ch);
      else
	{
	  if (!IS_SET(ch->act, PLR_HAS_SNOWSHOES))
	    {
	      send_to_char ("The going is extremely tough without some type of snowshoes or skis.\n\r", ch);
	      move += 11;
	    }
	}
    }
  if (IS_PLAYER (ch))
    {
      weightmult = (get_curr_str (ch) + 
		    (IS_AUGMENTED(ch, AUG_BODY_STR) ? 2 : 0) +
		    (IS_AUGMENTED(ch, AUG_LEG_STR) ? 2 : 0) +
		    (IS_AUGMENTED(ch, AUG_FOOT_STR) ? 1 : 0));
      move += (ch->pcdata->carry_weight /(weightmult * WGT_MULT))-1;
      
      if (IS_AUGMENTED(ch, AUG_FOOT_SPD)) move -=(number_range(0,2));
      if (IS_AUGMENTED(ch, AUG_LEG_SPD)) move -=(number_range(0,2));
      if (IS_HURT(ch, LETHARGY))
	move +=number_range(1,30);
      if (move < 0) move = 0;
      if (IS_AFF(ch, FLYING)) 
	move /=2;
      else
	if (!IS_SET (ch->act, PLR_HOLYWALK | PLR_HAS_SHOES) &&
	    RIDING (ch) == NULL && 
	    !IS_AUGMENTED(ch, AUG_FOOT_ARMOR))
	  {
	    if (to_sector > SECT_UNDERWATER) 
	      {
		send_to_char ("Ouch! Every step hurts! Try getting some shoes...\n\r", ch);
		move +=2;;
		
	      }
	  }
    }
  if (move < 1) move = 1;
  if ((ch->move < move || ch->move < 1) && RIDING (ch) == NULL)
    {
      send_to_char ("You are too exhausted to move.\n\r", ch);
      if (LEADER (ch) != NULL)
	{
	  sprintf (buf, "%s was too exhausted to follow!", NAME (ch));
	  group_notify (buf, ch);
	  return FALSE;
	}
      return FALSE;
    }
  
  if (RIDING (ch) == NULL)
    {
      if(pow.easier_moves)
	SUBMOVE(ch,(move/2));
    else
      SUBMOVE(ch,move);
    }
  if (ch->move < 20 && number_range(1,7) == 2)
    {
      act ("You start breathing heavily and exhaustion overcomes your tired body.", ch, NULL, NULL, TO_CHAR_SPAM);
      act ("$n is breathing heavily and looks very sweaty.", ch, NULL, NULL, TO_ROOM_SPAM);
    }
  WAIT_STATE (ch, 1);
  if (IS_PLAYER (ch))
    {
      if(to_sector == SECT_UNDERWATER || 
	 (to_sector == SECT_WATER_SWIM && 
	  !IS_AFF(ch, FLYING) &&
	  !IS_SET(ch->act, PLR_HAS_BOAT)))
	{
	  sprintf (buf, "You swim %s.", dir_name[door]);
	  if (!IS_AFF(ch, WATER_BREATH) 
	      && !check_skill(ch, gsn_swim))
	    {
	      send_to_char ("You try to swim, but your skill is not great enough!\n\r", ch);
	      SUBMOVE(ch, 5);
	      return FALSE;
	    }
	  flagone = TRUE;
	}
      else if (!IS_AFF (ch, FLYING) &&
	       (to_sector == SECT_WATER_SWIM 
		|| to_sector == SECT_WATER_NOSWIM))
	{
	  sprintf (buf, "You paddle %s.", dir_name[door]);
	  flagtwo = TRUE;
	}
      else if (MOUNTED_BY (ch) != NULL)
	sprintf (buf, "You wander %s, rode by %s.", dir_name[door],
		 PERS (MOUNTED_BY (ch), ch));
      else if (RIDING (ch) != NULL)
	sprintf (buf, "You ride %s %s.", PERS (RIDING (ch), ch),
		 dir_name[door]);
      else if (IS_AFF (ch, FLYING))
	sprintf (buf, "You fly %s.", dir_name[door]);
      else if (IS_AFF (ch, SNEAK))
	{
	  sprintf (buf, "You sneak %s.", dir_name[door]);
	  check_skill(ch, gsn_sneak);
	}
      else if (ch->position == POSITION_RUNNING)
	sprintf (buf, "You run %s.", dir_name[door]);
      else
	sprintf (buf, "You walk %s.", dir_name[door]);
    }
  buf[0] = UPPER (buf[0]);
  strcat(buf, "\n\r");
  send_to_char (buf, ch);
  
  for (fch = in_room->people; fch != NULL; fch = fch_next)
    {
      fch_next = fch->next_in_room;
      if (fch->position < POSITION_STANDING || 
	  ch == fch || 
	  RIDING (ch) == fch || 
	  MOUNTED_BY (ch) == fch
          || (IS_PLAYER(fch) && (fch->pcdata->play ||
				 fch->position == POSITION_CASTING)))
	continue;
      if (!can_see (fch, ch) && RIDING(ch) == NULL)
	continue;
      if (IS_MOB(fch) && IS_SET(fch->pIndexData->act4, ACT4_LEAVESCRIPT))
	{
	again_20:
	  {
	    SINGLE_TRIGGER *tr;
	    SCRIPT_INFO *s;
	    for (tr = trigger_list[TLEAVES]; tr != NULL; tr = tr->next)
	      {
		if (IS_MOB (fch) && fch->pIndexData->vnum == tr->attached_to_mob)
		  {
		    if (tr->players_only && IS_MOB (ch))
		      continue;
		    if (tr->running_info && !tr->interrupted)
		      continue;	/* Already running, interrupted, but script says not to allow interruptions. */
		    if (tr->running_info && tr->interrupted != 2)
		      {
			end_script (tr->running_info);
			goto again_20;
		      }
		    /* ----------------- */
		    /* Start the script! */
		    /* ----------------- */
		    tr->running_info = mem_alloc (sizeof (*tr->running_info));
		    s = tr->running_info;
		    bzero (s, sizeof (*s));
		    s->current = ch;
		    s->mob = fch;
		    strcpy (s->code_seg, tr->code_label);
		    s->current_line = 0;
		    s->called_by = tr;
		    s->next = info_list;
		    info_list = s;
		    execute_code (s);
		    /* ----------------- */
		  }
	      }
	  }
	}
      /* End trigger check! */
      
      if (MOUNTED_BY (ch) != NULL)
	break; 
      else if (ballista_push)
	sprintf (buf, "$N get slammed %s!", dir_name[door]);
      else if (RIDING (ch) != NULL)
	sprintf (buf, "$N rides %s %s.", PERS(RIDING(ch), fch), dir_name[door]);
      else if (IS_AFF (ch, FLYING) && !IS_AFF(ch, SNEAK))
	sprintf (buf, "$N flies %s.", dir_name[door]);
      else if (flagtwo)
	{
	  sprintf (buf, "$N travels %s through the water.", dir_name[door]);
	}
      else if (flagone)
	{
	  sprintf (buf, "$N swims %s.", dir_name[door]);
	}
      else if (IS_AFF (ch, SNEAK))
	{
	  if (IS_SET (fch->act, PLR_HOLYLIGHT) || (IS_PLAYER (ch) && !check_skill(ch, gsn_sneak)))
	    sprintf (buf, "$N sneaks %s.", dir_name[door]);
	  else
	    buf[0] = '\0';
	}
      else if ((IS_MOB (ch) && IS_SET (ch->act, ACT_SCRAMBLE))
	       || (IS_PLAYER (ch) && ch->position == POSITION_RUNNING))
	sprintf (buf, "$N runs %s.", dir_name[door]);
      else
	sprintf (buf, "$N leaves %s.", dir_name[door]);
      buf[0] = UPPER (buf[0]);
      if (buf[0] != '\0')
	{
	  if (!is_same_group (fch, ch) || fch->position != POSITION_STANDING)
	    act (buf, fch, NULL, ch, TO_CHAR);
	}
    }
  if (((ch->hit < ch->max_hit / 2) || IS_HURT (ch, WOUND)) &&
      (in_room->sector_type < SECT_WATER_SWIM || 
       in_room->sector_type > SECT_HOLLOW || 
       (in_room->sector_type > SECT_CLOUDS && 
	in_room->sector_type < SECT_TROPICAL)) &&
      (IS_PLAYER(ch) || ch->pIndexData->mobtype != MOB_GHOST))
    SET_BIT(in_room->blood, blood_number[door]);           
  
  if (ch->in_room == to_room)
    return FALSE;

  
  /* This is the new code that sets tracks. Yes, it looks a little funny,
     but it is very compact and does what it needs to. */
  
  for (i = 0; i < 2; i++)
    {
      if (i == 0)
	curr_room = in_room;
      else
	curr_room = to_room;
      if (IS_PLAYER(ch))
	track_thing =  (ONLINE *) ch->pcdata->online_spot;
      else
	track_thing = (CHAR_DATA *) ch;
      fndd = FALSE;
      for (trk = curr_room->tracks; trk != NULL; trk = trk->next)
	{
	  if (trk->who == track_thing)
	    {
	      fndd = TRUE;
	      break;
	    }
	}
      if (!fndd)
	{
	  if (i ==0)
	    trk = new_track (ch, curr_room, MAX_DIR, door);
	  else
	    trk = new_track (ch, curr_room, rev_dir[door], MAX_DIR);
	}
      if (trk)
	{
	  if (i == 0)
	    {
	      trk->dir %= 10;
	      trk->dir += 10 * door;
	    }
	  else
	    {
	      trk->dir -= (trk->dir % 10);
	      trk->dir += rev_dir[door];
	    }
	  
	}
    }
  
  /* Leaving room, check for triggers on room! */
  if (IS_SET(ch->in_room->room_flags, ROOM_LEAVESCRIPT))
    {
    again_21:
      {
	SINGLE_TRIGGER *tr;
	SCRIPT_INFO *s;
	for (tr = trigger_list[TLEAVES]; tr != NULL; tr = tr->next)
	  {
	    if (ch->in_room->vnum == tr->attached_to_room)
	      {
		if (tr->running_info && !tr->interrupted)
		  continue;		/* Already running, interrupted, but script says not to allow interruptions. */
		if (tr->players_only && IS_MOB (ch))
		  continue;
		if (tr->running_info && tr->interrupted != 2)
		  {
		    end_script (tr->running_info);
		    goto again_21;
		  }
		/* ----------------- */
		/* Start the script! */
		/* ----------------- */
		tr->running_info = mem_alloc (sizeof (*tr->running_info));
		s = tr->running_info;
		bzero (s, sizeof (*s));
		s->current = ch;
		s->room = ch->in_room;
		strcpy (s->code_seg, tr->code_label);
		s->current_line = 0;
		s->called_by = tr;
		s->next = info_list;
		info_list = s;
		execute_code (s);
		/* ----------------- */
	      }
	  }
      }
    }
  /* End trigger check! */
  
  
  
  
  
  /* Char from room/ char to room  */
  
  if(ch == in_room->people)
    in_room->people = ch->next_in_room;
  else
    {
      CHAR_DATA *prev;
      for (prev = in_room->people; prev; prev = prev->next_in_room)
	{
	  if (prev->next_in_room == ch)
	    {
	      prev->next_in_room = ch->next_in_room;
	      break;
	    }
	}
      if (prev == NULL) return FALSE;
    }
  
 
  if(IS_PLAYER(ch))
    {
      in_room->light -= ch->pcdata->light;
      in_room->area->nplayer--;
      if (--in_room->pcs < 1)
	{
	  in_room->pcs = 0;
	  for (fch = in_room->people; fch != NULL; fch = fch->next_in_room)
	    {
	      if (IS_MOB (fch))
		remove_from_aggro_list (fch);
	    }
	}
    }
  else
    {
      if(in_room->pcs == 0)
	remove_from_aggro_list(ch);
      if (IS_SET(ch->pIndexData->act4, ACT4_COMMANDSCRIPT))
	in_room->command_objs--;
      if (ch->in_room->command_objs < 0)
	in_room->command_objs = 0;
    }
 
  if ((IS_SET(to_room->room_flags,ROOM_INDOORS | ROOM_UNDERGROUND) || 
       to_room->sector_type >= SECT_CAVE)  && 
      IS_AFF(ch,FLYING) && 
      (ch->height > INDOOR_FLY_HEIGHT)) 
    {
      send_to_char("You cannot fly while indoors.\n\r",ch);
      do_land(ch,"");
    }
  ch->in_room = to_room;
  if (to_room->people != ch)
    ch->next_in_room = to_room->people;
  to_room->people = ch;
  if(IS_PLAYER(ch))
    {
      CHAR_DATA *d;
      for (d = to_room->people; d != NULL; d = d->next_in_room)
	{
	  if (IS_MOB (d))
	    {
	      add_to_aggro_list (d);
	    }    
	} 
      to_room->area->nplayer++;
      to_room->pcs++;
      to_room->light += ch->pcdata->light;
      if(to_room->vnum >= BATTLEGROUND_START_VNUM && to_room->vnum <=
	 BATTLEGROUND_END_VNUM)
	ch->pcdata->battleground = BATTLE_FIGHTING;
      else
	{
	  ch->pcdata->battleground = 0;
	  ch->pcdata->wasroom = in_room->vnum;
	}
    }
  else
    {
      if ((in_room->area->nplayer == 0) != (to_room->area->nplayer == 0))
	{
	  remove_char_from_list (ch);
	  add_char_to_list (ch);
	}
      if (IS_SET(ch->pIndexData->act4, ACT4_COMMANDSCRIPT))
	ch->in_room->command_objs++;
      if(ch->in_room->command_objs < 0)
	ch->in_room->command_objs = 0;
      if (IS_SET(ch->pIndexData->act4, ACT4_MOVESCRIPT))
	{
	again_22:	
	  {
	    SINGLE_TRIGGER *tr;
	    SCRIPT_INFO *s;
	    for (tr = trigger_list[TMOVES]; tr != NULL; tr = tr->next)
	      {
		if (ch->pIndexData->vnum == tr->attached_to_mob)
		  {
		    if (tr->running_info && !tr->interrupted)
		      continue;	/* Already running, interrupted, but script says not to allow interruptions. */
		    if (tr->running_info && tr->interrupted != 2)
		      {
			end_script (tr->running_info);
			goto again_22;
		      }
		    /* ----------------- */
		    /* Start the script! */
		    /* ----------------- */
		    tr->running_info = mem_alloc (sizeof (*tr->running_info));
		    s = tr->running_info;
		    bzero (s, sizeof (*s));
		    s->current = ch;
		    s->mob = ch;
		    strcpy (s->code_seg, tr->code_label);
		    s->current_line = 0;
		    s->called_by = tr;
		    s->next = info_list;
		    info_list = s;
		    execute_code (s);
		    /* ----------------- */
		  }
	      }
	  }
	}
    }
  if (RIDING (ch) != NULL && 
      ch->in_room != RIDING (ch)->in_room
      && depth == 0)
    {
      depth++;
      if (!move_char (RIDING (ch), door))
	{
	  check_fgt (ch);
	  check_fgt (ch->fgt->riding);
	  send_to_char ("You just left your mount behind...\n\r", ch);
	  ch->fgt->riding->fgt->mounted_by = NULL;
	  ch->fgt->riding = NULL;
	}
      depth--;
    }
  else if (MOUNTED_BY (ch) != NULL && 
	   ch->in_room != MOUNTED_BY (ch)->in_room
	   && depth == 0)
    {
      depth++;
      if (!move_char (MOUNTED_BY (ch), door))
	{
	  send_to_char ("You just left your rider behind...\n\r", ch);
	  check_fgt (ch);
	  check_fgt (ch->fgt->mounted_by);
	  ch->fgt->mounted_by->fgt->riding = NULL;
	  ch->fgt->mounted_by = NULL;
	}
      depth--;
    }
  
  if (IS_PLAYER(ch) && ch->position == POSITION_RUNNING && !IS_SET
      (ch->pcdata->act2, PLR_BRIEF))
    {
      SET_BIT (ch->pcdata->act2, PLR_BRIEF);
      do_look (ch, "auto");
      REMOVE_BIT (ch->pcdata->act2, PLR_BRIEF);
    }
  else
    {
      do_look (ch, "auto");
    }
  
  if (ch->fgt && ch->fgt->pulling && 
      ch->fgt->pulling->in_room == in_room)
    {
      for (fch = in_room->people; fch != NULL; fch = fch->next_in_room)
	{
	  if (fch != ch && fch->fgt && fch->fgt->pulling == ch->fgt->pulling)
	    {
	      act ("$n stops pulling on $p.", fch, fch->fgt->pulling, NULL, TO_ROOM);
	      act ("You stop pulling on $p.", fch, fch->fgt->pulling, NULL, TO_CHAR);
	    }
	}
      act ("You drag $p along with you.", ch, ch->fgt->pulling, NULL, TO_CHAR);
      act ("$n drags $p along with $m.", ch, ch->fgt->pulling, NULL, TO_ROOM);
      obj_from (ch->fgt->pulling);
      obj_to (ch->fgt->pulling, to_room);
      ch->move -= 10;
    }


  /* Entered room, check for triggers on room! */
  if (IS_SET(to_room->room_flags, ROOM_ENTERSCRIPT))
    {
    again_23:
      {
	SINGLE_TRIGGER *tr;
	SCRIPT_INFO *s;
	for (tr = trigger_list[TENTERS]; tr != NULL; tr = tr->next)
	  {
	    if (ch->in_room->vnum == tr->attached_to_room)
	      {
		if (tr->running_info && !tr->interrupted)
		  continue;		/* Already running, interrupted, but script says not to allow interruptions. */
		if (tr->players_only && IS_MOB (ch))
		  continue;
		if (tr->running_info && tr->interrupted != 2)
		  {
		    end_script (tr->running_info);
		    goto again_23;
		  }
		/* ----------------- */
		/* Start the script! */
		/* ----------------- */
		tr->running_info = mem_alloc (sizeof (*tr->running_info));
		s = tr->running_info;
		bzero (s, sizeof (*s));
		s->current = ch;
		s->room = ch->in_room;
		strcpy (s->code_seg, tr->code_label);
		s->current_line = 0;
		s->called_by = tr;
		s->next = info_list;
		info_list = s;
		execute_code (s);
		/* ----------------- */
	      }
	  }
      }
    }
  /* End trigger check! */
  
  
  for (fch = to_room->people; fch != NULL; fch = fch_next)
    {
      fch_next = fch->next_in_room;
      if (ch == fch || RIDING (ch) == fch || MOUNTED_BY (ch) == fch
          || (IS_PLAYER(fch) && 
	      (fch->pcdata->play || fch->position == POSITION_CASTING)))
	continue;
      
      if (IS_DET(ch, SNEAK) && number_range(1,3) == 2)
	{
	  sprintf (buf, "You sense a life-form moving in from the %s.", dir_rev[door]);
	  act (buf, ch, NULL, fch, TO_CHAR);
	  continue;
	}
      if (!can_see (fch, ch) && (RIDING (ch) == NULL))
	continue;
      if (MOUNTED_BY (ch) != NULL)
	break; 
      if (depth == 0 && !yelled && IS_MOB (fch) && fch->society && !fleeing &&
	  fch->society != ch->society && !FIGHTING (ch) &&
	  (soc = society_lookup (NULL, fch->society)) != NULL &&
	  IS_SET (soc->flags, SOCIETY_XENOPHOBIC | SOCIETY_AGGRESSIVE) &&
	  can_yell (fch) && can_see (fch, ch) && IS_AWAKE (fch))
	{
	  being_attacked_yell = TRUE;
	  yelled = TRUE;
	  multi_hit (fch, ch, TYPE_UNDEFINED);
	  sprintf (buf, "Help! %s is entering our homeland!", NAME (ch));
	  do_yell (fch, buf);
	  being_attacked_yell = FALSE;
	}
      if (ballista_push)
	sprintf (buf, "$N get slammed in from %s!", dir_rev[door]);
      else if (RIDING (ch) != NULL)
	sprintf (buf, "$N rides %s in from %s.",
		 PERS (RIDING (ch), fch), dir_rev[door]);
      else if (IS_AFF (ch, FLYING) && !IS_AFF(ch, SNEAK))
	sprintf (buf, "$N flies in from %s.",
		 dir_rev[door]);
      else if (IS_AFF (ch, SNEAK))
	{
	  if (IS_SET (fch->act, PLR_HOLYLIGHT) || 
	      (IS_PLAYER (ch) && !check_skill(ch, gsn_sneak)))
	    sprintf (buf, "$N sneaks in from %s.", dir_rev[door]);
	  else
	    buf[0] = '\0';
	}
      else if (flagone)
	{
	  sprintf (buf, "$N swims in from %s.", dir_rev[door]);
	}
      else if (flagtwo)
	{
	  sprintf (buf, "$N paddles in from %s.", dir_rev[door]);
	}
      else if ((IS_MOB (ch) && IS_SET (ch->act, ACT_SCRAMBLE))
	       || (IS_PLAYER (ch) && ch->position == POSITION_RUNNING))
	sprintf (buf, "$N runs in from %s.", dir_rev[door]);
      else
	sprintf (buf, "$N arrives from %s.", dir_rev[door]);
      buf[0] = UPPER (buf[0]);
      if (buf[0] != '\0')
	{
	  /*	 if (!is_same_group(fch,ch)) */
	  act (buf, fch, NULL, ch, TO_CHAR);
	}
      if ((IS_PLAYER(fch) && IS_PLAYER(ch)) &&
	  DIFF_ALIGN(ch, fch) && LEVEL(ch) < 100 && LEVEL(fch) < 100)
	{
	  if (fch->pcdata->no_quit_pk < 4)
	    fch->pcdata->no_quit_pk = 4; /* JRAJRA */
	  if (ch->pcdata->no_quit_pk < 4)
	    ch->pcdata->no_quit_pk = 4; /* JRAJRA */
	} 
      /* Entered room, check for triggers on mobbies! */
      if (IS_MOB(fch) && IS_SET(fch->pIndexData->act4, ACT4_ENTERSCRIPT))
	{
	again_24:
	  {
	    SINGLE_TRIGGER *tr;
	    SCRIPT_INFO *s;
	    for (tr = trigger_list[TENTERS]; tr != NULL; tr = tr->next)
	      {
		if (IS_MOB (fch) && fch->pIndexData->vnum == tr->attached_to_mob)
		  {
		    if (tr->running_info && !tr->interrupted)
		      continue;	/* Already running, interrupted, but script says not to allow interruptions. */
		    if (tr->players_only && IS_MOB (ch))
		      continue;
		    if (tr->running_info && tr->interrupted != 2)
		      {
			end_script (tr->running_info);
			goto again_24;
		      }
		    /* ----------------- */
		    /* Start the script! */
		    /* ----------------- */
		    tr->running_info = mem_alloc (sizeof (*tr->running_info));
		    s = tr->running_info;
		    bzero (s, sizeof (*s));
		    s->current = ch;
		    s->mob = fch;
		    strcpy (s->code_seg, tr->code_label);
		    s->current_line = 0;
		    s->called_by = tr;
		    s->next = info_list;
		    info_list = s;
		    execute_code (s);
		    /* ----------------- */
		  }
	      }
	  }
	}
      /* End trigger check! */
      
   
    } 
  if (IS_PLAYER (ch))
    {
      if (check_skill(ch, gsn_search))
	{
	  bool yesno = FALSE;
	  int hh;
	  for (hh = 0; hh < 6; hh++)
	    if (ch->in_room->exit[hh] && ch->in_room->exit[hh]->d_info && IS_SET (ch->in_room->exit[hh]->d_info->exit_info, EX_HIDDEN))
	      yesno = TRUE;
	  if (yesno && number_range (1, 4) == 3)
	    send_to_char ("You sense a hidden exit somewhere in this room. Perhaps you should\n\rsearch in all directions...\n\r", ch);
	}
      if (HUNTING (ch) != NULL)
	do_track (ch, "continue");
    }
  for (fch = in_room->people; fch != NULL; fch = fch_next)
    {
      fch_next = fch->next_in_room;
      if (MASTER (fch) == ch && fch->position >= POSITION_STANDING && FIGHTING (fch) == NULL && (!MASTER(ch) || MASTER(ch) == fch))
	{
	  act ("You follow $N $t.", fch, dir_name[door], ch, TO_CHAR);
	  if(move_char (fch, door))
	    followers++;
	}
    }
    
  if (IS_PLAYER(ch))
    { 
      for (i=0; i < 6; i++)
	{
	  curr_room = ch->in_room;
	  for (n = 0; n < 4; n++)
	    {
	      if (((pexit = curr_room->exit[i])  == NULL) 
		  || ((troom =(ROOM_DATA *) pexit->to_room) == NULL)
		  || (pexit->d_info && IS_SET(pexit->d_info->exit_info, EX_CLOSED))
		  || troom->pcs <= 0)
		break;
	      for (viewer = troom->people; viewer != NULL; viewer =viewer->next_in_room)
		{
		  if (IS_MOB(viewer) || !DIFF_ALIGN(ch, viewer)) continue;
		  if (LEVEL(ch) > 100) continue;
		  viewer->pcdata->no_quit_pk = 7;
		  ch->pcdata->no_quit_pk = 7;
		  if (!IS_SET(viewer->pcdata->act2, PLR_AUTOSCAN)
		      || !check_skill(viewer, gsn_sixth_sense)
                      || IS_HURT(ch, BLIND) 
                      || viewer->pcdata->play
		      || viewer->position == POSITION_CASTING)
		    continue;
		  if (!can_see_nextdoor (viewer, ch))
		    sprintf(buf, "Someone arrives");
		  else
		    sprintf(buf, "You see +* A %s %s *+ arrive", align_info[ch->pcdata->alignment].name, (race_info[ch->pcdata->race].name));
		  if (n == 0) strcat(buf, " close by");
		  else if (n > 1) strcat (buf, " far off");
		  switch (i)
		    {
		    case 0:
		      strcat(buf, " to the south");
		      break;
		    case 1:
		      strcat(buf, " to the west");
		      break;
		    case 2:
		      strcat(buf, " to the north");
		      break;
		    case 3:
		      strcat(buf, " to the east");
		      break;
		    case 4:
		      strcat(buf, " down below");
		      break;
		    case 5:
		      strcat(buf, " up above");
		      break;
		    }
		  if (followers > 0)
		    sprintf(buf2, " with %d followers.\n\r", followers);
		  else
		    sprintf(buf2, ".\n\r");
		  strcat (buf, buf2);
		  send_to_char(buf, viewer);
		  break;
		}
	      curr_room = troom;
	    }
	}
      if (IS_HURT(ch, BLIND))
        REMOVE_BIT(ch->pcdata->act2, PLR_MAPPING);    
      else if (ch->desc && IS_SET(ch->pcdata->act2, PLR_MAPPING))
	{
	  int newx = ch->pcdata->x;
	  int newy = ch->pcdata->y;
	  if ((door % 2) == 0)
	    newy += (door-1);
	  else
	    newx += (2-door);
	  if (newy < 2 || newx < 2 || newy > MAP_HEIGHT-2 || newx >
	      MAP_WIDTH-2 || door == 4 || door == 5 || IS_SET(ch->pcdata->act2,
							      PLR_MAPSPAM))
	    {
	      small_map(ch);
	    }
	  else 
	    { 
              bool found = FALSE;
	      sprintf(buf, "\x1b[%d;%dr",MAP_HEIGHT,ch->pcdata->pagelen);
	      send_to_char(buf, ch);
	      gotoxy(ch, ch->pcdata->x,ch->pcdata->y);
              if (in_room->pcs > 0 &&
		  IS_SET(ch->pcdata->act2, PLR_VIEWPLAYERS))
                {
                  if (LEVEL(ch) == MAX_LEVEL)
                    {
                      found = TRUE;
                      send_to_char("\x1b[1;31mP", ch);
                    }
                  else
                    {
		      for(fch = in_room->people; fch != NULL; fch=fch->next_in_room)
                        {
                          if (IS_PLAYER(fch) && !DIFF_ALIGN(ch, fch))
                            {
			      found = TRUE;
			      send_to_char("@", ch);
			      break;
                            }
                        }
                    }
		}
	      if (!found  && IS_SET(ch->pcdata->act2, PLR_VIEWMOBS))
		{
		  for (fch = in_room->people; fch != NULL; fch = fch->next_in_room)
		    {
		      if (IS_MOB(fch))
			{
			  sprintf(buf, "%s%c\x1b[0;37m", color_table[fch->pIndexData->color].code, fch->pIndexData->symbol);
			  send_to_char(buf, ch);
			  found = TRUE;
			  break;
			}
		    }
		}
	      if (!found)
		{
		  sprintf(buf, "%s%c\x1b[0;37m", color_table[in_room->color].code, (IS_SET(ch->pcdata->act2, PLR_NOIBM) ? in_room->noibm : in_room->ibm));
		  send_to_char(buf, ch);
		  
		}
	      
	      gotoxy(ch, (newx), (newy));
              sprintf(buf, "\x1b[0;37m@\x1B[%d;1f",ch->pcdata->pagelen);
	      if ((door % 2) == 0)
		ch->pcdata->y += (door-1);
	      else
		ch->pcdata->x += (2-door);
	      send_to_char(buf, ch);
	    }
	}
      if (to_room->trap)
	{
	  if (!check_skill(ch, gsn_locate_trap))
	    {
	      send_to_char("You notice a trap in this room! Be careful.\n\r", ch);
	    }
	  else
	    set_off_trap(ch, NULL, MAX_DIR);
	}
      ch->pcdata->speedwalk += 2;
    }
  for (fch = in_room->people; fch != NULL; fch = fch->next_in_room)
    {
      if (fch->fgt)
	{
	  for (i = 0; i < 4; i++)
	    {
	      if (fch->fgt->attackers[i] == ch)
		fch->fgt->attackers[i] = NULL;
	    }
	}
    }
  return TRUE;
}

void
do_run (CHAR_DATA * ch, char *argy)
{
  char arg1[STD_LENGTH];
  char arg2[STD_LENGTH];
  int door, count;
  DEFINE_COMMAND ("run", do_run, POSITION_STANDING, 0, LOG_NORMAL, "Usage:  Run <direction> <distance>")

    argy = one_argy (argy, arg1);
  argy = one_argy (argy, arg2);
  if (ch->position != POSITION_STANDING)
    {
      send_to_char ("You must be standing to run!\n\r", ch);
      return;
    }
  if (LEVEL (ch) < 100 && ch->in_room && (ch->in_room->sector_type == SECT_WATER_NOSWIM ||
			       ch->in_room->sector_type == SECT_WATER_SWIM))
    {
      send_to_char ("You are in water; you can't run!\n\r", ch);
      return;
    }
  if (IS_AFF (ch, FLYING))
    {
      send_to_char ("Can't run while flying.\n\r", ch);
      return;
    }
  if (arg1[0] == '\0')
    {
      send_to_char ("Run which way?\n\r", ch);
      return;
    }
  count = 0;
  if (arg2[0] != '\0')
    count = atoi (arg2);
  door = get_direction_number (arg1);
  if (door > 5 || door < 0)
    {
      send_to_char ("Run which way?\n\r", ch);
      return;
    }
  NEW_POSITION(ch, POSITION_RUNNING);
  if (count)
    {
      while (count)
	{
	  if (!move_char (ch, door))
	    break;
	  SUBMOVE(ch,6);
	  if (ch->move < 5)
	    {
	      send_to_char ("You are too exhausted.\n\r", ch);
	      break;
	    }
	  count--;
	}
      NEW_POSITION(ch, POSITION_STANDING);
      return;
    }
  while (move_char (ch, door))
    {
      SUBMOVE(ch,6);
    }
  NEW_POSITION(ch, POSITION_STANDING);
  return;
}


void
do_north (CHAR_DATA * ch, char *argy)
{
  DEFINE_COMMAND ("north", do_north, POSITION_FIGHTING, 0, LOG_NORMAL, "Moves you north.")

    if (FIGHTING (ch) != NULL || ch->position == POSITION_FIGHTING) {
	send_to_char("You are in the middle of combat!\n",ch);
    	return;
	}
  move_char (ch, DIR_NORTH);

  return;
}

void
do_east (CHAR_DATA * ch, char *argy)
{
  DEFINE_COMMAND ("east", do_east, POSITION_FIGHTING, 0, LOG_NORMAL, "Moves you east.")

    if (FIGHTING (ch) != NULL || ch->position == POSITION_FIGHTING) {
	send_to_char("You are in the middle of combat!\n",ch);
	return;
	}
  move_char (ch, DIR_EAST);
  return;
}

void
do_south (CHAR_DATA * ch, char *argy)
{
  DEFINE_COMMAND ("south", do_south, POSITION_FIGHTING, 0, LOG_NORMAL, "Moves you south.")

    if (FIGHTING (ch) != NULL || ch->position == POSITION_FIGHTING) {
	send_to_char("You are in the middle of combat!\n",ch);
	return;
	}
  move_char (ch, DIR_SOUTH);
  return;
}

void
do_west (CHAR_DATA * ch, char *argy)
{
  DEFINE_COMMAND ("west", do_west, POSITION_FIGHTING, 0, LOG_NORMAL, "Moves you west.")

    if (FIGHTING (ch) != NULL || ch->position == POSITION_FIGHTING) {
	send_to_char("You are in the middle of combat!\n",ch);
	return;
	}
  move_char (ch, DIR_WEST);
  return;
}

void
do_up (CHAR_DATA * ch, char *argy)
{
  DEFINE_COMMAND ("up", do_up, POSITION_STANDING, 0, LOG_NORMAL, "Moves you up.")

    if (FIGHTING (ch) != NULL || ch->position == POSITION_FIGHTING)
    return;
  move_char (ch, DIR_UP);
  return;
}

void
do_down (CHAR_DATA * ch, char *argy)
{
  DEFINE_COMMAND ("down", do_down, POSITION_STANDING, 0, LOG_NORMAL, "Moves you down.")

    if (FIGHTING (ch) != NULL || ch->position == POSITION_FIGHTING)
    return;
  move_char (ch, DIR_DOWN);
  return;
}

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

  if ((door = get_direction_number (arg)) == MAX_DIR)
    {
      for (door = 0; door <= 5; door++)
	{
	  if ((pexit = ch->in_room->exit[door]) != NULL
	      && pexit->d_info 
	      && IS_SET (pexit->d_info->exit_info, EX_ISDOOR)
	      && !IS_SET (pexit->d_info->exit_info, EX_ISWALL)
	      && pexit->d_info->keyword != NULL
	      && is_name (arg, pexit->d_info->keyword))
	    return door;
	}
      return -1;
    }
  if ((pexit = ch->in_room->exit[door]) != NULL && 
      pexit->d_info 
      && IS_SET (pexit->d_info->exit_info,  EX_HIDDEN | EX_ISWALL) 
      && door < MAX_DIR)
    {
      act ("I see no door $T here.", ch, NULL, get_direction (arg), TO_CHAR);
      return -1;
    }
  if ((pexit = ch->in_room->exit[door]) == NULL)
    {
      act ("I see no door $T here.", ch, NULL, get_direction (arg), TO_CHAR);
      return -1;
    }
  if (!pexit->d_info || !IS_SET (pexit->d_info->exit_info, EX_ISDOOR))
    {
      send_to_char ("You can't do that.\n\r", ch);
      return -1;
    }
  return door;
}

void
do_open (CHAR_DATA * ch, char *argy)
{
  char arg[SML_LENGTH];
  SINGLE_OBJECT *obj;
  int door;
  DEFINE_COMMAND ("open", do_open, POSITION_RESTING, 0, LOG_NORMAL, "Allows you to open a door or object.")

    argy = one_argy (argy, arg);
  if (!str_cmp ("the", arg))
    argy = one_argy (argy, arg);
  if (arg[0] == '\0')
    {
      send_to_char ("Open what?\n\r", ch);
      return;
    }
  if ((door = find_door (ch, arg)) >= 0)
    {
      ROOM_DATA *to_room;
      EXIT_DATA *pexit;
      EXIT_DATA *pexit_rev;
      pexit = ch->in_room->exit[door];
      if (pexit->d_info)
	{
	  
	  if (!IS_SET (pexit->d_info->exit_info, EX_CLOSED))
	    {
	      send_to_char ("It's already open.\n\r", ch);
	      return;
	    }
	  if (IS_SET (pexit->d_info->exit_info, EX_LOCKED))
	    {
	      send_to_char ("It's locked.\n\r", ch);
	      return;
	    }
	  REMOVE_BIT (pexit->d_info->exit_info, EX_CLOSED);
	  if ((to_room = pexit->to_room) != NULL
	      && (pexit_rev = to_room->exit[rev_dir[door]]) != NULL
	      && pexit_rev->to_room == ch->in_room && pexit_rev->d_info)
	    {
	      CHAR_DATA *rch;
	      REMOVE_BIT (pexit_rev->d_info->exit_info, EX_CLOSED);
	      for (rch = to_room->people; rch != NULL; rch = rch->next_in_room)
		act ("The $T is opened from the other side.", rch, NULL, pexit_rev->d_info->keyword, TO_CHAR);
	    }
          if (pexit->d_info && pexit->d_info->trap)
            {
              set_off_trap(ch, NULL, door);
            }
        else
            {
              act ("$n opens the $T.", ch, NULL, pexit->d_info->keyword, TO_ROOM);
              act ("You open the $T.", ch, NULL, pexit->d_info->keyword, TO_CHAR);
            }
	}
    }
  if ((obj = get_obj_here (ch, arg, SEARCH_INV_FIRST)) != NULL)
    {
      if (obj->pIndexData->item_type != ITEM_CONTAINER)
	{
	  send_to_char ("That's not a container.\n\r", ch);
	  return;
	}
      else
	{
	  I_CONTAINER *con = (I_CONTAINER *) obj->more;
	  if (!IS_SET (con->flags, CONT_CLOSED))
	    {
	      send_to_char ("It's already open.\n\r", ch);
	      return;
	    }
	  if (!IS_SET (con->flags, CONT_CLOSEABLE))
	    {
	      send_to_char ("You can't do that.\n\r", ch);
	      return;
	    }
	  if (IS_SET (con->flags, CONT_LOCKED))
	    {
	      send_to_char ("It's locked.\n\r", ch);
	      return;
	    }
	  REMOVE_BIT (con->flags, CONT_CLOSED);
	  if (con->trap_type > 0)
	    {
              set_off_trap(ch, obj, 0);
            }	  
          else
            {
              act ("You open $p.", ch, obj, NULL, TO_CHAR);
              act ("$n opens $p.", ch, obj, NULL, TO_ROOM);
            }
	  return;
	}
    }
  if (door == -1)
    act ("I see no $T here.", ch, NULL, arg, TO_CHAR);
  return;
}

void
do_close (CHAR_DATA * ch, char *argy)
{
  char arg[SML_LENGTH];
  SINGLE_OBJECT *obj;
  int door;
  DEFINE_COMMAND ("close", do_close, POSITION_RESTING, 0, LOG_NORMAL, "Allows you to close a door or object.")

    argy = one_argy (argy, arg);
  if (!str_cmp ("the", arg))
    argy = one_argy (argy, arg);
  if (arg[0] == '\0')
    {
      send_to_char ("Close what?\n\r", ch);
      return;
    }
  if ((door = find_door (ch, arg)) >= 0)
    {
      ROOM_DATA *to_room;
      EXIT_DATA *pexit;
      EXIT_DATA *pexit_rev;
      pexit = ch->in_room->exit[door];
      if (pexit->d_info)
	{
	  if (IS_SET (pexit->d_info->exit_info, EX_CLOSED))
	    {
	      send_to_char ("It's already closed.\n\r", ch);
	      return;
	    }
	  if (pexit->d_info->str < 1)
	    {
              send_to_char ("That door is broken.\n\r", ch);
	      return;
	    }
	  SET_BIT (pexit->d_info->exit_info, EX_CLOSED);
	  act ("$n closes the $T.", ch, NULL, pexit->d_info->keyword, TO_ROOM);
          act ("You close the $T.", ch, NULL, pexit->d_info->keyword, TO_CHAR);
	  if ((to_room = pexit->to_room) != NULL
	      && (pexit_rev = to_room->exit[rev_dir[door]]) != 0
	      && pexit_rev->to_room == ch->in_room && pexit_rev->d_info)
	    {
	      CHAR_DATA *rch;
	      SET_BIT (pexit_rev->d_info->exit_info, EX_CLOSED);
		for (rch = to_room->people; rch != NULL; rch = rch->next_in_room)
		  {
		    act ("The $T is closed from the other side.", rch, NULL, pexit_rev->d_info->keyword, TO_CHAR);
		  }
	    }
	  return;
	}
    }
  if ((obj = get_obj_here (ch, arg, SEARCH_INV_FIRST)) != NULL)
    {
      if (obj->pIndexData->item_type != ITEM_CONTAINER)
	{
	  send_to_char ("That's not a container.\n\r", ch);
	  return;
	}
      else
	{
	  I_CONTAINER *cnt = (I_CONTAINER *) obj->more;
	  if (IS_SET (cnt->flags, CONT_CLOSED))
	    {
	      send_to_char ("It's already closed.\n\r", ch);
	      return;
	    }
	  if (!IS_SET (cnt->flags, CONT_CLOSEABLE))
	    {
	      send_to_char ("You can't do that.\n\r", ch);
	      return;
	    }
	  SET_BIT (cnt->flags, CONT_CLOSED);
          act ("You close $p$R.", ch, obj, NULL, TO_CHAR);
          act ("$n closes $p$R.", ch, obj, NULL, TO_ROOM);
	  return;
	}
    }
  if (door == -1)
    act ("I see no $T here.", ch, NULL, arg, TO_CHAR);
  return;
}

void
update_weight_num (CHAR_DATA * ch)
{
  SINGLE_OBJECT *obj;
  if (IS_MOB (ch))
    return;
  if (!ch)
    return;
  ch->pcdata->carry_weight = 0;
  ch->pcdata->carry_number = 0;
  ch->pcdata->command_objs = 0;
  for (obj = ch->carrying; obj != NULL; obj = obj->next_content)
    {
      ch->pcdata->carry_weight += get_obj_weight (obj);
      ch->pcdata->carry_number += get_obj_number (obj);
      if (IS_OBJ_STAT(obj, ITEM_COMMANDSCRIPT))
	ch->pcdata->command_objs++;
      
    }
  return;
}

bool
has_key (CHAR_DATA * ch, int key)
{
  SINGLE_OBJECT *obj;
  if (get_obj_index (key) == NULL || !ch)
    return FALSE;
  for (obj = ch->carrying; obj != NULL; obj = obj->next_content)
    if (obj->pIndexData->vnum == key)
      return TRUE;
  if (IS_PLAYER (ch) && IS_SET (ch->act, PLR_HOLYWALK))
    return TRUE;
  return FALSE;
}

void
do_lock (CHAR_DATA * ch, char *argy)
{
  char arg[SML_LENGTH];
  SINGLE_OBJECT *obj;
  int door;
  DEFINE_COMMAND ("lock", do_lock, POSITION_RESTING, 0, LOG_NORMAL, "Allows you to lock a door or object.")

    one_argy (argy, arg);
  if (arg[0] == '\0')
    {
      send_to_char ("Lock what?\n\r", ch);
      return;
    }
  if ((obj = get_obj_here (ch, arg, SEARCH_INV_FIRST)) != NULL)
    {
      if (obj->pIndexData->item_type != ITEM_CONTAINER)
	{
	  send_to_char ("That's not a container.\n\r", ch);
	  return;
	}
      else
	{
	  I_CONTAINER *cnt = (I_CONTAINER *) obj->more;
	  if (!IS_SET (cnt->flags, CONT_CLOSED))
	    {
	      send_to_char ("It's not closed.\n\r", ch);
	      return;
	    }
	  if (cnt->key_vnum <= 0)
	    {
	      send_to_char ("It can't be locked.\n\r", ch);
	      return;
	    }
	  if (!has_key (ch, cnt->key_vnum))
	    {
	      send_to_char ("You don't have the key.\n\r", ch);
	      return;
	    }
	  if (IS_SET (cnt->flags, CONT_LOCKED))
	    {
	      send_to_char ("It's already locked.\n\r", ch);
	      return;
	    }
	  SET_BIT (cnt->flags, CONT_LOCKED);
	  send_to_char ("*Click*\n\r", ch);
	  act ("$n locks $p.", ch, obj, NULL, TO_ROOM);
	  return;
	}
    }
  if ((door = find_door (ch, arg)) >= 0)
    {
      ROOM_DATA *to_room;
      EXIT_DATA *pexit;
      EXIT_DATA *pexit_rev;
      pexit = ch->in_room->exit[door];
      if (pexit->d_info)
	{
	  if (!IS_SET (pexit->d_info->exit_info, EX_CLOSED))
	    {
	      send_to_char ("It's not closed.\n\r", ch);
	      return;
	    }
	  if (pexit->d_info->key < 0)
	    {
	      send_to_char ("It can't be locked.\n\r", ch);
	      return;
	    }
	  if (!has_key (ch, pexit->d_info->key))
	    {
	      send_to_char ("You don't have the key.\n\r", ch);
	      return;
	    }
	  if (IS_SET (pexit->d_info->exit_info, EX_LOCKED))
	    {
	      send_to_char ("It's already locked.\n\r", ch);
	      return;
	    }
	  SET_BIT (pexit->d_info->exit_info, EX_LOCKED);
	  send_to_char ("*Click*\n\r", ch);
	  act ("$n locks the $T.", ch, NULL, pexit->d_info->keyword, TO_ROOM);
	  if ((to_room = pexit->to_room) != NULL
	      && (pexit_rev = to_room->exit[rev_dir[door]]) != 0
	      && pexit_rev->to_room == ch->in_room && pexit_rev->d_info)
	    {
	      CHAR_DATA *rch;
	      SET_BIT (pexit_rev->d_info->exit_info, EX_LOCKED);
		for (rch = to_room->people; rch != NULL; rch = rch->next_in_room)
		  act ("*Click* The $T is locked from the other side.", rch, NULL, pexit_rev->d_info->keyword, TO_CHAR);
	    }
	}
    }
  return;
}

void
do_unlock (CHAR_DATA * ch, char *argy)
{
  char arg[SML_LENGTH];
  SINGLE_OBJECT *obj;
  int door;
  DEFINE_COMMAND ("unlock", do_unlock, POSITION_RESTING, 0, LOG_NORMAL, "Allows you to unlock a door or object.")

    one_argy (argy, arg);
  if (arg[0] == '\0')
    {
      send_to_char ("Unlock what?\n\r", ch);
      return;
    }
  if ((obj = get_obj_here (ch, arg, SEARCH_INV_FIRST)) != NULL)
    {
      if (obj->pIndexData->item_type != ITEM_CONTAINER)
	{
	  send_to_char ("That's not a container.\n\r", ch);
	  return;
	}
      else
	{
	  I_CONTAINER *cnt = (I_CONTAINER *) obj->more;
	  if (!IS_SET (cnt->flags, CONT_CLOSED))
	    {
	      send_to_char ("It's not closed.\n\r", ch);
	      return;
	    }
	  if (cnt->key_vnum <= 0)
	    {
	      send_to_char ("It can't be unlocked.\n\r", ch);
	      return;
	    }
	  if (!has_key (ch, cnt->key_vnum))
	    {
	      send_to_char ("You don't have the key.\n\r", ch);
	      return;
	    }
	  if (!IS_SET (cnt->flags, CONT_LOCKED))
	    {
	      send_to_char ("It's already unlocked.\n\r", ch);
	      return;
	    }
	  REMOVE_BIT (cnt->flags, CONT_LOCKED);
	  act ("$n unlocks $p.", ch, obj, NULL, TO_ROOM);
	  act ("You unlock $p.", ch, obj, NULL, TO_CHAR);
	  return;
	}
    }
  if ((door = find_door (ch, arg)) >= 0)
    {
      ROOM_DATA *to_room;
      EXIT_DATA *pexit;
      EXIT_DATA *pexit_rev;
      pexit = ch->in_room->exit[door];
      if (pexit->d_info)
	{
	  if (!IS_SET (pexit->d_info->exit_info, EX_CLOSED))
	    {
	      send_to_char ("It's not closed.\n\r", ch);
	      return;
	    }
	  if (pexit->d_info->key < 1)
	    {
	      send_to_char ("It can't be unlocked.\n\r", ch);
	      return;
	    }
	  if (!has_key (ch, pexit->d_info->key))
	    {
	      send_to_char ("You don't have the key.\n\r", ch);
	      return;
	    }
	  if (!IS_SET (pexit->d_info->exit_info, EX_LOCKED))
	    {
	      send_to_char ("It's already unlocked.\n\r", ch);
	      return;
	    }
	  REMOVE_BIT (pexit->d_info->exit_info, EX_LOCKED);
	  if (IS_SET (pexit->d_info->exit_info, EX_EAT_KEY))
	    {
	      SINGLE_OBJECT *key;
	      for (key = ch->carrying; key; key = key->next_content)
		{
		  if (key->pIndexData->vnum == pexit->d_info->key)
		    {
		      obj_from (key);
		      free_it (key);
		      break;
		    }
		}
	      send_to_char ("It just ate your key!\n\r", ch);
	    }
	  act ("You unlock the $T.", ch, NULL, pexit->d_info->keyword, TO_CHAR);
	  act ("$n unlocks the $T.", ch, NULL, pexit->d_info->keyword, TO_ROOM);
	  if ((to_room = pexit->to_room) != NULL
	      && (pexit_rev = to_room->exit[rev_dir[door]]) != NULL
	      && pexit_rev->to_room == ch->in_room && pexit_rev->d_info)
	    {
	      REMOVE_BIT (pexit_rev->d_info->exit_info, EX_LOCKED);
	    }
	}
    }
  if (door == -1)
    act ("I see no $T here.", ch, NULL, arg, TO_CHAR);
  return;
}

void
do_pick (CHAR_DATA * ch, char *argy)
{
  SINGLE_OBJECT *lockpicks;
  char arg[SML_LENGTH];
  CHAR_DATA *gch;
  SINGLE_OBJECT *obj;
  int door;
  DEFINE_COMMAND ("pick", do_pick, POSITION_STANDING, 0, LOG_NORMAL, "Attempts to pick a door or object's lock.  Based on Pick skill.")
    if (IS_MOB(ch))
      return;
    one_argy (argy, arg);
  if (arg[0] == '\0')
    {
      send_to_char ("Pick what?\n\r", ch);
      return;
    }
  WAIT_STATE (ch, 28);
  lockpicks = get_item_held(ch, ITEM_TOOL);
  if (lockpicks == NULL || ((I_TOOL *) lockpicks->more)->tool_type != TOOL_LOCKPICK)
    {
      send_to_char("You must be using LOCKPICKS to pick a lock!\n\r", ch);
      return;
    }
  for (gch = ch->in_room->people; gch; gch = gch->next_in_room)
    {
      if (IS_MOB (gch) && IS_AWAKE (gch) && IS_SET (gch->act, ACT_SENTINEL))
	{
	  act ("$N is standing too close to the lock; you can't pick that door now!",
	       ch, NULL, gch, TO_CHAR);
	  return;
	}
    }
  if (!use_tool(lockpicks, TOOL_LOCKPICK))
    {
      send_to_char("Your lockpicks seem to have broken!\n\r", ch);
    }
  if (!check_skill(ch, gsn_pick_lock))
    {
      send_to_char ("You failed.\n\r", ch);
      return;
    }
  if ((door = find_door (ch, arg)) >= 0)
    {
      ROOM_DATA *to_room;
      EXIT_DATA *pexit;
      EXIT_DATA *pexit_rev;
      pexit = ch->in_room->exit[door];
      if (pexit->d_info)
	{
	  if (!IS_SET (pexit->d_info->exit_info, EX_CLOSED))
	    {
	      send_to_char ("It's not closed.\n\r", ch);
	      return;
	    }
	  if (pexit->d_info->key < 0 && !is_member(ch, GUILD_THIEF))
	    {
	      send_to_char ("It can't be picked.\n\r", ch);
	      return;
	    }
	  if (!IS_SET (pexit->d_info->exit_info, EX_LOCKED))
	    {
	      send_to_char ("It's already unlocked.\n\r", ch);
	      return;
	    }
	  if (IS_SET (pexit->d_info->exit_info, EX_PICKPROOF))
	    {
	      send_to_char ("You failed.\n\r", ch);
	      return;
	    }
	  REMOVE_BIT (pexit->d_info->exit_info, EX_LOCKED);
	  act ("You pick the $T.", ch, NULL, pexit->d_info->keyword, TO_CHAR);
	  act ("$n picks the $T.", ch, NULL, pexit->d_info->keyword, TO_ROOM);
	  if ((to_room = pexit->to_room) != NULL
	      && (pexit_rev = to_room->exit[rev_dir[door]]) != NULL
	      && pexit_rev->to_room == ch->in_room && pexit_rev->d_info)
	    {
	      REMOVE_BIT (pexit_rev->d_info->exit_info, EX_LOCKED);
	    }
	}
    }
  if ((obj = get_obj_here (ch, arg, SEARCH_INV_FIRST)) != NULL)
    {
      if (obj->pIndexData->item_type != ITEM_CONTAINER)
	{
	  send_to_char ("That's not a container.\n\r", ch);
	  return;
	}
      else
	{
	  I_CONTAINER *cnt = (I_CONTAINER *) obj->more;
	  if (!IS_SET (cnt->flags, CONT_CLOSED))
	    {
	      send_to_char ("It's not closed.\n\r", ch);
	      return;
	    }
	  if (cnt->key_vnum <= 0)
	    {
	      send_to_char ("It can't be unlocked.\n\r", ch);
	      return;
	    }
	  if (!IS_SET (cnt->flags, CONT_LOCKED))
	    {
	      send_to_char ("It's already unlocked.\n\r", ch);
	      return;
	    }
	  if (IS_SET (cnt->flags, CONT_PICKPROOF))
	    {
	      send_to_char ("You failed.\n\r", ch);
	      return;
	    }
	  REMOVE_BIT (cnt->flags, CONT_LOCKED);
	  act ("You pick $p.", ch, obj, NULL, TO_CHAR);
	  act ("$n picks $p.", ch, obj, NULL, TO_ROOM);
	  return;
	}
    }
  if (door == -1)
    act ("I see no $T here.", ch, NULL, arg, TO_CHAR);
  return;
}

void
do_stand (CHAR_DATA * ch, char *argy)
{
  AFFECT_DATA *paf;
  DEFINE_COMMAND ("stand", do_stand, POSITION_SLEEPING, 0, LOG_NORMAL, "Makes you stand up, from sleeping, resting, etc...")

    if (RIDING (ch) != NULL)
    {
      send_to_char ("If you wanted to stand on your own two feet you would not be riding!\n\r", ch);
      return;
    }
  if (ch->fgt && ch->fgt->ears > 9)
    {
      send_to_char ("You are bashed, and can't stand yet...\n\r", ch);
      return;
    }
  switch (ch->position)
    {
    case POSITION_SLEEPING:
      if (IS_HURT (ch, SLEEP) && ch->move < ch->max_move && (LEVEL (ch) < IMM_LEVEL || IS_MOB (ch)))
	{
	  send_to_char ("You can't wake up! Get back to full stamina!\n\r", ch);
	  return;
	}
      send_to_char ("You wake and stand up.\n\r", ch);
      act ("$n wakes and stands up.", ch, NULL, NULL, TO_ROOM);
      NEW_POSITION(ch, POSITION_STANDING);
      break;
    case POSITION_BASHED:
      check_fgt (ch);
      act ("You quickly stand, trying to avoid getting hit!", ch, NULL, NULL, TO_CHAR);
      act ("$n quickly stands, trying not to get hit in the process!", ch, NULL, NULL, TO_ROOM);
      if (FIGHTING (ch) == NULL)
	NEW_POSITION(ch, POSITION_STANDING);
      else
	NEW_POSITION(ch, POSITION_FIGHTING);
      ch->wait = 0;
      ch->fgt->combat_delay_count = -5;
      break;
    case POSITION_GROUNDFIGHTING:
      if ((number_range (1, (pow.groundfight_stand + ((ch->fgt->ground_pos == FP_CHOKE_1 || ch->fgt->ground_pos == FP_CHOKE_2 || ch->fgt->ground_pos == FP_CHOKE_3) ? 3: 0))) != 1))
	{
	  send_to_char ("You try to stand, but your opponent won't let you!\n\r", ch);
	  WAIT_STATE (ch, PULSE_VIOLENCE);
	  return;
	}
      else
	{
	  send_to_char ("\x1b[1;32mYou manage to wiggle free and stand up!\x1b[0;37m\n\r", ch);
	  act ("$B$3<-> $2$n manages to wiggle free and stand up! $3<->", ch, NULL, NULL, TO_ROOM);
	  NEW_POSITION(ch, POSITION_FIGHTING);
	  if (FIGHTING (ch) != NULL)
	    NEW_POSITION(FIGHTING (ch), POSITION_FIGHTING);
	}
      break;
    case POSITION_RESTING:
      send_to_char ("You stand up.\n\r", ch);
      act ("$n stands up.", ch, NULL, NULL, TO_ROOM);
      if (!IS_AFF (ch, FLYING))
	{
	  if (ch->in_room && ((!IS_SET(ch->in_room->room_flags,ROOM_INDOORS) && !IS_SET(ch->in_room->room_flags, ROOM_UNDERGROUND)) || ch->height<= INDOOR_FLY_HEIGHT) && IS_SET (ch->pcdata->nat_aff[AFF], FLYING))
	    {
	      if (IS_AFF (ch, SNEAK) && (is_member (ch, GUILD_THIEF) < 3))
		{
		  send_to_char ("You stop sneaking.\n\r", ch);
		  affect_strip (ch, gsn_sneak);
		} 
	      SET_BIT (ch->aff[AFF], FLYING);
	      send_to_char ("You begin to fly again!\n\r", ch);
	      act ("$n floats gently up in the air.", ch, NULL, NULL, TO_ROOM);
	    }
	  if (ch->in_room && ((!IS_SET(ch->in_room->room_flags,ROOM_INDOORS) && !IS_SET(ch->in_room->room_flags, ROOM_UNDERGROUND)) || ch->height<= INDOOR_FLY_HEIGHT)) { 
	    for (paf = ch->affected; paf != NULL; paf = paf->next)
	      {
		if (!IS_SET(paf->aff[AFF], FLYING))
		  continue;
		else if (paf->duration > 0)
		  {
		    if (IS_AFF (ch, SNEAK) && (is_member (ch, GUILD_THIEF) < 3))
		      {
			send_to_char ("You stop sneaking.\n\r", ch);
			affect_strip (ch, gsn_sneak);
		      } 
		    SET_BIT (ch->aff[AFF], FLYING);
		    send_to_char ("You begin to fly again!\n\r", ch);
		    act ("$n floats gently up in the air.", ch, NULL, NULL, TO_ROOM);
		  }
	      }
	  }
	}
      NEW_POSITION(ch, POSITION_STANDING);
      break;
    case POSITION_STANDING:
      send_to_char ("You are already standing.\n\r", ch);
      break;
    case POSITION_MEDITATING:
      send_to_char ("You stand up, and stop meditating.\n\r", ch);
      act ("$n stands up and stops meditating.", ch, NULL, NULL, TO_ROOM);
      NEW_POSITION(ch, POSITION_STANDING);
      break;
    case POSITION_FIGHTING:
      send_to_char ("You are already fighting!\n\r", ch);
      break;
    case POSITION_FALLING:
      send_to_char ("You can't! You're falling!\n\r", ch);
      break;
    }
  return;
}

void
do_rest (CHAR_DATA * ch, char *argy)
{
  DEFINE_COMMAND ("rest", do_rest, POSITION_RESTING, 0, LOG_NORMAL, "Rest makes your character sit and rest.")

    if (RIDING (ch) != NULL)
    {
      send_to_char ("You can't rest while you are riding! Dismount first.\n\r", ch);
      return;
    }
  if (IS_AFF (ch, FLYING))
    {
      do_land (ch, "");
    }

  switch (ch->position)
    {
    case POSITION_FALLING:
      send_to_char ("You are falling downward.\n\r", ch);
      break;
    case POSITION_SLEEPING:
      send_to_char ("You are already sleeping.\n\r", ch);
      break;
    case POSITION_RESTING:
      send_to_char ("You are already resting.\n\r", ch);
      break;
    case POSITION_MEDITATING:
      send_to_char ("You stop meditating and begin to rest.\n\r", ch);
      act ("$n stops meditating and rests.", ch, NULL, NULL, TO_ROOM);
      NEW_POSITION(ch, POSITION_RESTING);
      break;
    case POSITION_STANDING:
      send_to_char ("You rest.\n\r", ch);
      act ("$n rests.", ch, NULL, NULL, TO_ROOM);
      NEW_POSITION(ch, POSITION_RESTING);
      break;
    case POSITION_FIGHTING:
      send_to_char ("You are already fighting!\n\r", ch);
      break;
    }
  return;
}
void
do_sleep (CHAR_DATA * ch, char *argy)
{
  DEFINE_COMMAND ("sleep", do_sleep, POSITION_SLEEPING, 0, LOG_NORMAL, "Sleep allows you to sleep and recover moves and hps.")

  if (RIDING (ch) != NULL)
    {
      send_to_char ("It might be hazardous while riding. Dismount first.\n\r", ch);
      return;
    }
  if (IS_AFF (ch, FLYING))
    {
      do_land (ch, "");
    }
  if (FIGHTING (ch) && FIGHTING (ch) != NULL)
    {
      send_to_char ("But you're in the middle of combat.. it wouldn't be to your benefit!\n\r", ch);
      return;
    }
  if (pow.weather && IS_PLAYER (ch) && ch->in_room &&
      (ch->in_room->sector_type !=SECT_INSIDE))
    {
      if (cur_temp(ch) + ch->pcdata->warmth < 45)
	{
	  send_to_char ("You try to lie down to sleep, but you are just too cold! brrr...\n\r", ch);
	  return;
	}
    }
  switch (ch->position)
    {
    case POSITION_FALLING:
      send_to_char ("You are falling downward.\n\r", ch);
      break;
    case POSITION_SLEEPING:
      send_to_char ("You are already sleeping.\n\r", ch);
      break;
    case POSITION_MEDITATING:
      send_to_char ("You stop meditating and go to sleep.\n\r", ch);
      act ("$n stops meditating and falls asleep.", ch, NULL, NULL, TO_ROOM);
      NEW_POSITION(ch, POSITION_SLEEPING);
      break;
    case POSITION_RESTING:
    case POSITION_STANDING:
      send_to_char ("You sleep.\n\r", ch);
      act ("$n sleeps.", ch, NULL, NULL, TO_ROOM);
      NEW_POSITION(ch, POSITION_SLEEPING);
      break;
    case POSITION_FIGHTING:
      send_to_char ("You are fighting!\n\r", ch);
      break;
    }
  return;
}



void
do_wake (CHAR_DATA * ch, char *argy)
{
  char arg[SML_LENGTH];
  CHAR_DATA *victim;
  DEFINE_COMMAND ("wake", do_wake, POSITION_SLEEPING, 0, LOG_NORMAL, "This command allows you to wake up from sleep.")

    one_argy (argy, arg);
  if (arg[0] == '\0')
    {
      do_stand (ch, argy);
      return;
    }
  if (!IS_AWAKE (ch))
    {
      send_to_char ("You are asleep yourself!\n\r", ch);
      return;
    }
  if ((victim = get_char_room (ch, arg)) == NULL)
    {
      send_to_char ("They aren't here.\n\r", ch);
      return;
    }
  if (IS_AWAKE (victim))
    {
      act ("$N is already awake.", ch, NULL, victim, TO_CHAR);
      return;
    }
  if (IS_HURT (victim, SLEEP) && victim->move < victim->max_move && (LEVEL (victim) < IMM_LEVEL || IS_MOB (victim)))
    {
      act ("You can't wake $M!", ch, NULL, victim, TO_CHAR);
      return;
    }
  if (victim->hit < 1)
    {
      send_to_char ("That character is way too injured!\n\r", ch);
      return;
    }
  NEW_POSITION(victim, POSITION_STANDING);
  act ("You wake $M.", ch, NULL, victim, TO_CHAR);
  act ("$n wakes you.", ch, NULL, victim, TO_VICT);
  return;
}
void
do_sneak (CHAR_DATA * ch, char *argy)
{
  AFFECT_DATA af;
  bool sneakal;
  DEFINE_COMMAND ("sneak", do_sneak, POSITION_STANDING, 0, LOG_NORMAL, "Allows you to sneak.")
    bzero (&af, sizeof (af));
  sneakal = TRUE;
  if (RIDING (ch) != NULL)
    {
      send_to_char ("It's tough to sneak while riding, and won't do any good.\n\r", ch);
      return;
    }
  if (!IS_AFF (ch, SNEAK))
    sneakal = FALSE;
  if (IS_AFF (ch, FLYING))
      {
	if(is_member (ch, GUILD_THIEF) > 2)
	  {
	    send_to_char("Entering whisper flight mode...\n\r", ch);
	  }
	else
	  {
	    send_to_char ("You're too obvious, being in the air.\n\r", ch);
	    return;
	  }
      }
  send_to_char ("You attempt to move silently.\n\r", ch);
  affect_strip (ch, gsn_sneak);
  if (IS_MOB (ch) || number_percent () < ch->pcdata->learned[gsn_sneak] + ch->pcdata->plus_sneak)
    {
      af.type = gsn_sneak;
      af.duration = LEVEL (ch);
      af.location = APPLY_NONE;
      af.modifier = 0;
      af.aff[AFF] = SNEAK;
      affect_to_char (ch, &af);
    }
  return;
}

void
do_hide (CHAR_DATA * ch, char *argy)
{
  DEFINE_COMMAND ("hide", do_hide, POSITION_STANDING, 0, LOG_NORMAL, "Allows you to hide, based on skill.  People with the search skill can search for you, with some luck.")

    if (RIDING (ch) != NULL)
    {
      send_to_char ("Hide while riding! I don't think so...\n\r", ch);
      return;
    }
  if (ch->position != POSITION_STANDING && ch->position != POSITION_RESTING)
    {
      send_to_char ("You must be standing or resting to hide.\n\r", ch);
      return;
    }
  if (argy[0] == '\0')
    {
      send_to_char ("You attempt to hide.\n\r", ch);
      if (IS_AFF (ch, HIDE))
	REMOVE_BIT (ch->aff[AFF], HIDE);
      if (!IN_BATTLE (ch) && (IS_MOB (ch) ||
			      number_range (1, 104) <= ch->pcdata->learned[gsn_hide] + ch->pcdata->plus_hide))
	SET_BIT (ch->aff[AFF], HIDE);
      WAIT_STATE (ch, 5 * PULSE_VIOLENCE);
      return;
    }
  check_fgt (ch);
  do_drop (ch, argy);
  return;
}


void
do_visible (CHAR_DATA * ch, char *argy)
{
  DEFINE_COMMAND ("visible", do_visible, POSITION_SLEEPING, 0, LOG_NORMAL, "This command cancels all effects of invisibility, sneaking, etc...")

    
  affect_strip_bits (ch, AFF, (SNEAK*2-1));
  if (IS_PLAYER(ch)) ch->pcdata->wizinvis = 0;
  send_to_char ("Ok.\n\r", ch);
  return;
}



void
do_fly (CHAR_DATA * ch, char *argy)
{
  AFFECT_DATA *paf;
  DEFINE_COMMAND ("fly", do_fly, POSITION_DEAD, 0, LOG_NORMAL, "If you can, this makes you fly into the air.")
    if (ch->in_room && (IS_SET(ch->in_room->room_flags , ROOM_INDOORS) || IS_SET (ch->in_room->room_flags,ROOM_UNDERGROUND)) && (ch->height > INDOOR_FLY_HEIGHT)) 
      {
	send_to_char("You are indoors; you can't fly in here!\n\r",ch);
	return;
      }
  if (ch->position!=POSITION_STANDING) 
    {
       
      send_to_char("You must be in a standing position to begin flying.\n\r",ch);
      return;
    }
  if (IS_AFF (ch, FLYING))
    {
      send_to_char ("You're already flying!\n\r", ch);
      return;
    }
  if (IS_PLAYER (ch) && (IS_SET (ch->pcdata->nat_aff[AFF], FLYING)))
    {
      if (RIDING (ch) != NULL)
	{
	  send_to_char ("Not while you are riding!\n\r", ch);
	  return;
	}
      if (IS_AFF (ch, SNEAK))
	{ 
	  if(is_member(ch, GUILD_THIEF) > 2) 
	    {
	      send_to_char("Entering whisper flight mode...\n\r", ch);
	    }
	  else
	    {
	      send_to_char ("You cannot sneak while flying. You stop sneaking.\n\r", ch);
	      affect_strip (ch, gsn_sneak);
	    }
	}
      SET_BIT (ch->aff[AFF], FLYING);
      send_to_char ("You begin to fly again!\n\r", ch);
      act ("$n floats gently up in the air.", ch, NULL, NULL, TO_ROOM);
      return;
    }
  for (paf = ch->affected; paf != NULL; paf = paf->next)
    {
      if (!IS_SET(paf->aff[AFF], FLYING))
	continue;
      if (RIDING (ch) != NULL)
	{
	  send_to_char ("Not while you are riding!\n\r", ch);
	  return;
	}
      if (IS_AFF (ch, SNEAK))
	{
	  if(is_member(ch, GUILD_THIEF) > 2) 
	    {
	      send_to_char("Entering whisper flight mode...\n\r", ch);
	    }
	  else
	    {
	      send_to_char ("You cannot sneak while flying. You stop sneaking.\n\r", ch);
	      affect_strip (ch, gsn_sneak);
	    }
	}
      SET_BIT (ch->aff[AFF], FLYING);
      send_to_char ("You begin to fly again!\n\r", ch);
      act ("$n floats gently up in the air.", ch, NULL, NULL, TO_ROOM);
      return;
    }
  
  
  send_to_char ("You flap your arms, but never leave the ground.\n\r", ch);
  act ("$n flaps $s arms trying to fly, but can't.\n\r",
       ch, NULL, NULL, TO_ROOM);
  return;
}

void
do_land (CHAR_DATA * ch, char *argy)
{
  DEFINE_COMMAND ("land", do_land, POSITION_DEAD, 0, LOG_NORMAL, "Makes you land on the ground if you are flying.")

    if (!IS_AFF (ch, FLYING))
    {
      send_to_char ("But you're not flying!\n\r", ch);
      return;
    }
  send_to_char ("You gently float downward to the ground.\n\r", ch);
  REMOVE_BIT (ch->aff[AFF], FLYING);
  if (!ch->in_room) return;

  while (VALID_EDGE (ch->in_room, DIR_DOWN)
	 && ch->in_room->sector_type == SECT_AIR)
    {
      ROOM_DATA *to_room;
      to_room = ch->in_room->exit[DIR_DOWN]->to_room;
      act ("$n descends downward.", ch, NULL, NULL, TO_ROOM);
      char_from_room (ch);
      char_to_room (ch, to_room);
      do_look (ch, "auto");
      act ("$n descends from above.", ch, NULL, NULL, TO_ROOM);
    }
  return;
}


void
do_break (CHAR_DATA * ch, char *argy)
{
  char arg[SML_LENGTH];
  char extrabuf[SML_LENGTH];
  SINGLE_OBJECT *siege;
  int door;
  int value;
  CHAR_DATA *rch;
  int combined_strength;
  SINGLE_OBJECT *ram = NULL;
  DEFINE_COMMAND ("break", do_break, POSITION_STANDING, 0, LOG_NORMAL, "Break <direction> or Break <doorname> allows you to attempt to charge into a door, breaking it.  Based on strength.")

    one_argy (argy, arg);
  if (arg[0] == '\0')
    {
      send_to_char ("What do you want to break?\n\r", ch);
      return;
    }
  if (ch->position != POSITION_STANDING)
    {
      send_to_char ("You have to be standing to charge into something!\n\r", ch);
      return;
    }
  if ((siege = get_obj_here (ch, arg, SEARCH_ROOM_FIRST)) != NULL)
    {
      if (siege->pIndexData->item_type != ITEM_SIEGE)
	{
	  send_to_char ("That is not a siege engine!\n\r", ch);
	  return;
	}
      act("You work on smashing $p to pieces!", ch, siege, NULL, TO_CHAR);
      act ("$n works on smashing $p to pieces!", ch, siege, NULL, TO_ROOM);
      if (((I_SIEGE *)siege->more)->max_hps > 0)
	{
	  value = (((I_SIEGE *)siege->more)->hps * 5 )/((I_SIEGE *)siege->more)->max_hps;
	  switch (value)
	    {
	    case 5:
	    case 4:
	      act ("$p is barely scratched.", ch, siege, NULL, TO_CHAR);
	      act ("$p is barely scratched.", ch, siege, NULL, TO_ROOM);
	      break;
	    case 3:
	      act ("$p is starting to get some dents.", ch, siege, NULL, TO_CHAR);
	      act ("$p is starting to get some dents.", ch, siege, NULL, TO_ROOM);
	      break;
	    case 2:
	      act ("$p is dented and scarred.", ch, siege, NULL, TO_CHAR);
	      act ("$p is dented and scarred.", ch, siege, NULL, TO_ROOM);
	      break;
	    case 1:
	      act ("$p has pieces flying off with every blow.", ch, siege, NULL, TO_CHAR);
	      act ("$p has pieces flying off with every blow.", ch, siege, NULL, TO_ROOM);
	      break;
	    case 0:
	    default:
	      act ("$p has almost been reduced to a pile of trash.", ch, siege, NULL, TO_CHAR);
	      act ("$p has almost been reduced to a pile of trash.", ch, siege, NULL, TO_ROOM);
	      break;
	    }
	}
      WAIT_STATE (ch, PULSE_VIOLENCE);
      ((I_SIEGE *)siege->more)->hps -= (get_curr_str(ch) + number_range(1,10));
      if (((I_SIEGE *)siege->more)->hps < 0)
	{
	  SINGLE_OBJECT *crap;
	  act ("The $p has finally broken!", ch, siege, NULL, TO_CHAR);
	  act ("The $p has finally broken!", ch, siege, NULL, TO_ROOM);
	  obj_from(siege);
	  free_it (siege);
	  crap = create_object (get_obj_index(349), 1);
	  obj_to (crap, ch->in_room);
	  return;
	}
      
      return;
    }
  if ((door = find_door (ch, arg)) >= 0)
    {
      ROOM_DATA *to_room;
      EXIT_DATA *pexit;
      EXIT_DATA *pexit_rev;
      int dam, broke = 0;
      char buf[STD_LENGTH];
      pexit = ch->in_room->exit[door];
      if (pexit->d_info && !IS_SET (pexit->d_info->exit_info, EX_ISWALL))
	{
	  if (!IS_SET (pexit->d_info->exit_info, EX_CLOSED))
	    {
	      send_to_char ("It's already open.\n\r", ch);
	      return;
	    }
	  if (pexit->d_info->str < 0)
	    {
	      send_to_char ("It's already broken.\n\r", ch);
	      return;
	    }
	  
	  combined_strength = get_stat (ch, STR);;
	  if (ch->fgt && ch->fgt->pulling &&
	      ch->fgt->pulling->in_room == ch->in_room &&
	      ch->fgt->pulling->pIndexData->item_type == ITEM_SIEGE &&
	      ((I_SIEGE *)ch->fgt->pulling->more)->type == SIEGE_RAM)
	    {
	      ram = ch->fgt->pulling;
	      combined_strength = 0;
	      for (rch = ch->in_room->people; rch != NULL; rch = rch->next_in_room)
		{
		  if (rch->fgt && rch->fgt->pulling == ram)
		    combined_strength += get_stat (rch, STR);
		}
	      combined_strength += 10;
	    }
	  if (ram)
	    {
	      sprintf (extrabuf, " with %s", OOSTR (ram, short_descr));
	    }
	  else
	    extrabuf[0] = '\0';
	

	  if (door >= 0 && door <= 4)
	    {
	      act ("You charge towards the $T$t...", ch, extrabuf, pexit->d_info->keyword, TO_CHAR);
	      act ("$n charges towards the $T$t...", ch, extrabuf, pexit->d_info->keyword, TO_ROOM);
	    }
	  else if (door == 5)
	    {
	      act ("You stomp on the $T$t...", ch, extrabuf, pexit->d_info->keyword, TO_CHAR);
	      act ("$n stomps on the $T$t...", ch, extrabuf, pexit->d_info->keyword, TO_ROOM); 
	    }
	  else if (door == 6)
	    {
	      act ("You pound on the $T$t...", ch, extrabuf, pexit->d_info->keyword, TO_CHAR);
	      act ("$n pounds on the $T$t...", ch, extrabuf, pexit->d_info->keyword, TO_ROOM);
	    }

	  dam = combined_strength;
          if (IS_AUGMENTED(ch, AUG_ARM_ARMOR)) dam +=3;
          if (IS_AUGMENTED(ch, AUG_BODY_STR)) dam +=1;
          if (IS_AUGMENTED(ch, AUG_ARM_STR)) dam +=1;
          if (IS_AUGMENTED(ch, AUG_HAND_STR)) dam +=1;
	  if (IS_SET (pexit->d_info->exit_info, EX_BASHPROOF))
	    {
	      pexit->d_info->str = 100;
	      dam = 0;
	    }
	  if (dice (3, 6) < get_curr_str (ch) && dam > 0)
	    {
	      pexit->d_info->str -= number_range (1, get_curr_str (ch)/5);
	      if ((to_room = pexit->to_room) != NULL
		  && (pexit_rev = to_room->exit[rev_dir[door]]) != NULL
		  && pexit_rev->to_room == ch->in_room && pexit_rev->d_info)
		{
		  pexit_rev->d_info->str = pexit->d_info->str;
		}
	      if (pexit->d_info->str > 0)
		{
		  sprintf (buf, "SLAM! The $T %s",
			   door_cond (pexit->d_info->str));
		}
	      else
		sprintf (buf, "SLAM!");
	      act (buf, ch, NULL, pexit->d_info->keyword, TO_CHAR);
	      act (buf, ch, NULL, pexit->d_info->keyword, TO_ROOM);
	    }
	  else
	    {
	      send_to_char ("Slam! Ouch! That hurt!\n\r", ch);
	      sprintf (buf, "Slam! $n cringes in pain!");
	      act (buf, ch, NULL, NULL, TO_ROOM);
	      if (dam <= 0)
		dam = dice (1, pexit->d_info->str / 3);
	      if (dam >= ch->hit)
		ch->hit = 1;
	      else
		SUBHIT(ch, dam);
	    }
	  if (pexit->d_info->str < 0)
	    {
	      REMOVE_BIT (pexit->d_info->exit_info, EX_CLOSED | EX_ISDOOR);
	      act ("The $T is reduced to rubble!", ch, NULL, pexit->d_info->keyword, TO_ROOM);
	      act ("You reduced the $T to rubble!", ch, NULL, pexit->d_info->keyword, TO_CHAR);
	      broke = 1;
	    }
          if (pexit->d_info && pexit->d_info->trap)
            {
              set_off_trap(ch, NULL, door);
            }
	  WAIT_STATE(ch, 8);
	  if (pexit->d_info->str > 0)
	    return;
	  /* open the other side */
	  if ((to_room = pexit->to_room) != NULL
	      && (pexit_rev = to_room->exit[rev_dir[door]]) != NULL
	      && pexit_rev->to_room == ch->in_room && pexit_rev->d_info)
	    {
	      REMOVE_BIT (pexit_rev->d_info->exit_info, EX_CLOSED);
	      if (broke)
		REMOVE_BIT (pexit_rev->d_info->exit_info, EX_ISDOOR);
	    }
	}
      else
	{
	  send_to_char ("Which door was that?\n\r", ch);
	  return;
	}
    }
  send_to_char ("Break what?\n\r", ch);
  return;
}


char *
door_cond (int val)
{
  static char door_condit[100];
  if (val > 80)
    strcpy (door_condit, "looks the same as before.");
  else if (val > 70)
    strcpy (door_condit, "seems to be weakening a little.");
  else if (val > 55)
    strcpy (door_condit, "has a visible crack now.");
  else if (val > 39)
    strcpy (door_condit, "is concave from the impacts!");
  else if (val > 25)
    strcpy (door_condit, "won't stay standing much longer!");
  else if (val > 14)
    strcpy (door_condit, "looks like it could break any second!");
  else
    strcpy (door_condit, "What door?");
  return door_condit;
}