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

bool inventory = FALSE;
bool scan_now = FALSE;

char *
show_look_affects (CHAR_DATA * victim, CHAR_DATA * ch)
{
  static char buf[STD_LENGTH * 4];
  
  buf[0] = '\0'; 
  if (IS_PLAYER (ch) && (ch->pcdata->no_spam == 2 || ch->pcdata->no_spam == 1))
    {
      if (IS_HURT (victim, CHARM))
	strcat (buf, "\x1B[1;32m (charmed)");
      if (IS_AFF (victim, INVIS))
	strcat (buf, "\x1B[1;36m (\x1B[0;36mInvis\x1B[1;36m)");
      if (IS_AFF (victim, HIDE))
	strcat (buf, "\x1B[1;30m (Hidden)");
      if (IS_AFF (victim, SANCTUARY))
	strcat (buf, "\x1B[0;37m (\x1B[1;37mSanctuary\x1B[0;37m)");
      if (IS_AFF (victim, GAS))
	strcat (buf, "\x1B[0;32m (\x1b[1;32mGas\x1b[0;32m)");  
      if (IS_AFF (victim, WIND))
	strcat (buf, "\x1B[1;36m (\x1b[0;37mWind\x1b[1;36m)");   
      if (IS_AFF (victim, ACID))
	strcat (buf, "\x1B[1;32m (\x1b[1;30mAcid\x1b[1;32m)");   
      if (IS_AFF (victim, CHAOS))
	strcat (buf, "\x1B[1;35m (\x1b[0;35mChaos\x1b[1;35m)"); 
      if (IS_AFF (victim, SHARDS))
	strcat (buf, "\x1B[1;37m (\x1b[0;37mShards\x1b[1;37m)"); 
      if (IS_AFF (victim, SHOCK))
	strcat (buf, "\x1B[0;33m (\x1b[1;33mShock\x1b[0;33m)"); 
      if (IS_AFF (victim, ICE))
	strcat (buf, "\x1B[1;37m (\x1b[1;36mIce\x1b[1;37m)");   
      if (IS_AFF (victim, FIRE))
        strcat (buf, "\x1B[0;31m (\x1b[1;31mFire\x1b[0;31m)");     
      if (IS_HURT (victim, BURNING))
        strcat (buf, "\x1b[0;31m (B\x1b[1mu\x1b[33mr\x1b[37mn\x1b[33mi\x1b[31mn\x1b[0;31mg)");
      if (IS_HURT (victim, OUTLINE))
	strcat (buf, "\x1B[1;35m (Outlined)");
      if (IS_AFF (victim, FLYING))
	strcat (buf, "\x1B[0;1;35m (Flying)");
    }
  else
    {
      if (IS_HURT (victim, CHARM))
	{
	
	  strcat (buf, "\n\r\x1B[1;32m...$N is a servant/trained.");
	}
      if (IS_AFF (victim, INVIS) && IS_AFF (victim, HIDE))
	{
	  strcat (buf, "\n\r\x1B[1;30m...$N\x1B[1;30m is \x1B[0;36minvisible\x1B[1;30m and hidden.");
	}
      else
	{
	  if (IS_AFF (victim, INVIS))
	    {
	      strcat (buf, "\n\r\x1B[1;36m...$N\x1B[1;36m is \x1B[0;36minvisible\x1B[1;36m.");    
	    }
	  if (IS_AFF (victim, HIDE))
	    {
	      strcat (buf, "\n\r\x1B[1;30m...$N\x1B[1;30m is hidden.");
	    }
	}
      if (IS_AFF (victim, SANCTUARY))
	{
	  strcat (buf, "\n\r\x1B[0m...$N\x1B[0m is protected by a \x1B[1mbright\x1B[0m aura!");  
	}
      if (IS_AFF (victim, PROTECT))
	{
	  strcat (buf, "\n\r\x1B[0m...$N\x1B[0m is protected by a \x1B[0;34mdeep \x1B[1mblue\x1B[0m aura!"); 
	}
      if (IS_AFF (victim, GAS))
	{
	  strcat (buf, "\n\r\x1B[0;32m...$N\x1B[0;32m is protected by a cloud of noxious \x1b[1mGas\x1b[0;32m!");   
	}
      if (IS_AFF (victim, WIND))
	{
	  strcat (buf, "\n\r\x1B[0m...$N\x1B[0m is inside a swirling torrent of \x1b[1mwind\x1b[0m!");   
	}
      if (IS_AFF (victim, ACID))
	{
	  strcat (buf, "\n\r\x1B[0;32m...$N\x1B[0;32m is contained in a shroud of \x1B[1mAcid\x1B[0;32m!");  
	}
      if (IS_AFF (victim, CHAOS))
	{
	  strcat (buf, "\n\r\x1B[1;35m...$N\x1B[1;35m is surrounded by \x1B[1;36mrandom \x1b[0;35mChaos\x1b[1m!");     
	}
      if (IS_AFF (victim, SHARDS))
	{
	  strcat (buf, "\n\r\x1B[1;37m...$N\x1B[1;37m is behind a wall of \x1b[0mShards\x1b[1m!");     
	}
      if (IS_AFF (victim, SHOCK))
	{
	  strcat (buf, "\n\r\x1B[0;33m...$N\x1B[0;33m sparks with electric \x1b[1mpower\x1b[0;33m!"); 
	}
      if (IS_AFF (victim, ICE))
	{
	  strcat (buf, "\n\r\x1B[1;37m...$N\x1B[1;37m is encased in a torrent of \x1b[1;36mIce\x1b[1;37m!");   
	}
      if (IS_AFF (victim, FIRE))
	{
          strcat (buf, "\n\r\x1B[0;31m...$N is engulfed in a shield of \x1b[1;31mFlames\x1b[0;31m!");     
	}
      if (IS_AFF (victim, OUTLINE))
	{
	  strcat (buf, "\n\r\x1B[1;35m...$N\x1B[1;35's body is outlined for easy targeting!");     
	}
      if (IS_HURT (victim, BURNING))
	{
          strcat (buf, "\n\r\x1B[0;31m...$N\x1B[0;31m's flesh is blistering from burning f\x1B[1ml\x1B[1;33mam\x1B[1;31me\x1B[0;31ms!");
        }
      if (IS_AFF (victim, FLYING))
	{
          strcat (buf, "\n\r\x1B[1;35m...$N\x1B[1;35m is flying around here.");
	}
    }
  strcat (buf, "\x1b[0;37m");
  return buf;
}

void
do_where (CHAR_DATA * ch, char *argy)
{
  char buf[STD_LENGTH];
  char arg[SML_LENGTH];
  CHAR_DATA *victim;
  DESCRIPTOR_DATA *d;
  bool found;
  DEFINE_COMMAND ("where", do_where, POSITION_RESTING, 0, LOG_NORMAL, "This command shows you characters nearby, and what area you are in.")


  one_argy (argy, arg);
    if (!pow.allow_where)
    {
      send_to_char ("Huh?\n\r", ch);
      return;
    }  if (IS_MOB (ch))
    return;
  sprintf (buf, "You are in \x1B[1m%s\x1B[0m, built by:\x1B[1;31m %s\x1b[0;37m\n\r",
           ch->in_room->area->name, ch->in_room->area->builders);
  send_to_char (buf, ch);
  
  send_to_char ("Players near you:\n\r", ch);
  found = FALSE;
  for (d = descriptor_list; d; d = d->next)
    {
      if ((victim = d->character) != NULL
          && IS_PLAYER (victim)
          && victim->in_room != NULL
          && can_see (ch, victim) &&
          (!DIFF_ALIGN(ch, victim) || LEVEL(ch) > 100 || 
	   IS_HURT(victim, BEACON)))
        {
          if (LEVEL (ch) >= 100)
            {
              sprintf (buf, "%-28s %s [%d]\n\r", NAME (victim), 
		       victim->in_room->name, victim->in_room->vnum);
            }
          else if (d->connected == CON_PLAYING)
            {
              if (victim->in_room && (victim->in_room->area == ch->in_room->area) &&
                  victim != ch && (IS_HURT(victim, BEACON) || !DIFF_ALIGN(ch, victim)))
                {
                  found = TRUE;
                  sprintf (buf, "%-28s %s\n\r", NAME (victim), victim->in_room->name);
                }
              else
                buf[0] = '\0';
            }
	  send_to_char (buf, ch);
        }
    }
  if (!found)
    send_to_char ("No one else can be found.\n\r", ch);
  
  return;
}

/*
   Scan_direction scans up to three rooms away, or until a mob is found
   in the direction passed.
   */
void
scan_direction (CHAR_DATA * ch, int dir)
{
  EXIT_DATA *pexit;
  ROOM_DATA *troom;
  CHAR_DATA *mob;
  char final[STD_LENGTH];
  char buf[STD_LENGTH];
  bool fMultiple;
  int n = 0, max_iteration;
  hugebuf_o[0] = '\0';
  final[0] = '\0';
  max_iteration = 3;
  pexit = ch->in_room->exit[dir];
  if (pexit == NULL || (ROOM_DATA *) pexit->to_room == NULL)
    return;
  troom = (ROOM_DATA *) pexit->to_room;

  if (troom != NULL && (!pexit->d_info || (!IS_SET (pexit->d_info->exit_info, EX_CLOSED))) && room_is_dark (troom) && !IS_DET (ch, DARK))
    {
      if (troom->people &&
	  (IS_PLAYER (troom->people) ||
	   !IS_SET (troom->people->pIndexData->act3, ACT3_MIMIC)))
        {
          sprintf (buf, "You can make out some motion to the %s.\n\r", dir_name[URANGE (0, dir, MAX_DIR - 1)]);
          send_to_char (buf, ch);
        }
      return;
    }
  while ((pexit != NULL) && (n < max_iteration) &&
         ((ROOM_DATA *) pexit->to_room != NULL) && (!pexit->d_info || (!IS_SET (pexit->d_info->exit_info, EX_CLOSED)
                                         && pexit->d_info->exit_info != 1)))
    {
      fMultiple = FALSE;
      troom = (ROOM_DATA *) pexit->to_room;
      if (troom != NULL && troom->people != NULL)
        {
          int cnnt;
          cnnt = 0;
          for (mob = troom->people; mob != NULL; mob = mob->next_in_room)
            {
              if (!can_see_nextdoor (ch, mob) || !can_see (ch, mob) ||
		  (IS_MOB (mob) && IS_SET (mob->pIndexData->act3, ACT3_MIMIC)))
                continue;
              cnnt++;
              if (cnnt > 1 && mob->next_in_room == NULL && ((
                                            mob != troom->people) || (
                                                                             troom->people->next_in_room != NULL && mob != troom->people->next_in_room)))
                {
                  fMultiple = TRUE;
                  sprintf (buf, " and %s", rNAME (mob, ch));
                }
              else if (mob->next_in_room != NULL && can_see_nextdoor (ch, mob)
                       && mob->next_in_room->next_in_room != NULL)
                sprintf (buf, "%s, ", rNAME (mob, ch));
              else
                sprintf (buf, "%s", rNAME (mob, ch));
              strcat (final, buf);
            }
          if (cnnt > 0)
            {
              sprintf (buf, " %s %s \x1B[1;37m%s\x1B[0m from here.\n\r", fMultiple ? "are" : "is",
                       dist_name[URANGE (0, n, 7)],
                       dir_name[URANGE (0, dir, MAX_DIR - 1)]);
              strcat (final, buf);
            }
          if (final[0] != '\0')
            {
              final[0] = UPPER (final[0]);
              strcpy (hugebuf_o, final);
              send_to_char (hugebuf_o, ch);
            }
          final[0] = '\0';
          return;
        }
      pexit = troom->exit[dir];
      n++;
    }
  return;
}

