act_info.c

toc/code/act_info.c · 430.9 KB

From the archive fear2.1.3.tar.gz

Download the archive   « Back to the archive contents

/****************************************************************************
 * [S]imulated [M]edieval [A]dventure multi[U]ser [G]ame      |   \\._.//   *
 * -----------------------------------------------------------|   (0...0)   *
 * SMAUG 1.4 (C) 1994, 1995, 1996, 1998  by Derek Snider      |    ).:.(    *
 * -----------------------------------------------------------|    {o o}    *
 * SMAUG code team: Thoric, Altrag, Blodkai, Narn, Haus,      |   / ' ' \   *
 * Scryn, Rennard, Swordbearer, Gorog, Grishnakh, Nivek,      |~'~.VxvxV.~'~*
 * Tricops and Fireblade                                      |             *
 * ------------------------------------------------------------------------ *
 * Merc 2.1 Diku Mud improvments copyright (C) 1992, 1993 by Michael        *
 * Chastain, Michael Quan, and Mitchell Tse.                                *
 * Original Diku Mud copyright (C) 1990, 1991 by Sebastian Hammer,          *
 * Michael Seifert, Hans Henrik St{rfeldt, Tom Madsen, and Katja Nyboe.     *
 * ------------------------------------------------------------------------ *
 *			     Informational module			    *
 ****************************************************************************/


#include <sys/types.h>
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <sys/stat.h>
#include "mud.h"



char *const where_name[] = {
   "<used as light>      ",
   "<worn on finger>     ",
   "<worn on finger>     ",
   "<worn on neck>       ",
   "<worn around neck>   ",
   "<worn on body>       ",
   "<worn on head>       ",
   "<worn on left leg>   ",
   "<worn on right leg>  ",
   "<worn on left arm>   ",
   "<worn on right arm>  ",
   "<worn as shield>     ",
   "<worn about waist>   ",
   "<wielded>            ",
   "<dual wielded>       ",
   "<missile wielded>    ",
   "<lodged in ribs>     ",
   "<lodged in arm>      ",
   "<lodged in leg>      ",
   "<nocked>             ",
   "<worn on back>       "
};


/*
 * Local functions.
 */
void show_char_to_char_0 args((CHAR_DATA * victim, CHAR_DATA * ch));
void show_char_to_char_1 args((CHAR_DATA * victim, CHAR_DATA * ch, int type));
void show_char_to_char args((CHAR_DATA * list, CHAR_DATA * ch));
void show_condition args((CHAR_DATA * ch, CHAR_DATA * victim));
//Similar Helpfile Snippet Declarations
sh_int str_similarity( const char *astr, const char *bstr );
sh_int str_prefix_level( const char *astr, const char *bstr );
void similar_help_files(CHAR_DATA *ch, char *argument);

int showcollapse;

/*
 * Moved into a separate function so it can be used for other things
 * ie: online help editing				-Thoric
 */
HELP_DATA *get_help(CHAR_DATA * ch, char *argument)
{
   char argall[MIL];
   char argone[MIL];
   char argnew[MIL];
   HELP_DATA *pHelp;
   int lev;

   if (argument[0] == '\0')
      argument = "summary";

   if (isdigit(argument[0]))
   {
      lev = number_argument(argument, argnew);
      argument = argnew;
   }
   else
      lev = -2;
   /*
    * Tricky argument handling so 'help a b' doesn't match a.
    */
   argall[0] = '\0';
   while (argument[0] != '\0')
   {
      argument = one_argument(argument, argone);
      if (argall[0] != '\0')
         strcat(argall, " ");
      strcat(argall, argone);
   }

   for (pHelp = first_help; pHelp; pHelp = pHelp->next)
   {
      if (pHelp->level > get_trust(ch))
         continue;
      if (lev != -2 && pHelp->level != lev)
         continue;

      if (is_name(argall, pHelp->keyword))
         return pHelp;
   }

   return NULL;
}

char *format_obj_to_char(OBJ_DATA * obj, CHAR_DATA * ch, bool fShort, bool colors)
{
   static char buf[MSL];
   sh_int dam;
   sh_int color;

   color = AT_OBJECT;
   buf[0] = '\0';
   if (colors == TRUE)
   {
      switch (obj->item_type)
      {
         default:
            color = AT_OBJECT;
            break;
         case ITEM_BLOOD:
            color = AT_BLOOD;
            break;
         case ITEM_MONEY:
         case ITEM_TREASURE:
            color = AT_YELLOW;
            break;
         case ITEM_COOK:
         case ITEM_FOOD:
            color = AT_HUNGRY;
            break;
         case ITEM_DRINK_CON:
         case ITEM_FOUNTAIN:
            color = AT_THIRSTY;
            break;
         case ITEM_FIRE:
            color = AT_FIRE;
            break;
         case ITEM_SCROLL:
         case ITEM_WAND:
         case ITEM_STAFF:
         case ITEM_SPELLBOOK:
            color = AT_MAGIC;
            break;
      }
   }
   set_char_color(color, ch);
   switch (obj->item_type)
   {
      default:
         strcat(buf, "&c&w* ");
         strcat(buf, char_color_str(color, ch));
         break;

      case ITEM_ARMOR:
         dam = obj->value[3];
         if (IS_OBJ_STAT(obj, ITEM_CLOAK))
         {
            strcat(buf, "&c&w* ");
            strcat(buf, char_color_str(color, ch));
            break;
         }
         if (IS_SET(obj->wear_flags, ITEM_WEAR_SHIELD))
         {
            if (obj->value[1] == 0)
               dam = 100;
            else
               dam = obj->value[0] * 1000 / obj->value[1];
         }
         if (dam <= 199)
            strcat(buf, "&r* ");
         if (dam >= 200 && dam <= 399)
            strcat(buf, "&R* ");
         if (dam >= 400 && dam <= 599)
            strcat(buf, "&Y* ");
         if (dam >= 600 && dam <= 799)
            strcat(buf, "&B* ");
         if (dam >= 800)
            strcat(buf, "&P* ");
         strcat(buf, char_color_str(color, ch));
         break;

      case ITEM_WEAPON:
      case ITEM_SHEATH:
         if (obj->item_type == ITEM_WEAPON)
            dam = obj->value[0];
         else
            dam = obj->value[3];
         if (dam <= 199)
            strcat(buf, "&r* ");
         if (dam >= 200 && dam <= 399)
            strcat(buf, "&R* ");
         if (dam >= 400 && dam <= 599)
            strcat(buf, "&Y* ");
         if (dam >= 600 && dam <= 799)
            strcat(buf, "&B* ");
         if (dam >= 800)
            strcat(buf, "&P* ");
         strcat(buf, char_color_str(color, ch));
         break;

   }

   if (IS_OBJ_STAT(obj, ITEM_INVIS))
      strcat(buf, "(Invis) ");
   if (IS_AFFECTED(ch, AFF_DETECT_EVIL))
      strcat(buf, "(Red Aura) ");

   if (IS_AFFECTED(ch, AFF_DETECT_MAGIC) && IS_OBJ_STAT(obj, ITEM_MAGIC))
      strcat(buf, "(Magical) ");
   if (IS_OBJ_STAT(obj, ITEM_GLOW))
      strcat(buf, "(Glowing) ");
   if (IS_OBJ_STAT(obj, ITEM_HUM))
      strcat(buf, "(Humming) ");
   if (IS_OBJ_STAT(obj, ITEM_HIDDEN))
      strcat(buf, "(Hidden) ");
   if (IS_OBJ_STAT(obj, ITEM_BURIED))
      strcat(buf, "(Buried) ");
   if (IS_IMMORTAL(ch) && IS_OBJ_STAT(obj, ITEM_PROTOTYPE))
      strcat(buf, "(PROTO) ");
   if (IS_AFFECTED(ch, AFF_DETECTTRAPS) && is_trapped(obj))
      strcat(buf, "(Trap) ");
   if (IS_OBJ_STAT(obj, ITEM_NORESET) && IS_IMMORTAL(ch))
      strcat(buf, "(NORESET) ");
   if (IS_OBJ_STAT(obj, ITEM_TIMERESET) && IS_IMMORTAL(ch))
      strcat(buf, "(TIMERESET) ");

   if (fShort)
   {
      if (obj->short_descr)
         strcat(buf, obj->short_descr);  
   }
   else
   {
      if (obj->description && obj->item_type != ITEM_CORPSE_PC)
         strcat(buf, obj->description);
      if (obj->description && obj->item_type == ITEM_CORPSE_PC)
      {
         char arg[MIL];
         char *argh;
         argh = obj->short_descr;
         argh = one_argument(argh, arg);
         argh = one_argument(argh, arg);
         argh = one_argument(argh, arg);
         argh = one_argument(argh, arg);
         if (!str_cmp(arg, ch->name))
         {
            strcat(buf, "Your corpse lies here rotting away.");
         }
         else
         {
            strcat(buf, obj->description);
         }
      }
   }

   return buf;
}

OBJ_DATA *get_wear_hidden_cloak(CHAR_DATA *ch)
{
   OBJ_DATA *obj;
   
   for (obj = ch->last_carrying; obj; obj = obj->prev_content)
   {
      if (obj->wear_loc == WEAR_BACK && IS_OBJ_STAT(obj, ITEM_CLOAK) && IS_OBJ_STAT(obj, ITEM_HIDEIDENTITY))
         return obj;
   }
   return NULL;
}

OBJ_DATA *get_wear_cloak(CHAR_DATA *ch)
{
   OBJ_DATA *obj;
   
   for (obj = ch->last_carrying; obj; obj = obj->prev_content)
   {
      if (obj->wear_loc == WEAR_BACK && IS_OBJ_STAT(obj, ITEM_CLOAK))
         return obj;
   }
   return NULL;
}

void do_cloak(CHAR_DATA *ch, char *argument)
{
   OBJ_DATA *cloak;
   
   if (argument[0] == '\0')
   {
      send_to_char("Syntax: hood <on/off>\n\r", ch);
      return;
   }
   if ((cloak = get_wear_cloak(ch)) == NULL)
   {
      send_to_char("You are not wearing a cloak.\n\r", ch);
      return;
   }
   if (ch->position < POS_SITTING)
   {
      send_to_char("You can only pull your hood on/off if you are sitting/standing/mounted.\n\r", ch);
      return;
   }
   if (!str_cmp(argument, "on"))
   {
      if (xIS_SET(cloak->extra_flags, ITEM_HIDEIDENTITY))
      {
         send_to_char("It is already on.\n\r", ch);
         return;
      }
      act(AT_ACTION, "$n pulls the hood up on $p to cover $s face", ch, cloak, NULL, TO_ROOM);
      act(AT_ACTION, "You pull up the hood on your $p to cover your face", ch, cloak, NULL, TO_CHAR);
      xSET_BIT(cloak->extra_flags, ITEM_HIDEIDENTITY);
      return;
   }
   if (!str_cmp(argument, "off"))
   {
      if (!xIS_SET(cloak->extra_flags, ITEM_HIDEIDENTITY))
      {
         send_to_char("It is already off.\n\r", ch);
         return;
      }
      xREMOVE_BIT(cloak->extra_flags, ITEM_HIDEIDENTITY);
      act(AT_ACTION, "$n pulls down the hood on $p to reveil $s face", ch, cloak, NULL, TO_ROOM);
      act(AT_ACTION, "You pull down the hood on your $p to reveil your face", ch, cloak, NULL, TO_CHAR);
      return;
   }
   do_cloak(ch, "");
   return;
}

char *show_pers_title(CHAR_DATA *victim, CHAR_DATA *ch)
{
   if (!str_cmp(show_pers_output(victim, ch, 1, -1), victim->name))
      return victim->pcdata->title;
   else
      return "";
}

char *show_pers_pretitle(CHAR_DATA *victim, CHAR_DATA *ch)
{
   if (!str_cmp(show_pers_output(victim, ch, 1, -1), victim->name))
      return victim->pcdata->pretit;
   else
      return "";
}
      

