build.c

toc/code/build.c · 339.7 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.     *
 * ------------------------------------------------------------------------ *
 *		       Online Building and Editing Module		    *
 ****************************************************************************/

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



extern int top_affect;
extern int top_reset;
extern int top_ed;
extern bool fBootDb;
int xitfailed;

/*
 * Exit Pull/push types
 * (water, air, earth, fire)
 */
char *const ex_pmisc[] = { "undefined", "vortex", "vacuum", "slip", "ice", "mysterious" };

char *const ex_pwater[] = { "current", "wave", "whirlpool", "geyser" };

char *const ex_pair[] = { "wind", "storm", "coldwind", "breeze" };

char *const ex_pearth[] = { "landslide", "sinkhole", "quicksand", "earthquake" };

char *const ex_pfire[] = { "lava", "hotair" };


char *const ex_flags[] = {
   "isdoor", "closed", "locked", "secret", "swim", "pickproof", "fly", "climb",
   "dig", "eatkey", "nopassdoor", "hidden", "passage", "portal", "r1", "r2",
   "can_climb", "can_enter", "can_leave", "auto", "noflee", "searchable",
   "bashed", "bashproof", "nomob", "window", "can_look", "overland"
};

/* r_flags is now extended -- Xerves 11/99 */
char *const r_flags[] = {
   "dark", "death", "nomob", "indoors", "lawful", "neutral", "chaotic",
   "nomagic", "tunnel", "private", "safe", "solitary", "petshop", "norecall",
   "donation", "nodropall", "silence", "logspeech", "nodrop", "clanstoreroom",
   "nosummon", "noastral", "teleport", "teleshowdesc", "nofloor",
   "nosupplicate", "arena", "nomissile", "noexit", "imp", "prototype", "casteroom",
   "mark", "wilderness", "keepdesc", "map", "mountshop", "portal", "freekill", "anitem",
   "noloot", "tsafe", "nowdam", "forgeroom", "mananode", "nomilitary", "marketplace",
   "permdeath"
};

char *const o_flags[] = {
   "glow", "hum", "dark", "loyal", "evil", "invis", "magic", "nodrop", "bless",
   "antigood", "antievil", "antineutral", "noremove", "inventory",
   "antimage", "antithief", "antiwarrior", "anticleric", "organic", "metal",
   "donation", "clanobject", "clancorpse", "antivampire", "antidruid",
   "hidden", "poisoned", "covering", "deathrot", "buried", "prototype",
   "nolocate", "groundrot", "nogive", "nopurge", "antimonk", "antipaladin",
   "antiranger", "antiaugurer", "nodisarm", "nobreak", "onmap", "lodged", "piece",
   "artifact", "forgeable", "coal", "ore", "slab", "twohanded", "imbuable", "gem",
   "gemsetting", "sanctified", "noreset", "timereset", "cloak","mortar", "powreag", 
   "affreag", "mixed", "permreag","hideidentity", "repairwall", "kingdomkey",
   "kingdomeq", "gagremove", "corpserevive", "unique", "questobj", "typesword",
   "typeaxe", "typedagger", "typepolearm", "typestaves", "typeblunt", "qtokenlooted",
   "monkweapon"
};

char *const talent_flags[] = {
   "hp1", "hp2", "hp3", "hp4", "hp5", "mp1", "mp2", "mp3", "mp4", "mp5", "str1",
   "str2", "str3", "con1", "con2", "con3", "int1", "int2", "int3", "wis1", "wis2",
   "wis3", "dex1", "dex2", "dex3", "agi1", "agi2", "agi3", "end1", "end2", "end3",
   "sp1", "sp2", "sp3", "sp4", "sp5", "damcap1", "damcap2", "damcap3"
};

char *const mag_flags[] = {
   "returning", "backstabber", "bane", "loyal", "haste", "drain",
   "lightning_blade"
};

char *const w_flags[] = {
   "take", "finger", "neck", "body", "head", "legs", "arms",
   "shield", "waist", "wield", "_dual_", "missile", "lodge_rib",
   "lodge_arm", "lodge_leg", "aneck", "nocked", "back", "r2", "r3", "r4", "r5", "r6",
   "r7", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15"
};

char *const area_flags[] = {
   "nopkill", "freekill", "noteleport", "noquest", "changed", "resource", "carpenter", "noarea", "anitem",
   "noloot", "nowdam", "r11", "r12", "r13", "r14", "r15", "r16", "r17",
   "r18", "r19", "r20", "r21", "r22", "r23", "r24",
   "r25", "r26", "r27", "r28", "r29", "r30", "r31"
};

char *const o_types[] = {
   "none", "light", "scroll", "wand", "staff", "weapon", "_fireweapon", "_missile",
   "treasure", "armor", "potion", "_worn", "furniture", "trash", "_oldtrap",
   "container", "_note", "drinkcon", "key", "food", "money", "pen", "boat",
   "corpse", "corpse_pc", "fountain", "pill", "blood", "bloodstain",
   "scraps", "pipe", "herbcon", "herb", "incense", "fire", "book", "switch",
   "lever", "pullchain", "button", "dial", "rune", "runepouch", "match", "trap",
   "map", "portal", "paper", "tinder", "lockpick", "spike", "disease", "oil",
   "fuel", "_empty1", "_empty2", "missileweapon", "projectile", "quiver", "shovel",
   "salve", "cook", "keyring", "odor", "mountfood", "holdresource", "extractobj",
   "spellbook", "sheath", "noteboard", "repair", "mclimb", "gag", "flint", "toolkit",
   "gem", "questtoken"
};

char *const buykobj_types[] = 
{
   "hometown", "wilderness", "container", "sigil", "noteboard", "toroom", "tochar", "addreset", "bin",
   "wallrepair"
};

char *const buykmob_types[] = 
{
   "wilderness", "military", "hour", "4month", "addreset", "repair", "forge", "cleric", "worker",
   "guard", "soldier", "scout", "mage", "soldieragi", "soldiermove", "soldierdam", "soldierunarmed",
   "mounted", "soldieraddagi", "soldieraddmove", "soldieronemove", "tohit1", "tohit2", "tohit3", "tohit4",
   "ac1", "ac2", "ac3", "ac4", "dam1", "dam2", "dam3", "dam4", "curelight", "cureserious", "curecritical",
   "heal", "divinity", "powerheal", "bless", "armor", "stoneskin", "sanctify", "fleetarms", "sanctuary",
   "harm", "clericdamage", "leatheronly", "lightonly", "mediumonly", "shield", "kindred", "slink", "fireshield",
   "iceshield", "shockshield", "antimagicshell", "magedamage1", "magedamage2", "magedamage3", "magedamage4",
   "archer"
};
   
char *const qmob_flags[] = {   
   "hp", "agi", "str", "str2", "int", "int2", "lint", "lint2", "lhp", "lagi", "lstr",
   "lstr2", "dex", "ldex", "con", "lcon", "wis", "wis2", "lwis", "lwis2", "lck", "llck",
   "armor", "armor2", "larmor", "larmor2", "bash", "lbash", "slash", "lslash", "stab", "lstab",
   "dam", "dam2", "ldam", "ldam2", "nogold", "gold1", "gold2", "lgold1", "lgold2",
   "noaggro", "running", "undead", "livingdead", "sentinel", "dodge", "parry",
   "light", "serious", "critical", "heal", "sanctuary", "fshield", "sshield", 
   "ishield", "stoneskin", "disarm", "trip", "abash", "stun", "gouge", "backstab", "blindness",
   "lbreath", "gbreath", "firebreath", "frostbreath", "acidbreath", "curse", "harm", "fireball",
   "weaken", "poison", "sfire", "scold", "select", "senergy", "sblunt", "spierce", "sslash", "ssleep",
   "scharm", "snonmagic", "smagic", "sparalysis", "sair", "rfire", "rcold", "relect", "renergy", "rblunt",
   "rpierce", "rslash", "rsleep", "rcharm", "rnonmagic", "rmagic", "rparalysis", "rair", "ifire", "icold",
   "ielect", "ienergy", "iblunt", "ipierce", "islash", "isleep", "icharm", "inonmagic", "imagic", "iparalysis",
   "iair", "invisibile", "detectinvis", "hide", "truesight", "sneak", "detecthidden"
};
   
   
char *const a_types[] = {
   "none", "strength", "dexterity", "intelligence", "wisdom", "constitution",
   "sex", "class", "level", "age", "height", "weight", "mana", "hit", "move",
   "gold", "experience", "ac", "hitroll", "damroll", "save_poison", "save_rod",
   "save_para", "save_breath", "save_spell", "charisma", "affected", "resistant",
   "immune", "susceptible", "weaponspell", "luck", "backstab", "pick", "track",
   "steal", "sneak", "hide", "palm", "detrap", "dodge", "peek", "scan", "gouge",
   "search", "mount", "disarm", "kick", "parry", "bash", "stun", "punch", "climb",
   "grip", "scribe", "brew", "wearspell", "removespell", "mentalstate", "emotion",
   "stripsn", "remove", "dig", "full", "thirst", "drunk", "blood", "cook",
   "recurringspell", "contagious", "xaffected", "odor", "roomflag", "sectortype",
   "roomlight", "televnum", "teledelay", "agi", "armor", "shield", "stone", "sanctify",
   "tohit", "managen", "hpgen", "weightmod", "manafuse", "fasting", "manashell", "manashield",
   "managuard", "manaburn", "weaponclamp", "arrowcatch", "bracing", "hardening",
   "rfire", "rwater", "rair", "rearth", "renergy", "rmagic", "rnonmagic", "rblunt", "rpierce",
   "rslash", "rpoison", "rparalysis", "rholy", "runholy", "rundead"
};

char *const a_flags[] = {
   "blind", "invisible", "detect_evil", "detect_invis", "detect_magic",
   "detect_hidden", "hold", "sanctuary", "faerie_fire", "infrared", "curse",
   "_flaming", "poison", "protect", "_paralysis", "sneak", "hide", "sleep",
   "charm", "flying", "pass_door", "floating", "truesight", "detect_traps",
   "scrying", "fireshield", "shockshield", "r1", "iceshield", "possess",
   "berserk", "aqua_breath", "recurringspell", "contagious", "wizardeye",
   "e_wizardeye", "m_wizardeye", "balance", "nohunger", "nothirst", "gagged",
   "rez", "web", "snare", "nervepinch", "nyiji", "stalk"
};

char *const mi_flags[] = {
   "stationary", "patrol", "warn", "attacke", "attackn", "attacka", "nopass", "report",
   "invite", "noassist", "sentinel", "conquer", "nocloak", "nohood", "attackh", "attackc",
   "needintro", "kequiped"
};

char *const act_flags[] = {
   "npc", "sentinel", "scavenger", "banker", "castemob", "aggressive", "stayarea",
   "wimpy", "pet", "train", "practice", "immortal", "noquest", "polyself",
   "meta_aggr", "guardian", "running", "nowander", "mountable", "mounted",
   "scholar", "secretive", "notrack", "mobinvis", "noassist", "autonomous",
   "pacifist", "noattack", "annoying", "healer", "prototype", "r1", "protect",
   "scared", "trainer", "onmap", "mountsave", "watermob", "extractmob", "dumpgoods",
   "noupdn", "movemap", "undead", "kingdommob", "military", "sbseller", "restorelimbs", 
   "livingdead", "noreset", "timereset", "extractgoods", "repair", "noinsta", "nomercy",
   "forgemob", "extracttown", "grabbed", "captain", "boss", "questmob", "allowride"
};

char *const pc_flags[] = {
   "r1", "deadly", "unauthed", "norecall", "nointro", "gag", "retired", "guest",
   "nosummon", "pager", "notitled", "groupwho", "diagnose", "highgag", "watch",
   "nstart", "nobeep", "nofinger", "nogroup", "autoproto", "cnoassist", "r15", "r16", "r17", "r18",
   "r19", "r20", "r21", "r22", "r23", "r24", "r25"
};

char *const plr_flags[] = {
   "npc", "boughtpet", "shovedrag", "autoexits", "autoloot", "autosac", "blank",
   "outcast", "brief", "combine", "prompt", "telnet_ga", "holylight",
   "wizinvis", "roomvnum", "silence", "noemote", "attacker", "notell", "log",
   "deny", "freeze", "thief", "killer", "litterbug", "ansi", "rip", "nice",
   "flee", "autogold", "automap", "afk", "invisprompt", "questor", "remort",
   "statquestor", "oset", "mset", "redit", "gambler", "notrans", "onmap", "mapedit",
   "boughtmount", "pov", "portalhunt", "arenachar", "away", "pkreset", "warned",
   "noweather", "target", "carrybin", "Mxp", "rpsetup", "showasimm", "shownames",
   "uknown", "showpc", "haslastname", "onduty", "nosimiliar", "kreset", "mmobiles",
   "parry", "dodge", "tumble", "mapwindow", "autosplit", "wildertiles", "noriders",
   "notohit", "questloot", "counter"
};