void
show_list_to_char (SINGLE_OBJECT * list, CHAR_DATA * ch, bool fShort, bool fShowNothing)
{
  char buf[STD_LENGTH];
  char prgpstrShow[200][250];
  int prgnShow[200];
  char pstrShow[250];
  SINGLE_OBJECT *obj;
  int nShow;
  int iShow;
  int count;
  bool fCombine;
  count = 0;
  bzero (&prgpstrShow, sizeof (prgpstrShow));
  bzero (&prgnShow, sizeof (prgnShow));
  bzero (&pstrShow, sizeof (pstrShow));
  
  if (list == NULL)
    return;
  nShow = 0;
  for (obj = list; obj && obj != NULL; obj = obj->next_content)
    {
      if (obj->wear_loc == WEAR_NONE && can_see_obj (ch, obj)
          && ((!IS_SET (obj->extra_flags, ITEM_UNSEEN) &&
               !IS_SET (obj->pIndexData->extra_flags, ITEM_UNSEEN))
              || IS_SET (ch->act, PLR_HOLYLIGHT)))
        {

          strcpy (pstrShow, format_obj_to (obj, ch, fShort));
          fCombine = FALSE;
          if (IS_MOB (ch) || IS_SET (ch->pcdata->act2, PLR_COMBINE))
            {
              for (iShow = nShow - 1; iShow >= 0; iShow--)
                {
                  if (!strcmp (prgpstrShow[iShow], pstrShow))
                    {
                      prgnShow[iShow]++;
                      fCombine = TRUE;
                      break;
                    }
                }
            }
          if (!fCombine)
            {
              strcpy (prgpstrShow[nShow], pstrShow);
              prgnShow[nShow] = 1;
              nShow++;
              if (nShow >= 200)
                {
                  fprintf (stderr, "Error.  nShow>=200.  Ch: %s.\n", NAME (ch));
                  return;
                }
            }
        }
    }
  for (iShow = 0; iShow < nShow; iShow++)
    {
      if (IS_MOB (ch) || IS_SET (ch->pcdata->act2, PLR_COMBINE))
        {
          if (prgnShow[iShow] != 1)
            {
              sprintf (buf, "[x%d] ", prgnShow[iShow]);
              send_to_char (buf, ch);
            }
        }
      send_to_char (prgpstrShow[iShow], ch);
      if (fShort)
        send_to_char ("\x1B[0m", ch);
    }
  if (fShowNothing && nShow == 0)
    {
      if (IS_MOB (ch) || IS_SET (ch->pcdata->act2, PLR_COMBINE))
        send_to_char ("Nothing.\n\r", ch);
    }
  return;
}


void show_char_to_char (CHAR_DATA * list, CHAR_DATA * ch)
{

  CHAR_DATA *rch;   
  for (rch = list; rch != NULL; rch = rch->next_in_room)
    {
      if (IS_MOB (rch) && IS_SET (rch->pIndexData->act3, ACT3_MIMIC) &&
	  rch->position == POSITION_STANDING)
	{
	  if (IS_SET (ch->act, PLR_HOLYLIGHT))
	    send_to_char ("\x1b[1;31m->MIMIC<-\x1b[0;37m", ch);
	  send_to_char (LD (rch), ch);
	  send_to_char ("\n\r", ch);
	}
    }
  for (rch = list; rch != NULL; rch = rch->next_in_room)
    {
      if (rch == ch || 
	  (IS_PLAYER (ch) &&  IS_MOB (rch) && 
	   ((!IS_SET (ch->act, PLR_HOLYLIGHT) && 
	    IS_SET (rch->pIndexData->act3, ACT3_WALL)) ||
	    IS_SET (rch->pIndexData->act3, ACT3_MIMIC))))
	  continue;
      show_char_to_char_0 (rch, ch);
    }
  return;
}

void
show_char_to_char_0 (CHAR_DATA * victim, CHAR_DATA * ch)
{
  char buf[STD_LENGTH];
  char to_show[STD_LENGTH * 3];
  bool no_affects = FALSE;
  buf[0] = '\0';
  to_show[0]='\0';
  buf[0]='\0';
  if (!can_see (ch, victim) || victim == ch)
    return;
  
  
  sprintf (buf, "\x1b[1;3%dm", (IS_MOB (victim) ? 6 : 5));
  
  
  if (IS_PLAYER (victim))
    {
      if (victim->desc == NULL)
	strcat (buf, "\x1B[1;34m>LINKLESS< \x1B[1;35m");
    }
  else
    {
      if (IS_SET (victim->pIndexData->act3, ACT3_WALL))
	strcat (buf, "\x1b[1;32m->Wall<-\x1b[1;36m ");
    }
  
  to_show[0] = '\0';
  if (victim->position == POSITION_FIGHTING ||
      victim->position == POSITION_GROUNDFIGHTING ||
      victim->position == POSITION_BASHED)
    no_affects = TRUE;
  
  if (MOUNTED_BY (victim) == ch)
    sprintf (buf + strlen (buf), "%s%s is here being ridden by you.", (IS_MOB (victim) ? "\x1b[1;36m" : "\x1b[1;35m"), rNAME (victim, ch));
  else if (MOUNTED_BY (victim))
    {
      strcat (buf, rNAME (victim, ch));
      strcat (buf, (IS_MOB (victim) ? "\x1b[1;36m" : "\x1b[1;35m"));
      strcat (buf, " is here being ridden by ");
      strcat (buf, rNAME (MOUNTED_BY (victim), ch));
      strcat (buf, (IS_MOB (MOUNTED_BY(victim)) ? "\x1b[1;36m" : "\x1b[1;35m"));
      strcat (buf, ".");
    }
  else if (RIDING (victim) == ch)
    sprintf (buf + strlen (buf), "%s%s is riding you.", (IS_MOB (victim) ? "\x1b[1;36m" : "\x1b[1;35m"),rNAME (victim, ch));
  else if (RIDING (victim))
    {
      strcat (buf, rNAME (victim, ch));
      strcat (buf, (IS_MOB (victim) ? "\x1b[1;36m" : "\x1b[1;35m"));
      strcat (buf, " is here riding ");
      strcat (buf, (IS_MOB (RIDING(victim)) ? "\x1b[1;36m" : "\x1b[1;35m"));
      strcat (buf, rNAME (RIDING (victim), ch));
      strcat (buf, ".");
    }
  else if (victim->position == POSITION_STANDING && LD (victim) &&
	   IS_MOB (victim) && LD (victim)[0] != '\0')
    strcat (buf, LD (victim));
  else
    {
      strcat (buf, PERS (victim, ch)); 
      strcat (buf, (IS_MOB (victim) ? "\x1b[1;36m" : "\x1b[1;35m"));
      buf[0] = UPPER (buf[0]);
      strcat (buf, " is");
      switch (victim->position)
	{
	case POSITION_STANDING:
	  if (victim->fgt && 
	      victim->fgt->pulling)
	    sprintf (buf + strlen (buf), 
		     " here hitched up to %s\x1b[0;37m.", 
		     OOSTR (victim->fgt->pulling, short_descr));
	  else
	    strcat (buf, " here.");
	  break;
	case POSITION_RESTING:
	  strcat (buf, " resting here.");
	  break;
	case POSITION_FIGHTING:
	  strcat (buf, " here, fighting ");
	  if (FIGHTING (victim) == NULL)
	    strcat (buf, "thin air??");
	  else if (FIGHTING (victim) == ch)
	    strcat (buf, "YOU!");
	  else
	    {
	      strcat (buf, rNAME (FIGHTING (victim), ch));
	      strcat (buf, ".");
	    }
	  break;
	case POSITION_GROUNDFIGHTING:
	  strcat (buf, " fighting on the ground with ");
	  if (FIGHTING (victim) == NULL)
	    strcat (buf, "thin air??");
	  else if (FIGHTING (victim) == ch)
	    strcat (buf, "YOU!");
	  else if (FIGHTING (victim))
	    {
	      strcat (buf, rNAME (FIGHTING (victim), ch));
	      strcat (buf, ".");
	    }
	  break;
	case POSITION_BASHED:
	  strcat (buf, " on the ground, bashed.");
	  break;
	case POSITION_SLEEPING:
	  strcat (buf, " asleep here.");
	  break;
	case POSITION_MEDITATING:
	  strcat (buf, " meditating here.");
	  break;
	case POSITION_SEARCHING:
	  strcat (buf, " searching for something here.");
	  break;
	case POSITION_CASTING:
	  strcat(buf, " casting a spell.");
	  break;
	case POSITION_FALLING:
	  strcat (buf, " falling to the ground.");
	  break;
	case POSITION_FIRING:
	  strcat (buf, " firing a siege engine.");
	  break;
	case POSITION_SHOOTING:
	  strcat (buf, " aiming at someone.");
	  break;
	case POSITION_MINING:
	  strcat (buf, " mining for minerals.");
	  break;
	case POSITION_DEAD:
	  strcat (buf, " DEAD!!");
	  break;
	case POSITION_MORTAL:
	  strcat (buf, " mortally wounded.");
	  break;
	case POSITION_INCAP:
	  strcat (buf, " incapacitated.");
	  break;
	case POSITION_STUNNED:
	  strcat (buf, " lying here, stunned.");
	  break;
	}
    }
  strcpy (to_show, buf);
  if (!no_affects)
    {
      strcat (to_show, show_look_affects (victim, ch));
    }
  act (to_show, ch, NULL, victim, TO_CHAR);
  return;
}