char *show_pers_output(CHAR_DATA *ch, CHAR_DATA *looker, int type, int kingdom)
{
   char name[50];
   char hair[50];
   char height[50];
   char who[50];
   static char fullname[150];
   OBJ_DATA *cloak;
   INTRO_DATA *intro;
   strcpy(fullname, "");
   if (ch != NULL && looker != NULL && ch == looker)
   {
      if (IS_NPC(ch))
         return ch->short_descr;
      else
      {
         strcpy(fullname, "");
         sprintf(fullname, "%s%s %s", ch->pcdata->pretit, ch->name, ch->last_name);
         return &fullname[0];
      }
   }
   if (type == 0)
   {
      if (!can_see(looker, ch))
         return "someone";
   }
   if (type == 1 || type == 3)
   {
      if (!can_see_map(looker, ch))
         return "someone";
   }
   if (looker && IS_NPC(looker))
      return ch->name;
   if (type !=  2)
   {
      if (IS_NPC(ch) && type != 3)
         return ch->short_descr;
      if (IS_NPC(ch) && type == 3)
         return ch->name;
      if (IS_NPC(looker) && type != 3)
         return ch->short_descr;
      if (IS_NPC(looker) && type == 3)
         return ch->name;
         
      if ((!IS_NPC(looker) && xIS_SET(looker->act, PLR_SHOWNAMES)) || (!IS_NPC(ch) && xIS_SET(ch->act, PLR_UKNOWN)))
      {
         if (IS_NPC(ch))
            return ch->short_descr;
         else
         {
            strcpy(fullname, "");
            sprintf(fullname, "%s%s %s", ch->pcdata->pretit, ch->name, ch->last_name);
            return &fullname[0];
         }
      }
         
      if ((cloak = get_wear_hidden_cloak(ch)) != NULL)
      {
         return "a cloaked individual";
      }
            
      for (intro = looker->pcdata->first_introduction; intro; intro = intro->next)
      {
         if (intro->pid == ch->pcdata->pid && abs(intro->value) > 100000)
         {
            strcpy(who, "");
            if (IS_SET(intro->flags, INTRO_ATTACKER))
               strcat(who, "[ATTACKER] ");
            if (IS_SET(intro->flags, INTRO_KILLER))
               strcat(who, "[KILLER] ");
            if (IS_SET(intro->flags, INTRO_MYATTACKER))
               strcat(who, "[MY-ATTACKER] ");
            if (IS_SET(intro->flags, INTRO_MYKILLER))
               strcat(who, "[MY-KILLER] ");
            if (IS_SET(intro->flags, INTRO_THIEF))
               strcat(who, "[THIEF] ");
            if (IS_SET(intro->flags, INTRO_MYTHIEF))
               strcat(who, "[MY-THIEF] ");
            
            strcpy(fullname, "");
            sprintf(fullname, "%s%s%s %s", who, ch->pcdata->pretit, ch->name, ch->last_name);
            return &fullname[0];
         }
         if (intro->pid == ch->pcdata->pid)
            break;
      }
   }
   else
   {
      if (kingdom >= sysdata.max_kingdom)
      {
         bug("show_pers_ouput - %s is in an invalid kingdom", ch->name);
      }
      if (IS_NPC(ch))
         return ch->short_descr;
      if (kingdom < 2)
      {
         strcpy(fullname, "");
         sprintf(fullname, "%s%s %s", ch->pcdata->pretit, ch->name, ch->last_name);
         return &fullname[0];
      }
      if (ch->pcdata->hometown == kingdom)
      {
         strcpy(fullname, "");
         sprintf(fullname, "%s%s %s", ch->pcdata->pretit, ch->name, ch->last_name);
         return &fullname[0];
      }
      if (!IS_NPC(ch) && xIS_SET(ch->act, PLR_UKNOWN))
      {
         strcpy(fullname, "");
         sprintf(fullname, "%s%s %s", ch->pcdata->pretit, ch->name, ch->last_name);
         return &fullname[0];
      }
      if ((cloak = get_wear_hidden_cloak(ch)) != NULL)
      {
         return "a cloaked individual";
      }
      else
      {
         for (intro = kingdom_table[kingdom]->first_introduction; intro; intro = intro->next)
         {
            if (intro->pid == ch->pcdata->pid && abs(intro->value) > 100000)
            {
               strcpy(who, "");
               if (IS_SET(intro->flags, INTRO_ATTACKER))
                  strcat(who, "[ATTACKER] ");
               if (IS_SET(intro->flags, INTRO_KILLER))
                  strcat(who, "[KILLER] ");
               if (IS_SET(intro->flags, INTRO_MYATTACKER))
                  strcat(who, "[MY-ATTACKER] ");
               if (IS_SET(intro->flags, INTRO_MYKILLER))
                  strcat(who, "[MY-KILLER] ");
               if (IS_SET(intro->flags, INTRO_THIEF))
                  strcat(who, "[THIEF] ");
               if (IS_SET(intro->flags, INTRO_MYTHIEF))
                  strcat(who, "[MY-THIEF] ");
            
               strcpy(fullname, "");
               sprintf(fullname, "%s%s%s %s", who, ch->pcdata->pretit, ch->name, ch->last_name);
               return &fullname[0];
            }
            if (intro->pid == ch->pcdata->pid)
               break;
         }
      }
   }
   if (ch->race == RACE_OGRE)
   {
      if (ch->pcdata->skincolor >= 1 && ch->pcdata->skincolor <= 5)
         sprintf(name, "green ogre");
      if (ch->pcdata->skincolor >= 6 && ch->pcdata->skincolor <= 9)
         sprintf(name, "brown ogre");
      if (ch->pcdata->skincolor >= 10 && ch->pcdata->skincolor >= 14)
         sprintf(name, "black ogre");
   }
   if (ch->race == RACE_FAIRY)
   {
      if (ch->pcdata->skincolor >= 1 && ch->pcdata->skincolor <= 5)
         sprintf(name, "blue fairy");
      if (ch->pcdata->skincolor >= 6 && ch->pcdata->skincolor <= 10)
         sprintf(name, "green fairy");
      if (ch->pcdata->skincolor >= 11 && ch->pcdata->skincolor <= 15)
         sprintf(name, "pink fairy");
   }
   if (ch->race == RACE_HUMAN)
   {
      if (ch->pcdata->skincolor >= 1 && ch->pcdata->skincolor <= 6)
         sprintf(name, "white human");
      if (ch->pcdata->skincolor >= 7 && ch->pcdata->skincolor <= 10)
         sprintf(name, "brown human");
      if (ch->pcdata->skincolor >= 11 && ch->pcdata->skincolor <= 15)
         sprintf(name, "black human");
   }
   if (ch->race == RACE_ELF)
   {
      if (ch->pcdata->skincolor >= 1 && ch->pcdata->skincolor <= 6)
         sprintf(name, "white elf");
      if (ch->pcdata->skincolor >= 7 && ch->pcdata->skincolor <= 10)
         sprintf(name, "brown elf");
      if (ch->pcdata->skincolor >= 11 && ch->pcdata->skincolor <= 15)
         sprintf(name, "black elf");
   }
   if (ch->race == RACE_DWARF)
   {
      if (ch->pcdata->skincolor >= 1 && ch->pcdata->skincolor <= 6)
         sprintf(name, "white dwarf");
      if (ch->pcdata->skincolor >= 7 && ch->pcdata->skincolor <= 10)
         sprintf(name, "brown dwarf");
      if (ch->pcdata->skincolor >= 11 && ch->pcdata->skincolor <= 15)
         sprintf(name, "black dwarf");
   }
   if (ch->race == RACE_HOBBIT)
   {
      if (ch->pcdata->skincolor >= 1 && ch->pcdata->skincolor <= 6)
         sprintf(name, "white hobbit");
      if (ch->pcdata->skincolor >= 7 && ch->pcdata->skincolor <= 9)
         sprintf(name, "brown hobbit");
      if (ch->pcdata->skincolor >= 11 && ch->pcdata->skincolor <= 15)
         sprintf(name, "black hobbit");
   }

   if (ch->pcdata->hairlength == 1)
      sprintf(hair, "bald, ");
   else if (ch->pcdata->haircolor >= 1 && ch->pcdata->haircolor <= 3)
      sprintf(hair, "white haired, ");
   else if (ch->pcdata->haircolor >= 4 && ch->pcdata->haircolor <= 7)
      sprintf(hair, "grey haired, ");
   else if (ch->pcdata->haircolor >= 8 && ch->pcdata->haircolor <= 11)
      sprintf(hair, "brown haired, ");
   else if (ch->pcdata->haircolor >= 12 && ch->pcdata->haircolor <= 16)
      sprintf(hair, "black haired, ");
   else if (ch->pcdata->haircolor >= 17 && ch->pcdata->haircolor <= 20)
      sprintf(hair, "blonde haired, ");
   else if (ch->pcdata->haircolor >= 21 && ch->pcdata->haircolor <= 25)
      sprintf(hair, "red haired, ");
   else if (ch->pcdata->haircolor >= 26 && ch->pcdata->haircolor <= 30)
      sprintf(hair, "green haired, ");
   else if (ch->pcdata->haircolor >= 31 && ch->pcdata->haircolor <= 35)
      sprintf(hair, "blue haired, ");
   else if (ch->pcdata->haircolor >= 36 && ch->pcdata->haircolor <= 40)
      sprintf(hair, "purple haired, ");
      
   if (intro)
   {
      if (intro->value > 80000)
         sprintf(who, "a familiar ");
      else if (intro->value > 50000)
         sprintf(who, "a somewhat familiar ");
      else if (intro->value > 25000)
         sprintf(who, "a vaguely familiar ");
      else if (abs(intro->value) <= 10000)
         sprintf(who, "an almost unknown ");
      else if (intro->value >= -25000)
      {
         strcpy(who, "");
         if (IS_SET(intro->flags, INTRO_ATTACKER))
            strcat(who, "[ATTACKER] ");
         if (IS_SET(intro->flags, INTRO_KILLER))
            strcat(who, "[KILLER] ");
         if (IS_SET(intro->flags, INTRO_MYATTACKER))
            strcat(who, "[MY-ATTACKER] ");
         if (IS_SET(intro->flags, INTRO_MYKILLER))
            strcat(who, "[MY-KILLER] ");
         if (IS_SET(intro->flags, INTRO_THIEF))
            strcat(who, "[THIEF] ");
         if (IS_SET(intro->flags, INTRO_MYTHIEF))
            strcat(who, "[MY-THIEF] ");
            
         strcat(who, "an almost unknown ");
      }
      else if (intro->value >= -50000)
      {
         strcpy(who, "");
         if (IS_SET(intro->flags, INTRO_ATTACKER))
            strcat(who, "[ATTACKER] ");
         if (IS_SET(intro->flags, INTRO_KILLER))
            strcat(who, "[KILLER] ");
         if (IS_SET(intro->flags, INTRO_MYATTACKER))
            strcat(who, "[MY-ATTACKER] ");
         if (IS_SET(intro->flags, INTRO_MYKILLER))
            strcat(who, "[MY-KILLER] ");
         if (IS_SET(intro->flags, INTRO_THIEF))
            strcat(who, "[THIEF] ");
         if (IS_SET(intro->flags, INTRO_MYTHIEF))
            strcat(who, "[MY-THIEF] ");
            
         strcat(who, "a vaguely familiar ");
      }
      else if (intro->value >= -80000)  
      {
         strcpy(who, "");
         if (IS_SET(intro->flags, INTRO_ATTACKER))
            strcat(who, "[ATTACKER] ");
         if (IS_SET(intro->flags, INTRO_KILLER))
            strcat(who, "[KILLER] ");
         if (IS_SET(intro->flags, INTRO_MYATTACKER))
            strcat(who, "[MY-ATTACKER] ");
         if (IS_SET(intro->flags, INTRO_MYKILLER))
            strcat(who, "[MY-KILLER] ");
         if (IS_SET(intro->flags, INTRO_THIEF))
            strcat(who, "[THIEF] ");
         if (IS_SET(intro->flags, INTRO_MYTHIEF))
            strcat(who, "[MY-THIEF] ");
            
         strcat(who, "a somewhat familiar ");
      }
      else if (intro->value >= -100000)
      {
         strcpy(who, "");
         if (IS_SET(intro->flags, INTRO_ATTACKER))
            strcat(who, "[ATTACKER] ");
         if (IS_SET(intro->flags, INTRO_KILLER))
            strcat(who, "[KILLER] ");
         if (IS_SET(intro->flags, INTRO_MYATTACKER))
            strcat(who, "[MY-ATTACKER] ");
         if (IS_SET(intro->flags, INTRO_MYKILLER))
            strcat(who, "[MY-KILLER] ");
         if (IS_SET(intro->flags, INTRO_THIEF))
            strcat(who, "[THIEF] ");
         if (IS_SET(intro->flags, INTRO_MYTHIEF))
            strcat(who, "[MY-THIEF] ");
            
         strcat(who, "a familiar ");
      }   
      if (ch->pcdata->cheight >= 1 && ch->pcdata->cheight <= 5)
         sprintf(height, "short, ");
      if (ch->pcdata->cheight >= 6 && ch->pcdata->cheight <= 8)
         sprintf(height, "average, ");
      if (ch->pcdata->cheight >= 9 && ch->pcdata->cheight <= 13)
         sprintf(height, "tall, ");
   }
   else
   {
      strcpy(who, "");
      if (ch->pcdata->cheight >= 1 && ch->pcdata->cheight <= 5)
         sprintf(height, "a short, ");
      if (ch->pcdata->cheight >= 6 && ch->pcdata->cheight <= 8)
         sprintf(height, "an average, ");
      if (ch->pcdata->cheight >= 9 && ch->pcdata->cheight <= 13)
         sprintf(height, "a tall, ");
   }
   if(ch->fame >= 4000)
   {
      strcpy(fullname, "");
      sprintf(fullname, "%s%s", ch->pcdata->pretit, ch->last_name);
      return &fullname[0];
   }  
   else if(ch->fame >= 10000)
   {
      strcpy(fullname, "");
      sprintf(fullname, "%s%s %s", ch->pcdata->pretit, ch->name, ch->last_name);
      return &fullname[0];
   }
   else
   {
   	strcpy(fullname, "");
   	sprintf(fullname, "%s%s%s%s", who, height, hair, name);
   	return &fullname[0];
   }     
}

char *get_weapontype(sh_int wtype)
{
   switch (wtype)
   {
      default:
         return "Unknown";
      case 0:
         return "Hit";
      case 1:
         return "Slash";
      case 2:
         return "Pierce";
      case 3:
         return "Stab";
      case 4:
         return "Whip";
      case 5:
         return "Claw";
      case 6:
         return "Pound";
      case 7:
         return "Crush";
      case 8:
         return "Bolt";
      case 9:
         return "Arrow";
      case 10:
         return "Stone";
      case 11:
         return "Chop";
      case 12:
         return "Thrust";
      case 13:
         return "Swing";
      case 14:
         return "Rip";
      case 15:
         return "Knife";
      case 16:
         return "Cleave";
      case 17:
         return "Fist";
      case 18:
         return "Immolation";
      case 19:
         return "Freeze";
      case 20:
         return "Acid";
      case 21:
         return "Electrocution";
      case 22:
         return "Blessing";
      case 23:
         return "Curse";
   }
}
char *mastery_color(sh_int sn, sh_int cl)
{
   if (skill_table[sn]->mastery[cl] == 1)
      return "&Y";
   if (skill_table[sn]->mastery[cl] == 2)
      return "&c";
   if (skill_table[sn]->mastery[cl] == 3)
      return "&C";
   if (skill_table[sn]->mastery[cl] == 4)
      return "&R";
   if (skill_table[sn]->mastery[cl] == 5)
      return "&c&w";
   if (skill_table[sn]->mastery[cl] == 6)
      return "&w&W";

   return "&P";
}

char *mastery_diffcolor(sh_int sn, sh_int cl)
{
   if (skill_table[sn]->masterydiff[0] == 1)
      return "&Y";
   if (skill_table[sn]->masterydiff[0] == 2)
      return "&G&c";
   if (skill_table[sn]->masterydiff[0] == 3)
      return "&G&C";
   if (skill_table[sn]->masterydiff[0] == 4)
      return "&R";

   return "&P";
}

char *group_color(sh_int group, sh_int cl)
{
   int sn;
   sh_int max = -1;

   for (sn = 0; sn < top_sn && skill_table[sn] && skill_table[sn]->name; sn++)
   {
      if (skill_table[sn]->group[cl] == group)
      {
         if (max == -1)
         {
            max = skill_table[sn]->mastery[cl];
         }
         else
         {
            if (skill_table[sn]->mastery[cl] > max)
               max = skill_table[sn]->mastery[cl];
         }
      }
   }
   if (max == 1)
      return "&Y";
   if (max == 2)
      return "&c";
   if (max == 3)
      return "&C";
   if (max == 4)
      return "&R";

   return "&P";
}