char *const trap_flags[] = {
   "room", "obj", "enter", "leave", "open", "close", "get", "put", "pick",
   "unlock", "north", "south", "east", "west", "up", "down", "examine",
   "northeast", "northwest", "southeast", "southwest", "getobj", "putobj", "wearobj", 
   "dropobj", "identobj", "giveobj", "sacobj", "removeobj"
};

char *const cmd_flags[] = {
   "possessed", "polymorphed", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8",
   "r9", "r10", "r11", "r12", "r13", "r14", "r15", "r16", "r17", "r18", "r19",
   "r20", "r21", "r22", "r23", "r24", "r25", "r26", "r27", "r28", "r29", "r30"
};

char *const element_flags[] = {
   "air", "earth", "water", "fire", "energy", "unholy", "divine", "undead"
};

char *const wear_locs[] = {
   "light", "finger1", "finger2", "neck", "aneck", "body", "head", "leg1",
   "leg2", "arm1", "arm2", "shield", "waist", "wield", "dual_wield", "missile_wield",
   "lodge_rib", "lodge_arm", "lodge_leg", "nocked", "back"
};

char *const ris_flags[] = {
   "fire", "cold", "earth", "energy", "blunt", "pierce", "slash", "acid",
   "poison", "drain", "sleep", "charm", "hold", "nonmagic", "plus1", "plus2",
   "plus3", "plus4", "plus5", "plus6", "magic", "paralysis", "air", "unholy", "holy",
   "undead", "r5", "r6", "r7", "r8", "r9", "r10"
};

char *const trig_flags[] = {
   "up", "unlock", "lock", "d_north", "d_south", "d_east", "d_west", "d_up",
   "d_down", "door", "container", "open", "close", "passage", "oload", "mload",
   "teleport", "teleportall", "teleportplus", "death", "cast", "fakeblade",
   "rand4", "rand6", "trapdoor", "anotherroom", "usedial", "absolutevnum",
   "showroomdesc", "autoreturn", "r2", "r3"
};

char *const part_flags[] = {
   "head", "arms", "legs", "heart", "brains", "guts", "hands", "feet", "fingers",
   "ear", "eye", "long_tongue", "eyestalks", "tentacles", "fins", "wings",
   "tail", "scales", "claws", "fangs", "horns", "tusks", "tailattack",
   "sharpscales", "beak", "haunches", "hooves", "paws", "forelegs", "feathers",
   "r1", "r2"
};

char *const attack_flags[] = {
   "bite", "claws", "tail", "sting", "punch", "kick", "trip", "bash", "stun",
   "gouge", "backstab", "feed", "drain", "firebreath", "frostbreath",
   "acidbreath", "lightnbreath", "gasbreath", "poison", "nastypoison", "gaze",
   "blindness", "causeserious", "earthquake", "causecritical", "curse",
   "flamestrike", "harm", "fireball", "colorspray", "weaken", "r1"
};

char *const defense_flags[] = {
   "parry", "dodge", "heal", "curelight", "cureserious", "curecritical",
   "dispelmagic", "dispelevil", "sanctuary", "fireshield", "shockshield",
   "shield", "bless", "stoneskin", "teleport", "monsum1", "monsum2", "monsum3",
   "monsum4", "disarm", "iceshield", "grip", "truesight", "r4", "r5", "r6", "r7",
   "r8", "r9", "r10", "r11", "r12"
};

/*
 * Note: I put them all in one big set of flags since almost all of these
 * can be shared between mobs, objs and rooms for the exception of
 * bribe and hitprcnt, which will probably only be used on mobs.
 * ie: drop -- for an object, it would be triggered when that object is
 * dropped; -- for a room, it would be triggered when anything is dropped
 *          -- for a mob, it would be triggered when anything is dropped
 *
 * Something to consider: some of these triggers can be grouped together,
 * and differentiated by different arguments... for example:
 *  hour and time, rand and randiw, speech and speechiw
 * 
 */
char *const mprog_flags[] = {
   "act", "speech", "rand", "fight", "death", "hitprcnt", "entry", "greet",
   "allgreet", "give", "bribe", "hour", "time", "wear", "remove", "sac",
   "look", "exa", "zap", "get", "drop", "damage", "repair", "randiw",
   "speechiw", "pull", "push", "sleep", "rest", "leave", "script", "use"
};


char *flag_string(int bitvector, char *const flagarray[])
{
   static char buf[MSL];
   int x;

   buf[0] = '\0';
   for (x = 0; x < 32; x++)
      if (IS_SET(bitvector, 1 << x))
      {
         strcat(buf, flagarray[x]);
         strcat(buf, " ");
      }
   if ((x = strlen(buf)) > 0)
      buf[--x] = '\0';

   return buf;
}

char *ext_flag_string(EXT_BV * bitvector, char *const flagarray[])
{
   static char buf[MSL];
   int x;

   buf[0] = '\0';
   for (x = 0; x < MAX_BITS; x++)
      if (xIS_SET(*bitvector, x))
      {
         strcat(buf, flagarray[x]);
         strcat(buf, " ");
      }
   if ((x = strlen(buf)) > 0)
      buf[--x] = '\0';

   return buf;
}

/* Below 4 functions are local handler functions for do_build -- Xerves 12/99 */

int resource_value(int value)
{
   int rvalue = 0;

   if (value == ROOM_NO_MAGIC
      || value == ROOM_PRIVATE
      || value == ROOM_SOLITARY || value == ROOM_SILENCE || value == ROOM_NODROP || value == ROOM_NO_SUMMON || value == ROOM_NO_ASTRAL)
      rvalue = 3000;

   if (value == ROOM_NO_MOB || value == ROOM_NODROPALL)
      rvalue = 2000;

   return rvalue;
}

int resource_value2(int value)
{
   int rvalue = 0;


   if (value == EX_ISDOOR)
      rvalue = 100;
   if (value == EX_SECRET || value == EX_HIDDEN)
      rvalue = 1000;
   if (value == EX_PICKPROOF || value == EX_BASHPROOF || value == EX_NOPASSDOOR)
      rvalue = 3000;

   return rvalue;
}

bool can_build(CHAR_DATA * ch, int x, int y)
{
   int cnt;
   
   if (IS_NPC(ch))
      return FALSE;
      
   for (cnt = 1; cnt <= 150; cnt++)
   {
      if (ch->pcdata->town->roomcoords[cnt][0] == x && ch->pcdata->town->roomcoords[cnt][1] == y
      &&  ch->pcdata->town->roomcoords[cnt][2] == ch->map)
      {     
         break;
      }
   }
   if (cnt == 151)
      return FALSE;
   if (kingdom_sector[ch->map][x][y] != ch->pcdata->hometown)
      return FALSE;
   if (!in_town_range(ch->pcdata->town, x, y, ch->map))
      return FALSE;
      
   return TRUE;
}

bool can_rmodify(CHAR_DATA * ch, ROOM_INDEX_DATA * room)
{
   sh_int vnum = room->vnum;
   AREA_DATA *pArea;

   if (IS_NPC(ch))
      return FALSE;

   if (IS_ONMAP_FLAG(ch))
   {
      send_to_char("You cannot use redit from the overland maps.\n\r", ch);
      return FALSE;
   }
   if (get_trust(ch) >= sysdata.level_modify_proto)
      return TRUE;
   if (!xIS_SET(room->room_flags, ROOM_PROTOTYPE))
   {
      send_to_char("You cannot modify this room.\n\r", ch);
      return FALSE;
   }
   if (!ch->pcdata || !(pArea = ch->pcdata->area))
   {
      send_to_char("You must have an assigned area to modify this room.\n\r", ch);
      return FALSE;
   }
   if (vnum >= pArea->low_r_vnum && vnum <= pArea->hi_r_vnum)
      return TRUE;

   send_to_char("That room is not in your allocated range.\n\r", ch);
   return FALSE;
}

bool is_prototype(CHAR_DATA *ch, OBJ_DATA * obj, CHAR_DATA *mob)
{
   if (ch && !IS_NPC(ch) && IS_SET(ch->pcdata->flags, PCFLAG_AUTOPROTO))
      return TRUE;
   if (obj)
   {
      if (IS_OBJ_STAT(obj, ITEM_PROTOTYPE))
         return TRUE;
   }
   if (mob)
   {
      if (IS_ACT_FLAG(mob, ACT_PROTOTYPE))
         return TRUE;
   }
   return FALSE;
}


bool can_omodify(CHAR_DATA * ch, OBJ_DATA * obj)
{
   sh_int vnum = obj->pIndexData->vnum;
   AREA_DATA *pArea;

   if (IS_NPC(ch))
      return FALSE;
   if (get_trust(ch) >= sysdata.level_modify_proto)
      return TRUE;
   if (!IS_OBJ_STAT(obj, ITEM_PROTOTYPE))
   {
      send_to_char("You cannot modify this object.\n\r", ch);
      return FALSE;
   }
   if (!ch->pcdata || !(pArea = ch->pcdata->area))
   {
      send_to_char("You must have an assigned area to modify this object.\n\r", ch);
      return FALSE;
   }
   if (vnum >= pArea->low_o_vnum && vnum <= pArea->hi_o_vnum)
      return TRUE;

   send_to_char("That object is not in your allocated range.\n\r", ch);
   return FALSE;
}

bool can_oedit(CHAR_DATA * ch, OBJ_INDEX_DATA * obj)
{
   sh_int vnum = obj->vnum;
   AREA_DATA *pArea;

   if (IS_NPC(ch))
      return FALSE;
   if (get_trust(ch) >= sysdata.level_modify_proto) /* Tracker1 */
      return TRUE;
   if (!IS_OBJ_STAT(obj, ITEM_PROTOTYPE))
   {
      send_to_char("You cannot modify this object.\n\r", ch);
      return FALSE;
   }
   if (!ch->pcdata || !(pArea = ch->pcdata->area))
   {
      send_to_char("You must have an assigned area to modify this object.\n\r", ch);
      return FALSE;
   }
   if (vnum >= pArea->low_o_vnum && vnum <= pArea->hi_o_vnum)
      return TRUE;

   send_to_char("That object is not in your allocated range.\n\r", ch);
   return FALSE;
}


bool can_mmodify(CHAR_DATA * ch, CHAR_DATA * mob)
{
   sh_int vnum;
   AREA_DATA *pArea;

   if (mob == ch)
      return TRUE;

   if (!IS_NPC(mob))
   {
      if (get_trust(ch) >= sysdata.level_modify_proto && get_trust(ch) > get_trust(mob))
         return TRUE;
      else
         send_to_char("You can't do that.\n\r", ch);
      return FALSE;
   }

   vnum = mob->pIndexData->vnum;

   if (IS_NPC(ch))
      return FALSE;
   if (get_trust(ch) >= sysdata.level_modify_proto)
      return TRUE;
   if (!xIS_SET(mob->act, ACT_PROTOTYPE))
   {
      send_to_char("You cannot modify this mobile.\n\r", ch);
      return FALSE;
   }
   if (!ch->pcdata || !(pArea = ch->pcdata->area))
   {
      send_to_char("You must have an assigned area to modify this mobile.\n\r", ch);
      return FALSE;
   }
   if (vnum >= pArea->low_m_vnum && vnum <= pArea->hi_m_vnum)
      return TRUE;

   send_to_char("That mobile is not in your allocated range.\n\r", ch);
   return FALSE;
}

bool can_medit(CHAR_DATA * ch, MOB_INDEX_DATA * mob)
{
   sh_int vnum = mob->vnum;
   AREA_DATA *pArea;

   if (IS_NPC(ch))
      return FALSE;
   if (get_trust(ch) >= sysdata.level_modify_proto) /* Tracker1 */
      return TRUE;
   if (!xIS_SET(mob->act, ACT_PROTOTYPE))
   {
      send_to_char("You cannot modify this mobile.\n\r", ch);
      return FALSE;
   }
   if (!ch->pcdata || !(pArea = ch->pcdata->area))
   {
      send_to_char("You must have an assigned area to modify this mobile.\n\r", ch);
      return FALSE;
   }
   if (vnum >= pArea->low_m_vnum && vnum <= pArea->hi_m_vnum)
      return TRUE;

   send_to_char("That mobile is not in your allocated range.\n\r", ch);
   return FALSE;
}