void
show_char_to_char_1 (CHAR_DATA * victim, CHAR_DATA * ch)
{
  char buf[STD_LENGTH];
  SINGLE_OBJECT *obj;
  int loc;
  int percent, percent2;
  bool found;
  bool equiped;
  

  if (IS_MOB (victim) && IS_SET (victim->pIndexData->act3, ACT3_MIMIC) &&
      victim->position == POSITION_STANDING)
    {
      send_to_char ("(This object is in the room)\n\r", ch);
      if (DSC(victim) && DSC (victim)[0] != '\0' && !FIGHTING(ch))
	{
	  send_to_char (DSC (victim), ch);
	  send_to_char ("\x1b[0;37m", ch);
	}
      else
	{
	  act ("You don't see anything special about $N.", ch, NULL, victim, TO_CHAR);
	}
      return;
    }
  
  
  if (IS_PLAYER (ch) && IS_PLAYER (victim))
    {
      send_to_char (victim->pcdata->name, ch);
      if (LEVEL (victim) < 10)
        send_to_char (" is an inexperienced member of the \x1B[1m", ch);
      else if (LEVEL (victim) < 25)
        send_to_char (" is a member of the \x1B[1m", ch);
      else if (LEVEL (victim) < 45)
        send_to_char (" is well respected amongst the \x1B[1m", ch);
      else if (LEVEL (victim) < 70)
        send_to_char (" is a hero amongst the \x1B[1m", ch);
      else if (LEVEL (victim) < 100)
        send_to_char (" is a legend amongst the \x1B[1m", ch);
      else
        send_to_char (" is a god who belongs to the \x1B[1m", ch);
      send_to_char (race_info[victim->pcdata->race].name, ch);
      send_to_char ("\x1B[0m race.\n\r", ch);
    }
  if (victim == ch)
    {
      sprintf (buf, "You are %d\' %d\" tall.", ch->height / 12, ch->height % 12);
    }
  else
    {
      sprintf (buf, "$E is");
      if (ch->height > victim->height)
        strcat (buf, " shorter than you.");
      else if (ch->height < victim->height)
        strcat (buf, " taller than you.");
      else
        strcat (buf, " the same height as you.");
    }
  act (buf, ch, NULL, victim, TO_CHAR);
  if (DSC(victim) && DSC (victim)[0] != '\0' && !FIGHTING(ch))
    {
      send_to_char (DSC (victim), ch);
      send_to_char ("\x1b[0;37m", ch);
    }
  else
    {
      act ("You don't see anything special about $M.", ch, NULL, victim, TO_CHAR);
    }
  if (victim->max_hit > 0)
    percent = (100 * victim->hit) / victim->max_hit;
  else
    percent = 0;
  if (victim->max_move > 0)
    percent2 = (100 * victim->move) / victim->max_move;
  else
    percent2 = 0;
  send_to_char ("\n\r", ch);
  if (percent > 100)
    percent = 100;
  if (percent2 > 100)
    percent2 = 100;
  if (percent2 < 1) percent2=1;
  strcpy (buf, PERS (victim, ch));
  if (percent > 0)
    sprintf (buf, " %s %s and looks %s.\n\r\n\r", capitalize (PERS (victim, ch)),
             percent_ded[percent/10],
             percent_tired[percent2 / 10]);
  else
    sprintf (buf, " %s is mortally wounded.\n\r\n\r",
             capitalize (PERS (victim, ch)));
  send_to_char (buf, ch);
  found = FALSE; equiped = FALSE;
  
  for (obj = victim->carrying; obj != NULL && obj->wear_loc != WEAR_NONE; obj = obj->next_content)
    {
      loc = 2;
      if (can_see_obj(ch, obj))
	{
          equiped = TRUE;
	  if (worn_flags[obj->wear_loc].flagname == ITEM_WIELD)
	    {
	      if (obj->wear_num % 2 == 0)
		sprintf(buf, "<primary hand>       %s\x1b[0;37m", format_obj_to (obj, ch, TRUE));
	      else           
		sprintf(buf, "<secondary hand>     %s\x1b[0;37m", format_obj_to (obj, ch, TRUE));
	    }
	  else
	    sprintf(buf, "%s%s\x1b[0;37m", worn_flags[obj->wear_loc].wear_name, format_obj_to (obj, ch, TRUE));
	  send_to_char(buf, ch); 
	}
    }

  if (victim != ch
      && (IS_IMMORTAL (ch) || check_skill(ch, gsn_peek)))
    {
      if (equiped) send_to_char("\n\r", ch);
      send_to_char ("You peek at the inventory:\n\r", ch);
      if (tally_coins (victim) > 0)
        {
          char tttt[200];
	  int i;
	  for (i = MAX_COINS-1; i >= 0; i--)
	    {
	      if (victim->coins[i] > 0)
		{
		  sprintf(tttt, "%d %s %s.\n\r", victim->coins[i], coin_color[i], (victim->coins[i] > 1 ? "coins" : "coin"));
		  send_to_char(tttt, ch);
		}
	    }
	}
      show_list_to_char (victim->carrying, ch, TRUE, FALSE);
    }
  return;
}

bool
check_blind (CHAR_DATA * ch)
{
  if (IS_PLAYER (ch) && IS_SET (ch->act, PLR_HOLYLIGHT))
    return TRUE;
  if (IS_HURT (ch, BLIND))
    {
      send_to_char ("\x1B[33mYou can't see a thing!\x1B[0m\n\r", ch);
      return FALSE;
    }
  return TRUE;
}

void
do_glance (CHAR_DATA * ch, char *argy)
{
  char buf[STD_LENGTH];
  CHAR_DATA *victim;
  int percent, percent2;
  DEFINE_COMMAND ("glance", do_glance, POSITION_RESTING, 0, LOG_NORMAL, "This command allows you to glance at the condition of a player or mob.")

    if (ch->position < POSITION_SLEEPING)
    {
      send_to_char ("\x1B[1mYou can't see anything but stars!\x1B[0m\n\r", ch);
      return;
    }
  if (ch->position == POSITION_SLEEPING)
    {
      send_to_char ("\x1B[1;30mYou can't see anything, you're sleeping!\x1B[0m\n\r", ch);
      return;
    }
  if (!check_blind (ch))
    return;
  if (IS_PLAYER (ch)
      && !IS_SET (ch->act, PLR_HOLYLIGHT)
      && (room_is_dark (ch->in_room) && !IS_DET (ch, DARK)))
    {
      send_to_char ("\x1B[1;30mIt is pitch black ... \x1B[0m\n\r", ch);
      if (ch->in_room) show_char_to_char (ch->in_room->people, ch);
      return;
    }
  if ((victim = get_char_room (ch, argy)) != NULL)
    {
      if (victim->max_hit > 0)
        percent = (100 * victim->hit) / victim->max_hit;
      else
        percent = -1;
      if (victim->max_move > 0)
        percent2 = (100 * victim->move) / victim->max_move;
      else
        percent2 = 0;
      if (percent > 100)
        percent = 100;
      if (percent2 > 100)
        percent2 = 100;
      if (percent2 < 1) percent2=1;
      strcpy (buf, PERS (victim, ch));
      if (percent > 0)
        sprintf (buf, "%s %s and looks %s.\n\r", capitalize (PERS (victim, ch)),
                 percent_ded[percent / 10],
                 percent_tired[percent2 / 10]);
      else
        sprintf (buf, " %s is \x1B[34mmortally wounded\x1B[0m.\n\r",
                 capitalize (PERS (victim, ch)));
      send_to_char (buf, ch);
    }
  return;
}


void
do_scan (CHAR_DATA * ch, char *argy)
{
  int i;
  DEFINE_COMMAND ("scan", do_scan, POSITION_RESTING, 0, LOG_NEVER, "This command allows you to scan your surroundings and find players/creatures that are nearby.")
    
    if (IS_PLAYER(ch) && !str_cmp(argy, "refresh") && 
	!IS_HURT(ch,BLIND) && IS_DET(ch, DARK) && 
	IS_SET(ch->pcdata->act2, PLR_MAPPING))
      {
	char buf[SML_LENGTH];
	sprintf(buf, "\x1b[%d;%dr", MAP_HEIGHT, ch->pcdata->pagelen);
	send_to_char(buf, ch);
	ch->pcdata->x = MAP_WIDTH/2;
	ch->pcdata->y = MAP_HEIGHT/2;
	small_map(ch);
	sprintf(buf, "\x1B[%d;1f", ch->pcdata->pagelen);
	send_to_char(buf, ch); 
	WAIT_STATE(ch, PULSE_VIOLENCE);
	return;
      }
  
  scan_now = TRUE;
  send_to_char ("You scan all four directions around you:\n\r\n\r", ch);
  for (i = 0; i < MAX_DIR; i++)
    {
      do_look (ch, dir_letter[i]);
    }
  scan_now = FALSE;
  return;
}



int
GET_DAMROLL (CHAR_DATA * ch)
{
  return (ch->damroll + add_damroll (ch) + str_app[get_curr_str(ch)].dam);
}

int
GET_HITROLL (CHAR_DATA * ch)
{
  return (ch->hitroll + add_hitroll (ch) + (get_curr_dex(ch)*3/2));
}