// Can use at a portal spot to see what is available to portal to
void freeportals(CHAR_DATA * ch)
{
   int p;
   int count = 0;
   int fnd = 0;
   int found = 0;
   char buf[MSL];
   OMAP_DATA *mobj;
   OBJ_DATA *obj;
   ROOM_INDEX_DATA *room;
   char finbuf[MSL];

   if (ch->in_room->vnum != ROOM_VNUM_PORTAL)
   {
      for (p = 0; p < sysdata.last_portal; p++)
      {
         if (xIS_SET(ch->pcdata->portalfnd, p))
         {
            if (ch->coord->x == portal_show[p]->x && ch->coord->y == portal_show[p]->y && ch->map == portal_show[p]->map)
            {
               fnd++;
            }
         }
      }
   }
   else
      fnd++;

   if (fnd == 0)
   {
      send_to_char("You need to be at a portal to get a list of free ones.\n\r", ch);
      return;
   }
   fnd = 0;
   sprintf(finbuf, "---------------------------------------------------------\n\r");
   for (obj = first_object; obj; obj = obj->next)
   {
      if (obj->item_type == ITEM_PORTAL)
      {
         if (obj->in_room && obj->in_room->vnum == ROOM_VNUM_PORTAL)
         {
            found = 1;
         }
      }
   }
   if (found == 0)
   {
      fnd++;
      room = get_room_index(ROOM_VNUM_PORTAL);
      if (ch->in_room->vnum != room->vnum)
      {
         sprintf(buf, "[HM]       %s\n\r", room->name);
         strcat(finbuf, buf);
      }
   }
   for (p = 0; p < sysdata.last_portal; p++)
   {
      found = 0;
      if (xIS_SET(ch->pcdata->portalfnd, p))
      {
         count++;
         for (mobj = first_wilderobj; mobj; mobj = mobj->next)
         {
            if (mobj->mapobj->item_type == ITEM_PORTAL)
            {
               if (mobj->mapobj->value[0] == portal_show[p]->x && mobj->mapobj->value[1] == portal_show[p]->y
                  && mobj->mapobj->value[2] == portal_show[p]->map)
               {
                  found = 1;
               }
            }
         }
         if (found == 0)
         {
            fnd++;
            if (ch->coord->x != portal_show[p]->x || ch->coord->y != portal_show[p]->y || ch->map != portal_show[p]->map)
            {
               sprintf(buf, "[%2d]       %s\n\r", count, portal_show[p]->desc);
               strcat(finbuf, buf);
            }
         }
      }
   }
   if (count == 0)
   {
      send_to_char("You have not found any portals.\n\r", ch);
      return;
   }
   if (fnd == 0)
   {
      send_to_char("All portal locations are in use right now.\n\r", ch);
      return;
   }
   else
   {
      send_to_char("Number     Location\n\r", ch);
      send_to_char(finbuf, ch);
   }
   return;
}

// Will allow players to search for new portals, have to be in portal room to switch the flag
void do_huntportals(CHAR_DATA * ch, char *argument)
{
   if (IS_NPC(ch))
   {
      send_to_char("Only Players can Hunt Portals.\n\r", ch);
      return;
   }
   if (ch->in_room->vnum != ROOM_VNUM_PORTAL)
   {
      send_to_char("You can only choose to start/shop hunting portals in the City Portal.\n\r", ch);
      return;
   }
   if (xIS_SET(ch->act, PLR_PORTALHUNT))
   {
      act(AT_MAGIC, "You sake as the power to hunt portals is removed from you.", ch, NULL, NULL, TO_CHAR);
      act(AT_MAGIC, "$n shakes a bit as the power to hunt portals is sucked from $m.", ch, NULL, NULL, TO_ROOM);
      xREMOVE_BIT(ch->act, PLR_PORTALHUNT);
   }
   else
   {
      act(AT_MAGIC, "$n eyes turn blue and fade back to normal as $e prepares to hunt portals.", ch, NULL, NULL, TO_ROOM);
      act(AT_MAGIC, "Your eyes turn blue and fade back to normal as you prepare to hunt portals.", ch, NULL, NULL, TO_CHAR);
      xSET_BIT(ch->act, PLR_PORTALHUNT);
   }
}
void do_markportal(CHAR_DATA * ch, char *argument)
{
   int p;
   int kdm;
   char buf[MSL];

   if (IS_NPC(ch))
   {
      send_to_char("Only Players can Mark Portals.\n\r", ch);
      return;
   }
   if (!IS_ONMAP_FLAG(ch))
   {
      send_to_char("You can only mark portals out in the Wilderness.\n\r", ch);
      return;
   }
   if (!xIS_SET(ch->act, PLR_PORTALHUNT))
   {
      send_to_char("You have to be magically blessed to hunt or mark portals.\n\r", ch);
      return;
   }
   for (p = 0; p < sysdata.last_portal; p++)
   {
      if (portal_show[p]->x == ch->coord->x && portal_show[p]->y == ch->coord->y && portal_show[p]->map == ch->map)
      {
         for (kdm = 0; kdm < sysdata.max_kingdom; kdm++)
         {
            if (kdm > 1)
            {
               sprintf(buf, "%s Portal", kingdom_table[kdm]->name);
               if (!str_cmp(portal_show[p]->desc, buf))
               {
                  send_to_char("Cannot mark Kingdom portals, you get them when you join.\n\r", ch);
                  return;
               }
            }
         }
         xSET_BIT(ch->pcdata->portalfnd, p);
         send_to_char("This portal has been marked.  listportals for portals you have found.\n\r", ch);
         return;
      }
   }
}

void do_listportals(CHAR_DATA * ch, char *argument)
{
   int p;
   int count = 0;
   char buf[MSL];
   char finbuf[MSL];

   if (IS_NPC(ch))
   {
      send_to_char("Only Players can List Portals.\n\r", ch);
      return;
   }

   if (!str_cmp(argument, "free"))
   {
      freeportals(ch);
      return;
   }

   sprintf(finbuf, "---------------------------------------------------------\n\r");

   for (p = 0; p < sysdata.last_portal; p++)
   {
      if (xIS_SET(ch->pcdata->portalfnd, p))
      {
         count++;
         sprintf(buf, "[%2d]       %s\n\r", count, portal_show[p]->desc);
         strcat(finbuf, buf);
      }
   }
   if (count == 0)
   {
      send_to_char("You have not found any portals.\n\r", ch);
      return;
   }
   else
   {
      send_to_char("Number     Location\n\r", ch);
      send_to_char(finbuf, ch);
   }
   return;
}

void do_settoadvance(CHAR_DATA *ch, char *argument)
{
   char arg1[MIL];
   char buf[MSL];
   int sphere;
   int group;
   int tier;
   
   if (argument[0] == '\0')
   {
      send_to_char("Syntax:  settoadvance show <sphere/group> <value/name>\n\r", ch);
      send_to_char("Syntax:  settoadvance set <sphere> <group> <tier> <value>\n\r", ch);
      return;
   }
   
   argument = one_argument(argument, arg1);
   
   if (!str_cmp(arg1, "show"))
   {
      argument = one_argument(argument, arg1);
      if (!str_cmp(arg1, "sphere"))
      {
         argument = one_argument(argument, arg1);
         if (atoi(arg1) > 0)
            sphere = atoi(arg1);
         else
            sphere = issphere(arg1);
         if (sphere > 0)
         {
            send_to_char("Sphere                   Group                    Tiers\n\r", ch);
            send_to_char("-------------------------------------------------------------------------\n\r", ch);
            for (group = 0; group < MAX_GROUP; group++)
            {
               if (sysdata.toadvance[sphere-1][group][0] > 0)
               {
                  strcpy(buf, "");
                  for (tier = 2; tier <= MAX_TIER; tier++)
                  {
                     sprintf(arg1, "   %-2d", sysdata.toadvance[sphere-1][group][tier-2]);
                     strcat(buf, arg1);
                  } 
                  ch_printf(ch, "%-20s     %-20s    %s\n\r", get_sphere_name2(sphere), get_group_name(group+1), buf);
               }
            }
            return;
         }
         send_to_char("That is not a valid sphere.\n\r", ch);
         return;
      }
      if (!str_cmp(arg1, "group"))
      {
         argument = one_argument(argument, arg1);
         if (atoi(arg1) > 0)
            group = atoi(arg1);
         else
            group = isgroup(arg1);
         if (group > 0)
         {
            send_to_char("Sphere                   Group                    Tiers\n\r", ch);
            send_to_char("-------------------------------------------------------------------------\n\r", ch);
            for (sphere = 0; sphere < MAX_SPHERE; sphere++)
            {
               if (sysdata.toadvance[sphere][group-1][0] > 0)
               {
                  strcpy(buf, "");
                  for (tier = 2; tier <= MAX_TIER; tier++)
                  {
                     sprintf(arg1, "   %-2d", sysdata.toadvance[sphere-1][group][tier-2]);
                     strcat(buf, arg1);
                  } 
                  ch_printf(ch, "%-20s     %-20s    %s\n\r", get_sphere_name2(sphere+1), get_group_name(group), buf);
               }
            }
            return;
         }
         send_to_char("That is not a valid group.\n\r", ch);
         return;
      }
   }
   
   if (!str_cmp(arg1, "set"))
   {
      argument = one_argument(argument, arg1);
      if (atoi(arg1) > 0)
         sphere = atoi(arg1);
      else
         sphere = issphere(arg1);
      if (sphere < 1 || sphere > MAX_SPHERE)
      {
         ch_printf(ch, "Range is 1 to %d", MAX_SPHERE);
         return;
      }
      
      argument = one_argument(argument, arg1);
      if (atoi(arg1) > 0)
         group = atoi(arg1);
      else
         group = isgroup(arg1);
      if (group < 1 || group > MAX_GROUP)
      {
         ch_printf(ch, "Range is 1 to %d", MAX_GROUP);
         return;
      }  
      
      argument = one_argument(argument, arg1);
      if (atoi(arg1) < 2 || atoi(arg1) > MAX_TIER)
      {
         ch_printf(ch, "Range is 2 to %d", MAX_TIER);
         return;
      }
      tier = atoi(arg1);
      
      if (atoi(argument) < 0)
      {
         send_to_char("The value has to be greater than or equal to 0.\n\r", ch);
         return;
      }
      sysdata.toadvance[sphere-1][group-1][tier-2] = atoi(argument);
      send_to_char("Done.\n\r", ch);
      return;
   }
   do_settoadvance(ch, "");
   return;
}

//Minimum requirements of mastery to learn a mastery above yours (like Novice to Expert)
int min_to_learn(int sn)
{
   int mdiff = skill_table[sn]->masterydiff[0];
   return sysdata.toadvance[skill_table[sn]->stype-1][skill_table[sn]->group[0]-1][mdiff-2];
}

void generate_webskill_help(CHAR_DATA *ch, char *skillname, char *bfilename)
{
   HELP_DATA *pHelp;
   char buf[MSL];
   char parse[MSL*2];
   char aparse[MSL];
   FILE *fp;
   char filename[MIL];
   int x;
   int y;
   
   sprintf(filename, "%sskill%s.htm", SKILLOUT_DIR, skillname);
   if ((fp = fopen(filename, "w")) == NULL)
   {
      send_to_char("Cannot write to the webhelp file (Help).\n\r", ch);
      return;
   }
   if ((pHelp = get_help(ch, skillname)) == NULL)
   {
      ch_printf(ch, "Cannot find helpfile for %s, aborting the write.", skillname);
      return;
   }
   sprintf(buf, "<html><head><title>Helpfile</title></head><body bgcolor=\"#DCE4E1\">-------------------------------------------------------<br>"
                "%s<br>-------------------------------------------------------<br><pre>", pHelp->keyword);
   for (x = 0,y = 0;;)
   {
      if (pHelp->text[x] == '&')
      {
         if (pHelp->text[x+1] == '&')
         {
            parse[y++] = '&';
         }
         x+=2;
      }
      else if (pHelp->text[x] == '\r')
      {
         x++;
      }
      else if (pHelp->text[x] == '\0')
      {
         parse[y] = '\0';
         break;
      }
      else
      {
         parse[y++] = pHelp->text[x++];
      }
   }
   sprintf(aparse, "</pre><p><a href=\"%s\">Go back</a>", bfilename);
   strcat(parse, aparse);
   for (x = 0;;x++)
   {
      if (buf[x] != '\0')
         putc(buf[x], fp);
      else
         break;
   }
   for (x = 0;;x++)
   {
      if (parse[x] != '\0')
         putc(parse[x], fp);
      else
         break;
   }
   fclose(fp);
   return;
}   

