act_wiz.c

toc/code/act_wiz.c · 409.6 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.0 (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.     *
 * ------------------------------------------------------------------------ *
 *			   Wizard/god command module			    *
 ****************************************************************************/

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


#define RESTORE_INTERVAL 21600

char *const save_flag[] = { "death", "kill", "passwd", "drop", "put", "give", "auto", "zap",
   "auction", "get", "receive", "idle", "backup", "quitbackup", "r14", "r15",
   "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", "r24", "r25", "r26",
   "r27", "r28", "r29", "r30", "r31"
};

void save_sysdata args((SYSTEM_DATA sys));

/* from comm.c */
bool write_to_descriptor args((int desc, char *txt, int length));
bool check_parse_name args((char *name, bool newchar));

/* from boards.c */
void note_attach(CHAR_DATA * ch);

/* from build.c */
int get_risflag(char *flag);
int get_defenseflag(char *flag);
int get_attackflag(char *flag);

/* from tables.c */
void write_race_file(int ra);


/*
 * Local functions.
 */
ROOM_INDEX_DATA *find_location args((CHAR_DATA * ch, char *arg));
void save_watchlist args((void));
void save_banlist args((void));
void close_area args((AREA_DATA * pArea));

int get_color(char *argument); /* function proto */

void sort_reserved args((RESERVE_DATA * pRes));

PROJECT_DATA *get_project_by_number args((int pnum));
NOTE_DATA *get_log_by_number args((PROJECT_DATA * pproject, int pnum));

/*
 * Global variables.
 */

char reboot_time[50];
time_t new_boot_time_t;
extern struct tm new_boot_struct;
extern OBJ_INDEX_DATA *obj_index_hash[MAX_KEY_HASH];
extern MOB_INDEX_DATA *mob_index_hash[MAX_KEY_HASH];
time_t copyover_time;

int get_saveflag(char *name)
{
   int x;

   for (x = 0; x < sizeof(save_flag) / sizeof(save_flag[0]); x++)
      if (!str_cmp(name, save_flag[x]))
         return x;
   return -1;
}

int csizeof(char *argument)
{
   int x;
   
   for (x = 0;; x++)
   {
      if (argument[x] == '\0')
         break;
   }
   return x;
}
void showpic(CHAR_DATA *ch, int type, char *argument)
{
   char buf[MSL];
   char arg[MIL];
   char arg2[MIL];
   DESCRIPTOR_DATA *d;
   DESCRIPTOR_DATA *dnext;
   int needhttp = 0;
   int x;
   int y = 0;
   int z;
   
   //Need atleast 4 characters
   if (csizeof(argument) < 4)
   {
      send_to_char("Invalid picture text count.\n\r", ch);
      return;
   }
   //Check to see if http was provided, if not it will be included later
   if (argument[0] != 'h' || argument[1] != 't' || argument[2] != 't' || argument[3] != 'p')
      needhttp = 1;
   //Checking to see if a FULL URL was provided or not
   for (x = 0;;)
   {
      if (argument[x] == '/')
         y = 1;
      if (argument[x] == '\0')
         break;
      x++;
   }
   //Player send argument and a FULL URL was passed, so lets not honor it.
   if (y == 1 && type == 3)
      return;
   if (y == 1)
   {   
      y = 0;
      for (x = 0;;)
      {
         //Found end of the string, lets to backwords so we can get the actual file name
         if (argument[x] == '\0')
         {
            for (;;)
            {
               x--;
               //File name found
               if (argument[x] == '/')
               {
                  z = x;
                  for (;;)
                  {
                     x++;
                     //Going forward to pick up the actual file name, outputing to arg (ex: picture.jpg)
                     if (argument[x] == '\0')
                     {
                        arg[y] = '\0';
                        break;
                     }
                     if (isspace(argument[x]))
                     {
                        continue;
                     }
                     arg[y++] = argument[x];
                  }
                  y = 0;
                  //Getting the path name and putting it in arg (ex: http://www.rafermand.net/)
                  for (;;)
                  {
                     if (y == z)
                     {
                        arg2[y] = argument[y];
                        arg2[y+1] = '\0';
                        break;
                     }
                     arg2[y] = argument[y];   
                     y++;
                  }
                  break;
               }
            }
            break;
         }
         x++;
      } 
      y = 1;  
   }
   
   //If 1 we are passing a full URL if not then just a cached picture request
   if (y == 1)
      sprintf(buf, "\x03Image fname=\"%s\" url=\"%s%s\" align=bottom\x04", arg, needhttp ? "http://" : "", arg2);
   else
      sprintf(buf, "\x03Image %s align=bottom\x04", argument);
      
   for (d = first_descriptor; d; d = dnext)
   {
      dnext = d->next;
      //Check only playing characters
      if (d->connected == CON_PLAYING && d->character)
      {         
         //If type 1 we are only looking for players in the same room
         if (type == 1 && !IN_SAME_ROOM(ch, d->character))
            continue;         
         act(AT_WHITE, buf, d->character, NULL, NULL, TO_CHAR);
      }
   }
   return;
}

void do_showpic(CHAR_DATA *ch, char *argument)
{
   char arg1[MIL];
   int type = 0;
   
   if (argument[0] == '\0')
   {
      if (IS_IMMORTAL(ch))
      {
         send_to_char("showpic <type> <picture>\n\r", ch);
         send_to_char("type = room or all\n\r", ch);
         return;
      }
      else
      {
         send_to_char("showpic <picture>\n\r", ch);
         return;
      }
   }
   //If isn't immortal send the player options
   if (!IS_IMMORTAL(ch))
   {
      showpic(ch, 3, argument);
      return;
   }
   argument = one_argument(argument, arg1);
   
   if (!str_cmp(arg1, "room"))
      type = 1;
   if (!str_cmp(arg1, "all"))
      type = 2;
   if (type == 0)
   {
      send_to_char("Not a valid type.\n\r", ch);
      return;
   }
   showpic(ch, type, argument);
   return;
}

void do_fightoutput(CHAR_DATA *ch, char *argument)
{
   int x, y, z;
   char arg1[MIL];
   char arg2[MIL];
   char arg3[MIL];
   char arg4[MIL];
   
   if (argument[0] == '\0')
   {
      send_to_char("Syntax:  fightoutput <hit, miss, dodge, parry, block, crit, insta>\n\r", ch);
      send_to_char("Syntax:  fightoutput <hit, miss, dodge, parry, block, crit, insta> add <bash/slash/stab> <text to add>\n\r", ch);
      send_to_char("Syntax:  fightoutput <hit, miss, dodge, parry, block, crit, insta> remove <bash/slash/stab> <number>\n\r", ch);
      send_to_char("Syntax:  fightoutput <hit, miss, dodge, parry, block, crit, insta> edit <bash/slash/stab> <number> <text to add>\n\r", ch);
      send_to_char("Syntax:  fightoutput variables\n\r", ch);
      return;
   }
   
   argument = one_argument(argument, arg1);
   argument = one_argument(argument, arg2);
   argument = one_argument(argument, arg3);
   
   if (!str_cmp(arg1, "variables"))
   {
      send_to_char("$B - Limb of the Target\n\r", ch);
      send_to_char("$n - One doing the attacking\n\r", ch);
      send_to_char("$N - One being attacked\n\r", ch);
      send_to_char("$G - Grip of the attacker\n\r", ch);
      send_to_char("$W - Weapon of the attacker\n\r", ch);
      send_to_char("$w - Weapon of the attackee\n\r", ch);
      send_to_char("$p - One doing the attacking (possessive)\n\r", ch);
      send_to_char("$P - One being attacked (possessive)\n\r", ch);
      send_to_char("$e - He/She/It/You (Attacker)\n\r", ch);
      send_to_char("$m - Him/Her/It/You (Attacker)\n\r", ch);
      send_to_char("$s - His/Her/Its/Your (Attacker)\n\r", ch);
      send_to_char("$E - He/She/It/You (Attackee)\n\r", ch);
      send_to_char("$M - Him/Her/It/You (Attackee)\n\r", ch);
      send_to_char("$S - His/Her/Its/Your (Attackee)\n\r", ch);
      send_to_char("$b - Name of Shield used to block\n\r", ch);
      send_to_char("$a - Adds s to the end of a word (for room and ch)\n\r", ch);
      send_to_char("$A - Adds es to the end of a word (for room and ch)\n\r", ch);
      send_to_char("$o - Adds s to the end of a word (for room and victim)\n\r", ch);
      send_to_char("$O - Adds es to the end of a word (for room and victim)\n\r", ch);
      return;
   }
   
   if (!str_cmp(arg1, "hit"))
      z = 0;
   else if (!str_cmp(arg1, "miss"))
      z = 1;
   else if (!str_cmp(arg1, "block"))
      z = 2;
   else if (!str_cmp(arg1, "insta"))
      z = 6;
   else
      return;
      
   if (!str_cmp(arg2, "remove"))
   {
      if (!str_cmp(arg3, "bash"))
         x = 0;
      else if (!str_cmp(arg3, "slash"))
         x = 1;
      else if (!str_cmp(arg3, "stab"))
         x = 2;
      else
      {
         send_to_char("That is not valid, your choices are:  bash, slash, stab\n\r", ch);
         return;
      }
      if (atoi(argument) >= high_value[z][x])
      {
         send_to_char("That number does not exist.\n\r", ch);
         return;
      }
      if (atoi(argument) == 0)
      {
         send_to_char("You cannot remove the last entry, you can edit it though.\n\r", ch);
         return;
      }
      if (atoi(argument) == high_value[z][x]-1)
      {
         strcpy((char *) battle_descriptions[z][x][atoi(argument)], "");
         high_value[z][x]--;
         fwrite_battle_descriptions();
      }
      else
      {
         int dx;
         dx = atoi(argument);
         for (;;)
         {
            if (dx == high_value[z][x])
            {
               strcpy((char *) battle_descriptions[z][x][dx-1], "");
               high_value[z][x]--;
               fwrite_battle_descriptions();
               break;
            }
            else
            {
               sprintf((char *) battle_descriptions[z][x][dx], (char *) battle_descriptions[z][x][dx+1]);
               dx++;
            }
         }
      }
   }      
   if (!str_cmp(arg2, "edit"))
   {
      argument = one_argument(argument, arg4);
      if (!str_cmp(arg3, "bash"))
         x = 0;
      else if (!str_cmp(arg3, "slash"))
         x = 1;
      else if (!str_cmp(arg3, "stab"))
         x = 2;
      else
      {
         send_to_char("That is not valid, your choices are:  bash, slash, stab\n\r", ch);
         return;
      }
      if (atoi(arg4) >= high_value[z][x])
      {
         send_to_char("That number does not exist.\n\r", ch);
         return;
      }
      if (strlen(argument) > 59)
      {
         send_to_char("You can only have 59 characters or less.\n\r", ch);
      }
      else
      {
         sprintf((char *) battle_descriptions[z][x][atoi(arg4)], argument);
         fwrite_battle_descriptions();
      }
   }
   if (!str_cmp(arg2, "add"))
   {
      if (!str_cmp(arg3, "bash"))
         x = 0;
      else if (!str_cmp(arg3, "slash"))
         x = 1;
      else if (!str_cmp(arg3, "stab"))
         x = 2;
      else
      {
         send_to_char("That is not valid, your choices are:  bash, slash, stab\n\r", ch);
         return;
      }
      if (high_value[0][x] >= 100)
      {
         send_to_char("You already have 100 on that grouping, you cannot add anymore.\n\r", ch);
         return;
      }
      if (strlen(argument) > 59)
      {
         send_to_char("You can only have 59 characters or less.\n\r", ch);
      }
      else
      {
         sprintf((char *) battle_descriptions[z][x][high_value[z][x]], argument);
         high_value[z][x]++;
         fwrite_battle_descriptions();
      }
   }            
   if (z == 0)
      send_to_char("&w&YHit Output\n\r\n\r", ch);
   else if (z == 1)
      send_to_char("&w&YMiss Output\n\r\n\r", ch);
   else if (z == 2)
      send_to_char("&w&YBlock Output\n\r\n\r", ch);
   else if (z == 6)
      send_to_char("&w&YInstant Kill Output\n\r\n\r", ch);
      
   for (x = 0; x < 3; x++)
   {
      for (y = 0; y < 100; y++)
      {
         if (y == 0)
         {
            if (x == 0)
               send_to_char("&w&W--------------------------------------&w&RBASH&w&W--------------------------------------\n\r", ch);
            if (x == 1)
               send_to_char("&w&W--------------------------------------&w&BSLASH&w&W-------------------------------------\n\r", ch);
            if (x == 2)
               send_to_char("&w&W--------------------------------------&w&CSTAB&w&W--------------------------------------\n\r", ch);
         }
         if (battle_descriptions[z][x][y][0] != '\0')
         {
            ch_printf(ch, "&c&w%3d > %s\n\r", y, battle_descriptions[z][x][y]);
         }
      }
   }
   return;
}

/*
 * The "watch" facility allows imms to specify the name of a player or
 * the name of a site to be watched. It is like "logging" a player except
 * the results are written to a file in the "watch" directory named with
 * the same name as the imm. The idea is to allow lower level imms to
 * watch players or sites without having to have access to the log files.
 */
void do_watch(CHAR_DATA * ch, char *argument)
{
   char arg[MIL];
   char arg2[MIL];
   char arg3[MIL];
   WATCH_DATA *pw;

   if (IS_NPC(ch))
      return;

   argument = one_argument(argument, arg);
   set_pager_color(AT_IMMORT, ch);

   if (arg[0] == '\0' || !str_cmp(arg, "help"))
   {
      send_to_pager("Syntax Examples:\n\r", ch);
      /*
       * Only Staff can see all the watches. The rest can just see their own.
       */
      if (get_trust(ch) >= LEVEL_HI_STAFF) /* Tracker1 */
         send_to_pager("   watch show all          show all watches\n\r", ch);
      send_to_pager("   watch show              show all my watches\n\r"
         "   watch size              show the size of my watch file\n\r"
         "   watch player joe        add a new player watch\n\r"
         "   watch site 2.3.123      add a new site watch\n\r"
         "   watch command make      add a new command watch\n\r"
         "   watch site 2.3.12       matches 2.3.12x\n\r"
         "   watch site 2.3.12.      matches 2.3.12.x\n\r"
         "   watch delete n          delete my nth watch\n\r"
         "   watch print 500         print watch file starting at line 500\n\r"
         "   watch print 500 1000    print 1000 lines starting at line 500\n\r" "   watch clear             clear my watch file\n\r", ch);
      return;
   }

   set_pager_color(AT_PLAIN, ch);
   argument = one_argument(argument, arg2);
   argument = one_argument(argument, arg3);

/*
 * Clear watch file
 */
   if (!str_cmp(arg, "clear"))
   {
      char fname[MIL];

      sprintf(fname, "%s%s", WATCH_DIR, strlower(ch->name));
      if (0 == remove(fname))
      {
         send_to_pager("Ok. Your watch file has been cleared.\n\r", ch);
         return;
      }
      send_to_pager("You have no valid watch file to clear.\n\r", ch);
      return;
   }

/*
 * Display size of watch file
 */
   if (!str_cmp(arg, "size"))
   {
      FILE *fp;
      char fname[MIL], s[MSL];
      int rec_count = 0;

      sprintf(fname, "%s%s", WATCH_DIR, strlower(ch->name));

      if (!(fp = fopen(fname, "r")))
      {
         send_to_pager("You have no watch file. Perhaps you cleared it?\n\r", ch);
         return;
      }

      fgets(s, MSL, fp);
      while (!feof(fp))
      {
         rec_count++;
         fgets(s, MSL, fp);
      }
      pager_printf(ch, "You have %d lines in your watch file.\n\r", rec_count);
      fclose(fp);
      return;
   }

/*
 * Print watch file
 */
   if (!str_cmp(arg, "print"))
   {
      FILE *fp;
      char fname[MIL], s[MSL];
      const int MAX_DISPLAY_LINES = 1000;
      int start, limit, disp_count = 0, rec_count = 0;

      if (arg2[0] == '\0')
      {
         send_to_pager("Sorry. You must specify a starting line number.\n\r", ch);
         return;
      }

      start = atoi(arg2);
      limit = (arg3[0] == '\0') ? MAX_DISPLAY_LINES : atoi(arg3);
      limit = UMIN(limit, MAX_DISPLAY_LINES);

      sprintf(fname, "%s%s", WATCH_DIR, strlower(ch->name));
      if (!(fp = fopen(fname, "r")))
         return;
      fgets(s, MSL, fp);

      while ((disp_count < limit) && (!feof(fp)))
      {
         if (++rec_count >= start)
         {
            send_to_pager(s, ch);
            disp_count++;
         }
         fgets(s, MSL, fp);
      }
      send_to_pager("\n\r", ch);
      if (disp_count >= MAX_DISPLAY_LINES)
         send_to_pager("Maximum display lines exceeded. List is terminated.\n\r"
            "Type 'help watch' to see how to print the rest of the list.\n\r"
            "\n\r" "Your watch file is large. Perhaps you should clear it?\n\r", ch);

      fclose(fp);
      return;
   }

/*
 * Display all watches
 * Only STAFF can see all the watches. The rest can just see their own.
 */
   if (get_trust(ch) >= LEVEL_HI_STAFF /* Tracker1 */
      && !str_cmp(arg, "show") && !str_cmp(arg2, "all"))
   {
      pager_printf(ch, "%-12s %-14s %-15s\n\r", "Imm Name", "Player/Command", "Player Site");
      if (first_watch)
         for (pw = first_watch; pw; pw = pw->next)
            if (get_trust(ch) >= pw->imm_level)
               pager_printf(ch, "%-14s %-12s %-15s\n\r",
                  pw->imm_name, pw->target_name ? pw->target_name : " ", pw->player_site ? pw->player_site : " ");
      return;
   }

/*
 * Display only those watches belonging to the requesting imm 
 */
   if (!str_cmp(arg, "show") && arg2[0] == '\0')
   {
      int cou = 0;

      pager_printf(ch, "%-3s %-12s %-14s %-15s\n\r", " ", "Imm Name", "Player/Command", "Player Site");
      if (first_watch)
         for (pw = first_watch; pw; pw = pw->next)
            if (!str_cmp(ch->name, pw->imm_name))
               pager_printf(ch, "%3d %-12s %-14s %-15s\n\r",
                  ++cou, pw->imm_name, pw->target_name ? pw->target_name : " ", pw->player_site ? pw->player_site : " ");
      return;
   }

/*
 * Delete a watch belonging to the requesting imm
 */
   if (!str_cmp(arg, "delete") && isdigit(*arg2))
   {
      int cou = 0;
      int num;

      num = atoi(arg2);
      if (first_watch)
         for (pw = first_watch; pw; pw = pw->next)
            if (!str_cmp(ch->name, pw->imm_name))
               if (num == ++cou)
               {
                  /* Oops someone forgot to clear up the memory --Shaddai */
                  if (pw->imm_name)
                     DISPOSE(pw->imm_name);
                  if (pw->player_site)
                     DISPOSE(pw->player_site);
                  if (pw->target_name)
                     DISPOSE(pw->target_name);
                  /* Now we can unlink and then clear up that final
                   * pointer -- Shaddai 
                   */
                  UNLINK(pw, first_watch, last_watch, next, prev);
                  DISPOSE(pw);
                  save_watchlist();
                  send_to_pager("Deleted.\n\r", ch);
                  return;
               }
      send_to_pager("Sorry. I found nothing to delete.\n\r", ch);
      return;
   }

/*
 * Watch a specific player
 */
   if (!str_cmp(arg, "player") && *arg2)
   {
      WATCH_DATA *pinsert;
      CHAR_DATA *vic;
      char buf[MIL];

      if (first_watch) /* check for dups */
         for (pw = first_watch; pw; pw = pw->next)
            if (!str_cmp(ch->name, pw->imm_name) && pw->target_name && !str_cmp(arg2, pw->target_name))
            {
               send_to_pager("You are already watching that player.\n\r", ch);
               return;
            }

      CREATE(pinsert, WATCH_DATA, 1); /* create new watch */
      pinsert->imm_level = get_trust(ch);
      pinsert->imm_name = str_dup(strlower(ch->name));
      pinsert->target_name = str_dup(strlower(arg2));
      pinsert->player_site = NULL;

      /* stupid get_char_world returns ptr to "samantha" when given "sam" */
      /* so I do a str_cmp to make sure it finds the right player --Gorog */

      sprintf(buf, "0.%s", arg2);
      if ((vic = get_char_world(ch, buf))) /* if vic is in game now */
         if ((!IS_NPC(vic)) && !str_cmp(arg2, vic->name))
            SET_BIT(vic->pcdata->flags, PCFLAG_WATCH);

      if (first_watch) /* ins new watch if app */
         for (pw = first_watch; pw; pw = pw->next)
            if (strcmp(pinsert->imm_name, pw->imm_name) < 0)
            {
               INSERT(pinsert, pw, first_watch, next, prev);
               save_watchlist();
               send_to_pager("Ok. That player will be watched.\n\r", ch);
               return;
            }

      LINK(pinsert, first_watch, last_watch, next, prev); /* link new watch */
      save_watchlist();
      send_to_pager("Ok. That player will be watched.\n\r", ch);
      return;
   }

/*
 * Watch a specific site
 */
   if (!str_cmp(arg, "site") && *arg2)
   {
      WATCH_DATA *pinsert;
      CHAR_DATA *vic;

      if (first_watch) /* check for dups */
         for (pw = first_watch; pw; pw = pw->next)
            if (!str_cmp(ch->name, pw->imm_name) && pw->player_site && !str_cmp(arg2, pw->player_site))
            {
               send_to_pager("You are already watching that site.\n\r", ch);
               return;
            }

      CREATE(pinsert, WATCH_DATA, 1); /* create new watch */
      pinsert->imm_level = get_trust(ch);
      pinsert->imm_name = str_dup(strlower(ch->name));
      pinsert->player_site = str_dup(strlower(arg2));
      pinsert->target_name = NULL;

      for (vic = first_char; vic; vic = vic->next)
         if (!IS_NPC(vic) && vic->desc && *pinsert->player_site
            && !str_prefix(pinsert->player_site, vic->desc->host) && get_trust(vic) < pinsert->imm_level)
            SET_BIT(vic->pcdata->flags, PCFLAG_WATCH);

      if (first_watch) /* ins new watch if app */
         for (pw = first_watch; pw; pw = pw->next)
            if (strcmp(pinsert->imm_name, pw->imm_name) < 0)
            {
               INSERT(pinsert, pw, first_watch, next, prev);
               save_watchlist();
               send_to_pager("Ok. That site will be watched.\n\r", ch);
               return;
            }

      LINK(pinsert, first_watch, last_watch, next, prev);
      save_watchlist();
      send_to_pager("Ok. That site will be watched.\n\r", ch);
      return;
   }

/*
 * Watch a specific command - FB
 */
   if (!str_cmp(arg, "command") && *arg2)
   {
      WATCH_DATA *pinsert;
      CMDTYPE *cmd;
      bool found = FALSE;

      for (pw = first_watch; pw; pw = pw->next)
      {
         if (!str_cmp(ch->name, pw->imm_name) && pw->target_name && !str_cmp(arg2, pw->target_name))
         {
            send_to_pager("You are already watching that command.\n\r", ch);
            return;
         }
      }

      for (cmd = command_hash[LOWER(arg2[0]) % 126]; cmd; cmd = cmd->next)
      {
         if (!strcmp(arg2, cmd->name))
         {
            found = TRUE;
            break;
         }
      }

      if (!found)
      {
         send_to_pager("No such command exists.\n\r", ch);
         return;
      }
      else
      {
         SET_BIT(cmd->flags, CMD_WATCH);
      }

      CREATE(pinsert, WATCH_DATA, 1);
      pinsert->imm_level = get_trust(ch);
      pinsert->imm_name = str_dup(strlower(ch->name));
      pinsert->player_site = NULL;
      pinsert->target_name = str_dup(arg2);

      for (pw = first_watch; pw; pw = pw->next)
      {
         if (strcmp(pinsert->imm_name, pw->imm_name) < 0)
         {
            INSERT(pinsert, pw, first_watch, next, prev);
            save_watchlist();
            send_to_pager("Ok, That command will be watched.\n\r", ch);
            return;
         }
      }

      LINK(pinsert, first_watch, last_watch, next, prev);
      save_watchlist();
      send_to_pager("Ok. That site will be watched.\n\r", ch);
      return;
   }

   send_to_pager("Sorry. I can't do anything with that. " "Please read the help file.\n\r", ch);
   return;
}

void do_wizhelp(CHAR_DATA * ch, char *argument)
{
   CMDTYPE *cmd;
   char wizcols[MAX_LEVEL - (LEVEL_PC - 1)] = "YOwPCBG";
   int col, hash;
   int curr_lvl;

   col = 0;
   set_pager_color(AT_PLAIN, ch);
   for (curr_lvl = LEVEL_PC; curr_lvl <= get_trust(ch); curr_lvl++)
   {
      pager_printf_color(ch, "\n\r&c&w[&G&WLEVEL %-2d&c&w] \n\r", curr_lvl);
      col = 0;
      for (hash = 0; hash < 126; hash++)
         for (cmd = command_hash[hash]; cmd; cmd = cmd->next)
            if ((cmd->level == curr_lvl) && cmd->level <= get_trust(ch))
            {
               pager_printf_color(ch, "&%c%-17s", wizcols[URANGE(0, cmd->level - LEVEL_PC, MAX_LEVEL - LEVEL_PC)], cmd->name);
               if (++col % 6 == 0)
                  send_to_pager_color("\n\r", ch);
            }
   }
   send_to_pager("\n\r", ch);
   return;
}

void do_restrict(CHAR_DATA * ch, char *argument)
{
   char arg[MIL];
   char arg2[MIL];
   char buf[MSL];
   sh_int level, hash;
   CMDTYPE *cmd;
   bool found;

   found = FALSE;
   set_char_color(AT_IMMORT, ch);

   argument = one_argument(argument, arg);
   if (arg[0] == '\0')
   {
      send_to_char("Restrict which command?\n\r", ch);
      return;
   }

   argument = one_argument(argument, arg2);
   if (arg2[0] == '\0')
      level = get_trust(ch);
   else
      level = atoi(arg2);

   level = UMAX(UMIN(get_trust(ch), level), 0);

   hash = arg[0] % 126;
   for (cmd = command_hash[hash]; cmd; cmd = cmd->next)
   {
      if (!str_prefix(arg, cmd->name) && cmd->level <= get_trust(ch))
      {
         found = TRUE;
         break;
      }
   }

   if (found)
   {
      if (!str_prefix(arg2, "show"))
      {
         sprintf(buf, "%s show", cmd->name);
         do_cedit(ch, buf);
/*    		ch_printf( ch, "%s is at level %d.\n\r", cmd->name, cmd->level );*/
         return;
      }
      cmd->level = level;
      ch_printf(ch, "You restrict %s to level %d\n\r", cmd->name, level);
      sprintf(buf, "%s restricting %s to level %d", ch->name, cmd->name, level);
      log_string(buf);
   }
   else
      send_to_char("You may not restrict that command.\n\r", ch);

   return;
}

/* 
 * Check if the name prefix uniquely identifies a char descriptor
 */
CHAR_DATA *get_waiting_desc(CHAR_DATA * ch, char *name)
{
   DESCRIPTOR_DATA *d;
   CHAR_DATA *ret_char = NULL;
   static unsigned int number_of_hits;

   number_of_hits = 0;
   for (d = first_descriptor; d; d = d->next)
   {
      if (d->character && (!str_prefix(name, d->character->name)) && IS_WAITING_FOR_AUTH(d->character))
      {
         if (++number_of_hits > 1)
         {
            ch_printf(ch, "%s does not uniquely identify a char.\n\r", name);
            return NULL;
         }
         ret_char = d->character; /* return current char on exit */
      }
   }
   if (number_of_hits == 1)
      return ret_char;
   else
   {
      send_to_char("No one like that waiting for authorization.\n\r", ch);
      return NULL;
   }
}

// used below to load an object with one line
void newobj_to_container(CHAR_DATA * ch, OBJ_DATA * container, int vnum)
{
   OBJ_DATA *obj;
   OBJ_INDEX_DATA *iobj;

   iobj = get_obj_index(vnum);
   if (iobj != NULL)
   {
      obj = create_object(iobj, 0);
      obj_to_obj(obj, container);
   }
}

//Been modified to create a few basic newbie items and put them in a sack
void do_newbieset(CHAR_DATA * ch, char *argument)
{
   OBJ_DATA *cobj;
   OBJ_INDEX_DATA *iobj;

   if ((ch->pcdata->council && !str_cmp(ch->pcdata->council->name, "Newbie Council")) || get_trust(ch) >= LEVEL_IMM)
   {
      if (argument[0] == '\0')
      {
         iobj = get_obj_index(123);
         if (iobj != NULL)
         {
            cobj = create_object(iobj, 0);
            obj_to_char(cobj, ch);
            newobj_to_container(ch, cobj, 5400); //book
            newobj_to_container(ch, cobj, 5468); //torch
            newobj_to_container(ch, cobj, 5473); //long sword
            newobj_to_container(ch, cobj, 5477); //dagger
            newobj_to_container(ch, cobj, 5483); //staff
            newobj_to_container(ch, cobj, 5492); //knuckle
            newobj_to_container(ch, cobj, 5485); //club
            newobj_to_container(ch, cobj, 5501); //water
            newobj_to_container(ch, cobj, 5504); //mana
            newobj_to_container(ch, cobj, 5507); //hp
            newobj_to_container(ch, cobj, 5507); //hp
            newobj_to_container(ch, cobj, 5509); //move
            newobj_to_container(ch, cobj, 5509); //move
            newobj_to_container(ch, cobj, 5494); //lamb
            newobj_to_container(ch, cobj, 5494); //lamb
            newobj_to_container(ch, cobj, 5494); //lamb
            newobj_to_container(ch, cobj, 5494); //lamb
            newobj_to_container(ch, cobj, 5494); //lamb
            newobj_to_container(ch, cobj, 5514); //potion of gods
            send_to_char("A new sack with the equipment has been created.\n\r", ch);
            return;
         }
         else
         {
            bug("A newbie set was not created!");
            send_to_char("An error occured, the imms have been contacted.\n\r", ch);
         }
      }
      else if (!str_cmp(argument, "book"))
      {
         iobj = get_obj_index(5400);
         if (iobj != NULL)
         {
            cobj = create_object(iobj, 0);
            obj_to_char(cobj, ch);
         }
         send_to_char("A newbie book is now in your inventory.\n\r", ch);
         return;
      }
      else
      {
         send_to_char("Syntax: newbieset [book].\n\r", ch);
         return;
      }
   }
}
void do_goauth(CHAR_DATA * ch, char *argument)
{
   if ((ch->pcdata->council && !str_cmp(ch->pcdata->council->name, "Newbie Council")) || get_trust(ch) >= LEVEL_IMM)
   {
      if (ch->pcdata->council && !str_cmp(ch->pcdata->council->name, "Newbie Council"))
      {
         if (xIS_SET(ch->in_room->room_flags, ROOM_NO_RECALL)
            || in_hellmaze(ch)
            || IS_AFFECTED(ch, AFF_CURSE)
            || xIS_SET(ch->act, PLR_GAMBLER) || ch->fighting)
         {
            send_to_char("Cannot use this command to escape norecall rules, sorry.\n\r", ch);
            return;
         }
      }
      act(AT_ACTION, "$n disappears in a swirl of smoke.", ch, NULL, NULL, TO_ROOM);
      ch->coord->x = ch->coord->y = ch->map = -1;
      REMOVE_ONMAP_FLAG(ch);

      if (ch->mount)
      {
         ch->mount->coord->x = ch->mount->coord->y = ch->mount->map = -1;
         REMOVE_ONMAP_FLAG(ch->mount);
         char_from_room(ch->mount);
         char_to_room(ch->mount, get_room_index(ROOM_AUTH_START));
         update_objects(ch->mount, ch->mount->map, ch->mount->coord->x, ch->mount->coord->y);
         do_look(ch->mount, "auto");
      }
      if (ch->pcdata->pet)
      {
         ch->pcdata->pet->coord->x = ch->pcdata->pet->coord->y = ch->pcdata->pet->map = -1;
         REMOVE_ONMAP_FLAG(ch->pcdata->pet);
         char_from_room(ch->pcdata->pet);
         char_to_room(ch->pcdata->pet, get_room_index(ROOM_AUTH_START));
         do_look(ch->pcdata->pet, "auto");
      }
      if (ch->pcdata->mount && !ch->mount)
      {
         ch->pcdata->mount->coord->x = ch->pcdata->mount->coord->y = ch->pcdata->mount->map = -1;
         REMOVE_ONMAP_FLAG(ch->pcdata->mount);
         char_from_room(ch->pcdata->mount);
         char_to_room(ch->pcdata->mount, get_room_index(ROOM_AUTH_START));
         do_look(ch->pcdata->mount, "auto");
      }
      if (ch->on)
      {
         ch->on = NULL;
         ch->position = POS_STANDING;
      }
      if (ch->position != POS_STANDING)
      {
         ch->position = POS_STANDING;
      }
      char_from_room(ch);
      char_to_room(ch, get_room_index(ROOM_AUTH_START));
      update_objects(ch, ch->map, ch->coord->x, ch->coord->y);
      act(AT_ACTION, "$n appears in the room.", ch, NULL, NULL, TO_ROOM);
      do_look(ch, "auto");
   }
   else
   {
      send_to_char("Huh?", ch);
      return;
   }
}

//show all members in a lastname/house
void do_showhouse(CHAR_DATA *ch, char *argument)
{
   FILE *fp;
   char strsave[200];
   char members[50][13];
   char name[13];
   int x = 0;
   int y;
   
   if (argument[0] == '\0')
   {
      send_to_char("Syntax:  showhouse <lastname>\n\r", ch);
      return;
   }
   if (!IS_IMMORTAL(ch) && str_cmp(argument, ch->last_name))
   {
      send_to_char("You can only view the members of your house.\n\r", ch);
      return;
   }
   sprintf(strsave, "%s%c/%s", LNAME_DIR, tolower(argument[0]), capitalize(argument));
   if ((fp = fopen(strsave, "r")) == NULL)
   {
      send_to_char("That house does not exist, if it should, notify an immortal.\n\r", ch);
      return;
   }
   else
   {
      ch_printf(ch, "----------House of %s ----------\n\r", argument);
      for (;;)
      {
         sprintf(name, "%s", fread_lastname_line(fp));
         if (!str_cmp(name, "S"))
            break;
         else
         {
            sprintf(members[x++], "%s", name);
         }
      }
      y = x;
      for (x = 0;;x++)
      {
         if (y != x)
         {
            ch_printf(ch, "%s\n\r", members[x]);
         }
         else
         {
            return;
         }
      }
   }
}
   

//Now Newbie Council can auth, be careful who is on it.
void do_authorize(CHAR_DATA * ch, char *argument)
{
   char arg1[MIL];
   char arg2[MIL];
   char buf[MSL];
   char *strtime;
   CHAR_DATA *victim;
   AUTHORIZE_DATA *newauth;
   AUTHORIZE_DATA *pastauth;
   DESCRIPTOR_DATA *d;

   set_char_color(AT_LOG, ch);

   argument = one_argument(argument, arg1);
   argument = one_argument(argument, arg2);

   if ((ch->pcdata->council && !str_cmp(ch->pcdata->council->name, "Newbie Council")) || get_trust(ch) >= LEVEL_IMM)
   {
      if (arg1[0] == '\0')
      {
         send_to_char("&c&wUsage:  authorize <player> <yes|name|lastname|disconnect>\n\r", ch);
         send_to_char("Pending authorizations:\n\r", ch);
         send_to_char("&R----------------------------------------------------------------------------\n\r", ch);
         for (d = first_descriptor; d; d = d->next)
         {
            if ((victim = d->character) != NULL && IS_WAITING_FOR_AUTH(victim))
               ch_printf(ch, "&G&W %-15s %-15s &c&w a new %s (%s)...\n\r",
                  victim->name, victim->last_name, race_table[victim->race]->race_name, "Peaceful");
         }
         return;
      }
      if (!str_cmp(arg1, "list"))
      {
         if (first_authorized)
         {
            send_to_char("&c&wName          LastName      Authed by     Date                      IP\n\r", ch);
            send_to_char("&R--------------------------------------------------------------------------------------\n\r", ch);
            for (pastauth = first_authorized; pastauth; pastauth = pastauth->next)
            {
               pager_printf(ch, "&G&W%-12s  %-12s  &C%-12s  &c%-24s  %s\n\r", pastauth->name, pastauth->lastname, pastauth->authedby, pastauth->authdate,
                  pastauth->host ? pastauth->host : "Not Available");
            }
         }
         else
         {
            send_to_char("This list is currently empty.\n\r", ch);
         }
         return;
      }

      victim = get_waiting_desc(ch, arg1);
      if (victim == NULL)
         return;

      set_char_color(AT_IMMORT, victim);
      if (arg2[0] == '\0' || !str_cmp(arg2, "accept") || !str_cmp(arg2, "yes"))
      {
         victim->pcdata->auth_state = 3;
         victim->pcdata->authwait = -1;
         CREATE(newauth, AUTHORIZE_DATA, 1);
         newauth->name = QUICKLINK(victim->name);
         newauth->lastname = QUICKLINK(victim->last_name);
         newauth->authedby = QUICKLINK(ch->name);
         strtime = ctime(&current_time);
         strtime[strlen(strtime) - 1] = '\0';
         newauth->authdate = STRALLOC(strtime);
         sprintf(buf, "%s", victim->desc->host);
         newauth->host = STRALLOC(buf);
         LINK(newauth, first_authorized, last_authorized, next, prev);
         fwrite_authlist();
         if (victim->pcdata->authed_by)
            STRFREE(victim->pcdata->authed_by);
         victim->pcdata->authed_by = QUICKLINK(ch->name);
         sprintf(buf, "%s: authorized", victim->name);
         to_channel(buf, CHANNEL_AUTH, "Auth", LEVEL_IMMORTAL); /* Tracker1 */

         ch_printf(ch, "You have authorized %s.\n\r", PERS_MAP(victim, ch));

         /* Below sends a message to player when name is accepted - Brittany */
         ch_printf_color(victim, /* B */
            "\n\r&GThe MUD Administrators have accepted the name %s.\n\r"
            "You may enter Rafermand by typing ---pull sword---.\n\r", victim->name);
         return;
      }
      else if (!str_cmp(arg2, "disconnect"))
      {
         send_to_char_color("&RYou have been denied access.\n\r", victim);
         sprintf(buf, "%s: denied authorization", victim->name);
         to_channel(buf, CHANNEL_AUTH, "Auth", LEVEL_IMMORTAL); /* Tracker 1 */
         ch_printf(ch, "You have denied %s.\n\r", victim->name);
         do_quit(victim, "");
      }

      else if (!str_cmp(arg2, "name") || !str_cmp(arg2, "n") || !str_cmp(arg2, "no"))
      {
         victim->pcdata->auth_state = 2;
         victim->pcdata->authwait = 30000; //that should do :-)
         sprintf(buf, "%s: name denied", victim->name);
         to_channel(buf, CHANNEL_AUTH, "Auth", LEVEL_IMMORTAL);
         ch_printf_color(victim,
            "&R\n\rThe MUD Administrators or newbie councel found the name of %s to be\n\r"
            "unacceptable.  You may choose a new name by typing name and the new name you want\n\r"
            "to use.  Please remember, the name needs to be original - no DBZ characters, no character\n\r"
            "from a major book/tv show/movie and do not use names of major mobs in the game, or names\n\r"
            "that look like the names of an Immortal ex: Xerxes.\n\r", victim->name);
         ch_printf(ch, "You requested %s change names.\n\r", victim->name);
         return;
      }
      else if (!str_cmp(arg2, "lastname"))
      {
         victim->pcdata->auth_state = 4;
         victim->pcdata->authwait = 30000; //that should do :-)
         sprintf(buf, "%s: name denied", victim->name);
         to_channel(buf, CHANNEL_AUTH, "Auth", LEVEL_IMMORTAL);
         ch_printf(victim, "&R\n\rThat last name has been chosen to be unacceptable.  Please pick a new one with\n\r"
                           "the 'lastname' command.\n\r");
         ch_printf(ch, "You requested %s change lastnames.\n\r", victim->last_name);
         return;
      }        
      else
      {
         send_to_char("Invalid argument.\n\r", ch);
         return;
      }
   }
   else
   {
      send_to_char("Huh?", ch);
      return;
   }
}

void do_bamfin(CHAR_DATA * ch, char *argument)
{
   if (!IS_NPC(ch))
   {
      smash_tilde(argument);
      DISPOSE(ch->pcdata->bamfin);
      ch->pcdata->bamfin = str_dup(argument);
      send_to_char_color("&YBamfin set.\n\r", ch);
   }
   return;
}

void do_bamfout(CHAR_DATA * ch, char *argument)
{
   if (!IS_NPC(ch))
   {
      smash_tilde(argument);
      DISPOSE(ch->pcdata->bamfout);
      ch->pcdata->bamfout = str_dup(argument);
      send_to_char_color("&YBamfout set.\n\r", ch);
   }
   return;
}

//Zaps a character to 1 hp, a punishment warning :-)  Thanks NEV!
void do_wizzap(CHAR_DATA * ch, char *argument)
{
   CHAR_DATA *victim;

   if (argument[0] == '\0')
   {
      send_to_char("Syntax: wizzap <char>.\n\r", ch);
      return;
   }
   if ((victim = get_char_world(ch, argument)) == NULL)
   {
      send_to_char("They aren't here.\n\r", ch);
      return;
   }
   if (IS_NPC(victim))
   {
      send_to_char("Not on NPC's.\n\r", ch);
      return;
   }
   if (victim == ch)
   {
      send_to_char("If you are trying to revive brain cells, this is not the way.\n\r", ch);
      return;
   }
   if (victim->fighting)
   {
      send_to_char("Might as well slay them or wait till they are done fighting.\n\r", ch);
      return;
   }
   if (get_trust(victim) >= get_trust(ch))
   {
      send_to_char("You failed.\n\r", ch);
      return;
   }
   if (victim->position == POS_SLEEPING || victim->position == POS_RESTING)
      victim->position = POS_STANDING;
   send_to_char("\n\r&Y   \\\\\n\r", victim);
   send_to_char("&Y    \\\\\n\r", victim);
   send_to_char("&Y     \\\\\n\r", victim);
   send_to_char("&Y      \\\\\n\r", victim);
   send_to_char("&Y       \\\\\n\r", victim);
   send_to_char("&Y        \\\\\n\r", victim);
   send_to_char("&Y         \\\\   //\n\r", victim);
   send_to_char("&Y          \\\\ // \\\\\n\r", victim);
   send_to_char("&Y           //    \\\\\n\r", victim);
   send_to_char("&Y                  \\\\\n\r", victim);
   send_to_char("&Y                   \\\\\n\r", victim);
   send_to_char("&Y                    \\\\\n\r", victim);
   send_to_char("&Y                     \\\\\n\r", victim);
   send_to_char("&Y                      \\\\\n\r", victim);
   send_to_char("&Y                       \\\\\n\r\n\r", victim);
   victim->hit = 1;
   victim->mana = 1;
   victim->move = 1;
   act(AT_WHITE, "$n has zapped you with a big bolt of lightning!!!", ch, NULL, victim, TO_VICT);
   act(AT_WHITE, "You zap $N with a big bolt of lightning!!!", ch, NULL, victim, TO_CHAR);
   act(AT_WHITE, "$n zaps $N with a huge bolt of lightning, be glad it was not you.", ch, NULL, victim, TO_ROOM);
   return;
}

/* Simular to checkvnum, but will list the freevnums -- Xerves */
void do_free_vnums(CHAR_DATA * ch, char *argument)
{
   char buf[MSL];
   AREA_DATA *pArea;
   char arg1[MSL];
   bool area_conflict;
   int low_range, high_range;
   int lohi[600]; /* Up to 300 and a half areas, increase if you have more -- Xerves */
   int xfin = 0;
   int w = 0;
   int x = 0;
   int y = 0;
   int z = 0;

   argument = one_argument(argument, arg1);

   if (arg1[0] == '\0')
   {
      send_to_char("Please specify the low end of the range to be searched.\n\r", ch);
      return;
   }

   if (argument[0] == '\0')
   {
      send_to_char("Please specify the high end of the range to be searched.\n\r", ch);
      return;
   }

   low_range = atoi(arg1);
   high_range = atoi(argument);

   if (low_range < 1 || low_range > MAX_VNUM)
   {
      send_to_char("Invalid argument for bottom of range.\n\r", ch);
      return;
   }

   if (high_range < 1 || high_range > MAX_VNUM)
   {
      send_to_char("Invalid argument for top of range.\n\r", ch);
      return;
   }

   if (high_range < low_range)
   {
      send_to_char("Bottom of range must be below top of range.\n\r", ch);
      return;
   }
   /* Forces it to check in sets of 10 -- Xerves */
   low_range = low_range / 10;
   low_range = low_range * 10;
   set_char_color(AT_PLAIN, ch);

   for (pArea = first_asort; pArea; pArea = pArea->next_sort)
   {
      area_conflict = FALSE;
      if (IS_SET(pArea->status, AREA_DELETED))
         continue;
      else
      {
         if (low_range < pArea->low_r_vnum && pArea->low_r_vnum < high_range)
            area_conflict = TRUE;

         if (low_range < pArea->hi_r_vnum && pArea->hi_r_vnum < high_range)
            area_conflict = TRUE;

         if ((low_range >= pArea->low_r_vnum) && (low_range <= pArea->hi_r_vnum))
            area_conflict = TRUE;

         if ((high_range <= pArea->hi_r_vnum) && (high_range >= pArea->low_r_vnum))
            area_conflict = TRUE;
      }
      if (area_conflict)
      {
         lohi[x] = pArea->low_r_vnum;
         x++;
         lohi[x] = pArea->hi_r_vnum;
         x++;
      }
   }
   for (pArea = first_bsort; pArea; pArea = pArea->next_sort)
   {
      area_conflict = FALSE;
      if (IS_SET(pArea->status, AREA_DELETED))
         continue;
      else
      {
         if (low_range < pArea->low_r_vnum && pArea->low_r_vnum < high_range)
            area_conflict = TRUE;

         if (low_range < pArea->hi_r_vnum && pArea->hi_r_vnum < high_range)
            area_conflict = TRUE;

         if ((low_range >= pArea->low_r_vnum) && (low_range <= pArea->hi_r_vnum))
            area_conflict = TRUE;

         if ((high_range <= pArea->hi_r_vnum) && (high_range >= pArea->low_r_vnum))
            area_conflict = TRUE;
      }

      if (area_conflict)
      {
         lohi[x] = pArea->low_r_vnum;
         x++;
         lohi[x] = pArea->hi_r_vnum;
         x++;
      }
   }
   xfin = x;
   for (y = low_range; y < high_range; y = y + 50)
   {
      area_conflict = FALSE;
      z = y + 49; /* y is min, z is max */
      for (x = 0; x < xfin; x = x + 2)
      {
         w = x + 1;

         if (y < lohi[x] && lohi[x] < z)
         {
            area_conflict = TRUE;
            break;
         }
         if (y < lohi[w] && lohi[w] < z)
         {
            area_conflict = TRUE;
            break;
         }
         if (y >= lohi[x] && y <= lohi[w])
         {
            area_conflict = TRUE;
            break;
         }
         if (z <= lohi[w] && z >= lohi[x])
         {
            area_conflict = TRUE;
            break;
         }
      }
      if (area_conflict == FALSE)
      {
         sprintf(buf, "Open: %5d - %-5d\n\r", y, z);
         send_to_char(buf, ch);
      }
   }
   return;
}

   NPCRACE_DATA *next;
   NPCRACE_DATA *prev;
   int racenum;
   char *racename;
   int willload[MAX_QUEST_DIFF];
   char *description[MAX_QUEST_DIFF];
   int sex[MAX_QUEST_DIFF];
   int fulldescription[MAX_QUEST_DIFF];
   EXT_BV flags[MAX_QUEST_DIFF];
   EXT_BV nflags[MAX_QUEST_DIFF];
   
void do_npcrace(CHAR_DATA *ch, char *argument)
{
   char arg1[MIL];
   char arg2[MIL];
   int x;
   int num;
   NPCRACE_DATA *npcrace;
   NPCRACE_DATA *snpcrace;
   
   if (check_npc(ch))
      return;
   if (argument[0] == '\0')
   {
      send_to_char("npcrace view [stack/number]\n\r", ch);
      send_to_char("npcrace view willload/willnotload [diff]\n\r", ch);
      send_to_char("npcrace create <name>\n\r", ch);
      send_to_char("npcrace delete <number/race name>\n\r", ch);
      send_to_char("npcrace set <number/race name> <name/number/description/fulldescription/sex/willload/flags/nflags> <value>\n\r", ch);
      return;
   }
   argument = one_argument(argument, arg1);
   if (!str_cmp(arg1, "set"))
   {
      argument = one_argument(argument, arg1);
      if (arg1[0] == '\0')
      {
         send_to_char("You need to specify an npc number or name to set.\n\r", ch);
         return;
      }
      for (npcrace = first_npcrace; npcrace; npcrace = npcrace->next)
      {
         if (!str_cmp(npcrace->racename, arg1))
            break;
      }
      if (!npcrace)
      {
         if (atoi(arg1) < 0 || atoi(arg1) > max_npc_race)
         {
            send_to_char("That is not a valid npc.\n\r", ch);
            return;
         }
         if (!npcrace_table[atoi(arg1)])
         {
            send_to_char("That is not a valid npc.\n\r", ch);
            return;
         }
         npcrace = npcrace_table[atoi(arg1)];
      }    
      argument = one_argument(argument, arg1);
      if (!str_cmp(arg1, "flags"))
      {
         argument = one_argument(argument, arg1);
         if (atoi(arg1) < 1 || atoi(arg1) > MAX_QUEST_DIFF)
         {
            ch_printf(ch, "Range is 1 to %d", MAX_QUEST_DIFF);
            return;
         }
         xCLEAR_BITS(npcrace->flags[atoi(arg1)-1]);
         for (;;)
         {
            argument = one_argument(argument, arg2);  
            if (arg2[0] == '\0')
               break;
            else
            {
               if (get_qmobflag(arg2) != -1)
                  xSET_BIT(npcrace->flags[atoi(arg1)-1], get_qmobflag(arg2));
               else if (isdigit(arg2[0]))
                  xSET_BIT(npcrace->flags[atoi(arg1)-1], atoi(arg2)-1);
               else
                  ch_printf(ch, "%s is not a valid flag\n\r", arg2);
            }
         }
         send_to_char("Done.\n\r", ch);
         save_npcrace_file();
         return;
      }
      if (!str_cmp(arg1, "nflags"))
      {
         argument = one_argument(argument, arg1);
         if (atoi(arg1) < 1 || atoi(arg1) > MAX_QUEST_DIFF)
         {
            ch_printf(ch, "Range is 1 to %d", MAX_QUEST_DIFF);
            return;
         }
         xCLEAR_BITS(npcrace->nflags[atoi(arg1)-1]);
         for (;;)
         {
            argument = one_argument(argument, arg2);  
            if (arg2[0] == '\0')
               break;
            else
            {
               if (get_qmobflag(arg2) != -1)
                  xSET_BIT(npcrace->nflags[atoi(arg1)-1], get_qmobflag(arg2));
               else if (isdigit(arg2[0]))
                  xSET_BIT(npcrace->nflags[atoi(arg1)-1], atoi(arg2)-1);
               else
                  ch_printf(ch, "%s is not a valid flag\n\r", arg2);
            }
         }
         send_to_char("Done.\n\r", ch);
         save_npcrace_file();
         return;
      }
      if (!str_cmp(arg1, "description"))
      {
         argument = one_argument(argument, arg1);
         if (atoi(arg1) < 1 || atoi(arg1) > MAX_QUEST_DIFF)
         {
            ch_printf(ch, "Range is 1 to %d", MAX_QUEST_DIFF);
            return;
         }
         STRFREE(npcrace->description[atoi(arg1)-1]);
         npcrace->description[atoi(arg1)-1] = STRALLOC(argument);
         send_to_char("Done.\n\r", ch);
         save_npcrace_file();
         return;
      }
      if (!str_cmp(arg1, "fulldescription"))
      {
         argument = one_argument(argument, arg1);
         if (atoi(arg1) < 1 || atoi(arg1) > MAX_QUEST_DIFF)
         {
            ch_printf(ch, "Range is 1 to %d", MAX_QUEST_DIFF);
            return;
         }
         npcrace->fulldescription[atoi(arg1)-1] = atoi(argument);
         send_to_char("Done.\n\r", ch);
         save_npcrace_file();
         return;
      }
      if (!str_cmp(arg1, "sex"))
      {
         argument = one_argument(argument, arg1);
         if (atoi(arg1) < 1 || atoi(arg1) > MAX_QUEST_DIFF)
         {
            ch_printf(ch, "Range is 1 to %d", MAX_QUEST_DIFF);
            return;
         }
         if (atoi(argument) < 1 || atoi(argument) > 2)
         {
            send_to_char("Range is 1 (male) to 2 (female).\n\r", ch);
            return;
         }
         npcrace->sex[atoi(arg1)-1] = atoi(argument);
         send_to_char("Done.\n\r", ch);
         save_npcrace_file();
         return;
      }
      if (!str_cmp(arg1, "willload"))
      {
         argument = one_argument(argument, arg1);
         if (atoi(arg1) < 1 || atoi(arg1) > MAX_QUEST_DIFF)
         {
            ch_printf(ch, "Range is 1 to %d", MAX_QUEST_DIFF);
            return;
         }
         npcrace->willload[atoi(arg1)-1] = atoi(argument);
         send_to_char("Done.\n\r", ch);
         save_npcrace_file();
         return;
      }
      if (!str_cmp(arg1, "name"))
      {
         STRFREE(npcrace->racename);
         npcrace->racename = STRALLOC(argument);
         send_to_char("Done.\n\r", ch);
         save_npcrace_file();
         return;
      }
      if (!str_cmp(arg1, "number"))
      {
         if (atoi(argument) < 0 || atoi(argument) >= MAX_NPCRACE_TABLE)
         {
            ch_printf(ch, "Range is 0 to %d", MAX_NPCRACE_TABLE-1);
            return;
         }
         if (npcrace_table[atoi(argument)])
         {
            send_to_char("You can only change the number to one not taken.\n\r", ch);
            return;
         }
         x = 0;
         if (max_npc_race-1 == npcrace->racenum && atoi(argument) < npcrace->racenum)
         {
            for (snpcrace = first_npcrace; snpcrace; snpcrace = snpcrace->next)
            {
               if (snpcrace->racenum > x && npcrace != snpcrace)
                  x = snpcrace->racenum;
            }
            max_npc_race = x+1;
         }  
         npcrace_table[npcrace->racenum] = NULL;
         npcrace->racenum = atoi(argument);
         npcrace_table[npcrace->racenum] = npcrace;
         if (npcrace->racenum >= max_npc_race)
            max_npc_race = npcrace->racenum+1;
         send_to_char("Done.\n\r", ch);
         save_npcrace_file();
         return;
      }         
   }         
   if (!str_cmp(arg1, "delete"))
   {
      if (argument[0] == '\0')
      {
         send_to_char("You need to specify an npc number or name to set.\n\r", ch);
         return;
      }
      for (npcrace = first_npcrace; npcrace; npcrace = npcrace->next)
      {
         if (!str_cmp(npcrace->racename, argument))
            break;
      }
      if (!npcrace)
      {
         if (atoi(argument) < 0 || atoi(argument) > max_npc_race)
         {
            send_to_char("That is not a valid npc.\n\r", ch);
            return;
         }
         if (!npcrace_table[atoi(argument)])
         {
            send_to_char("That is not a valid npc.\n\r", ch);
            return;
         }
         npcrace = npcrace_table[atoi(argument)];
      } 
      STRFREE(npcrace->racename);
      for (x = 0; x <= MAX_QUEST_DIFF-1; x++)
      {
         STRFREE(npcrace->description[x]);
      }
      npcrace_table[npcrace->racenum] = NULL;
      x = 0;
      if (max_npc_race-1 == npcrace->racenum)
      {
         for (snpcrace = first_npcrace; snpcrace; snpcrace = snpcrace->next)
         {
            if (snpcrace->racenum > x && npcrace != snpcrace)
               x = snpcrace->racenum;
         }
         max_npc_race = x+1;
      } 
      UNLINK(npcrace, first_npcrace, last_npcrace, next, prev);
      DISPOSE(npcrace);
      save_npcrace_file();
      send_to_char("Done.\n\r", ch);
      return;
   }      
   if (!str_cmp(arg1, "create"))
   {
      if (argument[0] == '\0')
      {
         send_to_char("Need to specify a name for the npc race you want to create.\n\r", ch);
         return;
      }
      CREATE(npcrace, NPCRACE_DATA, 1);
      npcrace->racename = STRALLOC(argument);
      num = -1;
      for (snpcrace = first_npcrace; snpcrace; snpcrace = snpcrace->next)
      {
         if (snpcrace->racenum > num)
            num = snpcrace->racenum;
      }
      if (num == MAX_NPCRACE_TABLE-1)
      {
         send_to_char("The maximum amount of NPC races has been reached, you need to modify MAX_NPCRACE_TABLE in the code to add more.\n\r", ch);
         return;
      }
      npcrace->racenum = num+1;
      if (npcrace->racenum == max_npc_race)
         max_npc_race++;
      for (x = 0; x <= MAX_QUEST_DIFF-1; x++)
      {
         npcrace->willload[x] = npcrace->sex[x] = npcrace->fulldescription[x] = 0;
         npcrace->description[x] = STRALLOC("");
         xCLEAR_BITS(npcrace->flags[x]);
         xCLEAR_BITS(npcrace->nflags[x]);
      }
      npcrace_table[npcrace->racenum] = npcrace;
      LINK(npcrace, first_npcrace, last_npcrace, next, prev);
      save_npcrace_file();
      send_to_char("Done.\n\r", ch);
      return;
   }      
   if (!str_cmp(arg1, "view"))
   {
      one_argument(argument, arg1);
      if (!str_cmp(arg1, "willload"))
      {
         argument = one_argument(argument, arg1);
         if (atoi(argument) < 1 || atoi(argument) > MAX_QUEST_DIFF)
         {
            ch_printf(ch, "Range is 1 to %d", MAX_QUEST_DIFF);
            return;
         }
         ch_printf(ch, "Num  Name\n\r", ch);
         x = 0;
         for (num = 0; num < max_npc_race; num++)
         {
            if (npcrace_table[num])
            {
               npcrace = npcrace_table[num];
               if (npcrace->willload[atoi(argument)-1] == 1)
               {
                  ch_printf(ch, "%-3d> %-15s", npcrace->racenum, npcrace->racename);   
                  if (++x % 4 == 0)
                     ch_printf(ch, "\n\r");
               }
            }
         }
         if (x % 4 != 0)
            ch_printf(ch, "\n\r");
         return;
      }
      if (!str_cmp(arg1, "willnotload"))
      {
         argument = one_argument(argument, arg1);
         if (atoi(argument) < 1 || atoi(argument) > MAX_QUEST_DIFF)
         {
            ch_printf(ch, "Range is 1 to %d", MAX_QUEST_DIFF);
            return;
         }
         ch_printf(ch, "Num  Name\n\r", ch);
         x = 0;
         for (num = 0; num < max_npc_race; num++)
         {
            if (npcrace_table[num])
            {
               npcrace = npcrace_table[num];
               if (npcrace->willload[atoi(argument)-1] != 1)
               {
                  ch_printf(ch, "%-3d> %-15s", npcrace->racenum, npcrace->racename);   
                  if (++x % 4 == 0)
                     ch_printf(ch, "\n\r");
               }
            }
         }
         if (x % 4 != 0)
            ch_printf(ch, "\n\r");
         return;
      }
         
      if (!str_cmp(argument, "stack"))
      {
         x = 0;
         for (num = 0; num < max_npc_race; num++)
         {
            if (npcrace_table[num])
            {
               npcrace = npcrace_table[num];
               ch_printf(ch, "%-3d> %-15s", npcrace->racenum, npcrace->racename);   
               if (++x % 4 == 0)
                  ch_printf(ch, "\n\r");
            }
         }   
         if (x % 4 != 0)
            ch_printf(ch, "\n\r");
         return;
      }
      else if (argument[0] != '\0')
      {
         if (argument[0] == '\0')
         {
            send_to_char("You need to specify an npc number or name to set.\n\r", ch);
            return;
         }
         for (npcrace = first_npcrace; npcrace; npcrace = npcrace->next)
         {
            if (!str_cmp(npcrace->racename, argument))
               break;
         }
         if (!npcrace)
         {
            if (atoi(argument) < 0 || atoi(argument) > max_npc_race)
            {
               send_to_char("That is not a valid npc.\n\r", ch);
               return;
            }
            if (!npcrace_table[atoi(argument)])
            {
               send_to_char("That is not a valid npc.\n\r", ch);
               return;
            }
            npcrace = npcrace_table[atoi(argument)];
         } 
         ch_printf(ch, "Num  Name\n\r", ch);
         ch_printf(ch, "------------------------------------------\n\r"); 
         ch_printf(ch, "%-3d> %-20s\n\r", npcrace->racenum, npcrace->racename);
         ch_printf(ch, "\n\rDiff> Willload  Sex  FullDesc  Description\n\r");
         ch_printf(ch, "------------------------------------------------------------------------------------\n\r");         
         for (x = 0; x <= MAX_QUEST_DIFF-1; x++)
         {
            ch_printf(ch, "%-2d> %d %d %d %-20s ", x+1, npcrace->willload[x], npcrace->sex[x], npcrace->fulldescription[x], 
               npcrace->description[x]);
            if ((x+1)%3 == 0)
               ch_printf(ch, "\n\r");
         }
         if (x % 3 != 0)
            ch_printf(ch, "\n\r");
         ch_printf(ch, "\n\r       Diff  Flags\n\r");
         ch_printf(ch, "------------------------------------------------------------------------------------\n\r");    
         for (x = 0; x <= MAX_QUEST_DIFF-1; x++)
         {
            ch_printf(ch, "Flags   %-2d    %s\n\r", x+1, ext_flag_string(&npcrace->flags[x], qmob_flags));
            ch_printf(ch, "NFlags  %-2d    %s\n\r", x+1, ext_flag_string(&npcrace->nflags[x], qmob_flags));
         }
            
         return;
      }
      else
      {
         ch_printf(ch, "Num  Name                  Will load (for each diff)\n\r", ch);
         for (num = 0; num < max_npc_race; num++)
         {
            if (npcrace_table[num])
            {
               npcrace = npcrace_table[num];
               ch_printf(ch, "%-3d> %-20s", npcrace->racenum, npcrace->racename);   
               for (x = 0; x <= MAX_QUEST_DIFF-1; x++)
                  ch_printf(ch, "  %d", npcrace->willload[x]);
               ch_printf(ch, "\n\r");
            }
         }
      }
      return;
   }
   do_npcrace(ch, "");
   return;
}
void do_rank(CHAR_DATA * ch, char *argument)
{
   char add_len[MIL];
   int sp1, sx;
   char finrank[MIL];

   set_char_color(AT_IMMORT, ch);
   sp1 = strlen_color(argument);
   sprintf(add_len, " ");

   for (sx = 25; sx > sp1; sx--) /* 26 - 1 for add_len init. */
      strcat(add_len, " ");
   strcpy(finrank, argument); /* Adding spaces to finish out rank --Xerves */
   strcat(finrank, add_len); /* Adding the length to the end of the argument -- Xerves */

   if (IS_NPC(ch))
      return;
   if (!argument || argument[0] == '\0')
   {
      send_to_char("Usage:  rank <string>.\n\r", ch);
      send_to_char("   or:  rank none.\n\r", ch);
      return;
   }
   smash_tilde(argument);
   DISPOSE(ch->pcdata->rank);
   if (!str_cmp(argument, "none"))
      ch->pcdata->rank = str_dup("");
   else
      ch->pcdata->rank = str_dup(finrank);
   send_to_char("Ok.\n\r", ch);
   return;
}

/*8-19-99 Moved to caste.c */
/*11-28-98 Will change Caste ranking - Xerves */
/*
void do_caste(  CHAR_DATA *ch, char *argument  )
{

  char arg1[MIL];
  char arg2[MIL];
  int amount;
  CHAR_DATA *victim;

  if (IS_NPC(ch))
  {
     send_to_char( "NOT ON NPCs\n\r", ch);
     return;
  }

  if ( argument[0] == '\0' )
  {
     send_to_char( "Syntax: caste <name> <number> 1-15\n\r", ch);
     return;
  }

argument = one_argument(argument, arg1);
argument = one_argument(argument, arg2);

  if ( arg1 == '\0' || arg2 == '\0' )
  {
     send_to_char( "Syntax: caste <name> <number> 1-40 (help caste for info)\n\r", ch);
     return;
  }

  if ( ( victim = get_char_world( ch, arg1 ) ) == NULL )
  {
	send_to_char( "They aren't here.\n\r", ch );
	return;
  }

  if ( IS_NPC( victim ))
  {
      send_to_char( "NOT ON NPCs.\n\r", ch);
      return;
  }

  if ( get_trust( ch ) <= get_trust( victim ) && ch != victim )
  {
      send_to_char( "Don't do that AGAIN!.\n\r", ch );
	return;
  }

  if ( !is_number( arg2 ) )
  {
     send_to_char( "Syntax: caste <name> <number> 1-40 (help caste for info)\n\r", ch);
     return;
  }

    amount = atoi( arg2 );

  if ( amount < 1 || amount > 40 )
  {
     send_to_char( "Syntax: caste <name> <number> 1-40 (help caste for info)\n\r", ch);
     return;
  }

  victim->pcdata->caste = amount;
  return;
}  */

/* Critt's Link Dead Punt -- Xerves 8/3/99 */
void ld_punt(CHAR_DATA * ch)
{
   char buf[MSL];

   /*
      CHAR_DATA *vch;
      CHAR_DATA *vch_next; */
   int x, y;
   int level;

   set_char_color(AT_IMMORT, ch);

   if (!IS_NPC(ch) && !ch->desc)
   {
      if (ch->position == POS_MOUNTED)
         do_dismount(ch, "");
      if (ch->riding)
         do_dismount(ch, "");
      if (ch->position == POS_RIDING)
         ch->position = POS_STANDING;
      set_char_color(AT_WHITE, ch);
      /* if (ch)
         send_to_char( "You have been punted because you are link-dead...\n\r", ch ); */
      set_char_color(AT_GREY, ch);
      quitting_char = ch;
      save_char_obj(ch);
      if (sysdata.save_pets && ch->pcdata->pet)
      {
         extract_char(ch->pcdata->pet, TRUE);
      }
      if (ch->pcdata->clan)
         save_clan(ch->pcdata->clan);
      saving_char = NULL;
      level = get_trust(ch);
      /*  sprintf(buf, "%s has been punted.\n\r",capitalize(vch->name) );
         if (ch)
         send_to_char( buf, ch ); */
      act(AT_BYE, "$n has left the game.", ch, NULL, NULL, TO_CANSEE);
      if (!IS_IMMORTAL(ch))
      {
         sprintf(buf, "You feel that there is one less presence in %s...", sysdata.mud_name);
         talk_info(AT_BLUE, buf);
      }
      sprintf(buf, "%s has quit (Room %d).", ch->name, (ch->in_room ? ch->in_room->vnum : -1));
      log_string_plus(buf, LOG_COMM, level);
      extract_char(ch, TRUE); /* ch void after extraction -- Xerves */
      for (x = 0; x < MAX_WEAR; x++)
         for (y = 0; y < MAX_LAYERS; y++)
            save_equipment[x][y] = NULL;
   }
/*
    send_to_char( "All done.\n\r", ch ); */
   return;
}

void do_pkillcheck(CHAR_DATA *ch, char *argument)
{
   AREA_DATA *tarea;
   ROOM_INDEX_DATA *room;
   int vnum;
   
   for (tarea = first_area; tarea; tarea = tarea->next)
   {
      if (IS_SET(tarea->flags, AFLAG_NOKILL))
         ch_printf(ch, "&w&RArea: %s  Flag: NOPKILL\n\r", tarea->name);
      if (IS_SET(tarea->flags, AFLAG_ANITEM))
         ch_printf(ch, "&w&RArea: %s  Flag: ANITEM\n\r", tarea->name);
      if (IS_SET(tarea->flags, AFLAG_NOLOOT))
         ch_printf(ch, "&w&RArea: %s  Flag: NOLOOT\n\r", tarea->name);
         
      for (vnum = tarea->low_r_vnum; vnum <= tarea->hi_r_vnum; vnum++)
      {
         if ((room = get_room_index(vnum)) != NULL)
         {
            if (xIS_SET(room->room_flags, ROOM_TSAFE))
               ch_printf(ch, "&w&CArea: %s  Room: %d  Flag: NOPKILL\n\r", tarea->name, vnum);
            if (xIS_SET(room->room_flags, ROOM_SAFE))
               ch_printf(ch, "&w&CArea: %s  Room: %d  Flag: >>SAFE<<\n\r", tarea->name, vnum);
            if (xIS_SET(room->room_flags, ROOM_ANITEM))
               ch_printf(ch, "&w&CArea: %s  Room: %d  Flag: ANITEM\n\r", tarea->name, vnum);
            if (xIS_SET(room->room_flags, ROOM_NOLOOT))
               ch_printf(ch, "&w&CArea: %s  Room: %d  Flag: NOLOOT\n\r", tarea->name, vnum);
         }
      }
   }
   return;
}

/* For now, just a simple one item search on mobs, typically to find how
   many mobs there are in a level range or something of that sort
   -- Xerves 12/99 */
void do_minfo(CHAR_DATA * ch, char *argument)
{
   return;
 /*   char buf[MSL];
   MOB_INDEX_DATA *mob;
   char arg1[MIL];
   char arg2[MIL];
   char arg3[MIL];
   int pvnum;
   int mcount;
   int hihealth;
   int lohealth;
   int hidamage;
   int lodamage;

   mcount = 0;

   minfo <type> <first arg> <second arg>
      arg1   arg2        arg3    

   argument = one_argument(argument, arg1);
   argument = one_argument(argument, arg2);
   argument = one_argument(argument, arg3);

   if ((arg1[0] == '\0') || (arg2[0] == '\0') || (arg3[0] == '\0'))
   {
      send_to_char("Syntax: minfo <type> <first arg> <second arg>\n\rType - lv(args-lo level, hi level)\n\r", ch);
      return;
   }
   if (str_cmp(arg1, "lv"))
   {
      send_to_char("Only type right now is level of mobs\n\r", ch);
      return;
   }
   if (!str_cmp(arg1, "lv"))
   {
      if (atoi(arg2) > atoi(arg3))
      {
         send_to_char("The low has to be lower than the high\n\r", ch);
         return;
      }
      if (atoi(arg3) < atoi(arg2))
      {
         send_to_char("The high has to be higher than the low\n\r", ch);
         return;
      }
   }

   send_to_char("Vnum   Lv  Gold     Min HP  Max HP  Min Dam   Max Dam   Name\n\r", ch);
   for (pvnum = 1; pvnum < MAX_VNUM; pvnum++)
   {
      if ((mob = get_mob_index(pvnum)) == NULL)
         continue;
      else
      {
         if ((mob->level >= atoi(arg2)) && (mob->level <= atoi(arg3)))
         {
            hihealth = (mob->hitnodice * mob->hitsizedice + mob->hitplus);
            lohealth = (1 * mob->hitsizedice + mob->hitplus);
            hidamage = (mob->damnodice * mob->damsizedice + mob->damplus);
            lodamage = (1 * mob->damsizedice + mob->damplus);
            if (xIS_SET(mob->act, ACT_PACIFIST))
            {
               sprintf(buf, "&C%-5d  %-2d  %-7d  %-5d   %-5d   %-4d      %-4d      %s\n\r", mob->vnum, mob->level, mob->gold, lohealth, hihealth,
                  lodamage, hidamage, mob->short_descr);
               send_to_char(buf, ch);
            }
            else
            {
               sprintf(buf, "&G%-5d  %-2d  %-7d  %-5d   %-5d   %-4d      %-4d      %s\n\r", mob->vnum, mob->level, mob->gold, lohealth, hihealth,
                  lodamage, hidamage, mob->short_descr);
               send_to_char(buf, ch);
            }
            mcount++;
            continue;
         }
      }
   }*/
}

/* 3-12-99 Will change FLevel number - Xerves */
void do_flevel(CHAR_DATA * ch, char *argument)
{

   char arg1[MIL];
   char arg2[MIL];
   int amount;
   CHAR_DATA *victim;

   if (IS_NPC(ch))
   {
      send_to_char("NOT ON NPCs\n\r", ch);
      return;
   }

   if (argument[0] == '\0')
   {
      send_to_char("Syntax: flevel <name> <number> 2-7 or 0\n\r", ch);
      return;
   }

   argument = one_argument(argument, arg1);
   argument = one_argument(argument, arg2);

   if (arg1 == '\0' || arg2 == '\0')
   {
      send_to_char("Syntax: flevel <name> <number> 2-7 or 0 (help flevel for info)\n\r", ch);
      return;
   }

   if ((victim = get_char_world(ch, arg1)) == NULL)
   {
      send_to_char("They aren't here.\n\r", ch);
      return;
   }

   if (IS_NPC(victim))
   {
      send_to_char("NOT ON NPCs.\n\r", ch);
      return;
   }

   if (get_trust(ch) <= get_trust(victim) && ch != victim)
   {
      send_to_char("Don't do that AGAIN!.\n\r", ch);
      return;
   }

   if (!is_number(arg2))
   {
      send_to_char("Syntax: flevel <name> <number> 2-7 or 0 (help flevel for info)\n\r", ch);
      return;
   }

   amount = atoi(arg2);

   if (amount == 0)
   {
      victim->pcdata->flevel = 0;
      return;
   }

   if (amount < LEVEL_IMMORTAL || amount > MAX_LEVEL)
   {
      send_to_char("Syntax: flevel <name> <number> 2-7 or 0 (help flevel for info)\n\r", ch);
      return;
   }

   victim->pcdata->flevel = amount;
   return;
}


void do_retire(CHAR_DATA * ch, char *argument)
{
   char arg[MIL];
   CHAR_DATA *victim;

   set_char_color(AT_IMMORT, ch);

   one_argument(argument, arg);
   if (arg[0] == '\0')
   {
      send_to_char("Retire whom?\n\r", ch);
      return;
   }
   if ((victim = get_char_world(ch, arg)) == NULL)
   {
      send_to_char("They aren't here.\n\r", ch);
      return;
   }
   if (IS_NPC(victim))
   {
      send_to_char("Not on NPC's.\n\r", ch);
      return;
   }
   if (get_trust(victim) >= get_trust(ch))
   {
      send_to_char("You failed.\n\r", ch);
      return;
   }
   if (victim->level < LEVEL_IMM) /* Tracker1 */
   {
      ch_printf(ch, "The minimum level for retirement is %d.\n\r", LEVEL_IMM);
      return;
   }
   if (IS_RETIRED(victim))
   {
      REMOVE_BIT(victim->pcdata->flags, PCFLAG_RETIRED);
      ch_printf(ch, "%s returns from retirement.\n\r", victim->name);
      ch_printf(victim, "%s brings you back from retirement.\n\r", ch->name);
   }
   else
   {
      SET_BIT(victim->pcdata->flags, PCFLAG_RETIRED);
      ch_printf(ch, "%s is now a retired immortal.\n\r", victim->name);
      ch_printf(victim, "Courtesy of %s, you are now a retired immortal.\n\r", ch->name);
   }
   return;
}

void do_delay(CHAR_DATA * ch, char *argument)
{
   CHAR_DATA *victim;
   char arg[MIL];
   int delay;

   set_char_color(AT_IMMORT, ch);

   argument = one_argument(argument, arg);
   if (!*arg)
   {
      send_to_char("Syntax:  delay <victim> <# of rounds>\n\r", ch);
      return;
   }
   if (!(victim = get_char_world(ch, arg)))
   {
      send_to_char("No such character online.\n\r", ch);
      return;
   }
   if (IS_NPC(victim))
   {
      send_to_char("Mobiles are unaffected by lag.\n\r", ch);
      return;
   }
   if (!IS_NPC(victim) && get_trust(victim) >= get_trust(ch))
   {
      send_to_char("You haven't the power to succeed against them.\n\r", ch);
      return;
   }
   argument = one_argument(argument, arg);
   if (!*arg)
   {
      send_to_char("For how long do you wish to delay them?\n\r", ch);
      return;
   }
   if (!str_cmp(arg, "none"))
   {
      send_to_char("All character delay removed.\n\r", ch);
      victim->wait = 0;
      return;
   }
   delay = atoi(arg);
   if (delay < 1)
   {
      send_to_char("Pointless.  Try a positive number.\n\r", ch);
      return;
   }
   if (delay > 999)
   {
      send_to_char("You cruel bastard.  Just kill them.\n\r", ch);
      return;
   }
   WAIT_STATE(victim, delay * PULSE_VIOLENCE);
   ch_printf(ch, "You've delayed %s for %d rounds.\n\r", victim->name, delay);
   return;
}

void do_deny(CHAR_DATA * ch, char *argument)
{
   char arg[MIL];
   CHAR_DATA *victim;

   set_char_color(AT_IMMORT, ch);

   one_argument(argument, arg);
   if (arg[0] == '\0')
   {
      send_to_char("Deny whom?\n\r", ch);
      return;
   }
   if ((victim = get_char_world(ch, arg)) == NULL)
   {
      send_to_char("They aren't here.\n\r", ch);
      return;
   }
   if (IS_NPC(victim))
   {
      send_to_char("Not on NPC's.\n\r", ch);
      return;
   }
   if (get_trust(victim) >= get_trust(ch))
   {
      send_to_char("You failed.\n\r", ch);
      return;
   }
   xSET_BIT(victim->act, PLR_DENY);
   set_char_color(AT_IMMORT, victim);
   send_to_char("You are denied access!\n\r", victim);
   ch_printf(ch, "You have denied access to %s.\n\r", victim->name);
   if (victim->fighting)
      stop_fighting(victim, TRUE); /* Blodkai, 97 */
   char_quit(ch, FALSE); /* Rantic's info channel */
   return;
}

void do_disconnect(CHAR_DATA * ch, char *argument)
{
   char arg[MIL];
   DESCRIPTOR_DATA *d;
   CHAR_DATA *victim;

   set_char_color(AT_IMMORT, ch);

   one_argument(argument, arg);
   if (arg[0] == '\0')
   {
      send_to_char("Disconnect whom?\n\r", ch);
      return;
   }
   if ((victim = get_char_world(ch, arg)) == NULL)
   {
      send_to_char("They aren't here.\n\r", ch);
      return;
   }
   if (victim->desc == NULL)
   {
      act(AT_PLAIN, "$N doesn't have a descriptor.", ch, NULL, victim, TO_CHAR);
      return;
   }
   if (get_trust(ch) <= get_trust(victim))
   {
      send_to_char("They might not like that...\n\r", ch);
      return;
   }

   for (d = first_descriptor; d; d = d->next)
   {
      if (d == victim->desc)
      {
         close_socket(d, FALSE);
         send_to_char("Ok.\n\r", ch);
         return;
      }
   }
   bug("Do_disconnect: *** desc not found ***.", 0);
   send_to_char("Descriptor not found!\n\r", ch);
   return;
}


/*
 * Force a level one player to quit.             Gorog
 */
void do_fquit(CHAR_DATA * ch, char *argument)
{
   CHAR_DATA *victim;
   char arg1[MIL];

   set_char_color(AT_IMMORT, ch);

   argument = one_argument(argument, arg1);
   if (arg1[0] == '\0')
   {
      send_to_char("Force whom to quit?\n\r", ch);
      return;
   }
   if (!(victim = get_char_world(ch, arg1)))
   {
      send_to_char("They aren't here.\n\r", ch);
      return;
   }
   if (!NOT_AUTHED(victim))
   {
      send_to_char("Works only on unauthed players.\n\r", ch);
      return;
   }
   set_char_color(AT_IMMORT, victim);
   send_to_char("The MUD administrators force you to quit...\n\r", victim);
   if (victim->fighting)
      stop_fighting(victim, TRUE);
   char_quit(victim, FALSE); /* Rantic's info channel */
   ch_printf(ch, "You have forced %s to quit.\n\r", victim->name);
   return;
}

void do_forceclose(CHAR_DATA * ch, char *argument)
{
   char arg[MIL];
   DESCRIPTOR_DATA *d;
   int desc;

   set_char_color(AT_IMMORT, ch);

   one_argument(argument, arg);
   if (arg[0] == '\0')
   {
      send_to_char("Usage: forceclose <descriptor#>\n\r", ch);
      return;
   }

   desc = atoi(arg);
   for (d = first_descriptor; d; d = d->next)
   {
      if (d->descriptor == desc)
      {
         if (d->character && get_trust(d->character) >= get_trust(ch))
         {
            send_to_char("They might not like that...\n\r", ch);
            return;
         }
         close_socket(d, FALSE);
         send_to_char("Ok.\n\r", ch);
         return;
      }
   }
   send_to_char("Not found!\n\r", ch);
   return;
}

void echo_to_all(sh_int AT_COLOR, char *argument, sh_int tar)
{
   DESCRIPTOR_DATA *d;

   if (!argument || argument[0] == '\0')
      return;

   for (d = first_descriptor; d; d = d->next)
   {
      /* Added showing echoes to players who are editing, so they won't
         miss out on important info like upcoming reboots. --Narn */
      if (d->connected == CON_PLAYING || d->connected == CON_EDITING)
      {
         /* This one is kinda useless except for switched.. */
         if (tar == ECHOTAR_PC && IS_NPC(d->character))
            continue;
         else if (tar == ECHOTAR_IMM && !IS_IMMORTAL(d->character))
            continue;
         set_char_color(AT_COLOR, d->character);
         send_to_char(argument, d->character);
         send_to_char("\n\r", d->character);
      }
   }
   return;
}

void do_echo(CHAR_DATA * ch, char *argument)
{
   char arg[MIL];
   sh_int color;
   int target;
   char *parg;

   set_char_color(AT_IMMORT, ch);

   if (xIS_SET(ch->act, PLR_NO_EMOTE))
   {
      send_to_char("You can't do that right now.\n\r", ch);
      return;
   }
   if (argument[0] == '\0')
   {
      send_to_char("Echo what?\n\r", ch);
      return;
   }

   if ((color = get_color(argument)))
      argument = one_argument(argument, arg);
   parg = argument;
   argument = one_argument(argument, arg);
   if (!str_cmp(arg, "PC") || !str_cmp(arg, "player"))
      target = ECHOTAR_PC;
   else if (!str_cmp(arg, "imm"))
      target = ECHOTAR_IMM;
   else
   {
      target = ECHOTAR_ALL;
      argument = parg;
   }
   if (!color && (color = get_color(argument)))
      argument = one_argument(argument, arg);
   if (!color)
      color = AT_IMMORT;
   one_argument(argument, arg);
   if (!str_cmp(arg, "Thoric") || !str_cmp(arg, "Circe") || !str_cmp(arg, "Haus") || !str_cmp(arg, "Scryn") || !str_cmp(arg, "Blodkai"))
   {
      ch_printf(ch, "I don't think %s would like that!\n\r", arg);
      return;
   }
   echo_to_all(color, argument, target);
}

void echo_to_room(sh_int AT_COLOR, ROOM_INDEX_DATA * room, char *argument)
{
   CHAR_DATA *vic;

   for (vic = room->first_person; vic; vic = vic->next_in_room)
   {
      set_char_color(AT_COLOR, vic);
      send_to_char(argument, vic);
      send_to_char("\n\r", vic);
   }
}

void do_recho(CHAR_DATA * ch, char *argument)
{
   char arg[MIL];
   sh_int color;

   set_char_color(AT_IMMORT, ch);

   if (xIS_SET(ch->act, PLR_NO_EMOTE))
   {
      send_to_char("You can't do that right now.\n\r", ch);
      return;
   }
   if (argument[0] == '\0')
   {
      send_to_char("Recho what?\n\r", ch);
      return;
   }

   one_argument(argument, arg);
   if (!str_cmp(arg, "Thoric") || !str_cmp(arg, "Circe") || !str_cmp(arg, "Haus") || !str_cmp(arg, "Scryn") || !str_cmp(arg, "Blodkai"))
   {
      ch_printf(ch, "I don't think %s would like that!\n\r", arg);
      return;
   }
   if ((color = get_color(argument)))
   {
      argument = one_argument(argument, arg);
      echo_to_room(color, ch->in_room, argument);
   }
   else
      echo_to_room(AT_IMMORT, ch->in_room, argument);
}

ROOM_INDEX_DATA *find_location(CHAR_DATA * ch, char *arg)
{
   CHAR_DATA *victim;
   OBJ_DATA *obj;

   if (is_number(arg))
      return get_room_index(atoi(arg));

   if (!str_cmp(arg, "pk")) /* "Goto pk", "at pk", etc */
      return get_room_index(last_pkroom);

   if ((victim = get_char_world(ch, arg)) != NULL)
      return victim->in_room;

   if ((obj = get_obj_world(ch, arg)) != NULL)
      return obj->in_room;

   return NULL;
}

void do_wblock(CHAR_DATA *ch, char *argument)
{
   char arg[MIL];
   WBLOCK_DATA *wblock;
   WINFO_DATA *winfo;
   int cnt = 0;
   int recent = 0;
  
   if (!IN_WILDERNESS(ch))
   {
      send_to_char("Only in the wilderness.\n\r", ch);
      return;
   }
   for (wblock = first_wblock; wblock; wblock = wblock->next)
   {   
      if (ch->coord->x <= wblock->endx && ch->coord->x >= wblock->stx 
      && ch->coord->y <= wblock->endy && ch->coord->y >= wblock->sty && ch->map == wblock->map)
      {     
         break;
      }
   }
   if (!wblock)
   {
      send_to_char("An error occured, tell Xerves.\n\r", ch);
      bug("do_wblock: In Wilderness but not in wblock section (%d %d).\n\r", ch->coord->x, ch->coord->y);
      return;
   }
  
   if (argument[0] == '\0') //Send the default info for the room you are in
   {             
      ch_printf(ch, "Startx: %d\n\r", wblock->stx);
      ch_printf(ch, "Endx:   %d\n\r", wblock->endx);
      ch_printf(ch, "Starty: %d\n\r", wblock->sty);
      ch_printf(ch, "Endy:   %d\n\r", wblock->endy); 
      ch_printf(ch, "Map     %d\n\r", wblock->map);
      ch_printf(ch, "Level   %d\n\r", wblock->lvl);
      ch_printf(ch, "Kills   %d\n\r", wblock->kills);
       
      for (winfo = wblock->first_player; winfo; winfo = winfo->next)
      {
         cnt++;
         if (time(0) - winfo->time <= 7200)
            recent++;
      }
      ch_printf(ch, "%d Players have visited\n\r", cnt);
      ch_printf(ch, "%d Of those players recently visited\n\r", recent);
      ch_printf(ch, "Type wblock players to see the full list of visited\n\r");
      return;
   }
   argument = one_argument(argument, arg);
   if (!str_prefix(arg, "players"))
   {
      for (winfo = wblock->first_player; winfo; winfo = winfo->next)
      {
        int dtime, sec, min, hour;
        char buf[150];
        dtime = time(0) - winfo->time;
        if (dtime > 86400)
        {
           dtime = dtime/86400;
           sprintf(buf, "Days Ago: %d\n\r", dtime);
        }
        else
        {
           sec = dtime % 60;
           hour = dtime / 3600;
           if (dtime > 60)
           {
              min = dtime / 60;
              min = min % 60;
           }
           else
           {
              min = 0;
           }
           sprintf(buf, "Hours: %d Minutes %d Seconds %d", hour, min, sec);
        }
        ch_printf(ch, "Pid: %d      %s\n\r", winfo->pid, buf); 
      }
      return;
   }
   if (!str_prefix(arg, "Startx") || !str_prefix(arg, "Starty") || !str_prefix(arg, "Endx") || !str_prefix(arg, "Endy"))
   {
      send_to_char("You cannot change those, sorry.\n\r", ch);
      return;
   }
   if (!str_prefix(arg, "Kills"))
   {
      if (get_trust(ch) >= LEVEL_STAFF)
      {
         if (atoi(argument) < 0 || atoi(argument) > 100)
            send_to_char("Range is 0 to 100\n\r", ch);
         wblock->kills = atoi(argument);
         save_wblock_data();
      }
      else
      {
         send_to_char("You do not have the power to do that.\n\r", ch);
         return;
      }
   }
   if (!str_prefix(arg, "Levels"))
   {
      if (get_trust(ch) >= LEVEL_STAFF)
      {
         if (atoi(argument) < 0 || atoi(argument) > 100)
            send_to_char("Range is 0 to 100\n\r", ch);
         wblock->lvl = atoi(argument);
         save_wblock_data();
      }
      else
      {
         send_to_char("You do not have the power to do that.\n\r", ch);
         return;
      }
   }
   do_wblock(ch, "");
}
      
void do_transfer(CHAR_DATA * ch, char *argument)
{
   char arg1[MIL];
   char arg2[MIL];
   char arg3[MIL];
   char buf[MSL];
   ROOM_INDEX_DATA *location;
   DESCRIPTOR_DATA *d;
   CHAR_DATA *victim;
   sh_int x = -1;
   sh_int y = -1;

   set_char_color(AT_IMMORT, ch);

   argument = one_argument(argument, arg1);
   argument = one_argument(argument, arg2);
   if (arg1[0] == '\0')
   {
      send_to_char("Transfer whom (and where)?\n\r", ch);
      return;
   }
   if (!str_cmp(arg1, "all"))
   {
      for (d = first_descriptor; d; d = d->next)
      {
         if (d->connected == CON_PLAYING
            && d->character != ch
            && d->character->in_room
            && d->newstate != 2
            && can_see_map(ch, d->character))
         {
            if (xIS_SET(d->character->act, PLR_NOTRANS))
            {
               if (get_trust(ch) >= get_trust(d->character))
               {
                  sprintf(buf, "%s %s", d->character->name, arg2);
                  do_transfer(ch, buf);
               }
            }
            else
               continue;
            sprintf(buf, "%s %s", d->character->name, arg2);
            do_transfer(ch, buf);
         }
      }
      return;
   }

   /*
    * Thanks to Grodyn for the optional location parameter.
    */

   if (arg2[0] == '\0')
   {
      location = ch->in_room;
   }
   else
   {
      if ((location = find_location(ch, arg2)) == NULL)
      {
         send_to_char("No such location.\n\r", ch);
         return;
      }
      if (room_is_private(location) && get_trust(ch) < sysdata.level_override_private)
      {
         send_to_char("That room is private right now.\n\r", ch);
         return;
      }
   }
   if ((victim = get_char_world(ch, arg1)) == NULL)
   {
      send_to_char("They aren't here.\n\r", ch);
      return;
   }
   if (!IS_NPC(victim))
   {
      if (xIS_SET(victim->in_room->room_flags, ROOM_IMP))
      {
         set_char_color(AT_WHITE, ch);
         send_to_char("Sorry, the person you tried to transfer is in an admin room\n\r", ch);
         return;
      }
   }
   if (!IS_NPC(victim))
   {
      if (xIS_SET(victim->act, PLR_GAMBLER))
      {
         send_to_char("Wait till they are done gambling and try again.\n\r", ch);
         return;
      }
   }
   if (xIS_SET(victim->act, PLR_NOTRANS))
   {
      if (get_trust(ch) < get_trust(victim))
      {
         send_to_char("Sorry, the person you tried to transfer has a notrans flag\n\r", ch);
         return;
      }
   }
   if (ch == victim || (arg2[0] != '\0'))
   {
      if (!IS_NPC(victim))
      {
         if (xIS_SET(location->room_flags, ROOM_IMP) && victim->pcdata->caste < caste_Staff)
         {
            set_char_color(AT_WHITE, ch);
            set_char_color(AT_WHITE, victim);
            send_to_char("That room is for staff only!\n\r", ch);
            send_to_char("Transfer stopped because of staff only room!\n\r", victim);
            return;
         }
      }
      else
      {
         if (xIS_SET(location->room_flags, ROOM_IMP))
            return;
      }
   }
   if (NOT_AUTHED(victim))
   {
      send_to_char("They are not authorized yet!\n\r", ch);
      return;
   }
   if (!victim->in_room)
   {
      send_to_char("They have no physical location!\n\r", ch);
      return;
   }
   if (IS_NPC(victim) && (xIS_SET(victim->act, ACT_PROTECT)) && (get_trust(ch) < LEVEL_ADMIN))
   {
      send_to_char("This mob is protected against forces, transfers, slays, and purges\n\r", ch);
      return;
   }
   if (location->vnum == OVERLAND_SOLAN)
   {
      if (!xIS_SET(ch->act, PLR_ONMAP) && xIS_SET(victim->act, ACT_ONMAP))
      {
         send_to_char("Sorry, cannot transfer a mob/player around on the map while you aren't on it.\n\r", ch);
         return;
      }
   }
   if (victim->fighting)
      stop_fighting(victim, TRUE);
   act(AT_MAGIC, "$n disappears in a cloud of swirling colors.", victim, NULL, NULL, TO_ROOM);
   victim->retran = victim->in_room->vnum;
   victim->retran_x = victim->coord->x;
   victim->retran_y = victim->coord->y;
   victim->retran_map = victim->map;
   char_from_room(victim);
   char_to_room(victim, location);

   /* To properly handle map transfers if the immortal is on the map.
    * Also handles cases of transing from one map to another - Samson 8-21-99
    */
   /* Redid to make sure it works right :-) -- Xerves */
   if (location->vnum == OVERLAND_SOLAN)
   {
      argument = one_argument(argument, arg3);
      if (arg3[0] != '\0' && argument[0] != '\0')
      {
         x = atoi(arg3);
         y = atoi(argument);

         if (x < 1 || x > MAX_X)
         {
            sprintf(buf, "Valid x coordinates are 1 to %d.\n\rThrowing out coordinates.", MAX_X);
            send_to_char(buf, ch);
            x = -1;
            y = -1;
         }

         if (y < 1 || y > MAX_Y)
         {
            sprintf(buf, "Valid y coordinates are 1 to %d.\n\rThrowing out coordinates.", MAX_Y);
            send_to_char(buf, ch);
            x = -1;
            x = -1;
         }
      }
      if (room_is_private_wilderness(ch, location, ch->coord->x, ch->coord->y, ch->map) && get_trust(ch) < sysdata.level_override_private)
      {
         send_to_char("That room is private right now.\n\r", ch);
         return;
      }
      if (!IS_NPC(victim))
      {
         if (xIS_SET(ch->act, PLR_ONMAP) && !xIS_SET(victim->act, PLR_ONMAP))
         {
            xSET_BIT(victim->act, PLR_ONMAP);

            victim->map = ch->map;
            if (x == -1 && y == -1)
            {
               victim->coord->x = ch->coord->x;
               victim->coord->y = ch->coord->y;
            }
            else
            {
               victim->coord->x = x;
               victim->coord->y = y;
            }
         }
         else if (!xIS_SET(ch->act, PLR_ONMAP) && !xIS_SET(victim->act, PLR_ONMAP))
         {
            xSET_BIT(victim->act, PLR_ONMAP);

            victim->map = MAP_SOLAN;
            if (x == -1 && y == -1)
            {
               victim->coord->x = ENTRY_X;
               victim->coord->y = ENTRY_Y;
            }
            else
            {
               victim->coord->x = x;
               victim->coord->y = y;
            }
         }
         else if (xIS_SET(ch->act, PLR_ONMAP) && xIS_SET(victim->act, PLR_ONMAP))
         {
            victim->map = ch->map;
            if (x == -1 && y == -1)
            {
               victim->coord->x = ch->coord->x;
               victim->coord->y = ch->coord->y;
            }
            else
            {
               victim->coord->x = x;
               victim->coord->y = y;
            }
         }
      }
      else
      {
         if (xIS_SET(ch->act, PLR_ONMAP) && !xIS_SET(victim->act, ACT_ONMAP))
         {
            xSET_BIT(victim->act, ACT_ONMAP);

            victim->map = ch->map;
            victim->coord->x = ch->coord->x;
            victim->coord->y = ch->coord->y;
         }
         else if (!xIS_SET(ch->act, PLR_ONMAP) && !xIS_SET(victim->act, ACT_ONMAP))
         {
            xSET_BIT(victim->act, ACT_ONMAP);

            victim->map = MAP_SOLAN;
            victim->coord->x = ENTRY_X;
            victim->coord->y = ENTRY_Y;
         }
         else if (xIS_SET(ch->act, PLR_ONMAP) && xIS_SET(victim->act, ACT_ONMAP))
         {
            victim->map = ch->map;
            victim->coord->x = ch->coord->x;
            victim->coord->y = ch->coord->y;
         }
      }
   }
   else
   {
      if (IS_NPC(victim))
         xREMOVE_BIT(victim->act, ACT_ONMAP);
      else
         xREMOVE_BIT(victim->act, PLR_ONMAP);

      victim->map = -1;
      victim->coord->x = -1;
      victim->coord->y = -1;
   }
   
   if (victim->mount)
   {
      char_from_room(victim->mount);
      char_to_room(victim->mount, victim->in_room);
      victim->mount->coord->x = victim->coord->x;
      victim->mount->coord->y = victim->coord->y;
      victim->mount->map = victim->map;
      if (victim->coord->x < 1)
         REMOVE_ONMAP_FLAG(victim->mount);
      else
         SET_ONMAP_FLAG(victim->mount);
   }  
   if (!IS_NPC(victim) && victim->pcdata->pet)
   {
      char_from_room(victim->pcdata->pet);
      char_to_room(victim->pcdata->pet, victim->in_room);
      victim->pcdata->pet->coord->x = victim->coord->x;
      victim->pcdata->pet->coord->y = victim->coord->y;
      victim->pcdata->pet->map = victim->map;
      if (victim->coord->x < 1)
         REMOVE_ONMAP_FLAG(victim->pcdata->pet);
      else
         SET_ONMAP_FLAG(victim->pcdata->pet);
   }  
   if (!IS_NPC(victim) && victim->pcdata->mount && !victim->mount)
   {
      char_from_room(victim->pcdata->mount);
      char_to_room(victim->pcdata->mount, victim->in_room);
      victim->pcdata->mount->coord->x = victim->coord->x;
      victim->pcdata->mount->coord->y = victim->coord->y;
      victim->pcdata->mount->map = victim->map;
      if (victim->coord->x < 1)
         REMOVE_ONMAP_FLAG(victim->pcdata->mount);
      else
         SET_ONMAP_FLAG(victim->pcdata->mount);
   }  
   if (victim->rider)
   {
      char_from_room(victim->rider);
      char_to_room(victim->rider, victim->in_room);
      victim->rider->coord->x = victim->coord->x;
      victim->rider->coord->y = victim->coord->y;
      victim->rider->map = victim->map;
      if (victim->coord->x < 1)
         REMOVE_ONMAP_FLAG(victim->rider);
      else
         SET_ONMAP_FLAG(victim->rider);
      update_objects(victim->rider, victim->rider->map, victim->rider->coord->x, victim->rider->coord->y);
   }  
   if (victim->riding)
   {
      char_from_room(victim->riding);
      char_to_room(victim->riding, victim->in_room);
      victim->riding->coord->x = victim->coord->x;
      victim->riding->coord->y = victim->coord->y;
      victim->riding->map = victim->map;
      if (victim->coord->x < 1)
         REMOVE_ONMAP_FLAG(victim->riding);
      else
         SET_ONMAP_FLAG(victim->riding);
      update_objects(victim->riding, victim->riding->map, victim->riding->coord->x, victim->riding->coord->y);
   }  

   if (victim->on)
   {
      victim->on = NULL;
      victim->position = POS_STANDING;
   }
   if (victim->position != POS_STANDING && victim->position != POS_RIDING)
   {
      victim->position = POS_STANDING;
   }


   update_objects(victim, victim->coord->x, victim->coord->y, victim->map);
   act(AT_MAGIC, "$n arrives from a puff of smoke.", victim, NULL, NULL, TO_ROOM);
   if (ch != victim)
      act(AT_IMMORT, "$n has transferred you.", ch, NULL, victim, TO_VICT);
   do_look(victim, "auto");
}

void do_retran(CHAR_DATA * ch, char *argument)
{
   char arg[MIL];
   CHAR_DATA *victim;
   char buf[MSL];

   set_char_color(AT_IMMORT, ch);

   argument = one_argument(argument, arg);
   if (arg[0] == '\0')
   {
      send_to_char("Retransfer whom?\n\r", ch);
      return;
   }
   if (!(victim = get_char_world(ch, arg)))
   {
      send_to_char("They aren't here.\n\r", ch);
      return;
   }
   sprintf(buf, "'%s' %d", victim->name, victim->retran);
   do_transfer(ch, buf);
   victim->coord->x = victim->retran_x;
   victim->coord->y = victim->retran_y;
   victim->map = victim->retran_map;
   if (victim->coord->x >= 1 && victim->coord->y >= 1 && victim->map >= 0)
   {
      if (IS_NPC(victim))
         xSET_BIT(victim->act, ACT_ONMAP);
      else
         xSET_BIT(victim->act, PLR_ONMAP);
   }
   return;
}

void do_regoto(CHAR_DATA * ch, char *argument)
{
   char buf[MSL];

   sprintf(buf, "%d", ch->regoto);

   if (ch->regoto_x >= 1 && ch->regoto_y >= 1 && ch->regoto_map >= 0)
      sprintf(buf, "map solan %d %d", ch->regoto_x, ch->regoto_y);

   do_goto(ch, buf);

   return;
}

/*  Added do_atmob and do_atobj to reduce lag associated with at
 *  --Shaddai
 */
void do_atmob(CHAR_DATA * ch, char *argument)
{
   char arg[MIL];
   ROOM_INDEX_DATA *location;
   ROOM_INDEX_DATA *original;
   CHAR_DATA *wch;
   sh_int origmap, origx, origy;

   set_char_color(AT_IMMORT, ch);

   argument = one_argument(argument, arg);
   if (arg[0] == '\0' || argument[0] == '\0')
   {
      send_to_char("At where what?\n\r", ch);
      return;
   }
   if ((wch = get_char_world(ch, arg)) == NULL || !IS_NPC(wch) || wch->in_room == NULL)
   {
      send_to_char("No such mobile in existance.\n\r", ch);
      return;
   }
   location = wch->in_room;
   if (room_is_private(location) || room_is_private_wilderness(ch, location, wch->coord->x, wch->coord->y, wch->map))
   {
      if (get_trust(ch) < sysdata.level_override_private) /* Tracker1 */
      {
         send_to_char("That room is private right now.\n\r", ch);
         return;
      }
      else
      {
         send_to_char("Overriding private flag!\n\r", ch);
      }
   }

   origmap = ch->map;
   origx = ch->coord->x;
   origy = ch->coord->y;

   /* Bunch of checks to make sure the "ator" is temporarily on the same grid as
    * the "atee" - Samson
    */

   if (xIS_SET(location->room_flags, ROOM_MAP) && !IS_ONMAP_FLAG(ch))
   {
      SET_ONMAP_FLAG(ch);
      ch->map = wch->map;
      ch->coord->x = wch->coord->x;
      ch->coord->y = wch->coord->y;
   }
   else if (xIS_SET(location->room_flags, ROOM_MAP) && IS_ONMAP_FLAG(ch))
   {
      ch->map = wch->map;
      ch->coord->x = wch->coord->x;
      ch->coord->y = wch->coord->y;
   }
   else if (!xIS_SET(location->room_flags, ROOM_MAP) && IS_ONMAP_FLAG(ch))
   {
      REMOVE_ONMAP_FLAG(ch);
      ch->map = -1;
      ch->coord->x = -1;
      ch->coord->y = -1;
   }

   set_char_color(AT_PLAIN, ch);
   original = ch->in_room;
   char_from_room(ch);
   char_to_room(ch, location);
   update_objects(ch, ch->coord->x, ch->coord->y, ch->map);
   interpret(ch, argument);

   if (IS_ONMAP_FLAG(ch) && !xIS_SET(original->room_flags, ROOM_MAP))
      REMOVE_ONMAP_FLAG(ch);
   else if (!IS_ONMAP_FLAG(ch) && xIS_SET(original->room_flags, ROOM_MAP))
      SET_ONMAP_FLAG(ch);

   ch->map = origmap;
   ch->coord->x = origx;
   ch->coord->y = origy;

   update_objects(ch, ch->coord->x, ch->coord->y, ch->map);

   if (!char_died(ch))
   {
      char_from_room(ch);
      char_to_room(ch, original);
   }
   return;
}

void do_atobj(CHAR_DATA * ch, char *argument)
{
   char arg[MIL];
   ROOM_INDEX_DATA *location;
   ROOM_INDEX_DATA *original;
   OBJ_DATA *obj;
   sh_int origmap, origx, origy;

   set_char_color(AT_IMMORT, ch);

   argument = one_argument(argument, arg);
   if (arg[0] == '\0' || argument[0] == '\0')
   {
      send_to_char("At where what?\n\r", ch);
      return;
   }

   if ((obj = get_obj_world(ch, arg)) == NULL || !obj->in_room)
   {
      send_to_char("No such object in existance.\n\r", ch);
      return;
   }
   location = obj->in_room;
   if (room_is_private(location) || (xIS_SET(location->room_flags, ROOM_MAP) &&  room_is_private_wilderness(ch, location, obj->coord->x, obj->coord->y, obj->map)))
   {
      if (get_trust(ch) < sysdata.level_override_private) /* Tracker1 */
      {
         send_to_char("That room is private right now.\n\r", ch);
         return;
      }
      else
      {
         send_to_char("Overriding private flag!\n\r", ch);
      }
   }

   origmap = ch->map;
   origx = ch->coord->x;
   origy = ch->coord->y;

   /* Bunch of checks to make sure the imm is on the same grid as the object - Samson */
   if (xIS_SET(location->room_flags, ROOM_MAP) && !IS_ONMAP_FLAG(ch))
   {
      SET_ONMAP_FLAG(ch);
      ch->map = obj->map;
      ch->coord->x = obj->coord->x;
      ch->coord->y = obj->coord->y;
   }
   else if (xIS_SET(location->room_flags, ROOM_MAP) && IS_ONMAP_FLAG(ch))
   {
      ch->map = obj->map;
      ch->coord->x = obj->coord->x;
      ch->coord->y = obj->coord->y;
   }
   else if (!xIS_SET(location->room_flags, ROOM_MAP) && IS_ONMAP_FLAG(ch))
   {
      REMOVE_ONMAP_FLAG(ch);
      ch->map = -1;
      ch->coord->x = -1;
      ch->coord->y = -1;
   }

   set_char_color(AT_PLAIN, ch);
   original = ch->in_room;
   char_from_room(ch);
   char_to_room(ch, location);
   update_objects(ch, ch->coord->x, ch->coord->y, ch->map);
   interpret(ch, argument);

   if (IS_ONMAP_FLAG(ch) && !xIS_SET(original->room_flags, ROOM_MAP))
      REMOVE_ONMAP_FLAG(ch);
   else if (!IS_ONMAP_FLAG(ch) && xIS_SET(original->room_flags, ROOM_MAP))
      SET_ONMAP_FLAG(ch);

   ch->map = origmap;
   ch->coord->x = origx;
   ch->coord->y = origy;
   update_objects(ch, ch->coord->x, ch->coord->y, ch->map);

   if (!char_died(ch))
   {
      char_from_room(ch);
      char_to_room(ch, original);
   }
   return;
}

void do_at(CHAR_DATA * ch, char *argument)
{
   char arg[MIL];
   ROOM_INDEX_DATA *location = NULL;
   ROOM_INDEX_DATA *original;
   DESCRIPTOR_DATA *d = NULL;
   sh_int cfound = 0;
   sh_int origmap, origx, origy;

   set_char_color(AT_IMMORT, ch);

   argument = one_argument(argument, arg);
   if (arg[0] == '\0' || argument[0] == '\0')
   {
      send_to_char("At where what?\n\r", ch);
      return;
   }
   if (is_number(arg))
      location = get_room_index(atoi(arg));
   else if (!str_cmp(arg, "pk"))
      location = get_room_index(last_pkroom);
   else
   {
      for (d = first_descriptor; d; d = d->next)
      {
         if ((d->connected != CON_PLAYING && d->connected != CON_EDITING) || !can_see_map(ch, d->character) || str_cmp(d->character->name, arg))
            continue;
         break;
      }
      if (d)
      {
         cfound = 1;
         location = d->character->in_room;
      }
   }

   if (!location)
   {
      send_to_char("No such location.\n\r", ch);
      return;
   }
   if (room_is_private(location))
   {
      if (get_trust(ch) < sysdata.level_override_private) /* Tracker1 */
      {
         send_to_char("That room is private right now.\n\r", ch);
         return;
      }
      else
      {
         send_to_char("Overriding private flag!\n\r", ch);
      }
   }
   if (xIS_SET(location->room_flags, ROOM_IMP))
   {
      send_to_char("Sorry you cannot attempt to at in a staff room.\n\r", ch);
      return;
   }
   if (xIS_SET(ch->in_room->room_flags, ROOM_IMP))
   {
      send_to_char("Please leave the staff room before doing at.\n\r", ch);
      return;
   }


   origmap = ch->map;
   origx = ch->coord->x;
   origy = ch->coord->y;

   /* Bunch of checks to make sure the imm is on the same grid as the object - Samson */
   if (d)
   {
      if (xIS_SET(location->room_flags, ROOM_MAP) && !IS_ONMAP_FLAG(ch))
      {
         SET_ONMAP_FLAG(ch);
         ch->map = d->character->map;
         ch->coord->x = d->character->coord->x;
         ch->coord->y = d->character->coord->y;
      }
      else if (xIS_SET(location->room_flags, ROOM_MAP) && IS_ONMAP_FLAG(ch))
      {
         ch->map = d->character->map;
         ch->coord->x = d->character->coord->x;
         ch->coord->y = d->character->coord->y;
      }
      else if (!xIS_SET(location->room_flags, ROOM_MAP) && IS_ONMAP_FLAG(ch))
      {
         REMOVE_ONMAP_FLAG(ch);
         ch->map = -1;
         ch->coord->x = -1;
         ch->coord->y = -1;
      }
      set_char_color(AT_PLAIN, ch);
      original = ch->in_room;
      char_from_room(ch);
      char_to_room(ch, location);
      update_objects(ch, ch->coord->x, ch->coord->y, ch->map);
      if (!room_is_private_wilderness(ch, location, ch->coord->x, ch->coord->y, ch->map) && get_trust(ch) >= sysdata.level_override_private)
      {
         interpret(ch, argument);
      }
      else
      {
         send_to_char("This room is private.\n\r", ch);
      }


      if (IS_ONMAP_FLAG(ch) && !xIS_SET(original->room_flags, ROOM_MAP))
         REMOVE_ONMAP_FLAG(ch);
      else if (!IS_ONMAP_FLAG(ch) && xIS_SET(original->room_flags, ROOM_MAP))
         SET_ONMAP_FLAG(ch);

      ch->map = origmap;
      ch->coord->x = origx;
      ch->coord->y = origy;

      update_objects(ch, ch->coord->x, ch->coord->y, ch->map);
   }
   else
   {
      REMOVE_ONMAP_FLAG(ch)

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

Site Stats

Snippets: 1791
Codebases: 571