int
add_damroll (CHAR_DATA * ch)
{ 
  return 0;
    return 0;
  if (ch->in_room->sector_type >= SECT_CAVE || IS_SET(ch->in_room->room_flags, ROOM_UNDERGROUND))
    return 4;
  if (IS_SET (ch->in_room->room_flags, ROOM_INDOORS))
    return 2;
  if (weather_info.sunlight > SUN_DARK)
    {
      if (weather_info.sky > SKY_CLOUDLESS)
        return -2;
      else
        return -7;
    }
  return 4;
}

int
add_hitroll (CHAR_DATA * ch)
{
    return 0;
  if (ch->in_room->sector_type >= SECT_CAVE || IS_SET(ch->in_room->room_flags, ROOM_UNDERGROUND))
    return 8;
  if (IS_SET (ch->in_room->room_flags, ROOM_INDOORS))
    return 4;
  if (weather_info.sunlight > SUN_DARK)
    {
      if (weather_info.sky > SKY_CLOUDLESS)
        return -5;
      else
        return -13;
    }
  return 8;
}



void
do_look (CHAR_DATA * ch, char *argy)
{
  char buf[STD_LENGTH];
  char arg1[SML_LENGTH];
  char arg2[SML_LENGTH];
  char buff[SML_LENGTH];
  EXIT_DATA *pexit;
  CHAR_DATA *victim;
  SINGLE_OBJECT *obj;
  char *pdesc;
  int door = MAX_DIR;
  int i;
  int count, number;
  DEFINE_COMMAND ("look", do_look, POSITION_RESTING, 0, LOG_NORMAL, "This command enables you to look at your surroundings, at or in an object, or in a direction.")
/*Handles message boards if the character likes READ instead of NOTE */
    if (!ch->in_room) 
      {
        fprintf(stderr,"%s null room: look.\n",NAME(ch));
        return;
      }
  if (argy != '\0' && is_number (argy))
    {
      char buffie[25];
      sprintf (buffie, "read %d", atoi (argy));
      do_note (ch, buffie);
      return;
    }
  if (IS_PLAYER (ch) && (!str_cmp (argy, "at board") || !str_cmp (argy, "board")))
    {
      do_note (ch, "list");
      return;
    }
  
  buf[0] = '\0';
  if (ch->position < POSITION_SLEEPING)
    {
      send_to_char ("\x1B[1mYou can't see anything but stars!\x1B[0m\n\r", ch);
      return;
    }
  if (ch->position == POSITION_SLEEPING)
    {
      send_to_char ("\x1B[1;30mYou can't see anything, you're sleeping!\x1B[0m\n\r", ch);
      return;
    }
  if (!check_blind (ch))
    return;
  if (weather_info.sky == SKY_FOGGY
      && number_bits (2) != 0
      && IS_OUTSIDE (ch)
      && !IS_SET (ch->act, PLR_HOLYLIGHT) && !IS_DET(ch, FOGGY))
    {
      send_to_char ("It's hard to see through this fog.\n\r", ch);
      return;
    }
  argy = one_argy (argy, arg1);

  if (str_cmp (arg1, "in") && str_cmp (arg1, "i") && str_cmp (arg1, "inside"))
    while (str_cmp (arg1, "in") && argy != "" && argy[0] != '\0')
      argy = one_argy (argy, arg1);

  argy = one_argy (argy, arg2);
  while (argy != "" && argy[0] != '\0')
    argy = one_argy (argy, arg2);
  
  for (i = 0; i < MAX_DIR; i++)
    {
      if (!str_cmp (arg1, dir_name[i]) ||
	  !str_cmp (arg1, dir_letter[i]))
	{
	  door = i;
	  break;
	}
    }
  if (door == MAX_DIR)
    {
      if (IS_PLAYER (ch)
	  && !IS_SET (ch->act, PLR_HOLYLIGHT)
	  && room_is_dark (ch->in_room) && !IS_DET (ch, DARK))
	{
	  send_to_char ("\x1B[1;30mIt is pitch black ... \x1B[0m\n\r", ch);
	  return;
	}
      
      
      if (arg1[0] == '\0' || !str_cmp (arg1, "auto"))
	{
	      sprintf(buff, "\x1b[1;37m%s \x1b[1;34m[%s%s\x1b[1;34m/", show_room_name (ch, ch->in_room->name), sectors[ch->in_room->sector_type].color, sectors[ch->in_room->sector_type].name_seen);
	      if (ch->in_room->sector_type >= SECT_CAVE||IS_SET(ch->in_room->room_flags, ROOM_UNDERGROUND))
		strcat (buff, "\x1b[1;30mUnderground\x1b[34m]\x1b[0;37m");
	      else  if (IS_SET (ch->in_room->room_flags, ROOM_INDOORS))
		strcat (buff, "\x1b[1;30mIndoors\x1b[34m]\x1b[0;37m");
	      else if (weather_info.sunlight > SUN_DARK)
		{
		  if (weather_info.sky > SKY_CLOUDLESS)
		    {
		      switch (weather_info.sky)
			{
			case SKY_RAINING:
			  strcat (buff, "Raining]\x1b[0;37m");
			  break;
			case SKY_FOGGY:
			  strcat (buff, "\x1b[0;36mFoggy\x1b[34m]\x1b[0;37m");
			  break;
			case SKY_LIGHTNING:
			  strcat (buff, "\x1b[33mLightning\x1b[34m]\x1b[0;37m");
			  break;
			case SKY_CLOUDY:
			  strcat (buff, "\x1b[0;37mOvercast\x1b[34m]\x1b[0;37m");
			  break;
			}
		    }
		  else if (IS_SET(ch->in_room->room_flags, ROOM_SHADED))
		    strcat (buff, "\x1b[30mShaded\x1b[34m]\x1b[0;37m");
		  else
		    {
		      switch (weather_info.sunlight)
			{
			case SUN_RISE:
			  strcat (buff, "\x1b[31mSunrise\x1b[34m]\x1b[0;37m");
			  break;
			case SUN_MORNING:
			  strcat (buff, "\x1b[33mMorning\x1b[34m]\x1b[0;37m");
			  break;
			case SUN_MIDDAY:
			  strcat (buff, "\x1b[33mMidday\x1b[34m]\x1b[0;37m");
			  break;
			case SUN_AFTERNOON:
			  strcat (buff, "\x1b[33mAfternoon\x1b[34m]\x1b[0;37m");
			  break;
			case SUN_EVENING:
			  strcat (buff, "\x1b[33mEvening\x1b[34m]\x1b[0;37m");
			  break;
			case SUN_SET:
			  strcat (buff, "\x1b[31mSunset\x1b[34m]\x1b[0;37m");
			  break;
			}
		    }
		}
	      else 
		{
		  if (weather_info.sky == SKY_LIGHTNING)
		    strcat(buff, "\x1b[33mLightning\x1b[34m/\x1b[30mNight\x1b[34m]\x1b[0;37m");
		  else if (weather_info.sky == SKY_RAINING)
		    strcat (buff, "Raining/\x1b[30mNight\x1b[34m]\x1b[0;37m");
		  else
		    strcat (buff, "\x1b[30mNight\x1b[34m]\x1b[0;37m");
		}
	      strcat (buff, "\n\r");
	      send_to_char (buff, ch);

	  if (arg1[0] == '\0' || (IS_PLAYER (ch) &&
				  !IS_SET (ch->pcdata->act2, PLR_BRIEF)))
	    {
              send_to_char (ch->in_room->description, ch);
	    }
	  if (IS_PLAYER (ch) && IS_SET (ch->pcdata->act2, PLR_AUTOEXIT))
	    {
	      do_exits (ch, "auto");
	    }
	  if(ch->in_room->blood > 0)
	    { 
	      int i;
	      char bufg[1000];
	      char buff[100];
	      sprintf(bufg, "\x1b[0;31m");
	      for (i = 0; i < 6; i++)
		{
		  if (IS_SET(ch->in_room->blood, blood_number[i]))
		    {
		      sprintf(buff, "There is a trail of blood leading \x1b[1;31m%s\x1b[0;31m.\n\r", dir_name[i]);
		      strcat(bufg, buff);
		    }
		}
	      strcat(bufg, "\x1b[0;37m");
	      send_to_char(bufg, ch);
	    }
	  
	  {
	    int i;
	    int coin_types = 0;
	    int coin_used = 0;
	    char bufff[300];
	    for (i = 0; i < MAX_COINS; i++)
	      {
		if (ch->in_room->coins[i] > 0)
		  coin_types++;
	      }
	    if (coin_types > 0)
	      {
		if (coin_types == 1)
		  {
		    for (i = 0; i < MAX_COINS; i++)
		      if (ch->in_room->coins[i] > 0)
			break;
		    sprintf(bufff, "There %s %d %s %s here.\n\r", (ch->in_room->coins[i] > 1 ? "are" : "is"), ch->in_room->coins[i], coin_color[i], (ch->in_room->coins[i] > 1 ? "coins" : "coin"));
		    send_to_char(bufff, ch);
		  }
		else
		  {
		    sprintf(buff, "There ");
		    for (i = 0; i < MAX_COINS; i++)
		      {
			if (ch->in_room->coins[i] > 0)
			  {
			    if (ch->in_room->coins[i] > 1)
			      strcat(buff, "are ");
			    else
			      strcat(buff, "is ");
			    break;
			  }
		      }
		    for (i = 0; i < MAX_COINS; i++)
		      {
			if (ch->in_room->coins[i] > 0)
			  {
			    coin_used++;
			    if (coin_used < coin_types)
			      {
				sprintf(bufff, "%d %s %s, ", ch->in_room->coins[i], coin_color[i], (ch->in_room->coins[i] > 1 ? "coins" : "coin"));
				strcat(buff, bufff);
			      }
			    else
			      {
				sprintf(bufff, "and %d %s %s here.\n\r", ch->in_room->coins[i], coin_color[i], (ch->in_room->coins[i] > 1 ? "coins" : "coin"));
				strcat(buff, bufff);
			      }
			  }
		      }
		    send_to_char (buff, ch);
		  }
	      }
	  }
	  if (ch->in_room->contents)
	    {
	      send_to_char("\x1b[0;36m", ch);
	    }
	  show_list_to_char (ch->in_room->contents, ch, FALSE, FALSE);
	  show_char_to_char (ch->in_room->people, ch);
	  if (arg1[0]=='\0' || (ch->in_room &&
				(ch->in_room->contents || ch->in_room->people != ch ||
				 ch->in_room->people->next_in_room))) {
	    send_to_char ("\x1B[37;0m", ch);
	  }
	  return;
	}
      if (!str_cmp (arg1, "i") || !str_cmp (arg1, "in") || !str_cmp (arg1, "inside"))
	{
	  /* 'look in' */
	  if (arg2[0] == '\0')
	    {
	      send_to_char ("Look in what?\n\r", ch);
	      return;
	    }
	  if ((obj = get_obj_here (ch, arg2, SEARCH_INV_FIRST)) == NULL)
	    {
	      send_to_char ("You do not see that here.\n\r", ch);
	      return;
	    }
          switch (obj->pIndexData->item_type)
	    {
	    default:
	      send_to_char ("That is not a container.\n\r", ch);
	      break;
	    case ITEM_LIGHT:
	      {
		I_LIGHT *light = (I_LIGHT *) obj->more;
		if (obj->carried_by && obj->wear_loc == WEAR_NONE)
		  send_to_char ("(In Inventory) ", ch);
		if (obj->carried_by && obj->wear_loc != WEAR_NONE)
		  send_to_char ("(Equipped) ", ch);
		if (!obj->carried_by)
		  send_to_char ("(On the Ground) ", ch);
		if (light->max_light != 0)
		  {
		    int percent = PERCENTAGE (light->light_now, light->max_light);
		    if (light->light_now <= 0)
		      {
			send_to_char ("It is empty.\n\r", ch);
			break;
		      }
		    else
		      {
			sprintf (buf, "It's %s of fuel.\n\r",
				 percent < 10 ? "almost empty" :
				 percent < 40 ? "less than half full" :
				 percent < 60 ? "half full" :
				 percent < 90 ? "more than half" : "full");
			send_to_char (buf, ch);
		      }
		  }
		else
		  send_to_char ("It contains nothing.\n\r", ch);
		break;
	      }
	    case ITEM_DRINK_CON:
	      {
		I_DRINK *dr = (I_DRINK *) obj->more;
		if (obj->carried_by && obj->wear_loc == WEAR_NONE)
		  send_to_char ("(In Inventory) ", ch);
		if (obj->carried_by && obj->wear_loc != WEAR_NONE)
		  send_to_char ("(Equipped) ", ch);
		if (!obj->carried_by)
		  send_to_char ("(On the Ground) ", ch);
		if (dr->liquid_now <= 0)
		  {
		    send_to_char ("It is empty.\n\r", ch);
		    break;
		  }
		else
		  {
		    int percent = PERCENTAGE (dr->liquid_now, dr->max_liquid);
		    if (dr->liquid_type == -1)
		      {
			if (obj->carried_by && obj->wear_loc == WEAR_NONE)
			  send_to_char ("(In Inventory) ", ch);
			if (obj->carried_by && obj->wear_loc != WEAR_NONE)
			  send_to_char ("(Equipped) ", ch);
			if (!obj->carried_by)
			  send_to_char ("(On the Ground) ", ch);
			sprintf (buf, "It's %s of lamp oil.\n\r",
				 percent < 10 ? "almost empty" :
				 percent < 40 ? "less than half full" :
				 percent < 60 ? "half full" :
				 percent < 70 ? "more than half full" :
				 "full");
		      }
		    else
		      {
			if (obj->carried_by && obj->wear_loc == WEAR_NONE)
			  send_to_char ("(In Inventory) ", ch);
			if (obj->carried_by && obj->wear_loc != WEAR_NONE)
			  send_to_char ("(Equipped) ", ch);
			if (!obj->carried_by)
			  send_to_char ("(On the Ground) ", ch);
			sprintf (buf, "It's %s of a %s liquid.\n\r",
				 percent < 10 ? "almost empty" :
				 percent < 40 ? "less than half full" :
				 percent < 60 ? "half full" :
				 percent < 70 ? "more than half full" :
				 "full",
				 (dr->liquid_type > 12 ? "ERROR!!" : liq_table[dr->liquid_type].liq_color));
                  }
		    send_to_char (buf, ch);
		  }
		break;
	      }
	    case ITEM_CONTAINER:
	    case ITEM_CORPSE_NPC:
	    case ITEM_CORPSE_PC:
	      {
		I_CONTAINER *con = (I_CONTAINER *) obj->more;
		if (obj->carried_by && obj->wear_loc == WEAR_NONE)
		  send_to_char ("(In Inventory) ", ch);
		if (obj->carried_by && obj->wear_loc != WEAR_NONE)
		  send_to_char ("(Equipped) ", ch);
		if (!obj->carried_by)
		  send_to_char ("(On the Ground) ", ch);
		if (IS_SET (con->flags, CONT_CLOSED))
		  {
		    send_to_char ("It is closed.\n\r", ch);
		    break;
		  }
                if (LEVEL (ch) > (MAX_LEVEL - 1) && (obj->pIndexData->item_type == ITEM_CORPSE_PC || obj->pIndexData->item_type == ITEM_CORPSE_NPC))
		  {
		    print_reasons (ch, obj);
		  }
		act ("$p\x1B[0m contains:", ch, obj, NULL, TO_CHAR);
		if (con->money > 0)
		  {
		    char ttu[500];
		    sprintf (ttu, "%s coins.\n\r", name_amount (con->money));
		    send_to_char (ttu, ch);
		  }
		show_list_to_char (obj->contains, ch, TRUE, TRUE);
		break;
	      }
	    }
	  return;
	}
      if ((victim = get_char_room (ch, arg1)) == NULL)
	{
	  CHAR_DATA *rch;
	  for (rch = ch->in_room->people; rch != NULL; rch = rch->next_in_room)
	    {
	      if (IS_PLAYER (rch) || 
		  !IS_SET (rch->pIndexData->act3, ACT3_MIMIC)
		  || !can_see (ch, rch))
		continue;
	      if (is_name (arg1, RNAME (rch)))
		{
		  victim = rch;
		  break;
		}
	    }
	}
      if (victim)
	{
	  show_char_to_char_1 (victim, ch);
	  if (IS_MOB (victim) && (FIGHTING (victim) == NULL) &&
	      IS_SET (victim->act, ACT_ATTITUDE) && can_see (victim, ch) &&
	      IS_AWAKE (victim))
	    {
	      do_say (victim, "How dare you look at me! You will die!");
	      multi_hit (victim, ch, TYPE_UNDEFINED);
	    }
	  return;
	}
      count = number_argy (arg1, arg2);
      number = 0;
      for (obj = ch->carrying; obj && obj != NULL; obj = obj->next_content)
	{
	  if (can_see_obj (ch, obj))
	    {
	      if (is_name (arg2, obj->pIndexData->name))
		{
		  if (++number != count)
		    continue;
		  send_to_char ("(This object is in your inventory)\n\r", ch);
		  pdesc=obj->pIndexData->description;
		  if (pdesc && pdesc[0] != '\0')
		    {		      
		      page_to_char (wordwrap(pdesc,79), ch);
		    }
		  else
		      act ("You see nothing special about $p.", ch, obj, ch, TO_CHAR);
		  return;
		}
	    }
	}
      for (obj = ch->carrying; obj && obj != NULL; obj = obj->next_content)
	{
	  if (can_see_obj (ch, obj))
	    {
	      if (is_approx_name (arg2, obj->pIndexData->name))
		{
		  if (++number != count)
		    continue;
		  send_to_char ("(This object is in your inventory)\n\r", ch);
		  pdesc=obj->pIndexData->description;
		  if (pdesc && pdesc[0] != '\0')
		    {  
		      page_to_char (wordwrap(pdesc,79), ch);
		    }
		  else
		    act ("You see nothing special about $p.", ch, obj, ch, TO_CHAR);

		  return;
		}
	    }
	}
      number = 0;
      for (obj = ch->in_room->contents; obj && obj != NULL; obj = obj->next_content)
	{
	  if (can_see_obj (ch, obj) && !(IS_SET(obj->extra_flags,
						ITEM_UNSEEN) && !IS_SET(ch->act, PLR_HOLYLIGHT)))
	    {
	      if (is_name (arg2, obj->pIndexData->name))
		{
		  if (++number != count)
		    continue;
		  send_to_char ("(This object is in the room)\n\r", ch);
		  pdesc=obj->pIndexData->description;
		  if (pdesc && pdesc[0] != '\0')
		    {  
		      page_to_char (wordwrap(pdesc,79), ch);
		    }		  
		  else
		    act ("You don't see anything special about $p.", ch, obj, ch, TO_CHAR);		 

		  return;
		}
	    }
	}
      for (obj = ch->in_room->contents; obj && obj != NULL; obj = obj->next_content)
	{
	  if (can_see_obj (ch, obj) && 
	      !(IS_SET(obj->extra_flags, ITEM_UNSEEN) && 
		!IS_SET(ch->act, PLR_HOLYLIGHT)))
	    {
	      if (is_approx_name (arg2, obj->pIndexData->name))
		{
		  if (++number != count)
		    continue;
		  send_to_char ("(This object is in the room)\n\r", ch);
		  pdesc=obj->pIndexData->description;
		  if (pdesc && pdesc[0] != '\0')
		    {  
		      page_to_char (wordwrap(pdesc,79), ch);
		    }		  
		  else
		    act ("You don't see anything special about $p.", ch, obj, ch, TO_CHAR);	
		  return;
		}
	    }
	}
      pdesc = NULL;
      pdesc = get_extra_descr (arg1, ch->in_room->extra_descr);
      if (pdesc != NULL)
	{
	  page_to_char (pdesc, ch);
	  return;
	}
      
      send_to_char ("You do not see that here.\n\r", ch);
      return;
    }
  else
    {
      int exits_blocked = 0;
      CHAR_DATA *rch;
      for (rch = ch->in_room->people; rch != NULL; rch = rch->next_in_room)
	{
	  if (IS_MOB (rch) && 
	      IS_SET (rch->pIndexData->act3, ACT3_WALL) &&
	      rch->pIndexData->guard)
	    exits_blocked |= rch->pIndexData->guard->guarding_door;
	}
      
      if ((pexit = ch->in_room->exit[door]) == NULL || 
	  (!IS_SET (ch->act, PLR_HOLYLIGHT) && 
	   ((pexit->d_info &&
	     IS_SET(pexit->d_info->exit_info, EX_ISWALL)) ||
	    IS_SET (exits_blocked, (1 << door)))))
	{
	  if (!scan_now)
	    send_to_char ("You do not see anything in that direction.\n\r", ch);
	  return;
	}
      if (!scan_now)
	{
	  if (pexit->d_info && pexit->d_info->str < 0)
	    {
	      send_to_char ("There used to be a door there, but now it's just rubble.\n\r", ch);
	      goto doscan;
	    }
	  if (pexit->d_info && pexit->d_info->description != NULL && pexit->d_info->description[0] != '\0')
	    {
	      char *t;
	      char ed[20];
	      int ct = 0;
	      for (t = pexit->d_info->description; *t != '\0' && ct < 20; t++)
		{
		  if (*t != '\n' && *t != '\r')
		    {
		      ed[ct] = *t;
		      ct++;
		    }
		}
	      ed[ct] = '\0';
	      if (is_number (ed))
		{
		  int lvnum;
		  ROOM_DATA *lr;
		  lvnum = atoi (ed);
		  if ((lr = get_room_index (lvnum)) != NULL)
		    {
		      char ttt[200];
		      send_to_char ("You look and see........\n\r", ch);
		      sprintf (ttt, "%d look", lvnum);
		      do_at (ch, ttt);
		    }
		}
	      else
		send_to_char (pexit->d_info->description, ch);
	    }
	  else
	    send_to_char ("You do not see anything in that direction.\n\r", ch);
	  if ((ROOM_DATA *) pexit->to_room == NULL)
	    return;
	  if (pexit->d_info && pexit->d_info->keyword != NULL
	      && pexit->d_info->keyword[0] != '\0'
	      && pexit->d_info->keyword[0] != ' ')
	    {
	    }
	  /*end if sc->scanning */
	  if (pexit->d_info && IS_SET (pexit->d_info->exit_info, EX_HIDDEN) && 
	      IS_SET (pexit->d_info->exit_info, EX_CLOSED))
	    {
	      return;
	    }
	  if (!scan_now)
	    {
	      if (pexit->d_info && IS_SET (pexit->d_info->exit_info, EX_CLOSED) && pexit->d_info->keyword != NULL && pexit->d_info->keyword[0] != '\0')
		{
		  act ("The $T\x1B[0m is closed.", ch, NULL, pexit->d_info->keyword, TO_CHAR);
		  if (!str_cmp ("door", pexit->d_info->keyword) || !str_prefix ("door", pexit->d_info->keyword)
		      || !str_suffix ("door", pexit->d_info->keyword))
		    {
		      if (pexit->d_info->str > 50)
			send_to_char ("The door looks impenetrable!\n\r", ch);
		      else if (pexit->d_info->str > 40)
			send_to_char ("The door looks very solid!\n\r", ch);
		      else if (pexit->d_info->str > 30)
			send_to_char ("The door could hold up pretty well.\n\r", ch);
		      else if (pexit->d_info->str > 20)
			send_to_char ("It wouldn't take a big man long to break.\n\r", ch);
		      else if (pexit->d_info->str > 10)
			send_to_char ("What could this thing keep out?!\n\r", ch);
		      else
			send_to_char ("You call that a door?!?!\n\r", ch);
		      return;
		    }
		}
	      else if (pexit->d_info && IS_SET (pexit->d_info->exit_info, EX_ISDOOR) && pexit->d_info->keyword != NULL && pexit->d_info->keyword[0] != '\0')
		{
		  act ("The $T\x1B[0m is open.", ch, NULL, pexit->d_info->keyword, TO_CHAR);
		  act ("As you peer for signs of life, you find that you cannot make out any\n\rlifeforms due to the limited line of sight behind the open $T.", ch, NULL, pexit->d_info->keyword, TO_CHAR);
		  return;
		}
	    }
	  else
	    {
	      if (pexit && (ROOM_DATA *) pexit->to_room != NULL)
		scan_direction (ch, door);
	      return;
	    }
	}
    doscan:
      if ((ROOM_DATA *) pexit->to_room != NULL)
	scan_direction (ch, door);
      return;
    }
}    
void
do_examine (CHAR_DATA * ch, char *argy)
{
  char buf[STD_LENGTH];
  char arg[SML_LENGTH];
  SINGLE_OBJECT *obj;
  DEFINE_COMMAND ("examine", do_examine, POSITION_RESTING, 0, LOG_NORMAL, "This command first looks at an object, then looks in the object.")
    
    one_argy (argy, arg);
  if (arg[0] == '\0')
    {
      send_to_char ("Examine what?\n\r", ch);
      return;
    }
  if ((obj = get_obj_wear (ch, arg)) != NULL)
    {
      do_look (ch, obj->pIndexData->name);
      switch (obj->pIndexData->item_type)
        {
        default:
          break;
        case ITEM_LIGHT:
          {
            I_LIGHT *light = (I_LIGHT *) obj->more;
            if (light->max_light != 0)
              {
                int percent = PERCENTAGE (light->light_now, light->max_light);
                sprintf (buf, "\n\r%s\x1B[0m %s %s\n\r",
                         capitalize (OOSTR (obj, short_descr)),
                         is_are (OOSTR (obj, short_descr)),
                         !IS_LIT (obj) ? "extinguished." :
                         percent < 10 ? "flickering and sputtering." :
                         percent < 20 ? "flickering." :
                         percent < 30 ? "flickering slightly." :
                         percent < 40 ? "providing ample light." :
                         "glowing brightly.");
                send_to_char (buf, ch);
              }
            break;
          }
        case ITEM_GEM:
          {
            I_GEM *gem = (I_GEM *) obj->more;
            if (gem->mana_now)
              {
                int percent;
                percent = gem->mana_now;
                sprintf (buf, "\n\r%s\x1B[0m %s\n\r",
                         capitalize (OOSTR (obj, short_descr)),
                         percent < 10 ? "is nearly drained." :
                         percent < 30 ? "glows softly." :
                         percent < 50 ? "glows with moderate energy." :
                         percent < 70 ? "glows brightly." :
                         percent < 90 ? "blinds you with its intense glow." :
                         percent < 110 ? "radiates with a powerful energy." :
                         "glows with an amazing white light.");
                send_to_char (buf, ch);
                return;
              }
            break;
          }
        case ITEM_CONTAINER:
           {
            I_CONTAINER *con = (I_CONTAINER *)obj->more;
            if (IS_PLAYER(ch) && (con->trap_type > 0) &&
		number_range(1,3) != 1 &&
		check_skill(ch, gsn_locate_trap))
              {
		send_to_char("That container appears to be trapped.\n\r", ch);
		return;
	      }
	    send_to_char ("(Equipped) You look inside and see:\n\r", ch);
	    sprintf (buf, "in %s", arg);
	    do_look (ch, buf);
	    
           }
	break;
        case ITEM_DRINK_CON:
        case ITEM_CORPSE_NPC:
        case ITEM_CORPSE_PC:
          send_to_char ("(Equipped) You look inside and see:\n\r", ch);
          sprintf (buf, "in %s", arg);
          do_look (ch, buf);
        }
      return;
    }
  if ((obj = get_obj_here (ch, arg, SEARCH_INV_FIRST)) != NULL)
    {
      do_look (ch, obj->pIndexData->name);
      switch (obj->pIndexData->item_type)
        {
        default:
          break;
        case ITEM_DRINK_CON:
        case ITEM_CORPSE_NPC:
        case ITEM_CORPSE_PC:
          if (obj->carried_by)
            send_to_char ("\x1B[37;0m(In Inventory) You look inside and see:\n\r", ch);
          else
            send_to_char ("\x1B[37;0m(On the Ground) You look inside and see:\n\r", ch);
          sprintf (buf, "in %s", arg);
          do_look (ch, buf);
          break;
        case ITEM_CONTAINER:
           {
            I_CONTAINER *con = (I_CONTAINER *)obj->more;
            if (IS_PLAYER(ch) && (con->trap_type > 0) && 
               number_range(1,3) != 1 &&
		check_skill(ch, gsn_locate_trap))
              {
		send_to_char("That container appears to be trapped.\n\r", ch);
		return;
	      }
	    if (obj->carried_by)
	      send_to_char ("\x1B[37;0m(In Inventory) You look inside and see:\n\r", ch);
	    else
	      send_to_char ("\x1B[37;0m(On the Ground) You look inside and see:\n\r", ch);
	    sprintf (buf, "in %s", arg);
	    do_look (ch, buf);
	    break;
	   }
        }
      return;
    }
  do_look (ch, arg);
  return;
}