char *get_webtiercolor(int x)
{
   if (x == 1)
      return "<font color=\"#FFFF00\">";
   if (x == 2)
      return "<font color=\"#008080\">";
   if (x == 3)
      return "<font color=\"#00FFFF\">";
   if (x == 4)
      return "<font color=\"#FF0000\">";
      
   return "<font color=\"#FFFF00\">";
}
int global_skillcount;
void generate_group_files(CHAR_DATA *ch, int sn)
{
   int csn;
   FILE *fp;
   char wbuf[MSL];
   char abuf[MSL];
   char filename[MSL];
   int x;
   int col = 0;
   
   sprintf(filename, "%s%s%s.htm", SKILLOUT_DIR, get_group_name(skill_table[sn]->group[0]),
                     get_sphere_name(skill_table[sn]->stype));
   if ((fp = fopen(filename, "w")) == NULL)
   {
      send_to_char("Cannot write to the webhelp file (Group).\n\r", ch);
      return;
   }
   sprintf(wbuf, "<html>\n<head>\n<title>Skill and Spell Groups</title>\n</head>\n<body bgcolor=\"#000000\">\n");
   sprintf(abuf, "<table width=600><tr><td><center><font color=red>%s</font></center></td></tr></table><p>\n<table width=600><tr>", get_sphere_name(skill_table[sn]->stype));
   strcat(wbuf, abuf);                  
   for (x = 1; x <= 4; x++)
   {
      for (csn = 0; csn < top_sn && skill_table[csn] && skill_table[csn]->name; csn++)
      {
         if (skill_table[csn]->group[0] == skill_table[sn]->group[0] && skill_table[csn]->stype == skill_table[sn]->stype 
         &&  skill_table[csn]->masterydiff[0] == x)
         {
            sprintf(abuf, "<td width=200><a href=\"skill%s.htm\">%s%s</font></a></td>", skill_table[csn]->name, get_webtiercolor(x), skill_table[csn]->name);
            global_skillcount++;
            generate_webskill_help(ch, skill_table[csn]->name, filename);
            strcat(wbuf, abuf);
            if (++col % 3 == 0)
               strcat(wbuf, "</tr>\n<tr>");
         }
      }
   }
   strcat(wbuf, "</tr></table>");
   sprintf(abuf, "<p><a href=\"skillout.htm\">Go back</a>");
   strcat(wbuf, abuf);
   col = 0;
   for (x = 0;;x++)
   {
      if (wbuf[x] != '\0')
         putc(wbuf[x], fp);
      else
         break;
   }
   fclose(fp);
}
/* List available groups and later individual skills */
void do_listgroups(CHAR_DATA * ch, char *argument)
{
   sh_int sn;
   sh_int csn;
   char buf[MSL];
   char buf2[MSL];
   char arg[MIL];
   sh_int sbuf[MAX_SPHERE+1];
   sh_int gbuf[MAX_GROUP+1];
   sh_int ranking[MAX_RANKING+1];
   sh_int ranking2[MAX_RANKING+1];
   int col = 0;
   int x;
   sh_int y;
   sh_int group;

   for (y = 1; y <= MAX_GROUP; y++)
      gbuf[y] = 0;
   for (y = 1; y <= MAX_SPHERE; y++)
      sbuf[y] = 0; 
   for (y = 1; y <= MAX_RANKING; y++)
   {
      ranking2[y] = 0;
      ranking[y] = 0;
   }

   set_char_color(AT_MAGIC, ch);
   if (argument[0] == '\0')
   {
      sprintf(buf, MXPFTAG("Command 'listgroups allgroups' desc='Click here to see a list of spell/skill groups'", "listgroups allgroups", "/Command"));
      ch_printf(ch, "Syntax: %s\n\r", buf);
      send_to_char("Syntax: listgroups <group name>\n\r", ch);
      send_to_char("Syntax: listgroups <skill name>\n\r", ch);     
      send_to_char("Syntax: listgroups toadvance <group name>\n\r", ch);
      if (get_trust(ch) == LEVEL_ADMIN)
         send_to_char("Syntax:  listgroups webprint\n\r", ch);
      return;
   }
   argument = one_argument(argument, arg);
   
   if (!str_cmp(arg, "toadvance"))
   {
      if ((group = isgroup(argument)) != -1)
      {
         for (sn = 0; sn < top_sn && skill_table[sn] && skill_table[sn]->name; sn++)
         {
            if (skill_table[sn]->group[0] == group)
            {
               if (skill_table[sn]->group[0] <= 5 && skill_table[sn]->stype == 4)
               {
                  if (skill_table[sn]->masterydiff[0] > 1 && ranking2[skill_table[sn]->masterydiff[0]] == 0)
                  {   
                     ranking2[skill_table[sn]->masterydiff[0]] = min_to_learn(sn);
                  }
               }
               else
               {
                  if (skill_table[sn]->masterydiff[0] > 1 && ranking[skill_table[sn]->masterydiff[0]] == 0)
                  {
                     ranking[skill_table[sn]->masterydiff[0]] = min_to_learn(sn);
                  }
               }
            }
         }
         if (group <= 5)
         {
            ch_printf(ch, "                                    %s\n\r--------------------------------------------------------------------------------\n\r", get_sphere_name2(3));
            if (ranking[2] > 0)
            {
               ch_printf(ch, "It will take (-%d-) %s skills/spells at %s to learn %s skills/spells.\n\r", ranking[2], get_tier_name(1), get_mastery_name(2), get_tier_name(2));
            }
            if (ranking[3] > 0)
            {
               ch_printf(ch, "It will take (-%d-) %s skills/spells at %s to learn %s skills/spells.\n\r", ranking[3], get_tier_name(2), get_mastery_name(3), get_tier_name(3));
            }
            if (ranking[4] > 0)
            {
               ch_printf(ch, "It will take (-%d-) %s skills/spells at %s to learn %s skills/spells.\n\r", ranking[4], get_tier_name(3), get_mastery_name(4), get_tier_name(4));
            }
            ch_printf(ch, "--------------------------------------------------------------------------------\n\r                                    %s\n\r", get_sphere_name2(4));
            send_to_char("--------------------------------------------------------------------------------\n\r", ch);
            if (ranking2[2] > 0)
            {
               ch_printf(ch, "It will take (-%d-) %s skills/spells at %s to learn %s skills/spells.\n\r", ranking2[2], get_tier_name(1), get_mastery_name(2), get_tier_name(2));
            }
            if (ranking2[3] > 0)
            {
               ch_printf(ch, "It will take (-%d-) %s skills/spells at %s to learn %s skills/spells.\n\r", ranking2[3], get_tier_name(2), get_mastery_name(3), get_tier_name(3));
            }
            if (ranking2[4] > 0)
            {
               ch_printf(ch, "It will take (-%d-) %s skills/spells at %s to learn %s skills/spells.\n\r", ranking2[4], get_tier_name(3), get_mastery_name(4), get_tier_name(4));
            }
            return;
         }
         else
         {
            if (ranking[2] > 0)
            {
               ch_printf(ch, "It will take (-%d-) %s skills/spells at %s to learn %s skills/spells.\n\r", ranking[2], get_tier_name(1), get_mastery_name(2), get_tier_name(2));
            }
            if (ranking[3] > 0)
            {
               ch_printf(ch, "It will take (-%d-) %s skills/spells at %s to learn %s skills/spells.\n\r", ranking[3], get_tier_name(2), get_mastery_name(3), get_tier_name(3));
            }
            if (ranking[4] > 0)
            {
               ch_printf(ch, "It will take (-%d-) %s skills/spells at %s to learn %s skills/spells.\n\r", ranking[4], get_tier_name(3), get_mastery_name(4), get_tier_name(4));
            }
            return;
         }
      }
   }
   if (!str_cmp(arg, "webprint"))
   {
      FILE *fp;
      char wbuf[MSL];
      char abuf[MSL];
      char filename[MSL];
      sprintf(filename, SKILLOUT_FILE);
      if ((fp = fopen(filename, "w")) == NULL)
      {
         send_to_char("Cannot write to the webhelp file.\n\r", ch);
         return;
      }
      global_skillcount = 0;
      sprintf(wbuf, "<html>\n<head>\n<title>Skill and Spell Groups</title>\n</head>\n<body text=white bgcolor=\"#000000\" link=\"#00FF00\" vlink=\"#00FFFF\">\n");
      for (sn = 0; sn < top_sn && skill_table[sn] && skill_table[sn]->name; sn++)
      {
         if (skill_table[sn]->group[0] > 0)
         {
            if (sbuf[skill_table[sn]->stype] == 0) //Sphere hasn't appeared yet
            {
               sprintf(abuf, "<table width=600><tr><td><center><font color=red>%s</font></center></td></tr></table><p>\n<table width=600><tr>", get_sphere_name(skill_table[sn]->stype));
               strcat(wbuf, abuf);
               csn = sn;
               for (sn = csn; sn < top_sn && skill_table[sn] && skill_table[sn]->name; sn++)
               {
                  if (gbuf[skill_table[sn]->group[0]] == 0 && skill_table[sn]->stype == skill_table[csn]->stype)
                  {                     
                     if (col++ % 3 == 0)
                     {
                        strcat(wbuf, "</tr>\n<tr>");
                     }
                     sprintf(abuf, "<td width=200><a href=\"%s%s.htm\">%s</a></td>", get_group_name(skill_table[sn]->group[0]),
                     get_sphere_name(skill_table[sn]->stype), get_group_name(skill_table[sn]->group[0]));
                     strcat(wbuf, abuf);
                     gbuf[skill_table[sn]->group[0]] = 1;
                     generate_group_files(ch, sn);
                  }
               }
               sn = csn;
               sbuf[skill_table[sn]->stype] = 1;
               for (y = 1; y < MAX_GROUP; y++)
                  gbuf[y] = 0;
               col = 0;
               strcat(wbuf, "</tr></table><p>\n");
            }
         }
      }
      sprintf(abuf, "<br>%d Total Skill/Spells available<br><a href=\"/\">Back to Rafermand website</a>", global_skillcount);
      strcat(wbuf, abuf);
      col = 0;
      for (x = 0;;x++)
      {
         if (wbuf[x] != '\0')
            putc(wbuf[x], fp);
         else
            break;
      }
      fclose(fp);
      send_to_char("Done.\n\r", ch);
      return;
   }
   if (!str_cmp(arg, "allgroups"))
   {
      send_to_char("Your available groups are...\n\r\n\r", ch);
      for (sn = 0; sn < top_sn && skill_table[sn] && skill_table[sn]->name; sn++)
      {
         if (skill_table[sn]->group[0] > 0)
         {
            if (sbuf[skill_table[sn]->stype] == 0) //Sphere hasn't appeared yet
            {
               ch_printf(ch, "\n\r                              &R%s&C                              \n\r", get_sphere_name(skill_table[sn]->stype));
               csn = sn;
               for (sn = csn; sn < top_sn && skill_table[sn] && skill_table[sn]->name; sn++)
               {
                  if (gbuf[skill_table[sn]->group[0]] == 0 && skill_table[sn]->stype == skill_table[csn]->stype)
                  {                     
                     if (col++ % 3 == 0)
                        send_to_char("\n\r", ch);
                     sprintf(buf, MXPFTAG("Listgroups '%s'", "%s", "/Listgroups") "%s", 
                        get_group_name(skill_table[sn]->group[0]), get_group_name(skill_table[sn]->group[0]), 
                        add_space(strlen(get_group_name(skill_table[sn]->group[0])), 24));
                     //sprintf(buf, "%-24s  ", get_group_name(skill_table[sn]->group[0]));
                     send_to_char(buf, ch);
                        gbuf[skill_table[sn]->group[0]] = 1;
                  }
               }
               sn = csn;
               sbuf[skill_table[sn]->stype] = 1;
               for (y = 1; y < MAX_GROUP; y++)
                  gbuf[y] = 0;
               col = 0;
               send_to_char("\n\r", ch);
            }
         }
      }
      if (col % 3 != 0)
         send_to_char("\n\r", ch);
      col = 0;
      set_char_color(AT_MAGIC, ch);
      send_to_char("\n\r\n\rYour available solo skills are...\n\r\n\r", ch);
      for (sn = 0; sn < top_sn && skill_table[sn] && skill_table[sn]->name; sn++)
      {
         if (skill_table[sn]->group[0] == 0 && skill_table[sn]->type == SKILL_SKILL)
         {
            sprintf(buf, "&c%-24s  ", skill_table[sn]->name);
            send_to_char(buf, ch);
            if (++col % 3 == 0)
               send_to_char("\n\r", ch);
         }
      }
      if (col % 3 != 0)
         send_to_char("\n\r", ch);
      return;
   }
   for (sn = 0; sn < top_sn && skill_table[sn] && skill_table[sn]->name; sn++)
   {
      if (!str_cmp(arg, skill_table[sn]->name))
      {
         if (skill_table[sn]->group[0] == 0)
         {
            sprintf(buf, "%s is a stand alone skill.\n\r", skill_table[sn]->name);
            send_to_char(buf, ch);
            return;
         }
         else
         {
            sprintf(buf2, MXPFTAG("Command 'listgroups \"%s\"' desc='Click here to view other skills/spells in this sphere'", "%s", "/Command"),
               get_group_name(skill_table[sn]->group[0]), get_group_name(skill_table[sn]->group[0]));
            sprintf(buf, "%s belongs to group %s sphere %s\n\r", skill_table[sn]->name, buf2, get_sphere_name(skill_table[sn]->stype));
            send_to_char(buf, ch);
            return;
         }
      }
   }
   if ((group = isgroup(arg)) != -1)
   {
      y = 0;
      for (y = 1; y <= MAX_SPHERE; y++)
         sbuf[y] = 0;

      for (sn = 0; sn < top_sn && skill_table[sn] && skill_table[sn]->name; sn++)
      {
         if (skill_table[sn]->group[0] == group)
         {
            if (sbuf[skill_table[sn]->stype] == 0) //Sphere not used
            {
               csn = sn;
               ch_printf(ch, "\n\r                              &R%s&C                              \n\r", get_sphere_name(skill_table[sn]->stype));
               for (x = 1; x <= 4; x++)
               {
                  for (sn = csn; sn < top_sn && skill_table[sn] && skill_table[sn]->name; sn++)
                  {
                     if (skill_table[sn]->group[0] == group && skill_table[sn]->stype == skill_table[csn]->stype 
                     &&  skill_table[sn]->masterydiff[0] == x)
                     {
                        y++;
                        if (y == 1)
                        {
                           send_to_char("\n\r\n\r", ch);
                        }
                         sprintf(buf2, MXPFTAG("Command 'help \"%s\"' desc='Click here to view a helpfile for the following skill/spell'", "%s", "/Command") "%s",
                            skill_table[sn]->name, skill_table[sn]->name, add_space(strlen(skill_table[sn]->name), 30));
                        sprintf(buf, "       %s%-30s%s", mastery_diffcolor(sn, 0), buf2, char_color_str(AT_MAGIC, ch));
                        send_to_char(buf, ch);
                        if (++col % 2 == 0)
                           send_to_char("\n\r", ch);
                     }
                  }
               }
               sn = csn;
               if (col % 2 != 0)
                  send_to_char("\n\r", ch);
               col = 0;
               sbuf[skill_table[sn]->stype] = 1;
            }
         }
      }
      if (col != 0 && y > 0)
      {
         send_to_char("\n\r", ch);
      }
      if (y == 0)
      {
         send_to_char("You have no skills in that particular group.\n\r", ch);
         bug("%d group has no skills", group);
      }
      return;
   }
   do_listgroups(ch, "");
   return;
}

//Start time parsing functions :-)
int getmin(void) //Gets the minutes 0 - 59
{
   int min;
   int difftime;

   difftime = time(0) - sysdata.start_calender;
   
   min = (difftime / cvttime(90));
   min = difftime - (min * cvttime(90));
   min = min * 10 / (cvttime(15));
   return min;
}
int gethour(void) //Gets the hours 0 - 23
{
   int hour;
   int difftime;

   difftime = time(0) - sysdata.start_calender;
   hour = (difftime / cvttime(2160));
   hour = difftime - (hour * cvttime(2160));
   hour = hour / (cvttime(2160) / 24);
   return hour;
}
int getday(void) //Gets the days 0 - 359
{
   int day;
   int difftime;

   difftime = time(0) - sysdata.start_calender;
   day = (difftime / cvttime(777600));
   day = difftime - (day * cvttime(777600));
   day = day / (cvttime(777600) / 360);
   return day;
}
int getyear(void) //Gets the year 0+
{
   int difftime;

   difftime = time(0) - sysdata.start_calender;
   return (difftime / cvttime(777600));
}
int getdayofmonth(int day) //Parses a day into a day in a month 1 - 30
{
   int eday;

   eday = (day / 30);
   eday = day - (eday * 30);
   return eday + 1;
}
int get_value_month(void) //Gets the day of the month
{
   return (getday()/30)+1;
}
   