int get_otype(char *type)
{
   int x;

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

int get_aflag(char *flag)
{
   int x;

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

int get_qmobflag(char *flag)
{
   int x;
   
   for (x = 0; x < (sizeof(qmob_flags) / sizeof(qmob_flags[0])); x++)
      if (!str_cmp(flag, qmob_flags[x]))
         return x;
   return -1;
}

int get_trapflag(char *flag)
{
   int x;

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

int get_atype(char *type)
{
   int x;

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

char *print_npc_race(int race)
{
   if (npcrace_table[race])
      return npcrace_table[race]->racename;
   else
      return "????";
}

int get_npc_race(char *type)
{
   int x;

   for (x = 0; x < MAX_NPCRACE_TABLE; x++)
   {
      if (npcrace_table[x] && !str_cmp(type, npcrace_table[x]->racename))
         return x;
   }
   return -1;
}

int get_wearloc(char *type)
{
   int x;

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

int get_exflag(char *flag)
{
   int x;

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

int get_pulltype(char *type)
{
   int x;

   if (!str_cmp(type, "none") || !str_cmp(type, "clear"))
      return 0;

   for (x = 0; x < (sizeof(ex_pmisc) / sizeof(ex_pmisc[0])); x++)
      if (!str_cmp(type, ex_pmisc[x]))
         return x;

   for (x = 0; x < (sizeof(ex_pwater) / sizeof(ex_pwater[0])); x++)
      if (!str_cmp(type, ex_pwater[x]))
         return x + PT_WATER;
   for (x = 0; x < (sizeof(ex_pair) / sizeof(ex_pair[0])); x++)
      if (!str_cmp(type, ex_pair[x]))
         return x + PT_AIR;
   for (x = 0; x < (sizeof(ex_pearth) / sizeof(ex_pearth[0])); x++)
      if (!str_cmp(type, ex_pearth[x]))
         return x + PT_EARTH;
   for (x = 0; x < (sizeof(ex_pfire) / sizeof(ex_pfire[0])); x++)
      if (!str_cmp(type, ex_pfire[x]))
         return x + PT_FIRE;
   return -1;
}

int get_rflag(char *flag)
{
   int x;

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

int get_mpflag(char *flag)
{
   int x;

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

int get_oflag(char *flag)
{
   int x;

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

int get_areaflag(char *flag)
{
   int x;

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

int get_wflag(char *flag)
{
   int x;

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

int get_miflag(char *flag)
{
   int x;

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

int get_actflag(char *flag)
{
   int x;

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

int get_talentflag(char *flag)
{
   int x;

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

int get_buykmobflag(char *type)
{
   int x;

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

int get_buykobjflag(char *type)
{
   int x;

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

int get_pcflag(char *flag)
{
   int x;

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

int get_plrflag(char *flag)
{
   int x;

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

int get_elementflag(char *flag)
{
   int x;

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

int get_risflag(char *flag)
{
   int x;

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

/*
 * For use with cedit --Shaddai
 */

int get_cmdflag(char *flag)
{
   int x;

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

int get_trigflag(char *flag)
{
   int x;

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

int get_partflag(char *flag)
{
   int x;

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

int get_attackflag(char *flag)
{
   int x;

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

int get_defenseflag(char *flag)
{
   int x;

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

int get_langflag(char *flag)
{
   int x;

   for (x = 0; lang_array[x] != LANG_UNKNOWN; x++)
      if (!str_cmp(flag, lang_names[x]))
         return lang_array[x];
   return LANG_UNKNOWN;
}
int get_langnum(char *flag)
{
   int x;

   for (x = 0; lang_array[x] != LANG_UNKNOWN; x++)
      if (!str_cmp(flag, lang_names[x]))
         return x;
   return -1;
}

/*
 * Remove carriage returns from a line
 */
char *strip_cr(char *str)
{
   static char newstr[MSL];
   int i, j;

   for (i = j = 0; str[i] != '\0'; i++)
      if (str[i] != '\r')
      {
         newstr[j++] = str[i];
      }
   newstr[j] = '\0';
   return newstr;
}

void goto_char(CHAR_DATA * ch, CHAR_DATA * wch, char *argument)
{
   ROOM_INDEX_DATA *location, *in_room;
   CHAR_DATA *fch, *fch_next;

   set_char_color(AT_IMMORT, ch);
   location = wch->in_room;

   if (is_ignoring(wch, ch))
   {
      send_to_char("No such location.\n\r", ch);
      return;
   }

   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)
      {
         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_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;
   }

   in_room = ch->in_room;
   if (ch->fighting)
      stop_fighting(ch, TRUE);

   /* Modified bamfout processing by Altrag, installed by Samson 12-10-97 */

   if (!xIS_SET(ch->act, PLR_WIZINVIS))
   {
	if(ch->pcdata && ch->pcdata->bamfout[0] != '\0')
	{
		act(AT_IMMORT, "$T", ch, NULL, ch->pcdata->bamfout, TO_ROOM);
	}
	else
	{
      		act(AT_IMMORT, "$T", ch, NULL, "leaves in a swirling mist.", TO_ROOM);
   	}
   }
   ch->regoto = ch->in_room->vnum;
   ch->regoto_x = ch->coord->x;
   ch->regoto_y = ch->coord->y;
   ch->regoto_map = ch->map;
   char_from_room(ch);
   if (ch->mount)
   {
      char_from_room(ch->mount);
      char_to_room(ch->mount, location);
   }
   char_to_room(ch, location);

   /* Modified bamfin processing by Altrag, installed by Samson 12-10-97 */
   if (!xIS_SET(ch->act, PLR_WIZINVIS))
   {
     	 if(ch->pcdata && ch->pcdata->bamfin[0] != '\0')
	 {
		act(AT_IMMORT, "$T", ch, NULL, ch->pcdata->bamfin, TO_ROOM);
	 }
	 else
	 {
	 	act(AT_IMMORT, "$T", ch, NULL, "appears in a swirling mist.", TO_ROOM);
   	 }
   }
   do_look(ch, "auto");

   if (ch->in_room == in_room)
      return;
   for (fch = in_room->first_person; fch; fch = fch_next)
   {
      fch_next = fch->next_in_room;
      if (fch->master == ch && IS_IMMORTAL(fch))
      {
         act(AT_ACTION, "You follow $N.", fch, NULL, ch, TO_CHAR);
         do_goto(fch, argument);
      }
/* Experimental change by Gorog so imm's personal mobs follow them */
      else if (IS_NPC(fch) && fch->master == ch)
      {
         char_from_room(fch);
         char_to_room(fch, location);
      }
   }
   return;
}

void goto_obj(CHAR_DATA * ch, OBJ_DATA * obj, char *argument)
{
   ROOM_INDEX_DATA *location, *in_room;
   CHAR_DATA *fch, *fch_next;

   set_char_color(AT_IMMORT, ch);
   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)
      {
         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_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;
   }

   in_room = ch->in_room;
   if (ch->fighting)
      stop_fighting(ch, TRUE);

   /* Modified bamfout processing by Altrag, installed by Samson 12-10-97 */
   if (!xIS_SET(ch->act, PLR_WIZINVIS))
      act(AT_IMMORT, "$n $T", ch, NULL, (ch->pcdata && ch->pcdata->bamfout[0] != '\0') ? ch->pcdata->bamfout : "leaves in a swirling mist.", TO_ROOM);

   ch->regoto = ch->in_room->vnum;
   ch->regoto_x = ch->coord->x;
   ch->regoto_y = ch->coord->y;
   ch->regoto_map = ch->map;
   char_from_room(ch);
   if (ch->mount)
   {
      char_from_room(ch->mount);
      char_to_room(ch->mount, location);
   }
   char_to_room(ch, location);

   /* Modified bamfin processing by Altrag, installed by Samson 12-10-97 */
   if (!xIS_SET(ch->act, PLR_WIZINVIS))
      act(AT_IMMORT, "$n $T", ch, NULL, (ch->pcdata && ch->pcdata->bamfin[0] != '\0') ? ch->pcdata->bamfin : "appears in a swirling mist.", TO_ROOM);

   do_look(ch, "auto");

   if (ch->in_room == in_room)
      return;
   for (fch = in_room->first_person; fch; fch = fch_next)
   {
      fch_next = fch->next_in_room;
      if (fch->master == ch && IS_IMMORTAL(fch))
      {
         act(AT_ACTION, "You follow $N.", fch, NULL, ch, TO_CHAR);
         do_goto(fch, argument);
      }
/* Experimental change by Gorog so imm's personal mobs follow them */
      else if (IS_NPC(fch) && fch->master == ch)
      {
         char_from_room(fch);
         char_to_room(fch, location);
      }
   }
   return;
}

void do_goto(CHAR_DATA * ch, char *argument)
{
   char arg[MIL];
   ROOM_INDEX_DATA *location;
   CHAR_DATA *fch;
   CHAR_DATA *wch;
   OBJ_DATA *obj;
   CHAR_DATA *fch_next;
   ROOM_INDEX_DATA *in_room;
   AREA_DATA *pArea;
   sh_int vnum;

   argument = one_argument(argument, arg);
   if (arg[0] == '\0')
   {
      send_to_char("Goto where?\n\r", ch);
      return;
   }
   if (IS_NPC(ch))
   {
      send_to_char("Mobs cannot use goto, they need to use mpgoto.\n\r", ch);
      return;
   }

   /* Begin Overland Map additions */
   if (!str_cmp(arg, "map"))
   {
      char arg1[MIL];
      char arg2[MIL];
      int x, y;
      int map = -1;

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

      if (arg1[0] == '\0')
      {
         send_to_char("Goto which map??\n\r", ch);
         return;
      }

      if (!str_cmp(arg1, "solan"))
         map = MAP_SOLAN;

      if (map == -1)
      {
         ch_printf(ch, "There isn't a map for '%s'.\n\r", arg1);
         return;
      }

      if (arg2[0] == '\0' && argument[0] == '\0')
      {
         enter_map(ch, 258, 250, map);
         return;
      }

      if (arg2[0] == '\0' || argument[0] == '\0')
      {
         send_to_char("Usage: goto map <mapname> <X> <Y>\n\r", ch);
         return;
      }

      x = atoi(arg2);
      y = atoi(argument);

      if (x < 1 || x > MAX_X)
      {
         ch_printf(ch, "Valid x coordinates are 1 to %d.\n\r", MAX_X);
         return;
      }

      if (y < 1 || y > MAX_Y)
      {
         ch_printf(ch, "Valid y coordinates are 1 to %d.\n\r", MAX_Y);
         return;
      }
      
      if (room_is_private_wilderness(ch, get_room_index(OVERLAND_SOLAN), x, y, map))
      {
         if (get_trust(ch) < sysdata.level_override_private)
         {
            send_to_char("That room is private right now.\n\r", ch);
            return;
         }
         else
            send_to_char("Overriding private flag!\n\r", ch);
      }


      if (ch->on)
      {
         ch->on = NULL;
         ch->position = POS_STANDING;
      }
      if (ch->position != POS_STANDING)
      {
         ch->position = POS_STANDING;
      }

      ch->regoto = ch->in_room->vnum;
      ch->regoto_x = ch->coord->x;
      ch->regoto_y = ch->coord->y;
      ch->regoto_map = ch->map;
      enter_map(ch, x, y, map);
      update_objects(ch, ch->coord->x, ch->coord->y, ch->map);
      return;
   }

   if (!is_number(arg))
   {
      if (ch->on)
      {
         ch->on = NULL;
         ch->position = POS_STANDING;
      }
      if (ch->position != POS_STANDING)
      {
         ch->position = POS_STANDING;
      }
      if ((wch = get_char_world(ch, arg)) != NULL && wch->in_room != NULL)
      {
         goto_char(ch, wch, argument);

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

      if ((obj = get_obj_world(ch, arg)) != NULL && obj->in_room != NULL)
      {
         goto_obj(ch, obj, argument);
         update_objects(ch, ch->coord->x, ch->coord->y, ch->map);
         return;
      }
   }
   /* End of Overland Map additions */

   if ((location = find_location(ch, arg)) == NULL)
   {
      vnum = atoi(arg);
      if (vnum < 0 || get_room_index(vnum))
      {
         send_to_char("You cannot find that...\n\r", ch);
         return;
      }
      if (get_trust(ch) < LEVEL_IMM /* Tracker1 */
         || vnum < 1 || IS_NPC(ch) || !ch->pcdata->area)
      {
         send_to_char("No such location.\n\r", ch);
         return;
      }
      if (get_trust(ch) < sysdata.level_modify_proto)
      {
         if (!ch->pcdata || !(pArea = ch->pcdata->area))
         {
            send_to_char("You must have an assigned area to create rooms.\n\r", ch);
            return;
         }
         if (vnum < pArea->low_r_vnum || vnum > pArea->hi_r_vnum)
         {
            send_to_char("That room is not within your assigned range.\n\r", ch);
            return;
         }
      }
      location = make_room(vnum);
      if (!location)
      {
         bug("Goto: make_room failed", 0);
         return;
      }
      location->area = ch->pcdata->area;
      set_char_color(AT_WHITE, ch);
      send_to_char("Waving your hand, you form order from swirling chaos,\n\rand step into a new reality...\n\r", ch);
   }

   if (room_is_private(location))
   {
      if (get_trust(ch) < sysdata.level_override_private)
      {
         send_to_char("That room is private right now.\n\r", ch);
         return;
      }
      else
         send_to_char("Overriding private flag!\n\r", ch);
   }

   if (!IS_NPC(ch))
   {
      if (xIS_SET(location->room_flags, ROOM_IMP) && ch->pcdata->caste < caste_Staff)
      {
         send_to_char("Nice Try, for Staff only\n\r", ch);
         return;
      }
   }
   else
   {
      if (xIS_SET(location->room_flags, ROOM_IMP))
         return;
   }
   if (!IS_NPC(ch))
   {
      if (xIS_SET(ch->act, PLR_GAMBLER))
      {
         send_to_char("I don't think leaving while gambling is a good idea!\n\r", ch);
         return;
      }
   }
   in_room = ch->in_room;
   if (ch->fighting)
      stop_fighting(ch, TRUE);

   if (!xIS_SET(ch->act, PLR_WIZINVIS))
      act(AT_IMMORT, "$n $T", ch, NULL, (ch->pcdata && ch->pcdata->bamfout[0] != '\0') ? ch->pcdata->bamfout : "leaves in a swirling mist.", TO_ROOM);

   ch->regoto = ch->in_room->vnum;
   ch->regoto_x = ch->coord->x;
   ch->regoto_y = ch->coord->y;
   ch->regoto_map = ch->map;
   char_from_room(ch);
   if (ch->mount)
   {
      char_from_room(ch->mount);
      char_to_room(ch->mount, location);
   }
   char_to_room(ch, location);
   if (IS_ONMAP_FLAG(ch))
   {
      REMOVE_ONMAP_FLAG(ch);
      REMOVE_PLR_FLAG(ch, PLR_MAPEDIT); /* Just in case they were editing */

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

   if (!xIS_SET(ch->act, PLR_WIZINVIS))
      act(AT_IMMORT, "$n $T", ch, NULL, (ch->pcdata && ch->pcdata->bamfin[0] != '\0') ? ch->pcdata->bamfin : "appears in a swirling mist.", TO_ROOM);

   do_look(ch, "auto");

   if (ch->in_room == in_room)
      return;
   for (fch = in_room->first_person; fch; fch = fch_next)
   {
      fch_next = fch->next_in_room;
      if (fch->master == ch && IS_IMMORTAL(fch))
      {
         act(AT_ACTION, "You follow $N.", fch, NULL, ch, TO_CHAR);
         do_goto(fch, argument);
      }
/* Experimental change by Gorog so imm's personal mobs follow them */
      else if (IS_NPC(fch) && fch->master == ch)
      {
         char_from_room(fch);
         char_to_room(fch, location);
      }
   }
   return;
}

//Destory a trainer :=)
void do_tdelete(CHAR_DATA * ch, char *argument)
{
   CHAR_DATA *victim;
   TRAINER_DATA *tdata;
   char buf[MSL];

   if (IS_NPC(ch))
   {
      send_to_char("This command is not for mobiles.\n\r", ch);
      return;
   }
   if (argument[0] == '\0')
   {
      send_to_char("Syntax: tdelete <mobile name>\n\r", ch);
      return;
   }
   if ((victim = get_char_room_new(ch, argument, 1)) == NULL)
   {
      send_to_char("They aren't here.\n\r", ch);
      return;
   }
   if (!IS_NPC(victim))
   {
      send_to_char("Only works on NPCs.\n\r", ch);
      return;
   }
   //Find the trainer and remove it, else tell player
   for (tdata = first_trainer; tdata; tdata = tdata->next)
   {
      if (tdata->vnum == victim->pIndexData->vnum)
      {
         xREMOVE_BIT(victim->act, ACT_TRAINER);
         xREMOVE_BIT(victim->act, ACT_CASTEMOB);
         xREMOVE_BIT(victim->act, ACT_PACIFIST);
         xREMOVE_BIT(victim->act, ACT_SENTINEL);
         xREMOVE_BIT(victim->pIndexData->act, ACT_TRAINER);
         xREMOVE_BIT(victim->pIndexData->act, ACT_CASTEMOB);
         xREMOVE_BIT(victim->pIndexData->act, ACT_PACIFIST);
         xREMOVE_BIT(victim->pIndexData->act, ACT_SENTINEL);
         UNLINK(tdata, first_trainer, last_trainer, next, prev);
         DISPOSE(tdata);
         fold_area(victim->in_room->area, victim->in_room->area->filename, FALSE, 1);
         sprintf(buf, "%s has removed %s as a trainer.", ch->name, victim->name);
         log_string_plus(buf, LOG_BUILD, ch->level);
         save_trainer_data();
         return;
      }
   }
   send_to_char("The Mob is no longer a trainer, remember pacifist and sentinel removed.\n\r", ch);
   return;
}


//Create a trainer setting for the poor mobile
void do_tcreate(CHAR_DATA * ch, char *argument)
{
   CHAR_DATA *victim;
   TRAINER_DATA *tdata;
   char buf[MSL];
   int x;

   if (IS_NPC(ch))
   {
      send_to_char("This command is not for mobiles.\n\r", ch);
      return;
   }
   if (argument[0] == '\0')
   {
      send_to_char("Syntax: tcreate <mobile name>\n\r", ch);
      return;
   }
   if ((victim = get_char_room_new(ch, argument, 1)) == NULL)
   {
      send_to_char("They aren't here.\n\r", ch);
      return;
   }
   if (!IS_NPC(victim))
   {
      send_to_char("Only works on NPCs.\n\r", ch);
      return;
   }
   //Make sure the mobile isn't already a trainer
   for (tdata = first_trainer; tdata; tdata = tdata->next)
   {
      if (tdata->vnum == victim->pIndexData->vnum)
      {
         send_to_char("This mobile is already a trainer, make sure it has a TRAINER flag.\n\r", ch);
         return;
      }
   }
   //It is clear now to add the mobile
   CREATE(tdata, TRAINER_DATA, 1);
   for (x = 0; x < 20; x++)
   {
      tdata->sn[x] = 0;
      tdata->mastery[x] = 0;
   }
   tdata->vnum = victim->pIndexData->vnum;
   xSET_BIT(victim->act, ACT_TRAINER);
   xSET_BIT(victim->act, ACT_CASTEMOB);
   xSET_BIT(victim->act, ACT_SENTINEL);
   xSET_BIT(victim->act, ACT_PACIFIST);
   xSET_BIT(victim->pIndexData->act, ACT_TRAINER);
   xSET_BIT(victim->pIndexData->act, ACT_CASTEMOB);
   xSET_BIT(victim->pIndexData->act, ACT_SENTINEL);
   xSET_BIT(victim->pIndexData->act, ACT_PACIFIST);
   LINK(tdata, first_trainer, last_trainer, next, prev);
   fold_area(victim->in_room->area, victim->in_room->area->filename, FALSE, 1);
   sprintf(buf, "%s has added %s as a trainer.", ch->name, victim->name);
   log_string_plus(buf, LOG_BUILD, ch->level);
   save_trainer_data();
   send_to_char("Done.\n\r", ch);
   return;
}

//View the trainers stats
void do_tstat(CHAR_DATA * ch, char *argument)
{
   CHAR_DATA *victim;
   TRAINER_DATA *tdata;
   BUYKTRAINER_DATA *ktrainer =NULL;
   int x;

   if (IS_NPC(ch))
   {
      send_to_char("This command is not for mobiles.\n\r", ch);
      return;
   }
   if (argument[0] == '\0')
   {
      send_to_char("Syntax: tstat <mobile name>\n\r", ch);
      return;
   }
   if ((victim = get_char_room_new(ch, argument, 1)) == NULL)
   {
      send_to_char("They aren't here.\n\r", ch);
      return;
   }
   if (!IS_NPC(victim))
   {
      send_to_char("Only works on NPCs.\n\r", ch);
      return;
   }
   //Find the trainer
   for (tdata = first_trainer; tdata; tdata = tdata->next)
   {
      if (tdata->vnum == victim->pIndexData->vnum)
      {
         break; //Trainer found, now break;
      }
   }
   if (!tdata)
   {
      for (ktrainer = first_buyktrainer; ktrainer; ktrainer = ktrainer->next)
      {
         if (victim->pIndexData->vnum == MOB_VNUM_TRAINER && victim->m2 == ktrainer->pid)
            break;
      }
   }
   if (tdata == NULL && ktrainer == NULL)
   {
      send_to_char("That mobile is not a trainer, to make the mobile a trainer, use tcreate.\n\r", ch);
      return;
   }
   for (x = 0; x < 20; x++)
   {
      if (tdata)
      {
         if (tdata->sn[x] != 0 && tdata->mastery[x] > 0)
         {
            if (!IS_VALID_SN(tdata->sn[x]))
            {
               bug("%s has an invalid sn at slot %d", victim->name, x + 1);
               ch_printf(ch, "&G&WSlot %d:  &c&wERROR: Has an invalid Sn.\n\r", x + 1);
               continue;
            }
            ch_printf(ch, "&G&WSlot %d:  &c&wMastery: &C%-8s   &c&wSkill: &c%s\n\r", x + 1,
               get_mastery_name(tdata->mastery[x]), skill_table[tdata->sn[x]]->name);
         }
      }
      else
      {
         if (ktrainer->sn[x] != 0 && ktrainer->mastery[x] > 0)
         {
            if (!IS_VALID_SN(ktrainer->sn[x]))
            {
               bug("%s has an invalid sn at slot %d", victim->name, x + 1);
               ch_printf(ch, "&G&WSlot %d:  &c&wERROR: Has an invalid Sn.\n\r", x + 1);
               continue;
            }
            ch_printf(ch, "&G&WSlot %d:  &c&wMastery: &C%-8s   &c&wSkill: &c%s\n\r", x + 1,
               get_mastery_name(ktrainer->mastery[x]), skill_table[ktrainer->sn[x]]->name);
         }
      }
   }
}

//Set the trainer values
void do_tset(CHAR_DATA * ch, char *argument)
{
   CHAR_DATA *victim;
   TRAINER_DATA *tdata;
   BUYKTRAINER_DATA *ktrainer = NULL;
   char arg1[MIL];
   char arg2[MIL];
   char buf[MSL];
   char masterybuf1[MSL];
   char masterybuf2[MSL];
   char snbuf1[MSL];
   char snbuf2[MSL];
   int cnt;
   int sn;

   if (IS_NPC(ch))
   {
      send_to_char("This command is not for mobiles.\n\r", ch);
      return;
   }
   if (argument[0] == '\0')
   {
      send_to_char("Syntax: tset <mobile> <field> <value>\n\r", ch);
      send_to_char("\n\rField being one of:\n\r", ch);
      send_to_char("Sn1-20, Mastery1-20\n\r", ch);
      return;
   }
   sprintf(buf, "tset: %s  tset %s", ch->name, argument);
   argument = one_argument(argument, arg1);
   argument = one_argument(argument, arg2);
   if ((victim = get_char_room_new(ch, arg1, 1)) == NULL)
   {
      send_to_char("They aren't here.\n\r", ch);
      return;
   }
   if (!IS_NPC(victim))
   {
      send_to_char("Only works on NPCs.\n\r", ch);
      return;
   }
   //Make sure the mobile isn't already a trainer
   for (tdata = first_trainer; tdata; tdata = tdata->next)
   {
      if (tdata->vnum == victim->pIndexData->vnum)
      {
         break; //Found it, so break
      }
   }
   if (!tdata)
   {
      for (ktrainer = first_buyktrainer; ktrainer; ktrainer = ktrainer->next)
      {
         if (victim->pIndexData->vnum == MOB_VNUM_TRAINER && victim->m2 == ktrainer->pid)
            break;
      }
   }
   if (tdata == NULL && ktrainer == NULL)
   {
      send_to_char("That mobile is not a trainer, to make the mobile a trainer, use tcreate.\n\r", ch);
      return;
   }
   log_string_plus(buf, LOG_BUILD, ch->level);
   //A simple loop which creates checks for sn1-20, etc without wasting MANY lines
   for (cnt = 0; cnt < 20; cnt++)
   {
      sprintf(snbuf1, "sn%d", cnt + 1);
      sprintf(snbuf2, "Sn%d", cnt + 1);
      sprintf(masterybuf1, "mastery%d", cnt + 1);
      sprintf(masterybuf2, "Mastery%d", cnt + 1);

      if (!str_cmp(arg2, snbuf1) || !str_cmp(arg2, snbuf2))
      {
         if (isdigit(argument[0]))
         {
            if (!IS_VALID_SN(atoi(argument)) && (atoi(argument) != 0))
            {
               send_to_char("The sn you provided is invalid.\n\r", ch);
               return;
            }
            if (tdata)
               tdata->sn[cnt] = atoi(argument);
            else
               ktrainer->sn[cnt] = atoi(argument);
         }
         else
         {
            sn = skill_lookup(argument);
            if (sn == -1)
            {
               send_to_char("Invalid Skill or Spell.\n\r", ch);
               return;
            }
            if (tdata)
               tdata->sn[cnt] = sn;
            else
               ktrainer->sn[cnt] = sn;
         }
         send_to_char("Done.\n\r", ch);
         if (tdata)
            save_trainer_data();
         else
            save_buykingdom_data();
         return;
      }
      if (!str_cmp(arg2, masterybuf1) || !str_cmp(arg2, masterybuf2))
      {
         if (isdigit(argument[0]))
         {
            if (atoi(argument) < 0 || atoi(argument) > MAX_RANKING)
            {
               ch_printf(ch, "The range for mastery is 0 to %d", MAX_RANKING);
               return;
            }
            if (tdata)
               tdata->mastery[cnt] = atoi(argument);
            else
               ktrainer->mastery[cnt] = atoi(argument);
         }
         else
         {
            sn = get_mastery_num(argument);
            if (sn == -1)
            {
               send_to_char("That is not a valid Mastery.\n\r", ch);
               return;
            }
            if (tdata)
               tdata->mastery[cnt] = sn;
            else
               ktrainer->sn[cnt] = sn;
         }
         send_to_char("Done.\n\r", ch);
         if (tdata)
            save_trainer_data();
         else
            save_buykingdom_data();
         return;
      }
   }
   do_tset(ch, "");
   return;
}

void do_addgem(CHAR_DATA * ch, char *argument)
{
   GEM_DATA *newgem;

   //char buf[MSL];
   char vnumarg[MIL];
   char costarg[MIL];
   char rarityarg[MIL];


   if (argument[0] == '\0')
   {
      send_to_char("Syntax: addgem <vnum> <cost> <rarity>\n\r", ch);
      send_to_char("		rarity: 1 -- common, 2 -- uncommon, 3 -- rare\n\r", ch);
      return;
   }

   argument = one_argument(argument, vnumarg);
   if (vnumarg[0] == '\0')
   {
      send_to_char("What vnum?\n\r", ch);
      return;
   }
   argument = one_argument(argument, costarg);
   if (costarg[0] == '\0')
   {
      send_to_char("It needs a cost!!\n\r", ch);
      return;
   }
   argument = one_argument(argument, rarityarg);
   if (rarityarg[0] == '\0')
   {
      send_to_char("Set a rarity.\n\r", ch);
      return;
   }

   //Check to make sure a numerical value is present
   if (!isdigit(vnumarg[0]))
   {
      send_to_char("You need to provide a vnum for the gem, not a name.\n\r", ch);
      return;
   }
   if (!isdigit(costarg[0]))
   {
      send_to_char("You need to provide a numerical value for the cost.\n\r", ch);
      return;
   }
   if (!isdigit(rarityarg[0]))
   {
      send_to_char("You need to provide a numerical value for the rarity (1-3) \n\r", ch);
      return;
   }
   //Make sure the object isn't already a gem
   for (newgem = first_gem; newgem; newgem = newgem->next)
   {
      if (newgem->vnum == atoi(vnumarg))
      {
         send_to_char("This object is already a gem.\n\r", ch);
         return;
      }
   }
   if ((get_obj_index(atoi(vnumarg))) == NULL)
   {
      send_to_char("This gem does not actually exist.\n\r", ch);
      return;
   }
   //It is clear now to add the object
   CREATE(newgem, GEM_DATA, 1);

   newgem->vnum = atoi(vnumarg);
   newgem->cost = atoi(costarg);
   newgem->rarity = atoi(rarityarg);
   gem_num += 1;

   LINK(newgem, first_gem, last_gem, next, prev);
   //sprintf(buf, "%s has added %s as a gem.", ch->name, newgem->vnum);
   //log_string_plus(buf, LOG_BUILD, ch->level);
   save_gem_data();
   send_to_char("Done.\n\r", ch);
   return;
}
void do_addbox(CHAR_DATA * ch, char *argument)
{
   BOX_DATA *newbox;

   if (argument[0] == '\0')
   {
      send_to_char("Syntax: addbox <vnum>\n\r", ch);
      return;
   }

   //Check to make sure a numerical value is present
   if (!isdigit(argument[0]))
   {
      send_to_char("You need to provide a vnum for the gem, not a name.\n\r", ch);
      return;
   }

   //Make sure the object isn't already a box
   for (newbox = first_box; newbox; newbox = newbox->next)
   {
      if (newbox->vnum == atoi(argument))
      {
         send_to_char("This object is already a box.\n\r", ch);
         return;
      }
   }

   if ((get_obj_index(atoi(argument))) == NULL)
   {
      send_to_char("This box does not actually exist.\n\r", ch);
      return;
   }

   //It is clear now to add the object
   CREATE(newbox, BOX_DATA, 1);

   newbox->vnum = atoi(argument);
   box_num += 1;

   LINK(newbox, first_box, last_box, next, prev);
   //sprintf(buf, "%s has added %s as a treasure box.", ch->name, newbox->vnum);
   //log_string_plus(buf, LOG_BUILD, ch->level);
   save_box_data();
   send_to_char("Done.\n\r", ch);
   return;
}

void do_mset(CHAR_DATA * ch, char *argument)
{
   char arg1[MIL];
   char arg2[MIL];
   char arg3[MIL];
   char buf[MSL];
   char outbuf[MSL];
   int num, size, plus;
   int v2;
   char char1, char2;
   CHAR_DATA *victim;
   int value;
   int minattr, maxattr;
   bool lockvictim;
   char *origarg = argument;

   set_char_color(AT_PLAIN, ch);

   if (IS_NPC(ch))
   {
      send_to_char("Mob's can't mset\n\r", ch);
      return;
   }

   if (!ch->desc)
   {
      send_to_char("You have no descriptor\n\r", ch);
      return;
   }

   switch (ch->substate)
   {
      default:
         break;
      case SUB_MOB_DESC:
         if (!ch->dest_buf)
         {
            send_to_char("Fatal error: report to Thoric.\n\r", ch);
            bug("do_mset: sub_mob_desc: NULL ch->dest_buf", 0);
            ch->substate = SUB_NONE;
            return;
         }
         victim = ch->dest_buf;
         if (char_died(victim))
         {
            send_to_char("Your victim died!\n\r", ch);
            stop_editing(ch);
            return;
         }
         STRFREE(victim->description);
         victim->description = copy_buffer(ch);
         if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         {
            STRFREE(victim->pIndexData->description);
            victim->pIndexData->description = QUICKLINK(victim->description);
         }
         stop_editing(ch);
         ch->substate = ch->tempnum;
         return;
   }

   victim = NULL;
   lockvictim = FALSE;
   smash_tilde(argument);

   if (ch->substate == SUB_REPEATCMD)
   {
      victim = ch->dest_buf;

      if (char_died(victim))
      {
         send_to_char("Your victim died!\n\r", ch);
         victim = NULL;
         argument = "done";
      }
      if (argument[0] == '\0' || !str_cmp(argument, " ") || !str_cmp(argument, "stat"))
      {
         if (victim)
            do_mstat(ch, victim->name);
         else
            send_to_char("No victim selected.  Type '?' for help.\n\r", ch);
         return;
      }
      if (!str_cmp(argument, "done") || !str_cmp(argument, "off"))
      {
         send_to_char("Mset mode off.\n\r", ch);
         ch->substate = SUB_NONE;
         ch->dest_buf = NULL;
         if (ch->pcdata && ch->pcdata->subprompt)
         {
            STRFREE(ch->pcdata->subprompt);
            ch->pcdata->subprompt = NULL;
            if (xIS_SET(ch->act, PLR_MSET)) /* mset flags, Crash no like -- Xerves */
               xREMOVE_BIT(ch->act, PLR_MSET);
         }
         return;
      }
   }
   if (victim)
   {
      lockvictim = TRUE;
      strcpy(arg1, victim->name);
      argument = one_argument(argument, arg2);
      strcpy(arg3, argument);
   }
   else
   {
      lockvictim = FALSE;
      argument = one_argument(argument, arg1);
      argument = one_argument(argument, arg2);
      strcpy(arg3, argument);
   }

   if (!str_cmp(arg1, "on"))
   {
      send_to_char("Syntax: mset <victim|vnum> on.\n\r", ch);
      return;
   }

   if (arg1[0] == '\0' || (arg2[0] == '\0' && ch->substate != SUB_REPEATCMD) || !str_cmp(arg1, "?"))
   {
      if (ch->substate == SUB_REPEATCMD)
      {
         if (victim)
            send_to_char("Syntax: <field>  <value>\n\r", ch);
         else
            send_to_char("Syntax: <victim> <field>  <value>\n\r", ch);
      }
      else
         send_to_char("Syntax: mset <victim> <field>  <value>\n\r", ch);
      send_to_char("Syntax: mset <victim> autostat <level>\n\r", ch);
      send_to_char("\n\r", ch);
      send_to_char("Field being one of:\n\r", ch);
      send_to_char("  str int wis dex con lck agi endurance sex\n\r", ch);
      send_to_char("  gold hp mana move practice align race\n\r", ch);
      send_to_char("  strper, intper, wisper, conper, dexper, lckper\n\r", ch);
      send_to_char("  agiper, hpper, manaper, moveper\n\r", ch);
      send_to_char("  hitroll damroll armor affected\n\r", ch);
      send_to_char("  rarmper larmper llegper rlegper\n\r", ch);
      send_to_char("  tohitstab tohitbash tohitslash\n\r", ch);
      send_to_char("  thirst drunk full blood flags talent\n\r", ch);
      send_to_char("  pos defpos part (see BODYPARTS)\n\r", ch);
      send_to_char("  sav1 sav2 sav4 sav4 sav5 (see SAVINGTHROWS)\n\r", ch);
      send_to_char("  m1 m2 m3 m4 m5 m6 m7 m8 m9 m10 m11 m12 (see CASTESLOTS)\n\r", ch);
      send_to_char("  rfire rwater rair rearth renergy rmagic rnonmagic rblunt\n\r", ch);
      send_to_char("  rpierce rslash rpoison rpara rholy runholy rundead (see NEWRESISTS)\n\r", ch);
      send_to_char("  resistant immune susceptible element(see RIS)\n\r", ch);
      send_to_char("  skincolor haircolor hairlength hairstyle eyecolor cheight cweight\n\r", ch);
      send_to_char("  attack defense\n\r", ch);
      if (sysdata.resetgame)
         send_to_char("  twinkpoints\n\r", ch);
      send_to_char("  speaking speaks (see LANGUAGES)\n\r", ch);
      send_to_char("  name short long description title spec clan\n\r", ch);
      send_to_char("  council favor deity cident fame spoints\n\r", ch);
      send_to_char("\n\r", ch);
      send_to_char("For editing index/prototype mobiles:\n\r", ch);
      send_to_char("  hitnumdie hitsizedie hitplus (hit points)\n\r", ch);
      send_to_char("  damnumdie damsizedie damplus (damage roll)\n\r", ch);
      send_to_char("  damaddlow damaddhi\n\r", ch);
      send_to_char("  Map resets:  coordx, coordy, onmap\n\r", ch);
      send_to_char("To toggle area flag: aloaded\n\r", ch);
      send_to_char("To toggle pkill flag: pkill\n\r", ch);
      return;
   }

   if (!victim && get_trust(ch) < LEVEL_HI_IMM) /* Tracker1 */
   {
      if ((victim = get_char_room_new(ch, arg1, 1)) == NULL)
      {
         send_to_char("They aren't here.\n\r", ch);
         return;
      }
   }
   else if (!victim)
   {
      if ((victim = get_char_world(ch, arg1)) == NULL)
      {
         send_to_char("No one like that in all the realms.\n\r", ch);
         return;
      }
   }

   if (get_trust(ch) < get_trust(victim) && !IS_NPC(victim))
   {
      send_to_char("You can't do that!\n\r", ch);
      ch->dest_buf = NULL;
      return;
   }
   /* Pondering where this went.....Will protect lower imms from setting players */
   if (!IS_NPC(victim) && get_trust(ch) < sysdata.level_mset_player)
   {
      send_to_char("Xerves deems you unready to fool in the ways of mortals.\n\r", ch);
      ch->dest_buf = NULL;
      return;
   }
   if (IS_NPC(victim) && (xIS_SET(victim->act, ACT_PROTECT)) && (get_trust(ch) < LEVEL_STAFF))
   {
      send_to_char("This mob is protected.  If you need to change it, ask Staff.\n\r", ch);
      ch->dest_buf = NULL;
      return;
   }
   if (lockvictim)
      ch->dest_buf = victim;

   minattr = 6;
   maxattr = 25;

   if (!IS_NPC(ch) && IS_SET(ch->pcdata->flags, PCFLAG_AUTOPROTO))
   {
      send_to_char("WARNING:  Making Changes in AUTOPROTO MODE!\n\r", ch);
   }
   if (!str_cmp(arg2, "on"))
   {
      if ((xIS_SET(ch->act, PLR_OSET)) || (xIS_SET(ch->act, PLR_MSET)))
      {
         send_to_char("Trying to turn on, while already on another, BLAH!\n\r", ch);
         return;
      }
      CHECK_SUBRESTRICTED(ch);
      ch_printf(ch, "Mset mode on. (Editing %s).\n\r", victim->name);
      ch->substate = SUB_REPEATCMD;
      ch->dest_buf = victim;
      if (ch->pcdata)
      {
         if (ch->pcdata->subprompt)
            STRFREE(ch->pcdata->subprompt);
         if (IS_NPC(victim))
            sprintf(buf, "<&CMset &W#%d&w> %%i", victim->pIndexData->vnum);
         else
            sprintf(buf, "<&CMset &W%s&w> %%i", victim->name);
         ch->pcdata->subprompt = STRALLOC(buf);
         if (!xIS_SET(ch->act, PLR_MSET)) /* Mset flags, Crash no like -- Xerves */
            xSET_BIT(ch->act, PLR_MSET);
      }
      return;
   }
   value = is_number(arg3) ? atoi(arg3) : -1;

   if (atoi(arg3) < -1 && value == -1)
      value = atoi(arg3);

   if (!str_cmp(arg2, "autostat"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (value < 1 || value > 130)
      {
         send_to_char("Range is 1 - 130 (help mobchart)\n\r", ch);
         return;
      }
      adjust_wildermob(victim, value, 0);
      send_to_char("Done.\n\r", ch);
      return;
   }  
   if (!str_cmp(arg2, "str"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (value < minattr || value > maxattr)
      {
         ch_printf(ch, "Strength range is %d to %d.\n\r", minattr, maxattr);
         return;
      }
      victim->perm_str = value;
      if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         victim->pIndexData->perm_str = value;
      return;
   }

   if (!str_cmp(arg2, "int"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (value < minattr || value > maxattr)
      {
         ch_printf(ch, "Intelligence range is %d to %d.\n\r", minattr, maxattr);
         return;
      }
      victim->perm_int = value;
      if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         victim->pIndexData->perm_int = value;
      return;
   }
   
   if (!str_cmp(arg2, "afffix"))
   {
      if (!can_mmodify(ch, victim))
         return;
      victim->apply_armor = victim->apply_shield = victim->apply_stone = victim->apply_sanctify = 0;
      victim->apply_tohit = victim->managen = victim->hpgen = victim->apply_wmod = 0;
      return;
   }   
   
   if (!str_cmp(arg2, "endurance"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (!IS_NPC(victim))
      {
         if (value < 10 || value > 104)
         {
            send_to_char("The values for Player Endurance are 10 to 104\n\r", ch);
            return;
         }
      }
      else
      {
         if (value < 10 || value > 135)
         {
            send_to_char("The values for Mobile Endurance ars 10 to 135\n\r", ch);
            return;
         }
      }
      victim->mover = value;
      if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         victim->pIndexData->mover = value;
      send_to_char("Done.\n\r", ch);
      return;
   }
   
   if (!str_cmp(arg2, "twinkpoints") && sysdata.resetgame)
   {
      if (!can_mmodify(ch, victim))
         return;
      if (IS_NPC(victim))
         return;
      if (value < 0 || value > 100)
      {
         send_to_char("The value ranges from 0 to 100.\n\r", ch);
         return;
      }
      victim->pcdata->twink_points = value;
      send_to_char("Done.\n\r", ch);
      return;
   } 

   if (!str_cmp(arg2, "rarmper"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (value < -1 || value > 1000)
      {
         send_to_char("The value ranges from -1 to 1000.\n\r", ch);
         return;
      }
      victim->con_rarm = value;
      send_to_char("Done.\n\r", ch);
      return;
   } 
   if (!str_cmp(arg2, "larmper"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (value < -1 || value > 1000)
      {
         send_to_char("The value ranges from -1 to 1000.\n\r", ch);
         return;
      }
      victim->con_larm = value;
      send_to_char("Done.\n\r", ch);
      return;
   }
   if (!str_cmp(arg2, "llegper"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (value < -1 || value > 1000)
      {
         send_to_char("The value ranges from -1 to 1000.\n\r", ch);
         return;
      }
      victim->con_lleg = value;
      send_to_char("Done.\n\r", ch);
      return;
   } 
   if (!str_cmp(arg2, "rlegper"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (value < -1 || value > 1000)
      {
         send_to_char("The value ranges from -1 to 1000.\n\r", ch);
         return;
      }
      victim->con_rleg = value;
      send_to_char("Done.\n\r", ch);
      return;
   }  
   
   if (!str_cmp(arg2, "strper"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (IS_NPC(victim))
      {
         send_to_char("On Pcs only.\n\r", ch);
         return;
      }
      if (value < 0 || value > 9999)
      {
         send_to_char("The value ranges from 0 to 9999.\n\r", ch);
         return;
      }
      victim->pcdata->per_str = value;
      send_to_char("Done.\n\r", ch);
      return;
   } 
   if (!str_cmp(arg2, "intper"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (IS_NPC(victim))
      {
         send_to_char("On Pcs only.\n\r", ch);
         return;
      }
      if (value < 0 || value > 9999)
      {
         send_to_char("The value ranges from 0 to 9999.\n\r", ch);
         return;
      }
      victim->pcdata->per_int = value;
      send_to_char("Done.\n\r", ch);
      return;
   } 
   if (!str_cmp(arg2, "wisper"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (IS_NPC(victim))
      {
         send_to_char("On Pcs only.\n\r", ch);
         return;
      }
      if (value < 0 || value > 9999)
      {
         send_to_char("The value ranges from 0 to 9999.\n\r", ch);
         return;
      }
      victim->pcdata->per_wis = value;
      send_to_char("Done.\n\r", ch);
      return;
   } 
   if (!str_cmp(arg2, "dexper"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (IS_NPC(victim))
      {
         send_to_char("On Pcs only.\n\r", ch);
         return;
      }
      if (value < 0 || value > 9999)
      {
         send_to_char("The value ranges from 0 to 9999.\n\r", ch);
         return;
      }
      victim->pcdata->per_dex = value;
      send_to_char("Done.\n\r", ch);
      return;
   } 
   if (!str_cmp(arg2, "conper"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (IS_NPC(victim))
      {
         send_to_char("On Pcs only.\n\r", ch);
         return;
      }
      if (value < 0 || value > 9999)
      {
         send_to_char("The value ranges from 0 to 9999.\n\r", ch);
         return;
      }
      victim->pcdata->per_con = value;
      send_to_char("Done.\n\r", ch);
      return;
   }  
   if (!str_cmp(arg2, "lckper"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (IS_NPC(victim))
      {
         send_to_char("On Pcs only.\n\r", ch);
         return;
      }
      if (value < 0 || value > 9999)
      {
         send_to_char("The value ranges from 0 to 9999.\n\r", ch);
         return;
      }
      victim->pcdata->per_lck = value;
      send_to_char("Done.\n\r", ch);
      return;
   } 
   if (!str_cmp(arg2, "agiper"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (IS_NPC(victim))
      {
         send_to_char("On Pcs only.\n\r", ch);
         return;
      }
      if (value < 0 || value > 999)
      {
         send_to_char("The value ranges from 0 to 999.\n\r", ch);
         return;
      }
      victim->pcdata->per_agi = value;
      send_to_char("Done.\n\r", ch);
      return;
   } 
   if (!str_cmp(arg2, "hpper"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (IS_NPC(victim))
      {
         send_to_char("On Pcs only.\n\r", ch);
         return;
      }
      if (value < 0 || value > 999)
      {
         send_to_char("The value ranges from 0 to 999.\n\r", ch);
         return;
      }
      victim->pcdata->per_hp = value;
      send_to_char("Done.\n\r", ch);
      return;
   }
   if (!str_cmp(arg2, "manaper"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (IS_NPC(victim))
      {
         send_to_char("On Pcs only.\n\r", ch);
         return;
      }
      if (value < 0 || value > 999)
      {
         send_to_char("The value ranges from 0 to 999.\n\r", ch);
         return;
      }
      victim->pcdata->per_mana = value;
      send_to_char("Done.\n\r", ch);
      return;
   }   
   if (!str_cmp(arg2, "moveper"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (IS_NPC(victim))
      {
         send_to_char("On Pcs only.\n\r", ch);
         return;
      }
      if (value < 0 || value > 999)
      {
         send_to_char("The value ranges from 0 to 999.\n\r", ch);
         return;
      }
      victim->pcdata->per_move = value;
      send_to_char("Done.\n\r", ch);
      return;
   }
   
   if (!str_cmp(arg2, "spoints"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (IS_NPC(victim))
      {
         send_to_char("On Pcs only.\n\r", ch);
         return;
      }
      if (value < 0 || value > 99999999)
      {
         send_to_char("The value ranges from 0 to 99999999.\n\r", ch);
         return;
      }
      victim->pcdata->spoints = value;
      send_to_char("Done.\n\r", ch);
      return;
   }
   if (!str_cmp(arg2, "rair"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (value < -1 || value > 1000 || value == 0)
      {
         ch_printf(ch, "Range is -1 to 1000.  0 is invalid (equivalant to 100).  See HELP NEWRESETS\n\r");
         return;
      }
      if (value == -1)
         value = -500;
      victim->apply_res_air[0] = value;
      if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         victim->pIndexData->apply_res_air = value;
      return;
   }
   if (!str_cmp(arg2, "rearth"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (value < -1 || value > 1000 || value == 0)
      {
         ch_printf(ch, "Range is -1 to 1000.  0 is invalid (equivalant to 100).  See HELP NEWRESETS\n\r");
         return;
      }
      if (value == -1)
         value = -500;
      victim->apply_res_earth[0] = value;
      if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         victim->pIndexData->apply_res_earth = value;
      return;
   }
   if (!str_cmp(arg2, "renergy"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (value < -1 || value > 1000 || value == 0)
      {
         ch_printf(ch, "Range is -1 to 1000.  0 is invalid (equivalant to 100).  See HELP NEWRESETS\n\r");
         return;
      }
      if (value == -1)
         value = -500;
      victim->apply_res_energy[0] = value;
      if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         victim->pIndexData->apply_res_energy = value;
      return;
   }
   if (!str_cmp(arg2, "rmagic"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (value < -1 || value > 1000 || value == 0)
      {
         ch_printf(ch, "Range is -1 to 1000.  0 is invalid (equivalant to 100).  See HELP NEWRESETS\n\r");
         return;
      }
      if (value == -1)
         value = -500;
      victim->apply_res_magic[0] = value;
      if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         victim->pIndexData->apply_res_magic = value;
      return;
   }
   if (!str_cmp(arg2, "rnonmagic"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (value < -1 || value > 1000 || value == 0)
      {
         ch_printf(ch, "Range is -1 to 1000.  0 is invalid (equivalant to 100).  See HELP NEWRESETS\n\r");
         return;
      }
      if (value == -1)
         value = -500;
      victim->apply_res_nonmagic[0] = value;
      if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         victim->pIndexData->apply_res_nonmagic = value;
      return;
   }
   if (!str_cmp(arg2, "rblunt"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (value < -1 || value > 1000 || value == 0)
      {
         ch_printf(ch, "Range is -1 to 1000.  0 is invalid (equivalant to 100).  See HELP NEWRESETS\n\r");
         return;
      }
      if (value == -1)
         value = -500;
      victim->apply_res_blunt[0] = value;
      if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         victim->pIndexData->apply_res_blunt = value;
      return;
   }
   if (!str_cmp(arg2, "rpierce"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (value < -1 || value > 1000 || value == 0)
      {
         ch_printf(ch, "Range is -1 to 1000.  0 is invalid (equivalant to 100).  See HELP NEWRESETS\n\r");
         return;
      }
      if (value == -1)
         value = -500;
      victim->apply_res_pierce[0] = value;
      if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         victim->pIndexData->apply_res_pierce = value;
      return;
   }
   if (!str_cmp(arg2, "rslash"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (value < -1 || value > 1000 || value == 0)
      {
         ch_printf(ch, "Range is -1 to 1000.  0 is invalid (equivalant to 100).  See HELP NEWRESETS\n\r");
         return;
      }
      if (value == -1)
         value = -500;
      victim->apply_res_slash[0] = value;
      if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         victim->pIndexData->apply_res_slash = value;
      return;
   }
   if (!str_cmp(arg2, "rpoison"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (value < -1 || value > 1000 || value == 0)
      {
         ch_printf(ch, "Range is -1 to 1000.  0 is invalid (equivalant to 100).  See HELP NEWRESETS\n\r");
         return;
      }
      if (value == -1)
         value = -500;
      victim->apply_res_poison[0] = value;
      if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         victim->pIndexData->apply_res_poison = value;
      return;
   }
   if (!str_cmp(arg2, "rpara"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (value < -1 || value > 1000 || value == 0)
      {
         ch_printf(ch, "Range is -1 to 1000.  0 is invalid (equivalant to 100).  See HELP NEWRESETS\n\r");
         return;
      }
      if (value == -1)
         value = -500;
      victim->apply_res_paralysis[0] = value;
      if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         victim->pIndexData->apply_res_paralysis = value;
      return;
   }
   if (!str_cmp(arg2, "rholy"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (value < -1 || value > 1000 || value == 0)
      {
         ch_printf(ch, "Range is -1 to 1000.  0 is invalid (equivalant to 100).  See HELP NEWRESETS\n\r");
         return;
      }
      if (value == -1)
         value = -500;
      victim->apply_res_holy[0] = value;
      if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         victim->pIndexData->apply_res_holy = value;
      return;
   }
   if (!str_cmp(arg2, "runholy"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (value < -1 || value > 1000 || value == 0)
      {
         ch_printf(ch, "Range is -1 to 1000.  0 is invalid (equivalant to 100).  See HELP NEWRESETS\n\r");
         return;
      }
      if (value == -1)
         value = -500;
      victim->apply_res_unholy[0] = value;
      if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         victim->pIndexData->apply_res_unholy = value;
      return;
   }
   if (!str_cmp(arg2, "rundead"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (value < -1 || value > 1000 || value == 0)
      {
         ch_printf(ch, "Range is -1 to 1000.  0 is invalid (equivalant to 100).  See HELP NEWRESETS\n\r");
         return;
      }
      if (value == -1)
         value = -500;
      victim->apply_res_undead[0] = value;
      if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         victim->pIndexData->apply_res_undead = value;
      return;
   }
   if (!str_cmp(arg2, "rwater"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (value < -1 || value > 1000 || value == 0)
      {
         ch_printf(ch, "Range is -1 to 1000.  0 is invalid (equivalant to 100).  See HELP NEWRESETS\n\r");
         return;
      }
      if (value == -1)
         value = -500;
      victim->apply_res_water[0] = value;
      if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         victim->pIndexData->apply_res_water = value;
      return;
   }    
   if (!str_cmp(arg2, "rfire"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (value < -1 || value > 1000 || value == 0)
      {
         ch_printf(ch, "Range is -1 to 1000.  0 is invalid (equivalant to 100).  See HELP NEWRESETS\n\r");
         return;
      }
      if (value == -1)
         value = -500;
      victim->apply_res_fire[0] = value;
      if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         victim->pIndexData->apply_res_fire = value;
      return;
   }
   if (!str_cmp(arg2, "tohitstab"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (value < 0 || value > MAX_TOHITAC)
      {
         ch_printf(ch, "ToHitStab range is 0 to %d.\n\r", MAX_TOHITAC);
         return;
      }
      if (!IS_NPC(victim))
      {
         send_to_char("Only on npcs.\n\r", ch);
         return;
      }
      victim->tohitstab = value;
      if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         victim->pIndexData->tohitstab = value;
      return;
   }
   if (!str_cmp(arg2, "tohitslash"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (value < 0 || value > MAX_TOHITAC)
      {
         ch_printf(ch, "ToHitSlash range is 0 to %d.\n\r", MAX_TOHITAC);
         return;
      }
      if (!IS_NPC(victim))
      {
         send_to_char("Only on npcs.\n\r", ch);
         return;
      }
      victim->tohitslash = value;
      if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         victim->pIndexData->tohitslash = value;
      return;
   }
   if (!str_cmp(arg2, "tohitbash"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (value < 0 || value > MAX_TOHITAC)
      {
         ch_printf(ch, "ToHitBash range is 0 to %d.\n\r", MAX_TOHITAC);
         return;
      }
      if (!IS_NPC(victim))
      {
         send_to_char("Only on npcs.\n\r", ch);
         return;
      }
      victim->tohitbash = value;
      if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         victim->pIndexData->tohitbash = value;
      return;
   }
   
   if (!str_cmp(arg2, "armor"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (value < 0 || value > MAX_TOHITAC)
      {
         ch_printf(ch, "Armor range is 0 to %d.\n\r", MAX_TOHITAC);
         return;
      }
      if (!IS_NPC(victim))
      {
         send_to_char("Only on npcs.\n\r", ch);
         return;
      }
      victim->armor = value;
      if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         victim->pIndexData->ac = value;
      return;
   }

   if (!str_cmp(arg2, "wis"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (value < minattr || value > maxattr)
      {
         ch_printf(ch, "Wisdom range is %d to %d.\n\r", minattr, maxattr);
         return;
      }
      victim->perm_wis = value;
      if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         victim->pIndexData->perm_wis = value;
      return;
   }

   if (!str_cmp(arg2, "dex"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (value < minattr || value > maxattr)
      {
         ch_printf(ch, "Dexterity range is %d to %d.\n\r", minattr, maxattr);
         return;
      }
      victim->perm_dex = value;
      if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         victim->pIndexData->perm_dex = value;
      return;
   }

   if (!str_cmp(arg2, "con"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (value < minattr || value > maxattr)
      {
         ch_printf(ch, "Constitution range is %d to %d.\n\r", minattr, maxattr);
         return;
      }
      victim->perm_con = value;
      if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         victim->pIndexData->perm_con = value;
      return;
   }

   if (!str_cmp(arg2, "cha"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (value < minattr || value > maxattr)
      {
         ch_printf(ch, "Charisma range is %d to %d.\n\r", minattr, maxattr);
         return;
      }
      victim->perm_cha = value;
      if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         victim->pIndexData->perm_cha = value;
      return;
   }

   if (!str_cmp(arg2, "lck"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (value < minattr || value > maxattr)
      {
         ch_printf(ch, "Luck range is %d to %d.\n\r", minattr, maxattr);
         return;
      }
      victim->perm_lck = value;
      if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         victim->pIndexData->perm_lck = value;
      return;
   }

   if (!str_cmp(arg2, "agi"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (value < 10 || value > 100)
      {
         send_to_char("Agility Range is 10 to 100.\n\r", ch);
         return;
      }
      victim->perm_agi = value;
      if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         victim->pIndexData->perm_agi = value;
      return;
   }

   if (!str_cmp(arg2, "sav1"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (value < -30 || value > 30)
      {
         send_to_char("Saving throw range is -30 to 30.\n\r", ch);
         return;
      }
      victim->saving_poison_death = value;
      if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         victim->pIndexData->saving_poison_death = value;
      return;
   }

   if (!str_cmp(arg2, "sav2"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (value < -30 || value > 30)
      {
         send_to_char("Saving throw range is -30 to 30.\n\r", ch);
         return;
      }
      victim->saving_wand = value;
      if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         victim->pIndexData->saving_wand = value;
      return;
   }

   if (!str_cmp(arg2, "sav3"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (value < -30 || value > 30)
      {
         send_to_char("Saving throw range is -30 to 30.\n\r", ch);
         return;
      }
      victim->saving_para_petri = value;
      if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         victim->pIndexData->saving_para_petri = value;
      return;
   }

   if (!str_cmp(arg2, "sav4"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (value < -30 || value > 30)
      {
         send_to_char("Saving throw range is -30 to 30.\n\r", ch);
         return;
      }
      victim->saving_breath = value;
      if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         victim->pIndexData->saving_breath = value;
      return;
   }

   if (!str_cmp(arg2, "sav5"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (value < -30 || value > 30)
      {
         send_to_char("Saving throw range is -30 to 30.\n\r", ch);
         return;
      }
      victim->saving_spell_staff = value;
      if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         victim->pIndexData->saving_spell_staff = value;
      return;
   }

   if (!str_cmp(arg2, "sex"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (value < 0 || value > 2)
      {
         send_to_char("Sex range is 0 to 2.\n\r", ch);
         return;
      }
      victim->sex = value;
      if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         victim->pIndexData->sex = value;
      return;
   }
   if (!str_cmp(arg2, "race"))
   {
      if (!can_mmodify(ch, victim))
         return;
      value = get_npc_race(arg3);
      if (value < 0)
         value = atoi(arg3);
      if (!IS_NPC(victim) && (value < 0 || value >= MAX_RACE))
      {
         ch_printf(ch, "Race range is 0 to %d.\n", MAX_RACE - 1);
         return;
      }
      if (IS_NPC(victim) && (value < 0 || value >= max_npc_race))
      {
         ch_printf(ch, "Race range is 0 to %d.\n", max_npc_race - 1);
         return;
      }
      victim->race = value;
      if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         victim->pIndexData->race = value;
      return;
   }


   if (!str_cmp(arg2, "gold"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (value < 0 || value > 10000000)
      {
         send_to_char("Sorry, gold range is between 0 and 10,000,000. Please try again.\n\r", ch);
         return;
      }
      victim->gold = value;
      if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         victim->pIndexData->gold = value;
      return;
   }

   if (!str_cmp(arg2, "hitroll"))
   {
      if (!can_mmodify(ch, victim))
         return;
      victim->hitroll = URANGE(0, value, 85);
      if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         victim->pIndexData->hitroll = victim->hitroll;
      return;
   }

   if (!str_cmp(arg2, "damroll"))
   {
      if (!can_mmodify(ch, victim))
         return;
      victim->damroll = URANGE(0, value, 65);
      if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         victim->pIndexData->damroll = victim->damroll;
      return;
   }

   if (!str_cmp(arg2, "hp"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (value < 1 || value > MAX_HPMANA)
      {
         ch_printf(ch, "Hp range is 1 to %d hit points.\n\r", MAX_HPMANA);
         return;
      }
      victim->max_hit = value;
      return;
   }

   if (!str_cmp(arg2, "mana"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (value < 0 || value > MAX_HPMANA)
      {
         ch_printf(ch, "Mana range is 0 to %d mana points.\n\r", MAX_HPMANA);
         return;
      }
      victim->max_mana = value;
      return;
   }

   if (!str_cmp(arg2, "move"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (value < 0 || value > 30000)
      {
         send_to_char("Move range is 0 to 30,000 move points.\n\r", ch);
         return;
      }
      victim->max_move = value;
      if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         victim->pIndexData->max_move = value;
      return;
   }

   if (!str_cmp(arg2, "practice"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (value < 0 || value > 500)
      {
         send_to_char("Practice range is 0 to 500 sessions.\n\r", ch);
         return;
      }
      victim->practice = value;
      return;
   }

   if (!str_cmp(arg2, "align"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (value < -1000 || value > 1000)
      {
         send_to_char("Alignment range is -1000 to 1000.\n\r", ch);
         return;
      }
      victim->alignment = value;
      if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         victim->pIndexData->alignment = value;
      return;
   }
   if (!str_cmp(arg2, "cweight"))
   {
      if (IS_NPC(victim))
      {
         send_to_char("Can only adjust this on PCs.\n\r", ch);
         return;
      }
      if (!can_mmodify(ch, victim))
         return;
      if (value < 1 || value > 13)
      {
         send_to_char("Range is 1 to 13.\n\r", ch);
         return;
      }
      victim->pcdata->cweight = value;
      victim->height = number_range(race_table[victim->race]->height * .9, race_table[victim->race]->height * 1.1);
      victim->weight = number_range(race_table[victim->race]->weight * .9, race_table[victim->race]->weight * 1.1);
      victim->height = victim->height * get_heightweight_percent(victim->pcdata->cheight) / 100;
      victim->weight = victim->weight * get_heightweight_percent(victim->pcdata->cweight) / 100;
      return;
   }
   if (!str_cmp(arg2, "cheight"))
   {
      if (IS_NPC(victim))
      {
         send_to_char("Can only adjust this on PCs.\n\r", ch);
         return;
      }
      if (!can_mmodify(ch, victim))
         return;
      if (value < 1 || value > 13)
      {
         send_to_char("Range is 1 to 13.\n\r", ch);
         return;
      }
      victim->pcdata->cheight = value;
      return;
   }
   if (!str_cmp(arg2, "eyecolor"))
   {
      if (IS_NPC(victim))
      {
         send_to_char("Can only adjust this on PCs.\n\r", ch);
         return;
      }
      if (!can_mmodify(ch, victim))
         return;
      if (value < 1 || value > 24)
      {
         send_to_char("Range is 1 to 24.\n\r", ch);
         return;
      }
      victim->pcdata->eyecolor = value;
      return;
   }
   if (!str_cmp(arg2, "hairstyle"))
   {
      if (IS_NPC(victim))
      {
         send_to_char("Can only adjust this on PCs.\n\r", ch);
         return;
      }
      if (!can_mmodify(ch, victim))
         return;
      if (value < 1 || value > 15)
      {
         send_to_char("Range is 1 to 15.\n\r", ch);
         return;
      }
      victim->pcdata->hairstyle = value;
      return;
   }
   if (!str_cmp(arg2, "hairlength"))
   {
      if (IS_NPC(victim))
      {
         send_to_char("Can only adjust this on PCs.\n\r", ch);
         return;
      }
      if (!can_mmodify(ch, victim))
         return;
      if (value < 1 || value > 13)
      {
         send_to_char("Range is 1 to 13.\n\r", ch);
         return;
      }
      victim->pcdata->hairlength = value;
      return;
   }
   if (!str_cmp(arg2, "haircolor"))
   {
      if (IS_NPC(victim))
      {
         send_to_char("Can only adjust this on PCs.\n\r", ch);
         return;
      }
      if (!can_mmodify(ch, victim))
         return;
      if (value < 1 || value > 40)
      {
         send_to_char("Range is 1 to 40.\n\r", ch);
         return;
      }
      victim->pcdata->haircolor = value;
      return;
   }
   if (!str_cmp(arg2, "skincolor"))
   {
      if (IS_NPC(victim))
      {
         send_to_char("Can only adjust this on PCs.\n\r", ch);
         return;
      }
      if (!can_mmodify(ch, victim))
         return;
      if (value < 1 || value > 15)
      {
         send_to_char("Range is 1 to 15.\n\r", ch);
         return;
      }
      victim->pcdata->skincolor = value;
      return;
   }
   if (!str_cmp(arg2, "m1"))
   {
      if (get_trust(ch) < LEVEL_STAFF) /* Tracker1 */
      {
         send_to_char("Staff Only memebers can set this.\n\r", ch);
         return;
      }
      if (!can_mmodify(ch, victim))
         return;
      if (!IS_NPC(victim))
      {
         send_to_char("Not on PC's.\n\r", ch);
         return;
      }
      if (value < -10000000 || value > 10000000)
      {
         send_to_char("m1 range is -10,000,000 to 10,000,000.\n\r", ch);
         return;
      }
      victim->m1 = value;
      if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         victim->pIndexData->m1 = value;
      return;
   }
   if (!str_cmp(arg2, "m2"))
   {
      if (get_trust(ch) < LEVEL_STAFF) /* Tracker1 */
      {
         send_to_char("Staff Only memebers can set this.\n\r", ch);
         return;
      }
      if (!can_mmodify(ch, victim))
         return;
      if (!IS_NPC(victim))
      {
         send_to_char("Not on PC's.\n\r", ch);
         return;
      }
      if (value < -10000000 || value > 10000000)
      {
         send_to_char("m2 range is -10,000,000 to 10,000,000.\n\r", ch);
         return;
      }
      victim->m2 = value;
      if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         victim->pIndexData->m2 = value;
      return;
   }
   if (!str_cmp(arg2, "m3"))
   {
      if (get_trust(ch) < LEVEL_STAFF) /* Tracker1 */
      {
         send_to_char("Staff Only memebers can set this.\n\r", ch);
         return;
      }
      if (!can_mmodify(ch, victim))
         return;
      if (!IS_NPC(victim))
      {
         send_to_char("Not on PC's.\n\r", ch);
         return;
      }
      if (value < -10000000 || value > 10000000)
      {
         send_to_char("m3 range is -10,000,000 to 10,000,000.\n\r", ch);
         return;
      }
      victim->m3 = value;
      if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         victim->pIndexData->m3 = value;
      return;
   }
   if (!str_cmp(arg2, "m4"))
   {
      if (get_trust(ch) < LEVEL_STAFF) /* Tracker1 */
      {
         send_to_char("Staff Only memebers can set this.\n\r", ch);
         return;
      }
      if (!can_mmodify(ch, victim))
         return;
      if (!IS_NPC(victim))
      {
         send_to_char("Not on PC's.\n\r", ch);
         return;
      }
      if (value < -2000000000 || value > 2000000000)
      {
         send_to_char("m4 range is -2,000,000,000 to 2,000,000,000.\n\r", ch);
         return;
      }
      victim->m4 = value;
      if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         victim->pIndexData->m4 = value;
      return;
   }
   if (!str_cmp(arg2, "m5"))
   {
      if (get_trust(ch) < LEVEL_STAFF) /* Tracker1 */
      {
         send_to_char("Staff Only memebers can set this.\n\r", ch);
         return;
      }
      if (!can_mmodify(ch, victim))
         return;
      if (!IS_NPC(victim))
      {
         send_to_char("Not on PC's.\n\r", ch);
         return;
      }
      if (value < -2000000000 || value > 2000000000)
      {
         send_to_char("m5 range is -2,000,000,000 to 2,000,000,000.\n\r", ch);
         return;
      }
      victim->m5 = value;
      if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         victim->pIndexData->m5 = value;
      return;
   }
   if (!str_cmp(arg2, "m6"))
   {
      if (get_trust(ch) < LEVEL_STAFF) /* Tracker1 */
      {
         send_to_char("Staff Only memebers can set this.\n\r", ch);
         return;
      }
      if (!can_mmodify(ch, victim))
         return;
      if (!IS_NPC(victim))
      {
         send_to_char("Not on PC's.\n\r", ch);
         return;
      }
      if (value < -2000000000 || value > 2000000000)
      {
         send_to_char("m6 range is -2,000,000,000 to 2,000,000,000.\n\r", ch);
         return;
      }
      victim->m6 = value;
      if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         victim->pIndexData->m6 = value;
      return;
   }

   if (!str_cmp(arg2, "m7"))
   {
      if (get_trust(ch) < LEVEL_STAFF) /* Tracker1 */
      {
         send_to_char("Staff Only memebers can set this.\n\r", ch);
         return;
      }
      if (!can_mmodify(ch, victim))
         return;
      if (!IS_NPC(victim))
      {
         send_to_char("Not on PC's.\n\r", ch);
         return;
      }
      if (value < -2000000000 || value > 2000000000)
      {
         send_to_char("m7 range is 2,000,000,000 to -2,000,000,000\n\r", ch);
         return;
      }
      victim->m7 = value;
      if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         victim->pIndexData->m7 = value;
      return;
   }
   if (!str_cmp(arg2, "m8"))
   {
      if (get_trust(ch) < LEVEL_STAFF) /* Tracker1 */
      {
         send_to_char("Staff Only memebers can set this.\n\r", ch);
         return;
      }
      if (!can_mmodify(ch, victim))
         return;
      if (!IS_NPC(victim))
      {
         send_to_char("Not on PC's.\n\r", ch);
         return;
      }
      if (value < -2000000000 || value > 2000000000)
      {
         send_to_char("m8 range is 2,000,000,000 to -2,000,000,000\n\r", ch);
         return;
      }
      victim->m8 = value;
      if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         victim->pIndexData->m8 = value;
      return;
   }
   if (!str_cmp(arg2, "m9"))
   {
      if (get_trust(ch) < LEVEL_STAFF) /* Tracker1 */
      {
         send_to_char("Staff Only memebers can set this.\n\r", ch);
         return;
      }
      if (!can_mmodify(ch, victim))
         return;
      if (!IS_NPC(victim))
      {
         send_to_char("Not on PC's.\n\r", ch);
         return;
      }
      if (value < -2000000000 || value > 2000000000)
      {
         send_to_char("m9 range is 2,000,000,000 to -2,000,000,000\n\r", ch);
         return;
      }
      victim->m9 = value;
      if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         victim->pIndexData->m9 = value;
      return;
   }
   if (!str_cmp(arg2, "m10"))
   {
      if (get_trust(ch) < LEVEL_STAFF) /* Tracker1 */
      {
         send_to_char("Staff Only memebers can set this.\n\r", ch);
         return;
      }
      if (!can_mmodify(ch, victim))
         return;
      if (!IS_NPC(victim))
      {
         send_to_char("Not on PC's.\n\r", ch);
         return;
      }
      if (value < -2000000000 || value > 2000000000)
      {
         send_to_char("m6 range is -2,000,000,000 to 2,000,000,000.\n\r", ch);
         return;
      }
      victim->m10 = value;
      if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         victim->pIndexData->m10 = value;
      return;
   }
   if (!str_cmp(arg2, "m11"))
   {
      if (get_trust(ch) < LEVEL_STAFF) /* Tracker1 */
      {
         send_to_char("Staff Only memebers can set this.\n\r", ch);
         return;
      }
      if (!can_mmodify(ch, victim))
         return;
      if (!IS_NPC(victim))
      {
         send_to_char("Not on PC's.\n\r", ch);
         return;
      }
      if (value < -2000000000 || value > 2000000000)
      {
         send_to_char("m6 range is -2,000,000,000 to 2,000,000,000.\n\r", ch);
         return;
      }
      victim->m11 = value;
      if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         victim->pIndexData->m11 = value;
      return;
   }
   if (!str_cmp(arg2, "m12"))
   {
      if (get_trust(ch) < LEVEL_STAFF) /* Tracker1 */
      {
         send_to_char("Staff Only memebers can set this.\n\r", ch);
         return;
      }
      if (!can_mmodify(ch, victim))
         return;
      if (!IS_NPC(victim))
      {
         send_to_char("Not on PC's.\n\r", ch);
         return;
      }
      if (value < -2000000000 || value > 2000000000)
      {
         send_to_char("m6 range is -2,000,000,000 to 2,000,000,000.\n\r", ch);
         return;
      }
      victim->m12 = value;
      if (IS_NPC(victim) && (is_prototype(ch, NULL, victim)))
         victim->pIndexData->m12 = value;
      return;
   }
   if (!str_cmp(arg2, "coordx"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if ((value < 1 || value > MAX_X) && (value != 0))
      {
         ch_printf(ch, "X Range is 1 from %d or -1.\n\r", MAX_X);
         return;
      }
      victim->coord->x = value;
      return;
   }
   if (!str_cmp(arg2, "coordy"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if ((value < -1 || value > MAX_Y) && (value != 0))
      {
         ch_printf(ch, "Y Range is 1 from %d or -1.\n\r", MAX_Y);
         return;
      }
      victim->coord->y = value;
      return;
   }
   if (!str_cmp(arg2, "onmap"))
   {
      if (!can_mmodify(ch, victim))
         return;
      if (value < 0 || value > MAP_MAX)
      {
         ch_printf(ch, "X Range is 0 from %d.\n\rHelp onmap for map numbers.", MAP_MAX);
         return;
      }
      victim->map = value;
      return;
   }
   if (!str_cmp(arg2, "password"))
   {

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

Site Stats

Snippets: 1791
Codebases: 571