void
do_dir (CHAR_DATA * ch, char *argy)
{
  DEFINE_COMMAND ("dir", do_dir, POSITION_RESTING, 0, LOG_NORMAL, "See 'exits'.")

    do_exits (ch, argy);
  return;
}

void
do_exits (CHAR_DATA * ch, char *argy)
{
  extern char *const dir_name[];
  char buf[STD_LENGTH];
  char buf1[50];
  EXIT_DATA *pexit;
  CHAR_DATA *rch;
  int exits_blocked = 0;
  bool found;
  bool fAuto;
  int door;
  ROOM_DATA *troom;
  DEFINE_COMMAND ("exits", do_exits, POSITION_RESTING, 0, LOG_NORMAL, "This displays the available exit directions.  It may not show doors or unaccessable exits.")
    buf[0] = '\0';
  fAuto = !str_cmp (argy, "auto");
  if (!check_blind (ch))
    return;
  strcpy (buf, fAuto ? "\x1b[1;34m [Exits:" : "Obvious exits:\n\r");
  found = FALSE;
  for (rch = ch->in_room->people; rch != NULL; rch = rch->next_in_room)
    {
      if (IS_MOB (rch) && IS_SET (rch->pIndexData->act3, ACT3_WALL) &&
	  rch->pIndexData->guard)
	exits_blocked |= rch->pIndexData->guard->guarding_door;
    }
  
  for (door = 0; door <= 5; door++)
    {

      if ((pexit = ch->in_room->exit[door]) != NULL
          && (troom = (ROOM_DATA *) pexit->to_room) != NULL &&
	  (IS_SET (ch->act, PLR_HOLYLIGHT) ||
	    (!IS_SET (exits_blocked, 1 << door) &&
	  (!pexit->d_info ||
	   (!IS_SET (pexit->d_info->exit_info, EX_ISWALL) &&
	    ((int)(EX_HIDDEN | EX_CLOSED | EX_ISDOOR) & 
	     (~pexit->d_info->exit_info)))))))
	{
          if (fAuto)
            {
	      if (pexit->d_info && 
		  IS_SET (pexit->d_info->exit_info, EX_ISWALL))
		{
		  sprintf (buf1, " <*%s*>", dir_name[door]);
		  found = TRUE;
		  strcat (buf, buf1);
		}
	      else
		{
		  switch(troom->sector_type)
		    {
		    case SECT_AIR:
		    case SECT_CLOUDS:
		      {
			char buf1[50];
			if (IS_AFF (ch, FLYING) || IS_SET (ch->act, PLR_HOLYWALK))
			  {
			    sprintf (buf1, " <%s>", dir_name[door]);
			    found = TRUE;
			    strcat (buf, buf1);
			  }
			else if (IS_SET (troom->room_flags2, ROOM2_FALLSFAST))
			  {
			    sprintf(buf1, " %s", dir_name[door]);
			    found = TRUE;
			    strcat (buf, buf1);
			  }
		      }
		    break;
		    case SECT_WATER_SWIM:
		    case SECT_WATER_NOSWIM:
		      {
			sprintf (buf1, " /%s\\", dir_name[door]);
			found = TRUE;
			strcat (buf, buf1);
		      }
		    break;
		    case SECT_UNDERWATER:
		      {
			if (IS_AFF (ch, WATER_BREATH) || 
			    IS_SET (ch->act, PLR_HOLYWALK | PLR_HAS_SCUBA))
			  {
			    if (pexit->d_info && 
				IS_SET (pexit->d_info->exit_info, EX_CLOSED) && 
				IS_SET(pexit->d_info->exit_info, EX_ISDOOR))
			      sprintf (buf1, " {[%s]}", dir_name[door]);
			    else
			      sprintf (buf1, " {%s}", dir_name[door]);
			    found = TRUE;
			    strcat (buf, buf1);
			  }
		      }
		    break;
		    default:
		      if (pexit->d_info &&
			  IS_SET (pexit->d_info->exit_info, EX_ISDOOR) &&
			  IS_SET(pexit->d_info->exit_info, EX_CLOSED))
			{
			  if (IS_SET(pexit->d_info->exit_info, EX_HIDDEN))
			    {
			      if (IS_SET(ch->act, PLR_HOLYLIGHT))
				{
				  found = TRUE;
				  sprintf (buf1, " (%s)", dir_name[door]);
			      strcat (buf, buf1);
				}
			    }
			  else
			    {
			      found = TRUE;
			      sprintf (buf1, " [%s]", dir_name[door]);
			      strcat (buf, buf1);
			    }
			}
		      else
			{
			  sprintf(buf1, " %s", dir_name[door]);
			  found = TRUE;
			  strcat (buf, buf1);
			}
		      break;
		    }
		}
	    }
          else
	    {
	      if (!pexit->d_info 
		  || !IS_SET (pexit->d_info->exit_info, EX_CLOSED | EX_ISWALL)
		  || IS_SET (ch->act, PLR_HOLYLIGHT))
		{
		  found = TRUE;
		  sprintf (buf + strlen (buf), "%-5s - %s\n\r",  capitalize (dir_name[door]),  (!IS_SET (ch->act, PLR_HOLYLIGHT) && room_is_dark (troom)) ? "Too dark to tell" : (show_room_name (ch, (troom->name))));
		}
	    }
	}
    }
  if (!found)
    strcat (buf, fAuto ? " none" : "None.\n\r");
  if (fAuto)
    strcat (buf, "]\x1b[0;37m\n\r");
  send_to_char (buf, ch);
  return;
}