char *getmonth(int day) //Gets a valid name of a month
{
   int month;

   month = day / 30;
   if (month == 0)
      return "Jan";
   if (month == 1)
      return "Feb";
   if (month == 2)
      return "Mar";
   if (month == 3)
      return "Apr";
   if (month == 4)
      return "May";
   if (month == 5)
      return "Jun";
   if (month == 6)
      return "Jul";
   if (month == 7)
      return "Aug";
   if (month == 8)
      return "Sep";
   if (month == 9)
      return "Oct";
   if (month == 10)
      return "Nov";
   if (month == 11)
      return "Dec";

   return "Unk";
}

int get12hour(int hour) //Returns the hour in 12 hour format
{
   int ehour;

   ehour = hour;

   if (ehour > 11)
      ehour = ehour - 12;

   if (ehour == 0)
      ehour = 12;

   return ehour;
}

char *getampm(int hour) //Returns AM or PM
{
   if (hour >= 0 && hour <= 11)
      return "AM";
   else if (hour >= 12 && hour <= 23)
      return "PM";
   else
      return "AM";
}

char *getdayofweek(void) //Returns Mon, etc
{
   int day;
   int lday;
   int difftime;

   difftime = time(0) - sysdata.start_calender;
   day = (difftime / cvttime(2160));
   lday = day / 7;
   day = day - (lday * 7);
   if (day == 0)
      return "Sun";
   if (day == 1)
      return "Mon";
   if (day == 2)
      return "Tue";
   if (day == 3)
      return "Wed";
   if (day == 4)
      return "Thu";
   if (day == 5)
      return "Fri";
   if (day == 6)
      return "Sat";

   return "Sun";
}


/*
 * Actual Game time for Rafermand.  Keeps track of how much time has passed
 */
char *getgametime(void)
{
   int min;
   int hour;
   int day;
   int year;
   char month[10];
   char dayofweek[10];
   char ampm[10];
   char buf[MSL];
   char *rptr;

   min = hour = day = year = 0;


   /* 60 - min 3600 - hour  86400 - day  31,536,000 - year (RL)
      Game Time - Normal
      90 - hour 2160 - day  64,800 - month 777600 - year
      1.5 min - 1 hour 36 min - 1 day  18 hours - 1 month  9 days - 1 year 
      Game Time - Reset Game
      30 - hour 720 - day  21,600 - month 259200 - year
      .5 min - 1 hour 12 min - 1 day  6 hours - 1 month  3 days - 1 year 
      */

   min = getmin();
   hour = gethour();
   day = getday();
   year = getyear();
   sprintf(ampm, "%s", getampm(hour));
   sprintf(month, "%s", getmonth(day));
   day = getdayofmonth(day);
   hour = get12hour(hour);
   sprintf(dayofweek, "%s", getdayofweek());

   sprintf(buf, "The Gametime is:          %s %s %2.2d %2.2d:%2.2d %s %d", dayofweek, month, day, hour, min, ampm, 1000 + year);
   rptr = buf;
   return rptr;
}

/*
 * Some increasingly freaky hallucinated objects		-Thoric
 * (Hats off to Albert Hoffman's "problem child")
 */
char *hallucinated_object(int ms, bool fShort)
{
   int sms = URANGE(1, (ms + 10) / 5, 20);

   if (fShort)
      switch (number_range(6 - URANGE(1, sms / 2, 5), sms))
      {
         case 1:
            return "a sword";
         case 2:
            return "a stick";
         case 3:
            return "something shiny";
         case 4:
            return "something";
         case 5:
            return "something interesting";
         case 6:
            return "something colorful";
         case 7:
            return "something that looks cool";
         case 8:
            return "a nifty thing";
         case 9:
            return "a cloak of flowing colors";
         case 10:
            return "a mystical flaming sword";
         case 11:
            return "a swarm of insects";
         case 12:
            return "a deathbane";
         case 13:
            return "a figment of your imagination";
         case 14:
            return "your gravestone";
         case 15:
            return "the long lost boots of Ranger Qutius";
         case 16:
            return "a glowing tome of arcane knowledge";
         case 17:
            return "a long sought secret";
         case 18:
            return "the meaning of it all";
         case 19:
            return "the answer";
         case 20:
            return "the key to life, the universe and everything";
      }
   switch (number_range(6 - URANGE(1, sms / 2, 5), sms))
   {
      case 1:
         return "A nice looking sword catches your eye.";
      case 2:
         return "The ground is covered in small sticks.";
      case 3:
         return "Something shiny catches your eye.";
      case 4:
         return "Something catches your attention.";
      case 5:
         return "Something interesting catches your eye.";
      case 6:
         return "Something colorful flows by.";
      case 7:
         return "Something that looks cool calls out to you.";
      case 8:
         return "A nifty thing of great importance stands here.";
      case 9:
         return "A cloak of flowing colors asks you to wear it.";
      case 10:
         return "A mystical flaming sword awaits your grasp.";
      case 11:
         return "A swarm of insects buzzes in your face!";
      case 12:
         return "The extremely rare Deathbane lies at your feet.";
      case 13:
         return "A figment of your imagination is at your command.";
      case 14:
         return "You notice a gravestone here... upon closer examination, it reads your name.";
      case 15:
         return "The long lost boots of Ranger Qutius lie off to the side.";
      case 16:
         return "A glowing tome of arcane knowledge hovers in the air before you.";
      case 17:
         return "A long sought secret of all mankind is now clear to you.";
      case 18:
         return "The meaning of it all, so simple, so clear... of course!";
      case 19:
         return "The answer.  One.  It's always been One.";
      case 20:
         return "The key to life, the universe and everything awaits your hand.";
   }
   return "Whoa!!!";
}


/*
 * Show a list to a character.
 * Can coalesce duplicated items.
 */
//list_to_char just pumps it into list_to_char_type, it will take an option item type for use...
void show_list_to_char_type(OBJ_DATA * list, CHAR_DATA * ch, bool fShort, bool fShowNothing, int itemtype, const int iDefaultAction)
{
   char **prgpstrShow;
   char **prgpstrName;        /* for MXP */
   char **prgpstrShortName;   /* for MXP */
   int *prgnShow;
   int *pitShow;
   char *pstrShow;
   char *pstrName;            /* for MXP */
   char *pstrShortName;       /* for MXP */
   OBJ_DATA *obj;
   int nShow;
   int iShow;
   int type = 0;
   int count, offcount, tmp, ms, cnt;
   bool fCombine;
   char * pAction = NULL;

   if (!ch->desc)
      return;

   if (itemtype > 0)
      type = 1;


   /*
    * if there's no list... then don't do all this crap!  -Thoric
    */
   if (!list)
   {
      if (fShowNothing)
      {
         if (IS_NPC(ch) || xIS_SET(ch->act, PLR_COMBINE))
            send_to_char("     ", ch);
         set_char_color(AT_OBJECT, ch);
         send_to_char("Nothing.\n\r", ch);
      }
      return;
   }
   
   /* work out which MXP tag to use */ 
   switch (iDefaultAction)
   {
      case eItemGet:  pAction = "Get"; break;   /* item on ground */
      case eItemDrop: pAction = "Drop"; break;   /* item in inventory */
      case eItemBid:  pAction = "Bid"; break;   /* auction item */
   } /* end of switch on action */

   /*
    * Alloc space for output lines.
    */
   count = 0;
   for (obj = list; obj; obj = obj->next_content)
   {
      if (IS_ONMAP_FLAG(ch) || IS_OBJ_STAT(obj, ITEM_ONMAP))
      {
         if (obj->map != ch->map || obj->coord->x != ch->coord->x || obj->coord->y != ch->coord->y)
            continue;
      }
      count++;
   }

   ms = (ch->mental_state ? ch->mental_state : 1)
      * (IS_NPC(ch) ? 1 : (ch->pcdata->condition[COND_DRUNK] ? (ch->pcdata->condition[COND_DRUNK] / 12) : 1));

   /*
    * If not mentally stable...
    */
   if (abs(ms) > 40)
   {
      offcount = URANGE(-(count), (count * ms) / 100, count * 2);
      if (offcount < 0)
         offcount += number_range(0, abs(offcount));
      else if (offcount > 0)
         offcount -= number_range(0, offcount);
   }
   else
      offcount = 0;

   if (count + offcount <= 0)
   {
      if (fShowNothing)
      {
         if (IS_NPC(ch) || xIS_SET(ch->act, PLR_COMBINE))
            send_to_char("     ", ch);
         set_char_color(AT_OBJECT, ch);
         send_to_char("Nothing.\n\r", ch);
      }
      return;
   }

   CREATE(prgpstrShow, char *, count + ((offcount > 0) ? offcount : 0));
   CREATE( prgpstrName,	char*,	count + ((offcount > 0) ? offcount : 0) );
   CREATE( prgpstrShortName,	char*,	count + ((offcount > 0) ? offcount : 0) );
   CREATE(prgnShow, int, count + ((offcount > 0) ? offcount : 0));
   CREATE(pitShow, int, count + ((offcount > 0) ? offcount : 0));

   nShow = 0;
   tmp = (offcount > 0) ? offcount : 0;
   cnt = 0;

   /*
    * Format the list of objects.
    */
   for (obj = list; obj; obj = obj->next_content)
   {
      if (offcount < 0 && ++cnt > (count + offcount))
         break;

      if (IS_ONMAP_FLAG(ch) || IS_OBJ_STAT(obj, ITEM_ONMAP))
      {
         if (obj->map != ch->map || obj->coord->x != ch->coord->x || obj->coord->y != ch->coord->y)
            continue;
      }
      if (type == 1) // For Examine, will only show a certain itemtype if prompted
      {
         if (obj->item_type != itemtype)
            continue;
      }
      if (tmp > 0 && number_bits(1) == 0)
      {
         prgpstrShow[nShow] = str_dup(hallucinated_object(ms, fShort));
         prgpstrName [nShow] = str_dup( hallucinated_object(ms, TRUE) );
         prgpstrShortName [nShow] = str_dup( hallucinated_object(ms, TRUE) );
         prgnShow[nShow] = 1;
         pitShow[nShow] = number_range(ITEM_LIGHT, ITEM_BOOK);
         nShow++;
         --tmp;
      }
      if (obj->wear_loc == WEAR_NONE && can_see_obj(ch, obj) && (obj->item_type != ITEM_TRAP || IS_AFFECTED(ch, AFF_DETECTTRAPS)))
      {
         pstrShow = format_obj_to_char(obj, ch, fShort, TRUE);
         pstrName = obj->name;
         pstrShortName = obj->short_descr;
         fCombine = FALSE;

         if (IS_NPC(ch) || xIS_SET(ch->act, PLR_COMBINE))
         {
            /*
             * Look for duplicates, case sensitive.
             * Matches tend to be near end so run loop backwords.
             */
            for (iShow = nShow - 1; iShow >= 0; iShow--)
            {
               if (!strcmp(prgpstrShow[iShow], pstrShow))
               {
                  prgnShow[iShow] += obj->count;
                  fCombine = TRUE;
                  break;
               }
            }
         }

         pitShow[nShow] = obj->item_type;
         /*
          * Couldn't combine, or didn't want to.
          */
         if (!fCombine)
         {
            prgpstrShow[nShow] = str_dup(pstrShow);
            prgpstrName [nShow] = str_dup( pstrName );
      	    prgpstrShortName [nShow] = str_dup( pstrShortName );
            prgnShow[nShow] = obj->count;
            nShow++;
         }
         if (IS_ONMAP_FLAG(ch) || IS_OBJ_STAT(obj, ITEM_ONMAP))
         {
            if (obj->map != ch->map || obj->coord->x != ch->coord->x || obj->coord->y != ch->coord->y)
               continue;
         }
      }
   }
   if (tmp > 0)
   {
      int x;

      for (x = 0; x < tmp; x++)
      {
         prgpstrShow[nShow] = str_dup(hallucinated_object(ms, fShort));
         prgpstrName [nShow] = str_dup( hallucinated_object(ms, TRUE) );
         prgpstrShortName [nShow] = str_dup( hallucinated_object(ms, TRUE) );
         prgnShow[nShow] = 1;
         pitShow[nShow] = number_range(ITEM_LIGHT, ITEM_BOOK);
         nShow++;
      }
   }

   /*
    * Output the formatted list.  -Color support by Thoric
    */
   for (iShow = 0; iShow < nShow; iShow++)
   {
      switch (pitShow[iShow])
      {
         default:
            set_char_color(AT_OBJECT, ch);
            break;
         case ITEM_BLOOD:
            set_char_color(AT_BLOOD, ch);
            break;
         case ITEM_MONEY:
         case ITEM_TREASURE:
            set_char_color(AT_YELLOW, ch);
            break;
         case ITEM_COOK:
         case ITEM_FOOD:
            set_char_color(AT_HUNGRY, ch);
            break;
         case ITEM_DRINK_CON:
         case ITEM_FOUNTAIN:
            set_char_color(AT_THIRSTY, ch);
            break;
         case ITEM_FIRE:
            set_char_color(AT_FIRE, ch);
            break;
         case ITEM_SCROLL:
         case ITEM_WAND:
         case ITEM_STAFF:
         case ITEM_SPELLBOOK:
            set_char_color(AT_MAGIC, ch);
            break;
      }
      if (fShowNothing)
         send_to_char("     ", ch);
      if (pAction && ch->desc && ch->desc->mxp)
      {
         ch_printf (ch, MXPTAG ("%s '%s'"), pAction, prgpstrName[iShow]);   
      }
      send_to_char(prgpstrShow[iShow], ch);
      if (pAction && ch->desc && ch->desc->mxp)
         ch_printf (ch, MXPTAG ("/%s"), pAction);
/*	if ( IS_NPC(ch) || xIS_SET(ch->act, PLR_COMBINE) ) */
      {
         if (prgnShow[iShow] != 1)
            ch_printf(ch, " (%d)", prgnShow[iShow]);
      }

      send_to_char("\n\r", ch);
      DISPOSE(prgpstrShow[iShow]);
      if (prgpstrName[iShow])
         DISPOSE( prgpstrName[iShow] );
      if (prgpstrShortName[iShow])
         DISPOSE( prgpstrShortName[iShow] );
   }

   if (fShowNothing && nShow == 0)
   {
      if (IS_NPC(ch) || xIS_SET(ch->act, PLR_COMBINE))
         send_to_char("     ", ch);
      set_char_color(AT_OBJECT, ch);
      send_to_char("Nothing.\n\r", ch);
   }

   /*
    * Clean up.
    */
   DISPOSE(prgpstrShow);
   DISPOSE( prgpstrName );
   DISPOSE( prgpstrShortName );
   DISPOSE(prgnShow);
   DISPOSE(pitShow);
   return;
}

void show_list_to_char(OBJ_DATA * list, CHAR_DATA * ch, bool fShort, bool fShowNothing, const int iDefaultAction)
{
   show_list_to_char_type(list, ch, fShort, fShowNothing, 0, iDefaultAction);
   return;
}

/*
 * Show fancy descriptions for certain spell affects		-Thoric
 */
void show_visible_affects_to_char(CHAR_DATA * victim, CHAR_DATA * ch)
{
   char buf[MSL];
   char name[MSL];

   if (IS_NPC(victim))
      strcpy(name, victim->short_descr);
   else
      strcpy(name, PERS_MAP(victim, ch));
   name[0] = toupper(name[0]);

   if (IS_AFFECTED(victim, AFF_SANCTUARY))
   {
      set_char_color(AT_WHITE, ch);
      ch_printf(ch, "%s is shrouded in flowing shadow and light.\n\r", name);
   }
   if (IS_AFFECTED(victim, AFF_FIRESHIELD))
   {
      set_char_color(AT_FIRE, ch);
      ch_printf(ch, "%s is engulfed within a blaze of mystical flame.\n\r", name);
   }
   if (IS_AFFECTED(victim, AFF_SHOCKSHIELD))
   {
      set_char_color(AT_BLUE, ch);
      ch_printf(ch, "%s is surrounded by cascading torrents of energy.\n\r", name);
   }
/*Scryn 8/13*/
   if (IS_AFFECTED(victim, AFF_ICESHIELD))
   {
      set_char_color(AT_LBLUE, ch);
      ch_printf(ch, "%s is ensphered by shards of glistening ice.\n\r", name);
   }
   if (IS_AFFECTED(victim, AFF_CHARM) && !xIS_SET(victim->act, ACT_MOUNTABLE) && !xIS_SET(victim->act, ACT_PET))
   {
      set_char_color(AT_MAGIC, ch);
      ch_printf(ch, "%s wanders in a dazed, zombie-like state.\n\r", name);
   }
   if (!IS_NPC(victim) && !victim->desc && victim->switched && IS_AFFECTED(victim->switched, AFF_POSSESS))
   {
      set_char_color(AT_MAGIC, ch);
      strcpy(buf, PERS(victim, ch));
      strcat(buf, " appears to be in a deep trance...\n\r");
   }
}

void show_char_to_char_0(CHAR_DATA * victim, CHAR_DATA * ch)
{
   char buf[MSL];
   char buf1[MSL];
   char message[MSL];

   buf[0] = '\0';

   set_char_color(AT_PERSON, ch);
   if (!IS_NPC(victim) && !victim->desc)
   {
      if (!victim->switched)
         send_to_char_color("&P[(Link Dead)] ", ch);
      else if (!IS_AFFECTED(victim, AFF_POSSESS))
         strcat(buf, "(Switched) ");
   }
   if (IS_NPC(victim) && IS_AFFECTED(victim, AFF_POSSESS) && IS_IMMORTAL(ch) && victim->desc)
   {
      sprintf(buf1, "(%s)", PERS_MAP(victim->desc->original, ch));
      strcat(buf, buf1);
   }
   if (sysdata.resetgame && !IS_NPC(victim) && !get_wear_hidden_cloak(victim))
   {
      sprintf(buf1, "&w&R[%d] %s", get_player_statlevel(victim), char_color_str(AT_PERSON, ch));
      strcat(buf, buf1);
   }
   if (!IS_NPC(victim) && !xIS_SET(victim->act, PLR_SHOWASIMM) && xIS_SET(ch->act, PLR_SHOWPC))
      strcat(buf, "[PC] ");
   if (!IS_NPC(victim) && xIS_SET(victim->act, PLR_SHOWASIMM))
      strcat(buf, "[IMM] ");
   if (!IS_NPC(victim) && xIS_SET(victim->act, PLR_AFK))
      strcat(buf, "[AFK] ");

   if (!IS_NPC(victim) && !xIS_SET(victim->act, PLR_AFK) && xIS_SET(victim->act, PLR_AWAY))
      strcat(buf, "[AWAY] ");

   if ((!IS_NPC(victim) && xIS_SET(victim->act, PLR_WIZINVIS)) || (IS_NPC(victim) && xIS_SET(victim->act, ACT_MOBINVIS)))
   {
      if (!IS_NPC(victim))
         sprintf(buf1, "(Invis %d) ", victim->pcdata->wizinvis);
      else
         sprintf(buf1, "(Mobinvis %d) ", victim->mobinvis);
      strcat(buf, buf1);
   }
   if (IS_NPC(victim) && xIS_SET(victim->act, ACT_FORGEMOB))
   {
      sprintf(buf1, "&G&W[" MXPFTAG("Command 'forge list' desc='Click here to get a forge list'", "FORGE", "/Command") "] %s",
         char_color_str(AT_PERSON, ch));
      strcat(buf, buf1);
   }
   if (IS_NPC(victim) && xIS_SET(victim->act, ACT_TRAINER))
   {
      sprintf(buf1, "&G&W[" MXPFTAG("Command 'learn \"%s\"' desc='Click here to see what %s Teaches'", "TRAINER", "/Command") "] %s", 
      victim->name, victim->name, char_color_str(AT_PERSON, ch));
      strcat(buf, buf1);
   }
   if (IS_NPC(victim) && xIS_SET(victim->act, ACT_SBSELLER)) 
   {
      sprintf(buf1, "&G&W[" MXPFTAG("Command 'sbook list' desc='Click here to get a list of spellbooks from %s'", "SPELLBOOKS", "/Command") "] %s", 
      victim->name, char_color_str(AT_PERSON, ch));
      strcat(buf, buf1);
   }
   if (IS_NPC(victim) && xIS_SET(victim->act, ACT_PRACTICE))
   {
      sprintf(buf1, "&G&W[PRACTICE] %s", char_color_str(AT_PERSON, ch));
      strcat(buf, buf1);
   }
   if (IS_NPC(victim) && IS_IMMORTAL(ch) && !IS_NPC(ch) && xIS_SET(victim->act, ACT_NORESET))
   {
      sprintf(buf1, "&G&W[ONE RESET] %s", char_color_str(AT_PERSON, ch));
      strcat(buf, buf1);
   }
   if (IS_NPC(victim) && IS_IMMORTAL(ch) && !IS_NPC(ch) && xIS_SET(victim->act, ACT_TIMERESET))
   {
      sprintf(buf1, "&G&W[TIMERESET] %s", char_color_str(AT_PERSON, ch));
      strcat(buf, buf1);
   }
   if (IS_NPC(victim) && xIS_SET(victim->act, ACT_EXTRACTMOB))
   {
      if (IS_NPC(victim) && xIS_SET(victim->act, ACT_EXTRACTGOODS))
      {
         sprintf(buf1, "&w&C[EXTRACTING] %s", char_color_str(AT_PERSON, ch));
         strcat(buf, buf1);
      }
      else if (IS_NPC(victim) && xIS_SET(victim->act, ACT_DUMPGOODS))
      {
         sprintf(buf1, "&w&c[DUMPING] %s", char_color_str(AT_PERSON, ch));
         strcat(buf, buf1);
      }
      else
      {
         sprintf(buf1, "&c&w[PLANNING] %s", char_color_str(AT_PERSON, ch));
         strcat(buf, buf1);
      }
   }
   if (IS_NPC(victim) && xIS_SET(victim->act, ACT_QUESTMOB))
   {
      sprintf(buf1, "&w&W[QUESTGIVER] %s", char_color_str(AT_PERSON, ch));
      strcat(buf, buf1);
   }
   if (IS_NPC(victim) && xIS_SET(victim->act, ACT_CAPTAIN))
   {
      sprintf(buf1, "&w&C[CAPTAIN] %s", char_color_str(AT_PERSON, ch));
      strcat(buf, buf1);
   }
   if (IS_NPC(victim) && xIS_SET(victim->act, ACT_BOSS))
   {
      sprintf(buf1, "&w&R[BOSS] %s", char_color_str(AT_PERSON, ch));
      strcat(buf, buf1);
   }
/*
   if (!IS_NPC(victim))
   {
      if (victim->pcdata->caste == 1)
         strcat(buf, "&Y(Serf)&P ");
      else if (victim->pcdata->caste == 2)
         strcat(buf, "&Y(Peasant)&P ");
      else if (victim->pcdata->caste == 3)
         strcat(buf, "&Y(Laborer)&P ");
      else if (victim->pcdata->caste == 4)
         strcat(buf, "&Y(Apprentice)&P ");
      else if (victim->pcdata->caste == 5)
         strcat(buf, "&Y(Journeymen)&P ");
      else if (victim->pcdata->caste == 6)
         strcat(buf, "&Y(Master)&P ");
      else if (victim->pcdata->caste == 7)
         strcat(buf, "&Y(Merchant)&P ");
      else if (victim->pcdata->caste == 8)
         strcat(buf, "&Y(Trader)&P ");
      else if (victim->pcdata->caste == 9 && victim->sex == 0)
         strcat(buf, "&Y(Businessman)&P ");
      else if (victim->pcdata->caste == 9 && victim->sex == 1)
         strcat(buf, "&Y(Businessman)&P ");
      else if (victim->pcdata->caste == 9 && victim->sex == 2)
         strcat(buf, "&Y(Businesswoman)&P ");
      else if (victim->pcdata->caste == 10)
         strcat(buf, "&Y(Mayor)&P ");

      else if (victim->pcdata->caste == 11)
         strcat(buf, "&P(Page)&P ");
      else if (victim->pcdata->caste == 12)
         strcat(buf, "&P(Squire)&P ");
      else if (victim->pcdata->caste == 13)
         strcat(buf, "&P(Knight)&P ");
      else if (victim->pcdata->caste == 14)
         strcat(buf, "&P(Baronet)&P ");
      else if (victim->pcdata->caste == 15)
         strcat(buf, "&P(Baron)&P ");
      else if (victim->pcdata->caste == 16)
         strcat(buf, "&P(Earl)&P ");
      else if (victim->pcdata->caste == 17)
         strcat(buf, "&P(Viscount)&P ");
      else if (victim->pcdata->caste == 18)
         strcat(buf, "&P(Count)&P ");
      else if (victim->pcdata->caste == 19)
         strcat(buf, "&P(Duke)&P ");
      else if (victim->pcdata->caste == 20)
         strcat(buf, "&P(Marquis)&P ");

      else if (victim->pcdata->caste == 21)
         strcat(buf, "&C(Vassal)&P ");
      else if (victim->pcdata->caste == 22)
         strcat(buf, "&C(Lord-Vassal)&P ");
      else if (victim->pcdata->caste == 23)
         strcat(buf, "&C(Lord)&P ");
      else if (victim->pcdata->caste == 24)
         strcat(buf, "&C(Hi-Lord)&P ");
      else if (victim->pcdata->caste == 25)
         strcat(buf, "&C(Captain)&P ");
      else if (victim->pcdata->caste == 26)
         strcat(buf, "&C(Minister)&P ");
      else if (victim->pcdata->caste == 27 && victim->sex == 0)
         strcat(buf, "&C(Prince)&P ");
      else if (victim->pcdata->caste == 27 && victim->sex == 1)
         strcat(buf, "&C(Prince)&P ");
      else if (victim->pcdata->caste == 27 && victim->sex == 2)
         strcat(buf, "&C(Princess)&P ");
      else if (victim->pcdata->caste == 28 && victim->sex == 0)
         strcat(buf, "&C(King)&P ");
      else if (victim->pcdata->caste == 28 && victim->sex == 1)
         strcat(buf, "&C(King)&P ");
      else if (victim->pcdata->caste == 28 && victim->sex == 2)
         strcat(buf, "&C(Queen)&P ");
      else if (victim->pcdata->caste == 29)
         strcat(buf, "&O(Avatar)&P ");
      else if (victim->pcdata->caste == 30)
         strcat(buf, "&O(Legend)&P ");

      else if (victim->pcdata->caste == 31)
         strcat(buf, "&G&W(Ascender)&P ");
      else if (victim->pcdata->caste == 32)
         strcat(buf, "&G&W(Immortal)&P ");
      else if (victim->pcdata->caste == 33)
         strcat(buf, "&G&W(God)&P ");
      else if (victim->pcdata->caste == 34)
         strcat(buf, "&G&W(Staff)&P ");
      else if (victim->pcdata->caste == 35)
         strcat(buf, "&G&W(Admin)&P ");
      else
         strcat(buf, "&r(Casteless)&P ");
   }
*/

   if (!IS_NPC(victim)
      && victim->pcdata->clan
      && victim->pcdata->clan->badge && (victim->pcdata->clan->clan_type != CLAN_ORDER && victim->pcdata->clan->clan_type != CLAN_GUILD))
      ch_printf_color(ch, "%s ", victim->pcdata->clan->badge);
   else
      set_char_color(AT_PERSON, ch);

   if (IS_AFFECTED(victim, AFF_INVISIBLE))
      strcat(buf, "(Invis) ");
   if (IS_AFFECTED(victim, AFF_HIDE))
      strcat(buf, "(Hide) ");
   if (IS_AFFECTED(victim, AFF_STALK))
      strcat(buf, "(Stalking) ");
   if (IS_AFFECTED(victim, AFF_PASS_DOOR))
      strcat(buf, "(Translucent) ");
   if (IS_AFFECTED(victim, AFF_FAERIE_FIRE))
      strcat(buf, "(Pink Aura) ");


   if (IS_AFFECTED(victim, AFF_BERSERK))
      strcat(buf, "(Wild-eyed) ");
   if (!IS_NPC(victim) && xIS_SET(victim->act, PLR_ATTACKER))
      strcat(buf, "(ATTACKER) ");
   if (!IS_NPC(victim) && xIS_SET(victim->act, PLR_KILLER))
      strcat(buf, "(KILLER) ");
   if (!IS_NPC(victim) && xIS_SET(victim->act, PLR_THIEF))
      strcat(buf, "(THIEF) ");
   if (!IS_NPC(victim) && xIS_SET(victim->act, PLR_LITTERBUG))
      strcat(buf, "(LITTERBUG) ");
   if (IS_NPC(victim) && IS_IMMORTAL(ch) && xIS_SET(victim->act, ACT_PROTOTYPE))
      strcat(buf, "(PROTO) ");
   if (IS_NPC(victim) && ch->mount && ch->mount == victim && ch->in_room == ch->mount->in_room)
      strcat(buf, "(Mount) ");
   if (victim->desc && victim->desc->connected == CON_EDITING)
      strcat(buf, "(Writing) ");
   if (victim->morph != NULL)
      strcat(buf, "(Morphed) ");

   set_char_color(AT_PERSON, ch);
   if ((victim->position == victim->defposition && victim->long_descr[0] != '\0')
      || (victim->morph && victim->morph->morph && victim->morph->morph->defpos == victim->position))
   {
      if (victim->morph != NULL)
      {
         if (!IS_IMMORTAL(ch))
         {
            if (victim->morph->morph != NULL)
               strcat(buf, victim->morph->morph->long_desc);
            else
               strcat(buf, victim->long_descr);
         }
         else
         {
            strcat(buf, PERS(victim, ch));
            if (!IS_NPC(victim) && !xIS_SET(ch->act, PLR_BRIEF))
               strcat(buf, show_pers_title(victim, ch));
            strcat(buf, ".\n\r");
         }
      }
      else
      {
         if (ch->desc && ch->desc->mxp)
            sprintf(buf1, MXPFTAG("Mobile '%s' desc='%s'", "%s", "/Mobile"), victim->name, victim->short_descr, victim->long_descr);
         else
            sprintf(buf1, "%s", victim->long_descr);
         strcat(buf, buf1);
      }
      send_to_char(buf, ch);
      show_visible_affects_to_char(victim, ch);
      return;
   }
   else
   {
      if (victim->morph != NULL && victim->morph->morph != NULL && !IS_IMMORTAL(ch))
         strcat(buf, MORPHPERS(victim, ch));
        
      sprintf(buf1, MXPFTAG("Look '%s' desc='%s'", "%s", "/Look"), PERS(victim, ch), PERS(victim, ch), PERS(victim, ch));
      strcat(buf, buf1);
   }

   if (!IS_NPC(victim) && !xIS_SET(ch->act, PLR_BRIEF))
      strcat(buf, show_pers_title(victim, ch));

   switch (victim->position)
   {
      case POS_DEAD:
         strcat(buf, "&P is DEAD!!&G");
         break;
      case POS_MORTAL:
         strcat(buf, "&P is mortally wounded.&G");
         break;
      case POS_INCAP:
         strcat(buf, "&P is incapacitated.&G");
         break;
      case POS_STUNNED:
         strcat(buf, "&P is lying here stunned.&G");
         break;
      case POS_SLEEPING:
         if (victim->on != NULL)
         {
            if (IS_SET(victim->on->value[2], SLEEP_AT))
            {
               sprintf(message, "&P is sleeping at %s.", victim->on->short_descr);
               strcat(buf, message);
            }
            else if (IS_SET(victim->on->value[2], SLEEP_ON))
            {
               sprintf(message, "&P is sleeping on %s.", victim->on->short_descr);
               strcat(buf, message);
            }
            else
            {
               sprintf(message, "&P is sleeping in %s.", victim->on->short_descr);
               strcat(buf, message);
            }
         }
         else
         {
            if (ch->position == POS_SITTING || ch->position == POS_RESTING)
               strcat(buf, "&P is sleeping nearby.&G");
            else
               strcat(buf, "&P is deep in slumber here.&G");
         }
         break;
      case POS_RESTING:
         if (victim->on != NULL)
         {
            if (IS_SET(victim->on->value[2], REST_AT))
            {
               sprintf(message, "&P is resting at %s.", victim->on->short_descr);
               strcat(buf, message);
            }
            else if (IS_SET(victim->on->value[2], REST_ON))
            {
               sprintf(message, "&P is resting on %s.", victim->on->short_descr);
               strcat(buf, message);
            }
            else
            {
               sprintf(message, "&P is resting in %s.", victim->on->short_descr);
               strcat(buf, message);
            }
         }
         else
         {
            if (ch->position == POS_RESTING)
               strcat(buf, "&P is sprawled out alongside you.&G");
            else if (ch->position == POS_MOUNTED)
               strcat(buf, "&P is sprawled out at the foot of your mount.&G");
            else
               strcat(buf, "&P is sprawled out here.&G");
         }
         break;
      case POS_SITTING:
         if (victim->on != NULL)
         {
            if (IS_SET(victim->on->value[2], SIT_AT))
            {
               sprintf(message, "&P is sitting at %s.", victim->on->short_descr);
               strcat(buf, message);
            }
            else if (IS_SET(victim->on->value[2], SIT_ON))
            {
               sprintf(message, "&P is sitting on %s.", victim->on->short_descr);
               strcat(buf, message);
            }
            else
            {
               sprintf(message, "&P is sitting in %s.", victim->on->short_descr);
               strcat(buf, message);
            }
         }
         else
            strcat(buf, "&P is sitting here.");
         break;
      case POS_STANDING:
         if (victim->on != NULL)
         {
            if (IS_SET(victim->on->value[2], STAND_AT))
            {
               sprintf(message, "&P is standing at %s", victim->on->short_descr);
               strcat(buf, message);
            }
            else if (IS_SET(victim->on->value[2], STAND_ON))
            {
               sprintf(message, "&P is standing on %s", victim->on->short_descr);
               strcat(buf, message);
            }
            else
            {
               sprintf(message, "&P is standing in %s", victim->on->short_descr);
               strcat(buf, message);
            }
         }
         else if (IS_IMMORTAL(victim))
            strcat(buf, "&P is here before you");
         else if ((victim->in_room->sector_type == SECT_UNDERWATER) && !IS_AFFECTED(victim, AFF_AQUA_BREATH) && !IS_NPC(victim))
            strcat(buf, "&P is drowning here");
         else if (victim->in_room->sector_type == SECT_UNDERWATER)
            strcat(buf, "&P is here in the water");
         else if ((victim->in_room->sector_type == SECT_OCEANFLOOR) && !IS_AFFECTED(victim, AFF_AQUA_BREATH) && !IS_NPC(victim))
            strcat(buf, "&P is drowning here");
         else if (victim->in_room->sector_type == SECT_OCEANFLOOR)
            strcat(buf, "&P is standing here in the water");
         else if (IS_AFFECTED(victim, AFF_FLOATING) || IS_AFFECTED(victim, AFF_FLYING))
            strcat(buf, "&P is hovering here");
         else
            strcat(buf, "&P is standing here");
         
         if (victim->rider)
         {
            sprintf(message, " with %s on %s back.&G", PERS(victim->rider, ch), victim->sex==1 ? "his" : "her");
            strcat(buf, message);
         }
         else
            strcat(buf, ".&G");
         break;
      case POS_SHOVE:
         strcat(buf, "&P is being shoved around.&G");
         break;
      case POS_DRAG:
         strcat(buf, "&P is being dragged around.&G");
         break;
      case POS_MOUNTED: case POS_RIDING:
         strcat(buf, "&P is here, upon &G");
         if (victim->riding)
         {
            sprintf(message, "&Pthe back of %s.", PERS(victim->riding, ch));
            strcat(buf, message);
         }
         else if (!victim->mount)
            strcat(buf, "&Pthin air???");
         else if (victim->mount == ch)
            strcat(buf, "&Pyour back.&G");
         else if (victim->in_room == victim->mount->in_room)
         {
            strcat(buf, PERS(victim->mount, ch));
            strcat(buf, ".");
         }
         else
            strcat(buf, "&Psomeone who left??&G");
         break;
      case POS_FIGHTING:
      case POS_EVASIVE:
      case POS_DEFENSIVE:
      case POS_AGGRESSIVE:
      case POS_BERSERK:
         strcat(buf, "&P is here, fighting &G");
         if (!victim->fighting)
         {
            strcat(buf, "&Pthin air???&G");

            /* some bug somewhere.... kinda hackey fix -h */
            if (!victim->mount)
               victim->position = POS_STANDING;
            else
               victim->position = POS_MOUNTED;
         }
         else if (who_fighting(victim) == ch)
            strcat(buf, "&PYOU!&G");
         else if (victim->in_room == victim->fighting->who->in_room)
         {
            strcat(buf, PERS(victim->fighting->who, ch));
            strcat(buf, ".");
         }
         else
            strcat(buf, "&Psomeone who left??&G");
         break;
   }

   strcat(buf, "\n\r");
   buf[0] = UPPER(buf[0]);
   send_to_char(buf, ch);
   show_visible_affects_to_char(victim, ch);
   return;
}