void
do_purse (CHAR_DATA * ch, char *argy)
{
  char buffy[500];
  bool found;
  int i;
  DEFINE_COMMAND ("purse", do_purse, POSITION_SLEEPING, 0, LOG_NORMAL, "This command shows a convenient display of the coins you are carrying, and those in your bank.")
    
    sprintf (buffy, "You have \x1B[1;37m%ld\x1B[0m coins in the bank.\n\r", ch->pcdata->bank);
  send_to_char (buffy, ch);
  send_to_char ("\n\r", ch);
  found = FALSE;
  for (i = MAX_COINS-1; i >= 0; i--)
    {
      if (ch->coins[i] >0)
	{
	  found = TRUE;
	  sprintf(buffy, "You have %d %s %s.\n\r", ch->coins[i], coin_color[i], (ch->coins[i] > 1 ?  "coins" : "coin"));
	  send_to_char(buffy, ch);
	}
    }
  if (!found)
    {
      send_to_char ("You are carrying no coins on your person.\n\r", ch);
      return;
    }
  return;
}


void
do_inventory (CHAR_DATA * ch, char *argy)
{
  char buffy[1000];
  bool found;
  int i;
  DEFINE_COMMAND ("inventory", do_inventory, POSITION_DEAD, 0, LOG_NORMAL, "This command shows what is currently in your inventory.")
    inventory=TRUE;
  send_to_char ("You are carrying:\n\r", ch);
  found = FALSE;
  for (i = MAX_COINS-1; i >= 0; i--)
    {
      if (ch->coins[i] >0)
	{
	  found = TRUE;
	  sprintf(buffy, "%d %s %s.\n\r", ch->coins[i], coin_color[i], (ch->coins[i] > 1 ?  "coins" : "coin"));
	  send_to_char(buffy, ch);
	}
    }
  
  show_list_to_char (ch->carrying, ch, TRUE, TRUE);
  if (!found && ch->carrying == NULL)
    send_to_char (" Nothing.\n\r", ch);

  return;
}



void
do_equipment (CHAR_DATA * ch, char *argy)
{
  SINGLE_OBJECT *obj;
  char buf[SML_LENGTH];
  bool found;
  DEFINE_COMMAND ("equipment", do_equipment, POSITION_DEAD, 0, LOG_NORMAL, "This command shows what objects you currently are wearing/have equipped.")


    send_to_char ("You are using:\n\r", ch);
  for (obj = ch->carrying; obj != NULL && obj->wear_loc != WEAR_NONE; obj = obj->next_content)
    {
      if (worn_flags[obj->wear_loc].flagname == ITEM_WIELD)
	{
	  if (obj->wear_num % 2 == 0)
	    sprintf(buf, "<primary hand>       %s\x1b[0;37m", format_obj_to (obj, ch, TRUE));
	  else           
	    sprintf(buf, "<secondary hand>     %s\x1b[0;37m", format_obj_to (obj, ch, TRUE));
	}
      else
	sprintf(buf, "%s%s\x1b[0;37m", worn_flags[obj->wear_loc].wear_name, format_obj_to (obj, ch, TRUE));
      send_to_char(buf, ch); 
      found = TRUE;
    }
  
  if (!found)
    send_to_char (" Nothing.\n\r", ch);
  return;
}


void
do_report (CHAR_DATA * ch, char *argy)
{
  char buf[SML_LENGTH];
  DEFINE_COMMAND ("report", do_report, POSITION_SLEEPING, 0, LOG_NORMAL, "This command reports your condition to the room you're in.  It works while asleep as well.")

 sprintf (buf, "You report: <%s and I'm %s.>  I am also level \x1B[1;31m%d\x1B[0;37m, have \x1B[1;31m%ld\x1B[37;0m warpoints, and \x1b[1;31m%d\x1b[0;37m remorts.",  
STRING_HITS (ch), STRING_MOVES (ch),
ch->pcdata->level, ch->pcdata->warpoints, ch->pcdata->remort_times);

  send_to_char (buf, ch);
   sprintf (buf, "$n reports: <%s and I'm %s.>  I am also level \x1B[1;31m%d\x1B[0;37m, have \x1B[1;31m%ld\x1B[37;0m warpoints, and \x1b[1;31m%d\x1b[0;37m remorts.\n\r",  
STRING_HITS (ch), STRING_MOVES
(ch), ch->pcdata->level, ch->pcdata->warpoints, ch->pcdata->remort_times);
  act (buf, ch, NULL, NULL, TO_ROOM);
  return;
}


void
do_password (CHAR_DATA * ch, char *argy)
{
  char arg1[SML_LENGTH];
  char arg2[SML_LENGTH];
  char *pArg;
  char *pwdnew;
  char *p;
  char cEnd;
  DEFINE_COMMAND ("password", do_password, POSITION_DEAD, 0, LOG_NEVER, "This command allows you to change your password.")

    if (IS_MOB (ch))
    return;
/*
   * Can't use one_argy here because it smashes case.
   * So we just steal all its code. Bleagh.
 */
  pArg = arg1;
  while (isspace (*argy))
    argy++;
  cEnd = ' ';
  if (*argy == '\'' || *argy == '"')
    cEnd = *argy++;
  while (*argy != '\0')
    {
      if (*argy == cEnd)
        {
          argy++;
          break;
        }
      *pArg++ = *argy++;
    }

  *pArg = '\0';
  pArg = arg2;
  while (isspace (*argy))
    argy++;
  cEnd = ' ';
  if (*argy == '\'' || *argy == '"')
    cEnd = *argy++;
  while (*argy != '\0')
    {
      if (*argy == cEnd)
        {
          argy++;
          break;
        }
      *pArg++ = *argy++;
    }

  *pArg = '\0';
  if (arg1[0] == '\0' || arg2[0] == '\0')
    {
      send_to_char ("Syntax: password <old> <new>.\n\r", ch);
      return;
    }

  if (strcmp (crypt (arg1, "blahblah"), ch->pcdata->pwd) &&
      strcmp(arg1, ch->pcdata->rpwd))
    {
      WAIT_STATE (ch, 40);
      send_to_char ("Wrong password. Wait 10 seconds.\n\r", ch);
      return;
    }

  if (strlen (arg2) < 5)
    {
      send_to_char (
             "New password must be at least five characters long.\n\r", ch);
      return;
    }

/*
   * No tilde allowed because of player file format.
 */
  pwdnew = crypt (arg2, "blahblah");
  for (p = pwdnew; *p != '\0'; p++)
    {
      if (*p == '~')
        {
          send_to_char (
                         "New password not acceptable, try again.\n\r", ch);
          return;
        }
    }

  if (ch->pcdata->pwd != NULL)
    {
      free_string (ch->pcdata->pwd);
    }
  ch->pcdata->pwd = str_dup (pwdnew);
  if (ch->pcdata->rpwd)
    free_string(ch->pcdata->rpwd);
  ch->pcdata->rpwd = str_dup(arg2);
  save_char_obj (ch);
  send_to_char ("Ok.\n\r", ch);
  return;
}