void show_char_to_char_1(CHAR_DATA * victim, CHAR_DATA * ch, int type)
{
   OBJ_DATA *obj;
   int iWear;
   bool found;
   sh_int mastery;
   OBJ_DATA *cloak;
   int cloaked = 0;

   mastery = POINT_LEVEL(LEARNED(ch, gsn_peek), MASTERED(ch, gsn_peek));

   if (IS_ONMAP_FLAG(ch))
   {
      if (victim->map != ch->map || victim->coord->x != ch->coord->x || victim->coord->y != ch->coord->y)
         return;
   }

   if (can_see(victim, ch) && !IS_NPC(ch) && ch->level < LEVEL_IMMORTAL && type == 0)
   {
      act(AT_ACTION, "$n looks at you.", ch, NULL, victim, TO_VICT);
      if (victim != ch)
         act(AT_ACTION, "$n looks at $N.", ch, NULL, victim, TO_NOTVICT);
      else
         act(AT_ACTION, "$n looks at $mself.", ch, NULL, victim, TO_NOTVICT);
   }

   if (!get_wear_hidden_cloak(victim) || (get_wear_hidden_cloak(victim) && ch == victim))
   {
      if (victim->description[0] != '\0')
      {
         if (victim->morph != NULL && victim->morph->morph != NULL)
         {
            send_to_char(victim->morph->morph->description, ch);
            set_char_color(AT_ACTION, ch);
         }
         else
         {
            send_to_char(victim->description, ch);
            set_char_color(AT_ACTION, ch);
         }
      }
      else
      {
         if (victim->morph != NULL && victim->morph->morph != NULL)
            send_to_char(victim->morph->morph->description, ch);
         else if (IS_NPC(victim))
            act(AT_PLAIN, "You see nothing special about $M.", ch, NULL, victim, TO_CHAR);
         else if (ch != victim)
            act(AT_PLAIN, "$E isn't much to look at...", ch, NULL, victim, TO_CHAR);
         else
            act(AT_PLAIN, "You're not much to look at...", ch, NULL, NULL, TO_CHAR);
      }
   }

   show_race_line(ch, victim);
   show_condition(ch, victim);
   
   if (IS_AFFECTED(victim, AFF_FLYING))
   {
      if (victim == ch)
         send_to_char("You are flying\n\r", ch);
      else
         act(AT_PLAIN, "$N is flying above your head", ch, NULL, victim, TO_CHAR);
   }
   if (type == 1)
      return;
   if ((cloak = get_wear_cloak(victim)) != NULL)
   {
      if (ch != victim)
         cloaked = 1;
   }   
   found = FALSE;
   for (iWear = 0; iWear < MAX_WEAR; iWear++)
   {
      if ((obj = get_eq_char(victim, iWear)) != NULL && can_see_obj(ch, obj))
      {
         if (IS_IMMORTAL(ch) || !cloaked || (cloaked && (IS_SET(obj->wear_flags, ITEM_WEAR_SHIELD) || IS_SET(obj->wear_flags, ITEM_WEAR_HEAD)
         ||  IS_SET(obj->wear_flags, ITEM_WIELD) || IS_SET(obj->wear_flags, ITEM_DUAL_WIELD)
         ||  IS_SET(obj->wear_flags, ITEM_MISSILE_WIELD) || IS_SET(obj->wear_flags, ITEM_LODGE_RIB)
         ||  IS_SET(obj->wear_flags, ITEM_LODGE_ARM) || IS_SET(obj->wear_flags, ITEM_LODGE_LEG)
         ||  IS_SET(obj->wear_flags, ITEM_WEAR_NOCKED) || IS_SET(obj->wear_flags, ITEM_WEAR_BACK))))
         {
            if (!found)
            {
               send_to_char("\n\r", ch);
               if (victim != ch)
                  act(AT_PLAIN, "$N is using:", ch, NULL, victim, TO_CHAR);
               else
                  act(AT_PLAIN, "You are using:", ch, NULL, NULL, TO_CHAR);
               found = TRUE;
            }
            send_to_char(where_name[iWear], ch);
            send_to_char(format_obj_to_char(obj, ch, TRUE, FALSE), ch);
            send_to_char("\n\r", ch);
            set_char_color(AT_ACTION, ch);
         }
      }
   }

   /*
    * Crash fix here by Thoric
    */
   if (IS_NPC(ch) || victim == ch)
      return;

   if (IS_IMMORTAL(ch))
   {
      if (IS_NPC(victim))
         ch_printf(ch, "\n\rMobile #%d '%s' ", victim->pIndexData->vnum, victim->name);
      else
         ch_printf(ch, "\n\r%s ", PERS(victim, ch));
      ch_printf(ch, "is a %s.\n\r",
         victim->race < max_npc_race && victim->race >= 0 ? print_npc_race(victim->race) : "unknown");
   }

   if (number_percent() < 40+(mastery) && MASTERED(ch, gsn_peek) > 0 && ch->pcdata->learned[gsn_peek] > 0)
   {
      ch_printf(ch, "\n\rYou peek at %s inventory:\n\r", victim->sex == 1 ? "his" : victim->sex == 2 ? "her" : "its");
      show_list_to_char(victim->first_carrying, ch, TRUE, TRUE, eItemNothing );
      learn_from_success(ch, gsn_peek, victim);
   }
   else if (ch->pcdata->learned[gsn_peek] > 0 && ch->pcdata->ranking[gsn_peek] > 0)
      learn_from_failure(ch, gsn_peek, victim);

   return;
}


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

   for (rch = list; rch; rch = rch->next_in_room)
   {
      if (rch == ch)
         continue;

      if (IS_ONMAP_FLAG(ch))
      {
         if (rch->map != ch->map || rch->coord->x != ch->coord->x || rch->coord->y != ch->coord->y)
            continue;
      }

      if (can_see(ch, rch))
      {
         show_char_to_char_0(rch, ch);
      }
      else if (room_is_dark(ch->in_room) && IS_AFFECTED(rch, AFF_INFRARED) && !(!IS_NPC(rch) && IS_IMMORTAL(rch)))
      {
         set_char_color(AT_BLOOD, ch);
         send_to_char("The red form of a living creature is here.\n\r", ch);
      }
   }

   return;
}



bool check_blind(CHAR_DATA * ch)
{
   if (!IS_NPC(ch) && xIS_SET(ch->act, PLR_HOLYLIGHT))
      return TRUE;

   if (IS_AFFECTED(ch, AFF_TRUESIGHT))
      return TRUE;

   if (IS_AFFECTED(ch, AFF_BLIND))
   {
      send_to_char("You can't see a thing!\n\r", ch);
      return FALSE;
   }

   return TRUE;
}

/*
 * Returns classical DIKU door direction based on text in arg	-Thoric
 */
int get_door(char *arg)
{
   int door;

   if (!str_cmp(arg, "n") || !str_cmp(arg, "north"))
      door = 0;
   else if (!str_cmp(arg, "e") || !str_cmp(arg, "east"))
      door = 1;
   else if (!str_cmp(arg, "s") || !str_cmp(arg, "south"))
      door = 2;
   else if (!str_cmp(arg, "w") || !str_cmp(arg, "west"))
      door = 3;
   else if (!str_cmp(arg, "u") || !str_cmp(arg, "up"))
      door = 4;
   else if (!str_cmp(arg, "d") || !str_cmp(arg, "down"))
      door = 5;
   else if (!str_cmp(arg, "ne") || !str_cmp(arg, "northeast") || !str_cmp(arg, "f"))
      door = 6;
   else if (!str_cmp(arg, "nw") || !str_cmp(arg, "northwest") || !str_cmp(arg, "g"))
      door = 7;
   else if (!str_cmp(arg, "se") || !str_cmp(arg, "southeast") || !str_cmp(arg, "h"))
      door = 8;
   else if (!str_cmp(arg, "sw") || !str_cmp(arg, "southwest") || !str_cmp(arg, "i"))
      door = 9;
   else
      door = -1;
   return door;
}

void do_showcontrol(CHAR_DATA *ch, char *argument)
{
   if (IS_ONMAP_FLAG(ch))
   {
      display_map(ch, -1, -1, 1);
      return;
   }
}

void do_look(CHAR_DATA * ch, char *argument)
{
   char arg[MIL];
   char arg1[MIL];
   char arg2[MIL];
   char arg3[MIL];
   EXIT_DATA *pexit;
   CHAR_DATA *victim;
   OBJ_DATA *obj;
   ROOM_INDEX_DATA *original;
   char *pdesc;
   bool doexaprog;
   sh_int door;
   int number, cnt;

   if (!ch->desc)
      return;
   if (ch->position < POS_SLEEPING)
   {
      send_to_char("You can't see anything but stars!\n\r", ch);
      return;
   }

   if (ch->position == POS_SLEEPING)
   {
      send_to_char("You can't see anything, you're sleeping!\n\r", ch);
      return;
   }
   if (!check_blind(ch))
      return;

   if (!IS_NPC(ch) && !xIS_SET(ch->act, PLR_HOLYLIGHT) && !IS_AFFECTED(ch, AFF_INFRARED) && !IS_AFFECTED(ch, AFF_TRUESIGHT) && room_is_dark(ch->in_room))
   {
      set_char_color(AT_DGREY, ch);
      send_to_char("It is pitch black ... \n\r", ch);
      show_char_to_char(ch->in_room->first_person, ch);
      return;
   }

   argument = one_argument(argument, arg1);
   argument = one_argument(argument, arg2);
   argument = one_argument(argument, arg3);
   doexaprog = str_cmp("noprog", arg2) && str_cmp("noprog", arg3);

   if (arg1[0] == '\0' || !str_cmp(arg1, "auto") || !str_cmp(arg1, "nowilderness"))
   {
      if (IS_ONMAP_FLAG(ch))
      {
         display_map(ch, -1, -1, 0);
         show_list_to_char(ch->in_room->first_content, ch, FALSE, FALSE, eItemGet);
         show_char_to_char(ch->in_room->first_person, ch);
         return;
      }
      /* 'look' or 'look auto' */
      /* Check to see if room is wilderness first -- Xerves 11/99 */
      if (xIS_SET(ch->in_room->room_flags, ROOM_WILDERNESS) && str_cmp(arg1, "nowilderness") && !IS_NPC(ch))
      {
         do_map(ch, "");
         return;
      }

      set_char_color(AT_RMNAME, ch);
      send_to_char(ch->in_room->name, ch);
      send_to_char("\n\r", ch);
      set_char_color(AT_RMDESC, ch);

      if (arg1[0] == '\0' || (!IS_NPC(ch) && !xIS_SET(ch->act, PLR_BRIEF)))
      {
         if (ch->desc && !ch->desc->run_buf)
         {
            send_to_char( MXPTAG ("rdesc"), ch);
            send_to_char(ch->in_room->description, ch);
            send_to_char( MXPTAG ("/rdesc"), ch);
         }
      }

      if (!IS_NPC(ch) && xIS_SET(ch->act, PLR_AUTOMAP)) /* maps */
      {
         if (ch->in_room->map != NULL)
         {
            do_lookmap(ch, NULL);
         }
      }

      if (!IS_NPC(ch) && xIS_SET(ch->act, PLR_AUTOEXIT))
         do_exits(ch, "auto");


      show_list_to_char( ch->in_room->first_content, ch, FALSE, FALSE, eItemGet );
      show_char_to_char(ch->in_room->first_person, ch);
      return;
   }

   if (!str_cmp(arg1, "under"))
   {
      int count;

      /* 'look under' */
      if (arg2[0] == '\0')
      {
         send_to_char("Look beneath what?\n\r", ch);
         return;
      }

      if ((obj = get_obj_here(ch, arg2)) == NULL)
      {
         send_to_char("You do not see that here.\n\r", ch);
         return;
      }
      if (!CAN_WEAR(obj, ITEM_TAKE) && ch->level < sysdata.level_getobjnotake)
      {
         send_to_char("You can't seem to get a grip on it.\n\r", ch);
         return;
      }
      if (get_ch_carry_weight(ch) + obj->weight > can_carry_w(ch))
      {
         send_to_char("It's too heavy for you to look under.\n\r", ch);
         return;
      }
      count = obj->count;
      obj->count = 1;
      act(AT_PLAIN, "You lift $p and look beneath it:", ch, obj, NULL, TO_CHAR);
      act(AT_PLAIN, "$n lifts $p and looks beneath it:", ch, obj, NULL, TO_ROOM);
      obj->count = count;
      if (IS_OBJ_STAT(obj, ITEM_COVERING))
         show_list_to_char( obj->first_content, ch, TRUE, TRUE, eItemNothing );
      else
         send_to_char("Nothing.\n\r", ch);
      if (doexaprog)
         oprog_examine_trigger(ch, obj);
      return;
   }

   if (!str_cmp(arg1, "i") || !str_cmp(arg1, "in"))
   {
      int count;

      /* 'look in' */
      if (arg2[0] == '\0')
      {
         send_to_char("Look in what?\n\r", ch);
         return;
      }

      if ((obj = get_obj_here(ch, arg2)) == NULL)
      {
         send_to_char("You do not see that here.\n\r", ch);
         return;
      }

      switch (obj->item_type)
      {
         default:
            send_to_char("That is not a container.\n\r", ch);
            break;

         case ITEM_DRINK_CON:
            if (obj->value[1] <= 0)
            {
               send_to_char("It is empty.\n\r", ch);
               if (doexaprog)
                  oprog_examine_trigger(ch, obj);
               break;
            }

            ch_printf(ch, "It's %s full of a %s liquid.\n\r",
               obj->value[1] < obj->value[0] / 4
               ? "less than" : obj->value[1] < 3 * obj->value[0] / 4 ? "about" : "more than", liq_table[obj->value[2]].liq_color);

            if (doexaprog)
               oprog_examine_trigger(ch, obj);
            break;

         case ITEM_PORTAL:
            for (pexit = ch->in_room->first_exit; pexit; pexit = pexit->next)
            {
               if (pexit->vdir == DIR_PORTAL && IS_SET(pexit->exit_info, EX_PORTAL))
               {
                  if (room_is_private(pexit->to_room) && get_trust(ch) < sysdata.level_override_private)
                  {
                     set_char_color(AT_WHITE, ch);
                     send_to_char("That room is private buster!\n\r", ch);
                     return;
                  }
                  original = ch->in_room;
                  char_from_room(ch);
                  char_to_room(ch, pexit->to_room);
                  do_look(ch, "auto");
                  char_from_room(ch);
                  char_to_room(ch, original);
                  return;
               }
            }
            send_to_char("You see swirling chaos...\n\r", ch);
            break;
         case ITEM_SHEATH:
            ch_printf(ch, "It's a sheath for %s weapons and holds a max weight of %d.\n\r", get_weapontype(obj->value[1]), obj->value[0]);
         case ITEM_CONTAINER:
         case ITEM_QUIVER:
         case ITEM_CORPSE_NPC:
         case ITEM_CORPSE_PC:
            if (IS_SET(obj->value[1], CONT_CLOSED) && obj->item_type != ITEM_SHEATH)
            {
               send_to_char("It is closed.\n\r", ch);
               break;
            }

         case ITEM_KEYRING:
            count = obj->count;
            obj->count = 1;
            if (obj->item_type == ITEM_CONTAINER)
               act(AT_PLAIN, "$p contains:", ch, obj, NULL, TO_CHAR);
            else if (obj->item_type == ITEM_CORPSE_PC)
               ch_printf(ch, "The PC corpse contains:\n\r");
            else
               act(AT_PLAIN, "$p holds:", ch, obj, NULL, TO_CHAR);
            obj->count = count;
            show_list_to_char_type( obj->first_content, ch, TRUE, TRUE, atoi(argument), eItemNothing );
            if (doexaprog)
               oprog_examine_trigger(ch, obj);
            break;
      }
      return;
   }

   if ((pdesc = get_extra_descr(arg1, ch->in_room->first_extradesc)) != NULL)
   {
      send_to_char_color(pdesc, ch);
      return;
   }

   door = get_door(arg1);
   if ((pexit = find_door(ch, arg1, TRUE)) != NULL)
   {
      if (IS_SET(pexit->exit_info, EX_CLOSED) && !IS_SET(pexit->exit_info, EX_WINDOW))
      {
         if ((IS_SET(pexit->exit_info, EX_SECRET) || IS_SET(pexit->exit_info, EX_DIG)) && door != -1)
            send_to_char("Nothing special there.\n\r", ch);
         else
            act(AT_PLAIN, "The $d is closed.", ch, NULL, pexit->keyword, TO_CHAR);
         return;
      }
      if (IS_SET(pexit->exit_info, EX_BASHED))
         act(AT_RED, "The $d has been bashed from its hinges!", ch, NULL, pexit->keyword, TO_CHAR);

      if (pexit->description && pexit->description[0] != '\0')
         send_to_char(pexit->description, ch);
      else
         send_to_char("Nothing special there.\n\r", ch);

      /*
       * Ability to look into the next room   -Thoric
       */
      if (pexit->to_room
         && (IS_AFFECTED(ch, AFF_SCRYING) || IS_SET(pexit->exit_info, EX_xLOOK) || get_trust(ch) >= LEVEL_IMMORTAL))
      {
         if (!IS_SET(pexit->exit_info, EX_xLOOK) && get_trust(ch) < LEVEL_IMMORTAL)
         {
            set_char_color(AT_MAGIC, ch);
            send_to_char("You attempt to scry...\n\r", ch);
            /*
             * Change by Narn, Sept 96 to allow characters who don't have the
             * scry spell to benefit from objects that are affected by scry.
             */
            if (!IS_NPC(ch))
            {
               int percent = LEARNED(ch, skill_lookup("scry"));

               if (!percent)
               {
                  percent = 55; /* 95 was too good -Thoric */
               }

               if (number_percent() > percent)
               {
                  send_to_char("You fail.\n\r", ch);
                  return;
               }
            }
         }
         if (room_is_private(pexit->to_room) && get_trust(ch) < sysdata.level_override_private)
         {
            set_char_color(AT_WHITE, ch);
            send_to_char("That room is private buster!\n\r", ch);
            return;
         }
         if (!IS_NPC(ch))
         {
            if (xIS_SET(pexit->to_room->room_flags, ROOM_IMP) && ch->pcdata->caste < caste_Staff)
            {
               set_char_color(AT_WHITE, ch);
               send_to_char("That room is for staff only!\n\r", ch);
               return;
            }
         }
         else
         {
            if (xIS_SET(pexit->to_room->room_flags, ROOM_IMP))
               return;
         }
         original = ch->in_room;
         char_from_room(ch);
         char_to_room(ch, pexit->to_room);
         do_look(ch, "auto");
         char_from_room(ch);
         char_to_room(ch, original);
      }
      return;
   }
   else if (door != -1)
   {
      send_to_char("Nothing special there.\n\r", ch);
      return;
   }

   if ((victim = get_char_room_new(ch, arg1, 1)) != NULL)
   {
      show_char_to_char_1(victim, ch, 0);
      return;
   }


   /* finally fixed the annoying look 2.obj desc bug -Thoric */
   number = number_argument(arg1, arg);
   for (cnt = 0, obj = ch->last_carrying; obj; obj = obj->prev_content)
   {
      if (can_see_obj(ch, obj))
      {
         if (IS_OBJ_STAT(obj, ITEM_ONMAP))
         {
            if (!IS_ONMAP_FLAG(ch))
               return;

            if (ch->map != obj->map
               || ch->coord->x != obj->coord->x
               || ch->coord->y != obj->coord->y)
            {
               send_to_char("You do not see that here.\n\r", ch);
               return;
            }
         }
         if ((pdesc = get_extra_descr(arg, obj->first_extradesc)) != NULL)
         {
            if ((cnt += obj->count) < number)
               continue;
            send_to_char_color(pdesc, ch);
            if (doexaprog)
               oprog_examine_trigger(ch, obj);
            return;
       

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

Site Stats

Snippets: 1791
Codebases: 571