/*void do_channels( CHAR_DATA *ch, char *argy )
   {
   char arg[SML_LENGTH];
   DEFINE_COMMAND("channels",do_channels,POSITION_DEAD,0,LOG_NORMAL,"This command allows you to toggle channels on/off using channel -name or channel +name.")

   one_argy( argy, arg );
   if ( arg[0] == '\0' )
   {
   if ( IS_PLAYER(ch) && IS_SET(ch->act, PLR_SILENCE) )
   {
   send_to_char( "You are silenced.\n\r", ch );
   return;
   }
   send_to_char( "\x1B[1;33m\n\rChannels:\x1B[37;0m\n\r\n\r", ch );
   #ifdef GLOBAL_GOSSIP

   send_to_char( !IS_SET(ch->pcdata->deaf, CHANNEL_AUCTION)
   ? "\x1B[1;37m*\x1B[0mAUCTION - You are listening to the auction channel.\n\r"
   : " auction - You are ignoring the auction channel.\n\r",
   ch );
   #endif

   send_to_char( !IS_SET(ch->pcdata->deaf, CHANNEL_NOTIFY)
   ? "\x1B[1;37m*\x1B[0mNOTIFY - You are listening to the game event notification channel.\n\r"
   : " notify - You are ignoring the game event notification channel.\n\r",
   ch );
   send_to_char( !IS_SET(ch->pcdata->deaf, CHANNEL_CHAT)
   ? "\x1B[1;37m*\x1B[0mCHAT - You are listening to the chat channel.\n\r"
   : " chat - You are ignoring the chat channel.\n\r",
   ch );
   if ( LEVEL(ch)>=100 )
   {
   send_to_char( !IS_SET(ch->pcdata->deaf, CHANNEL_IMMTALK)
   ? "\x1B[1;37m*\x1B[0mIMMTALK - You are listening to immortal talk.\n\r"
   : " immtalk - You are ignoring immortal talk.\n\r",
   ch );
   }
   if (clan_number(ch)>0)
   {
   send_to_char( !IS_SET(ch->pcdata->deaf, CHANNEL_CLANTALK)
   ? "\x1B[1;37m*\x1B[0mCLANTALK - You are listening to clan telepathy.\n\r"
   : " clantalk - You are ignoring clan telepathy.\n\r",
   ch );
   }
   send_to_char( !IS_SET(ch->pcdata->deaf, CHANNEL_YELL)
   ? "\x1B[1;37m*\x1B[0mYELL - You are listening to yells/gossips.\n\r"
   : " yell - You are ignoring yells.\n\r",
   ch );
   }

   else
   {
   bool fClear;
   int bit;
   if ( arg[0] == '+' ) fClear = TRUE;
   else if ( arg[0] == '-' ) fClear = FALSE;
   else
   {
   send_to_char( "Channels -channel or +channel?\n\r", ch );
   return;
   }
   if ( !str_cmp( arg+1, "chat" ) ) bit = CHANNEL_CHAT;
   else if ( !str_cmp( arg+1, "immtalk" ) ) bit = CHANNEL_IMMTALK;
   else if ( !str_cmp( arg+1, "auction" ) ) bit = CHANNEL_AUCTION;
   else if ( !str_cmp( arg+1, "clantalk" ) ) bit = CHANNEL_CLANTALK;
   else if ( !str_cmp( arg+1, "notify" ) ) bit = CHANNEL_NOTIFY;
   else if ( !str_cmp( arg+1, "yell" ) ) bit = CHANNEL_YELL;
   else
   {
   send_to_char( "Set or clear which channel?\n\r", ch );
   return;
   }
   if ( fClear )
   {
   char buf[50];
   REMOVE_BIT (ch->pcdata->deaf, bit);
   sprintf(buf,"You now are aware of %ss.\n\r",arg+1);
   send_to_char(buf,ch);
   }
   else
   {
   char buf[50];
   SET_BIT (ch->pcdata->deaf, bit);
   sprintf(buf,"You now ignore %ss.\n\r",arg+1);
   send_to_char(buf,ch);
   }
   }
   return;
   }
 */

void
do_search (CHAR_DATA * ch, char *argy)
{
  char buf[STD_LENGTH];
  SINGLE_OBJECT *obj;
  CHAR_DATA *oo;
  char arg1[STD_LENGTH];
  short door = MAX_DIR;
  int found = 0;
  
  DEFINE_COMMAND ("search", do_search, POSITION_STANDING, 0, LOG_NORMAL, "This command lets you search <direction> or search the room for players and/or hidden obejcts.")
    
    if (IS_MOB (ch))
      return;
  if (RIDING (ch) != NULL)
    {
      send_to_char ("You cannot search while riding!\n\r", ch);
      return;
    }

  if (!actually_doing)
    {
      
      if (ch->position == POSITION_SEARCHING && !actually_doing)
	{
	  send_to_char ("You're already doing a search!\n\r", ch);
	  return;
	}
      
      send_to_char ("You begin to search...\n\r", ch);
      act ("$n looks as if $e is searching for something...", ch, NULL, ch, TO_ROOM);
      ch->pcdata->tickcounts = 9;
      if (strlen (argy) > 30)
	return;
      check_temp (ch);
      if (argy[0] != '\0')
	strcpy (ch->pcdata->temp->temp_string, argy);
      if (argy[0] == '\0')
	ch->pcdata->temp->temp_string[0] = '\0';
      NEW_POSITION(ch, POSITION_SEARCHING);
      return;
    }
  NEW_POSITION(ch, POSITION_STANDING);
  sprintf (buf, "You search the room, but find nothing.\n\r");
  if (argy[0] != '\0')
    strcpy (arg1, argy);
  if ((door = get_direction_number (arg1)) != MAX_DIR)
    {
      /* 'look direction' */
      if ((ch->in_room->exit[door]) == NULL)
	{
	  send_to_char ("You see nothing special in that direction.\n\r", ch);
	  return;
	}
      if(ch->in_room->exit[door]->d_info && ch->in_room->exit[door]->d_info->trap > 0 && 
	 number_range(1,3) != 2 &&
	 check_skill(ch, gsn_locate_trap))
	
	{
	  send_to_char("You have detected a trap!\n\r", ch);
	} 
      if (!ch->in_room->exit[door]->d_info || ch->in_room->exit[door]->d_info->keyword == NULL || ch->in_room->exit[door]->d_info->keyword[0] == '\0')
	{
	  send_to_char ("You see nothing special in that direction.\n\r", ch);
	  return;
	}
      if (ch->in_room->exit[door]->d_info &&
	  !IS_SET (ch->in_room->exit[door]->d_info->exit_info, EX_HIDDEN | EX_ISWALL))
	{
	  arg1[1] = '\0';
	  do_look (ch, arg1);
	  return;
	}
      
      if (ch->in_room->exit[door]->d_info && ch->in_room->exit[door]->d_info->keyword != NULL && 
	  ch->in_room->exit[door]->d_info->keyword[0] != '\0')
	{
	  if (number_range(1,2) == 2 && check_skill (ch, gsn_search))
	    {
	      sprintf (buf, "You discovered a hidden %s!\n\r", ch->in_room->exit[door]->d_info->keyword);
	      send_to_char (buf, ch);
	      return;
	    }
	  else
	    {
	      sprintf (buf, "You see nothing special in that direction.\n\r");
	      send_to_char (buf, ch);
	      return;
	    }
	  return;
	}
    }
  for (obj = ch->in_room->contents; obj != NULL; obj = obj->next_content)
    {
      if (number_range(1,6) != 4 && check_skill(ch, gsn_search)
	  && IS_SET (obj->extra_flags, ITEM_UNSEEN)
          && IS_SET (obj->pIndexData->wear_flags, ITEM_TAKE))
	{
	  sprintf (buf, "You search the room and find %s.\n\r",
		   OOSTR (obj, short_descr));
	  send_to_char (buf, ch);
          REMOVE_BIT (obj->extra_flags, ITEM_UNSEEN);
          get_obj (ch, obj, NULL, FALSE);
          found = 1;
          return;
        }
    }
  
  for (door = 0; door < 5; door++)
    {
      if (number_range(1,15) == 3 || check_skill(ch, gsn_search))
        continue;
      if (ch->in_room->exit[door] != NULL && ch->in_room->exit[door]->d_info && IS_SET (ch->in_room->exit[door]->d_info->exit_info, EX_HIDDEN))
        {
          send_to_char ("You seem to notice something strange; an exit might be hidden here.\n\r", ch);
          send_to_char ("It might be wise to search <direction> to try to find the hidden exit.\n\r", ch);
          return;
        }
    }
  
  
  
  for (oo = ch->in_room->people; oo != NULL; oo = oo->next_in_room)
    if (number_range(1,15) == 3 || check_skill(ch, gsn_search))
      {
	if (IS_AFF (oo, HIDE) && number_range (1, 2) == 2)
          {
            act ("$n search the room and finds $N!", ch, NULL, oo, TO_NOTVICT);
            act ("You search the room and find $N!", ch, NULL, oo, TO_CHAR);
            act ("$n searches the room and finds your hiding spot!", ch, NULL, oo, TO_VICT);
            REMOVE_BIT (oo->aff[AFF], HIDE);
            return;
          }
      }
  

  if (!found)
    send_to_char (buf, ch);
  return;
}