/*Property of Owen Emlen, copyright (C) 1996 */

/* To do: UNIQUE KEYS FOR OBJECTS AND MOBS FOR USE WITH JAVA CLIENT */


#define PIC_WAIT 15

/* #define WINDOWS 1 */

#ifndef WINDOWS
#define false    0
#define true     1

typedef int socket_t;


#else
#include "winsock.h"
#include "windows.h"

typedef SOCKET socket_t;
#define NOCRYPT
#endif

#define FALSE    0
#define TRUE     1
#define yes      1
#define no       0
#define YES      1
#define NO       0

/* Allow for boolean type... */
typedef unsigned char bool;
extern socket_t control;

typedef struct scriptassoc SA;
typedef struct combat_field COMBAT_FIELD;
typedef struct social_type SOCIAL;
typedef struct fight_data FGT;
typedef struct dammsg_data DAM_MSG;
typedef struct power_data POWER;
typedef struct shell_command SHELL;
typedef struct channel_type CHANNEL;
typedef struct cmd_type COMMAND;
typedef struct to_free TO_FREE;
typedef struct item_blood I_BLOOD;
typedef struct item_book I_BOOK;
typedef struct item_armor I_ARMOR;
typedef struct item_weapon I_WEAPON;
typedef struct item_drink_container I_DRINK;
typedef struct item_light I_LIGHT;
typedef struct item_tool I_TOOL;
typedef struct item_vehicle I_VEHICLE;
typedef struct item_fountain I_FOUNTAIN;
typedef struct item_potion I_POTION;
typedef struct item_spray I_SPRAY;
typedef struct item_food I_FOOD;
typedef struct item_gem I_GEM;
typedef struct item_wand I_WAND;
typedef struct item_furniture I_FURNITURE;
typedef struct item_container I_CONTAINER;
typedef struct item_climbable I_CLIMBABLE;
typedef struct affect_data AFFECT_DATA;
typedef struct area_data AREA_DATA;
typedef struct ban_data BAN_DATA;
typedef struct voting_data VOTING_DATA;
typedef struct spell_data SPELL_DATA;
typedef struct dam_moves PERCENT_STRUCT;
typedef struct damages_struct DAM_STRUCT;
typedef struct track_data TRACK_DATA;
typedef struct char_data CHAR_DATA;
typedef struct topten_data TOPTEN_DATA;
typedef struct rating_data RATING_DATA;
typedef struct limited_data LIMITED_DATA;
typedef struct bid_data BID_DATA;
typedef struct descriptor_data DESCRIPTOR_DATA;
typedef struct exit_data EXIT_DATA;
typedef struct ced CED_DATA;
typedef struct door_data DOOR_DATA;
typedef struct extra_descr_data DESCRIPTION_DATA;
typedef struct playerbase_data PLAYERBASE_DATA;
typedef struct variable_data VARIABLE_DATA;
typedef struct item_check ITEM_CHECK;
typedef struct help_data HELP_DATA;
typedef struct mob_proto_data MOB_PROTOTYPE;
typedef struct triggy TRIGGY_DATA;
typedef struct script_dat SCRIPT_DAT;
typedef struct note_data NOTE_DATA;
typedef struct obj_boat OBJ_BOAT;
typedef struct b_list BLIST;
typedef struct obj_data SINGLE_OBJECT;
typedef struct obj_proto_data OBJ_PROTOTYPE;
typedef struct temp_str TEMP_STR;
typedef struct pc_data REALCHAR_DATA;
typedef struct npc_data MOB_DATA;
typedef struct optional_data OPTIONAL_DATA;
typedef struct room_data ROOM_DATA;
typedef struct room_extended ROOM_MORE;
typedef struct reset_data RESET_DATA;
typedef struct shop_data SHOP_DATA;
typedef struct time_info_data TIME_INFO_DATA;
typedef struct weather_data WEATHER_DATA;
typedef struct script_data SCRIPT_DATA;
typedef struct trigger_data TRIGGER_DATA;
typedef struct clan_data CLAN_DATA;

typedef void CHR_FUNCTION (CHAR_DATA *, CHAR_DATA *, char *argy);
typedef void DO_COMMAND (CHAR_DATA *, char *);
typedef bool SPEC_FUNCTION (CHAR_DATA * ch);


/* All game-related DEFINES */

#define HASH_MAX       1564     /* Max list heads for rooms, objs, mobs */
#define STD_LENGTH     3048     /* Standard length string, 2048 */
#define SML_LENGTH     1524     /* Small length string, 512 */

#define MAX_MOB_TRO    7000     /* Maximum mob trophies, up to vnum 7000 */
                                /* Increasing this adds mem usage. */

/* ------------------------------------------------------------------------- */
/* If you are in between battleground_start_vnum and the end vnum, you are
   auto-considered to be in the battleground, and the mud will behave as if
   you are in the battleground. */
/* ------------------------------------------------------------------------- */
#define BATTLEGROUND_START_VNUM       600  /* Start bground room vnum */
#define BATTLEGROUND_END_VNUM         620  /* End bground room vnum */

#define SKILL_COUNT                   600	/* Must be 600 or higher for the */
					        /* Dynamic skills system */

#define TOP_LEVEL                     110       /* The maximum level. */

#define MAX_COLORS                    8		/* Maximum player configurable colors */
#define RACE_COUNT                    25	/* Max races is 25. Don't change! */
#define MAX_CLAN_STORAGE              30	/* How many items can a clan 
						   have in their clan storage? */
#define MAXST                         30	/* How many items can a person
						   have in person storage? */

#define COLOR_CHAT                    0
#define COLOR_CLANTALK                1
#define COLOR_IMMTALK                 6
#define COLOR_YELL                    2
#define COLOR_SAY                     3
#define COLOR_TELL                    4
#define COLOR_GODTALK                 5

#define MAX_TRADE                       5	/* Don't change this. */

#define STOREDIV                       14	/*item cost is divided by this to
						  determine the cost it will be to 
						  store the item */
#define MAX_LEVEL		   110		/* max possible level */
#define LEVEL_BUILDER              103		/* Builder level */
#define LEVEL_IMMORTAL             101		/* Minimum immortal level */

/* ---------------------- */
/* Do not change these... */
/* ---------------------- */
#define PULSE_PER_SECOND             9
#define PULSE_VIOLENCE               14
#define PULSE_MOBILE              (6 * PULSE_PER_SECOND)
#define PULSE_TICK                (35 * PULSE_PER_SECOND)
#define PULSE_AREA                (120 * PULSE_PER_SECOND)
#define PULSE_FIELD		     4

/* ------------------------------------------------------ */
/* Time of day defines.  Compatable with diku style muds. */
/* ------------------------------------------------------ */
#define SUN_DARK                    0
#define SUN_RISE                    1
#define SUN_LIGHT                   2
#define SUN_SET                     3
#define MOON_RISE                   4
#define MOON_SET                    5

/* ----------------------------------------------------------------------- */
/* Weather system model from Theisles, although I cannot guarentee similar
   implimentation... */
/* ----------------------------------------------------------------------- */
#define SKY_CLOUDLESS               0
#define SKY_CLOUDY                  1
#define SKY_RAINING                 2
#define SKY_LIGHTNING               3
#define SKY_FOGGY                   4

/* ------------------------------------------------------------------------- */
/* Fight option defines.  Can be toggled on/off through the 'fight' command. */
/* ------------------------------------------------------------------------- */
#define F_HEADBUTT      0x00000001
#define F_JUJI          0x00000002
#define F_ELBOW         0x00000004
#define F_KNEE          0x00000008
#define F_BITE          0x00000010
#define F_CHOKE         0x00000020

#define F_AGGRESSIVE    0x00010000
#define F_POWER         0x00020000
#define F_GROUND        0x00040000

/* --------------------------------------- */
/* POSITIONS for ground_pos.  Many unused. */
/* --------------------------------------- */
#define FP_CHOKE_1      0x00000001
#define FP_CHOKE_2      0x00000002
#define FP_CHOKE_3      0x00000004
#define FP_STUNNED      0x00000008
#define FP_BLEEDING     0x00000010
#define FP_TOO_HEAVY    0x00000020
#define FP_PUNCHING     0x00000040

/* --------------------------------------------------------------------- */
/* These bits describe a spell's behavior, for use with the online spell
   creation/editing system. */
/* --------------------------------------------------------------------- */
#define SPELL_SUMMON          0x00000001 	/* Summons a mob/character.
						   mob summoning can be toggled
						   on/off in power.dat */
#define SPELL_TELEPORT        0x00000002	/* Teleports the victim */
#define SPELL_ALL_IN_ROOM     0x00000004	/* Affects everyone in the room */
#define SPELL_REMOVES_BIT     0x00000008	/* Removes a bit (like poison) */
#define SPELL_HEALS_DAM       0x00000010	/* Instead of removing damage on
						   the victim in the dam field,
						   the spell will heal this dam. */
#define SPELL_MESSAGE         0x00000020	/* Sends a message to another player */
#define SPELL_DISPEL_MAGIC    0x00000040	/* Dispels magic */
#define SPELL_HURT_EVIL       0x00000080	/* Works only on evil players */
#define SPELL_HURT_GOOD       0x00000100	/* Works only on good players */
#define SPELL_HURT_UNDEAD     0x00000200	/* Harms only undead mobs */
#define SPELL_MODIFY_OBJECT   0x00000400	/* NOT DONE YET */
#define SPELL_IDENTIFY        0x00000800	/* Behaves as an identify spell */
#define SPELL_LOCATE_OBJECT   0x00001000	/* Behaves as locate object spell */
#define SPELL_SCRY            0x00002000	/* Behaves as scry spell -
						   used to look into the room where
						   someone else in the game is. */
#define SPELL_LOCATE_PERSON   0x00004000	/* Behaves as locate spell -
						   used to see the room name
						   where someone is in. */
#define SPELL_RECALL          0x00008000	/* The recall spell */
#define SPELL_FAIL_1_2        0x00010000	/* Spell will fail 1 out of 2
						   times, even if casting was
						   initially successful */
#define SPELL_FAIL_1_3        0x00020000	/* ditto, but 1 of 3 times. */
#define SPELL_FAIL_1_4        0x00040000	/* ditto, but 1 of 4 times. */
#define SPELL_TWO_SAVES       0x00080000	/* Victim gets 2 saves, so
						   the possibility of resisting
						   is greatly increased. */
#define SPELL_ARMOR_1_2       0x00100000	/* NOT DONE YET */
#define SPELL_ARMOR_1_4       0x00200000	/* " */
#define SPELL_ONLY_MULTI_MOBS 0x00400000	/* Only affects multiple mobs.
						   for use in conjunction with
						   all_in_room */
#define SPELL_HALVED_SAVE     0x00800000	/* Spell damage is divided in
						   half if the victim makes
						   a saving throw. */
#define SPELL_NOT_SELF        0x01000000	/* Spell cannot be cast on
						   the caster him/herself. */
#define SPELL_CHARM_PERSON    0x02000000	/* Unused for now. */
#define SPELL_OBJ_TO_ROOM     0x04000000	/* If the spell creates an
						   object, it will go into the
						   room instead of the character's
						   inventory. */
#define SPELL_ADD_MOVE        0x08000000	/* Adds the 'dam' field to the
						   victim's moves instead of doing
						   damage. */
#define SPELL_ACID            0x10000000	/* Eats equipment */
#define SPELL_FIRE            0x20000000	/* Burns equipment */
#define SPELL_ONLY_GROUP      0x40000000	/* Only affects people of your
						   alignment in the room.  For
						   use with all_in_room */
#define SPELL_ONLY_NOT_GROUP  0x80000000	/* Only affects people not of
						   your alignment in the room.
					   	   For use with all_in_room. */


/* --------------------------------------------------------------------------- */
/* Connected states, similar to MERC's, used to define what state a connection
   is in. */
/* --------------------------------------------------------------------------- */
#define CON_PLAYING                      0	/* Playing the game */
#define CON_STATE_ONE                    1	/* At login screen */
#define CON_GET_OLD_PASSWORD             2	/* Entering password */
#define CON_CONFIRM_NEW_NAME             3	/* New user, confirming new name */
#define CON_GET_NEW_PASSWORD             4	/* Asking for new password */
#define CON_CONFIRM_NEW_PASSWORD         5	/* Confirming new password */
#define CON_GET_NEW_SEX                  6	/* Get sex of new user */
#define CON_GET_NEW_RACE                 7	/* Get race of new user */
#define CON_CONFIRM_NEW_RACE             8	/* Confirm this race */
#define CON_READ_MOTD                   10	/* Reading the message of the day */
#define CON_CONFIRM_ROLL                11	/* Confirming stat roll */
#define CON_GET_NEW_ANSI                12	/* Asking for ANSI */
#define CON_ASK_MENU                    13	/* Login Menu.  Unused. */
#define CON_SHOW_TITLE                  14	/* Showing the title screen. */
#define CON_GET_PAGELEN                 15	/* Asking page length */
#define CON_CHANNELD                    16	/* Special for mudlink */
#define CON_RWHO			17	/* Executing remote who */

#define CON_AEDITOR                     -1	/* Area Editor */
#define CON_REDITOR                     -2	/* Room Editor */
#define CON_MEDITOR                     -3	/* Mob Editor */
#define CON_OEDITOR                     -4	/* Object Editor */
#define CON_CEDITOR                     -5	/* Clan Editor */
#define CON_FSEDITOR                    -7	/* Fullscreen Editor */
#define CON_PEDITOR                     -8	/* Player editor */
#define CON_SEDITOR                     -9	/* Spell Editor */
#define CON_GODMENU                    -10	/* God Menu */
#define CON_SOCEDIT                    -11	/* Social Editor */
#define CON_SCRIPTEDITOR               -12	/* Script/trigger Editor */
#define CON_SHELL		       -13	/* Shell */

/* ----------------------------------------------- */
/* Used for ACT calls, similar to diku style 'act' */
/* ----------------------------------------------- */
#define TO_ROOM             0	/* Display to the room, not to char */
#define TO_NOTVICT          1	/* Display to the room, not char or victim */
#define TO_VICT             2	/* Display to the victim */
#define TO_CHAR             3	/* Display to the character */
#define TO_NOTVICT_SPAM     4	/* Display TO_NOTVICT only if spam mode off */
#define TO_ROOM_SPAM        5	/* Display TO_ROOM only if spam mode off */
#define TO_VICT_SPAM        6	/* Display TO_VICT only if spam mode off */
#define TO_CHAR_SPAM        7	/* Display TO_CHAR only if spam mode off */

#define RC_GOODRACE     0x04000000	/* Mask for good race */
#define RC_EVILRACE     0x08000000	/* Mask for evil race */
#define RC_NEUTRALRACE  0x10000000	/* Unused. */

/* ---------- */
/* Mob types. */
/* ---------- */
#define MOB_HUMAN               0	/* Can groundfight */
#define MOB_ELF                 1	/* Can groundfight */ 
#define MOB_DWARF               2	/* Can groundfight */ 
#define MOB_GNOME               3	/* Can groundfight */ 
#define MOB_GIANT               4	/* Can groundfight */ 
#define MOB_DRAGON              5	/* Kickproof, bashproof */
#define MOB_CANINE              6
#define MOB_RODENT              7
#define MOB_INSECT              8
#define MOB_UNDEAD              9
#define MOB_GOLEM               10
#define MOB_DEMON               11
#define MOB_TROLL               12
#define MOB_BIRD                13
#define MOB_FISH                14
#define MOB_STATUE              15
#define MOB_FELINE              16
#define MOB_PLANT               17
#define MOB_GENERAL_ANIMAL      18
#define MOB_FAERIE              19
#define MOB_REPTILE             20
#define MOB_GHOST               21	/* Can only be hit by glowing/humming weapons */
#define MOB_OTHER               22
#define MOB_LYCAN               23	/* Don't use */
#define MOB_NIGHT               24	/* Don't use */ 
#define MOB_ORC                 25	/* Can groundfight */
#define MOB_DARKELF             26	/* Can groundfight */
#define MOB_DUMMY               27	/* Doesn't hit back */
#define MAX_MOB_TYPE            28

extern char *const mob_type[MAX_MOB_TYPE];

/* --------------------------------------------------------------------- */
/* Hit types for weapons.  Some unused.  Tried to maintain compatability
   with diku type muds... */
/* --------------------------------------------------------------------- */
#define TYPE_UNDEFINED               -1
#define TYPE_HIT                     1000	/* Max 1000 dynamic spells */
#define TYPE_SLASH                   1001
#define TYPE_PIERCE                  1002
#define TYPE_WHIP                    1003
#define TYPE_EXPLODE                 1004
#define TYPE_POUND                   1005
#define TYPE_SUCTION                 1006
#define TYPE_SHOT                    1090
#define MAX_ATTACK                   14		/* Unused! (?) max index+1 */
#define MAX_ATTACK_TYPES             8

/* -------------------------------------------------- */
/* Maximum player defined aliases a person can set up */
/* -------------------------------------------------- */
#define MAXALIAS      35

/* ----------------------------------- */
/* Color defines and other ANSI codes. */
/* ----------------------------------- */
#define BLACK      "\x1b[30m"
#define RED        "\x1b[31m"
#define GREEN      "\x1b[32m"
#define YELLOW     "\x1b[33m"
#define BLUE       "\x1b[34m"
#define PURPLE     "\x1b[35m"
#define CYAN       "\x1b[36m"
#define GREY       "\x1b[37m"

#define B_BLACK    "\x1b[40m"
#define B_RED      "\x1b[41m"
#define B_GREEN    "\x1b[42m"
#define B_YELLOW   "\x1b[43m"
#define B_BLUE     "\x1b[44m"
#define B_PURPLE   "\x1b[45m"
#define B_CYAN     "\x1b[46m"
#define B_GREY     "\x1b[47m"

#define CLRSCR     "\x1b[2J"
#define CLREOL     "\x1b[K"

#define DOWNARROW    "\x1b[B"
#define RIGHTARROW   "\x1b[C"
#define UPARROW      "\x1b[A"
#define LEFTARROW    "\x1b[D"
#define HOMEPOS      "\x1b[H"

#define BOLD       "\x1b[1m"
#define FLASH      "\x1b[5m"
#define INVERSE    "\x1b[7m"
#define NTEXT      "\x1b[0m"

#define TAB        "\x9"

/* ----------------------------------------- */
/* The color for items laying on the ground. */
/* ----------------------------------------- */
#define ITEMCOLOR  "\x1b[0;36m"


/* --------------------------------------------------------------------------- */
/* Tried to keep things similar to Diku/Merc, for area conversion, but I don't
   think it's very possible.. sigh */
/* --------------------------------------------------------------------------- */

#define ACT_SENTINEL         0x00000002		/* Mob doesn't move */
#define ACT_SCAVENGER        0x00000004		/* Picks things up from the ground */
#define ACT_AGGRESSIVE       0x00000008		/* Attacks players on sight */
#define ACT_STAY_AREA        0x00000010		/* Mob stays in it's area vnum */
#define ACT_WIMPY            0x00000020		/* Mob tries to flee when
						   low on hit points */

/* Note: I modelled pet code similar to the old TheIsles version I had.
   Although I don't think it's compatible, I tried to keep the same flags
   and general idea with pet storeroom/etc... */

#define ACT_PET              0x00000040		/* Is this a 'pet' mob? */
#define ACT_UNTOUCHABLE	     0x00000080		/* Only harmable by magic */
#define ACT_PRACTICE         0x00000100		/* This mob can teach things */
#define ACT_UNVAL            0x00000200		/* Unvalidated player! */

#define ACT_SCRAMBLE         0x00001000		/* Used for rushing/running */
#define ACT_MOUNTABLE        0x00002000		/* Can the mob be mounted? */
#define ACT_ANGRY            0x00008000		/* Similar to aggressive, but
						   doesn't attack so fast. */
#define ACT_STAY_SECTOR	     0x00010000		/* Stays in the sector type
						   it repop'd in */
#define ACT_BANK_TELLER      0x00020000		/* Is this a bank teller or
						   clan banker? */

/* ---------------------------------------------------------------------- */
/* On all flags from here on, there was no attempt to keep other codebase
   value flags */
/* ---------------------------------------------------------------------- */

#define REPAIRS_FREE         0x00080000		/* Repairs items for free */
#define REPAIRS_ONE          0x00100000		/* repairs 1/8 cost */
#define REPAIRS_TWO          0x00200000		/* ditto except 1/4 cost */
#define ACT_RESCUEONE        0x00400000		/* rescue mobs with name PRTCT */
#define ACT_RESCUETWO        0x00800000		/* rescue mobs with name CODEONE */
#define ACT_KILLGLADIATOR    0x01000000		/* kills 'gladiator' */
#define ACT_SLEEPAGGRO       0x02000000		/* aggro towards sleeping players */
#define ACT_ATTITUDE         0x04000000		/* attacks if looked at */
#define ACT_ASSISTONE        0x08000000		/* assists mobs with name AONE */
#define ACT_ASSISTTWO        0x10000000		/* assists mobs with name ATWO */
#define ACT_REST             0x20000000		/* mob rests when no PC's in room */
#define ACT_RANGER           0x40000000		/* attacks "beast" */
#define ACT_ASSISTALL        0x80000000		/* Will assist all fighting mobs in room */

#define ACT3_GUARD_ITEM      0x00000001		/* Set to guard an item */
#define ACT3_GUARD_DOOR      0x00000002		/* Set to guard a door */
#define ACT3_GUARD_MOB       0x00000004		/* Set to guard another mob */
#define ACT3_STAYROAD        0x00000008		/* Stays on city/road sectors only */

#define ACT3_TINKER          0x00000010		/* Tinker's guildmaster */
#define ACT3_WARRIOR         0x00000020		/* Warrior's guildmaster */
#define ACT3_THIEFG          0x00000040		/* Thief's guildmaster */
#define ACT3_HEALER          0x00000080		/* Healer's guildmaster */
#define ACT3_WIZARD          0x00000100		/* Wizard's guildmaster */
#define ACT3_RANGER          0x00000200		/* Ranger's guildmaster */
#define ACT3_ASSASSIN        0x00000400		/* Assassin's guildmaster */

#define ACT3_GUARD_DOOR_GOOD 0x00000800		/* Guards door from 'good' */
#define ACT3_GUARD_DOOR_EVIL 0x00001000		/* Guards door from 'evil' */
#define ACT3_KILL_GOOD       0x00002000		/* spams KILL GOOD */
#define ACT3_KILL_EVIL       0x00004000		/* spams KILL EVIL */

#define ACT3_MUTE            0x00010000		/* Can't yell */
#define ACT3_RIDE            0x00020000		/* Will ride the previously reset mob */
#define ACT3_FOLLOW          0x00040000		/* Will follow " " " " */
#define ACT3_REGENERATE      0x00080000		/* Regenerates at a fast rate */
#define ACT3_UNUSED          0x00100000
#define ACT3_SLEEP           0x00400000		/* Follows a daily sleep schedule */
#define ACT3_MAPPING         0x00800000		/* Mapping option on */
#define ACT3_DISABLED        0x01000000		/* Map disabled; indoors */
#define ACT3_TAP             0x02000000		/* tapping for engineers */

#define ACT4_MOBSWITCH    0x00000800	/* Switches opponents during combat */
#define ACT4_FASTHUNT     0x00001000	/* Hunts victims FAST */
#define ACT4_SOLOYELL     0x00002000	/* Will yell solo if attacked */
#define ACT4_STAYOFFROAD  0x00004000	/* Won't go onto city/road sectors */
#define ACT4_KILLALLONE   0x00008000	/* Kills everything flag one */
#define ACT4_KILLALLTWO   0x00010000	/* Kills everything flag two */
#define ACT4_KILLMEVIL    0x00020000	/* Kills evil mobs */
#define ACT4_KILLMGOOD    0x00040000	/* Kills good mobs */

/* ----------------------------------------------------------------------------- */
/* For all AFF_ flags, I tried to follow as closely as I could to Theisles/Merc
   standards!  Sorry if some are off... some are unused. */
/* ----------------------------------------------------------------------------- */

#define AFF_BLIND            0x00000001 	/* Blind */
#define AFF_INVISIBLE        0x00000002		/* Invisible */
#define AFF_DETECT_EVIL      0x00000004		/* People can tell evil objs/mobs */
#define AFF_DETECT_INVIS     0x00000008		/* See invis */
#define AFF_DETECT_MAGIC     0x00000010		/* People can tell magic items */
#define AFF_DETECT_HIDDEN    0x00000020		/* See hidden */
#define AFF_SANCTUARY        0x00000080		/* Absorbs 0 to 1/2 of damage */
#define AFF_FAERIE_FIRE      0x00000100		/* Lowers armor */
#define AFF_INFRARED         0x00000200		/* See in the dark */
#define AFF_CURSE            0x00000400		/* Cannot recall... */
#define AFF_POISON           0x00001000		/* Poisoned */


/* ------------------------------------------------------ */
/* From here down, I tried to keep the NiMud/Theisles std */
/* ------------------------------------------------------ */
#define AFF_PROTECT          0x00002000	/* Absorbs 1/2 damage done */
#define AFF_SNEAK            0x00008000	/* Sneaking.. */
#define AFF_HIDE             0x00010000	/* Hidden.. */
#define AFF_SLEEP            0x00020000	/* Forced sleep */
#define AFF_CHARM            0x00040000	/* Charmed */
#define AFF_FLYING           0x00080000	/* Flying */
#define AFF_PASS_DOOR        0x00100000	/* Pass through unlocked doors. */

/* ------------------------------------------------- */
/* These flags are non-compat with any other mudbase */
/* ------------------------------------------------- */
#define AFF_PLAGUE           0x00400000	/* Plagued.. plague spreads. */
#define AFF_BREATH_WATER     0x00800000	/* Breathe underwater */
#define AFF_PROT_EVIL        0x01000000	/* Protection from evil */
#define AFF_PROT_GOOD        0x02000000	/* Protection from good */
#define AFF_AWARENESS        0x08000000	/* See people enter the room while asleep */
#define AFF_NOXIOUS          0x10000000	/* Noxious fumes.  Unused. */
#define AFF_DETECT_GOOD      0x20000000	/* Detect good items/mobs */
#define AFF_NOCHARM          0x40000000	/* Not charmable */
#define AFF_SAFETY           0x80000000	/* Exempt from being attacked by
					   aggro mobs of much lower level */

#define AFF_PROT_FIRE           0x00000001	/* Protection from fire */
#define AFF_PROT_GAS            0x00000002	/* Protection from gas */
#define AFF_MINDSHIELD          0x00000004	/* Spell protection */
#define AFF_SPEED               0x00000008	/* Double attacks */
#define AFF_INSANITY            0x00000010	/* Insanity! */
/* -------------------------------------------- */
/* Sexflags - specifically follow Diku standard */
/* -------------------------------------------- */
#define SEX_NEUTRAL                   0
#define SEX_MALE                      1
#define SEX_FEMALE                    2


/* --------------------------------------------------------- */
/* These loosely follow theisles std and mortal conquest std */
/* --------------------------------------------------------- */
#define OBJ_VNUM_CORPSE_NPC           10	/* vnum of generic mob corpse */
#define OBJ_VNUM_CORPSE_PC            11	/* vnum of generic player corpse */
#define OBJ_VNUM_SEVERED_HEAD         12	/* vnum of severed head */
#define OBJ_VNUM_TORN_HEART           13	/* torn heart */
#define OBJ_VNUM_SLICED_ARM           14	/* sliced arm */
#define OBJ_VNUM_SLICED_LEG           15	/* sliced leg */
#define OBJ_VNUM_INTESTINES           16	/* intestines */
#define OBJ_VNUM_BLOOD                40	/* Blood trails */
#define ROOM_VNUM_ARENA             504		/* Arena room number */
#define VNUM_WAITONE                508		/* Waiting room 1 for arena */
#define VNUM_WAITTWO                509		/* Waiting room 2 for arena */

#define ARENA_WAIT_TICK               2		/* Ticks in waiting room 
						   before the arena battle 
						   begins */


#define SEARCH_INV_FIRST	1	/* Search inventory first, for use
					   with find_item_here. */
#define SEARCH_ROOM_FIRST	2	/* Search room first. */


/* ---------------------------------------------------------------------- */
/* Full compatibility with Theisles, but possible additions.  I can't
   guarentee all flags do exactly the same things.  Ranged weapons are
   completely disabled, as I lifted the ranged weapon code from an old
   version of mortal conquest, and feel bad about using it.. I'll code my
   own in due time. */
/* ---------------------------------------------------------------------- */
#define ITEM_LIGHT                  1
#define ITEM_SCROLL                 2
#define ITEM_WAND                   3
#define ITEM_STAFF                  4
#define ITEM_WEAPON                 5
#define ITEM_RANGED_WEAPON          6 	/* unused */
#define ITEM_AMMO                   7	/* unused */ 
#define ITEM_TREASURE               8
#define ITEM_ARMOR                  9
#define ITEM_POTION                10
#define ITEM_BOOK                  11
#define ITEM_FURNITURE             12
#define ITEM_TRASH                 13
#define ITEM_CONTAINER             15
#define ITEM_THROWN                16	/* unused */ 
#define ITEM_DRINK_CON             17
#define ITEM_KEY                   18
#define ITEM_FOOD                  19
#define ITEM_GEM                   21
#define ITEM_VEHICLE               22
#define ITEM_CORPSE_NPC            23
#define ITEM_CORPSE_PC             24
#define ITEM_FOUNTAIN              25
#define ITEM_PILL                  26
#define ITEM_TOOL                  27
#define ITEM_LIST                  28
#define ITEM_BLOOD                 29
#define ITEM_CLIMBABLE             30
#define ITEM_SCALABLE              31
#define ITEM_SCALE_DEV             32
#define ITEM_MAP                   33
#define ITEM_TICKET                34
#define ITEM_BOAT                  35
#define ITEM_REPELLANT             36
#define ITEM_MAX                   37


/* Pseudo oop - identifies a structure */
#define K_OBJECT         1	/* structure is an object */
#define K_OBJ            1	/* structure is an object */
#define K_CHAR           2	/* structure is a character */
#define K_ROOM           3	/* structure is a room */
#define K_PC             4	/* structure is a player structure */


/* ------------------------------------------------ */
/* Used for mapping while inside of vehicle 'rooms' */
/* ------------------------------------------------ */
#define MAP_INSIDE(ch)    ( ((ch)->in_room->more && (ch)->in_room->more->linked_to) ? (IS_SET((ch)->in_room->more->linked_to->room_flags,ROOM_INDOORS)) : (IS_SET((ch)->in_room->room_flags,ROOM_INDOORS)) )
#define MAP_INROOM(ch)    ( ((ch)->in_room->more && (ch)->in_room->more->linked_to) ? (ch)->in_room->more->linked_to : (ch)->in_room )



/* ------------------------------------- */
/* These values follow Theisles standard */
/* ------------------------------------- */
#define CONT_CLOSEABLE                0x01	/* Can container be opened/closed? */
#define CONT_PICKPROOF                0x02	/* Is the container pickproof? */
#define CONT_CLOSED                   0x04	/* Does the container default to closed? */
#define CONT_LOCKED                   0x08	/* Is the container locked? */
#define LIGHT_LIT                     0x01	/* Is the light lit? */
#define LIGHT_FILLABLE                0x02	/* Is the light refillable? */
#define TOOL_TINDERBOX                0x01	/* Is this a tinderbox? */
#define TOOL_LOCKPICK                 0x02	/* Is this a lockpick? */

/* ----------------------------------------------------------------------- */
/* For portals.  value 4 to retain compatibility with mortal conquest code */
/* ----------------------------------------------------------------------- */
#define FURN_EXIT                     4


/* ------------------------------------------------- */
/* I tried to keep compatibility with merc/theisles. */
/* ------------------------------------------------- */
#define ITEM_GLOW            0x00000001	/* Can hit ghosts if on a weapon */
#define ITEM_HUM             0x00000002	/* Can hit ghosts if on a weapon */
#define ITEM_EVIL            0x00000010	/* Registers with detect evil */
#define ITEM_GOOD            0x00800000 /* Registers with detect good */
#define ITEM_INVIS           0x00000020	/* Item is invisible */
#define ITEM_MAGIC           0x00000040	/* Item registers with detect magic */
#define ITEM_NODROP          0x00000080	/* Can't drop this item */
#define ITEM_ANTI_GOOD       0x00000200 /* Goods can't use this item */
#define ITEM_ANTI_EVIL       0x00000400	/* Evils can't use this item */
#define ITEM_ANTI_NEUTRAL    0x00000800	/* Neutrals can't use this item */
#define ITEM_NOREMOVE        0x00001000	/* Can't unequip this item */
#define ITEM_INVENTORY       0x00002000	/* For shop use, internal */
#define ITEM_NOSAVE          0x00004000	/* Item doesn't save when you quit */
#define ITEM_UNSEEN          0x00010000 /* Hidden.  Untakable hidden objects
					   cannot be searched for. */

/* ------------------ */
/* Weapon bonus flags */
/* ------------------ */
#define ITEM_PIERCE          0x00020000	/* Gives a bonus for piercing skill */
#define ITEM_SLASHING        0x00040000	/* slashing */
#define ITEM_CONCUSSION      0x00080000	/* pounding/concussion */
#define ITEM_WHIP            0x00100000	/* whipping */
#define ITEM_HEAVY_SLASH     0x00200000	/* Gives a slashing bonus; large if the
					   player is strong, not much if the
					   player is weak. */
#define ITEM_LIGHT_SLASH     0x00400000	/* Gives a large slashing bonus */
#define ITEM_LASER           0x40000000	/* laser */

#define ITEM_SAVE            0x10000000	/* Item saves with a character through death. */
#define ITEM_NOSTORE         0x20000000	/* Cannot store this item in the bank */
#define ITEM_NOPKILL         0x80000000	/* Non-pkiller item only.  Unused. */

/* --------------------------------------------------------------------------- */
/* Fully Theisles compatible.  I duplicated the follow flags with the idea
   in mind of someone eventually making a theisles --> thismud object converter */
/* --------------------------------------------------------------------------- */
#define ITEM_TAKE            0x00000001
#define ITEM_WEAR_FINGER     0x00000002
#define ITEM_WEAR_NECK       0x00000004
#define ITEM_WEAR_BODY       0x00000008
#define ITEM_WEAR_HEAD       0x00000010
#define ITEM_WEAR_LEGS       0x00000020
#define ITEM_WEAR_FEET       0x00000040
#define ITEM_WEAR_HANDS      0x00000080
#define ITEM_WEAR_ARMS       0x00000100
#define ITEM_WEAR_SHIELD     0x00000200
#define ITEM_WEAR_ABOUT      0x00000400
#define ITEM_WEAR_WAIST      0x00000800
#define ITEM_WEAR_WRIST      0x00001000
#define ITEM_WEAR_BELT       0x00002000
#define ITEM_WIELD           0x00004000
#define ITEM_HOLD            0x00004000

/* -------------------------------- */
/* Mortal conquest compatible flags */
/* -------------------------------- */
#define ITEM_WEAR_SHOULDER   0x00008000
#define ITEM_WEAR_FACE       0x00010000
#define ITEM_FLOATING        0x00020000
#define ITEM_WEAR_EAR1       0x00040000
#define ITEM_WEAR_ANKLE      0x00080000

/* -------------------------------------------------- */
/* Theisles/merc compatible, although many are unused */
/* -------------------------------------------------- */
#define APPLY_NONE                    0
#define APPLY_STR                     1
#define APPLY_DEX                     2
#define APPLY_INT                     3
#define APPLY_WIS                     4
#define APPLY_CON                     5
#define APPLY_HIT                    13
#define APPLY_MOVE                   14
#define APPLY_AC                     17	/* Negative is good */
#define APPLY_HITROLL                18	/* Positive is good */
#define APPLY_DAMROLL                19	/* Positive is good */
#define APPLY_SAVING_THROW           20	/* Negative is good */

/* ------------- */
/* Code specific */
/* ------------- */
#define APPLY_RESIST_SUMMON          21
#define APPLY_KICK_DAMAGE            22
#define APPLY_SNEAK                  23
#define APPLY_HIDE                   24


/* ------------------------------------------------------------------- */
/* Once again, the room flags keep semi-compatibility, although manny are
   unused, and some are very different */
/* ------------------------------------------------------------------- */
#define ROOM_DARK            0x00000001	/* Room is dark */
#define ROOM_NO_MOB          0x00000002	/* No mobs will wander into this room.
					   Mobs will, however, track through here. */
#define ROOM_INDOORS         0x00000004	/* Room is indoors */
#define ROOM_PET_SHOP        0x00000040	/* Is a pet shop */

#define ROOM_NO_RECALL       0x00000080	/* Can't recall from here */
#define ROOM_NOHEAR          0x00000080	/* Can't hear yells here */
#define ROOM_NOISY           0x00000100 /* Noisy; yells don't go as far */

#define R_MARK               0x00000200	/* Mark a room */
#define ROOM_NOSUMMON        0x00000400	/* Can't summon TO/FROM this room */
#define ROOM_UNTRACKABLE     0x00000800	/* Can't track through this room */
#define ROOM_MOVING          0x00002000	/* Room has a 'current' */
#define ROOM_NOMAGIC         0x00004000	/* No spells allowed here */
#define ROOM_SILENCE         0x00008000	/* Nobody can talk from here */

/* ----------- */
/* Traps below */
/* ----------- */
#define ROOM_ACIDSPRAY       0x00010000	/* Sprays player with acid */
#define ROOM_FALLSFAST       0x00020000	/* Person falls down if they are in
					   an air sector and can't fly. */
#define ROOM_ISVEHICLE       0x00040000	/* The room is a vehicle (buggy, boat, etc) */
#define ROOM_EXTRAHEAL       0x00100000	/* Slight healing bonus in this room */
#define ROOM_EXTRAMANA       0x00200000 /* Slight mana bonus in this room.. buggy */

#define ROOM_GYSERTRAP       0x00001000	/* Gyser scalds */
#define ROOM_AVALANCHE       0x00400000	/* Avalanche... goes off once (buggy) */
#define ROOM_MANADRAIN       0x00800000	/* Drains all mana */
#define ROOM_FIRETRAP        0x01000000	/* Fire burns characters */
#define ROOM_POISONTRAP      0x02000000	/* Poison arrows shoot characters */
#define ROOM_ARROWTRAP       0x04000000	/* Arrows shoot characters */
#define ROOM_ROCKTRAP        0x08000000	/* Rocks fall on characters */
#define ROOM_SPIKETRAP       0x10000000	/* Spikes stab characters */
#define ROOM_GASTRAPONE      0x20000000	/* Unused, not working */
#define ROOM_GASTRAPTWO      0x40000000	/* Noxious gas poisons characters */

/* Clan storage flag */
#define ROOM_CLANSTORE       0x80000000	/* This is a clan storage room */

/* Special dynamic descript flags */
#define ROOM2_OCEAN_D        0x00000001	/* Generate generic ocean description */
#define ROOM2_FOREST_D       0x00000002	/* Generate generic forest desc */
#define ROOM2_RFOREST_D      0x00000004	/* Generate generic rainforest desc */
#define ROOM2_FIELD_D        0x00000008	/* Generate season-based field desc */
#define ROOM2_LIGHTF_D       0x00000010	/* Generate light forest desc */
#define ROOM2_EARTHCAVE_D    0x00000020	/* Generate earthen cave desc */
#define ROOM2_ANCIENTROAD    0x00000040	/* Generate ancient road desc */
#define ROOM2_HILL_D         0x00000080	/* Generate generic hill desc */


/* ------------------------------------------------ */
/* Direction compatibility with all diku-based muds */
/* ------------------------------------------------ */
#define DIR_NORTH                     0
#define DIR_EAST                      1
#define DIR_SOUTH                     2
#define DIR_WEST                      3
#define DIR_UP                        4
#define DIR_DOWN                      5
#define MAX_DIR                       6


/* ------------------------------------- */
/* Mortal Conquest compatible exit flags */
/* ------------------------------------- */
#define EX_ISDOOR            0x00000001	/* This IS a door */
#define EX_CLOSED            0x00000002	/* Door is closed */
#define EX_LOCKED            0x00000004 /* Door is locked */
#define EX_PICKPROOF         0x00000010	/* Door cannot be picked */
#define EX_BASHPROOF         0x00000020	/* Door cannot be broken */
#define EX_HIDDEN            0x00000100	/* Hidden door */
#define EX_RESET             0x00000200	/* Resets on repop if broken */


/* ---------------------------------------- */
/* Small compatibility with Mortal Conquest */
/* ---------------------------------------- */
#define SECT_INSIDE                   0	/* Inside, set INDOORS flag too! */
#define SECT_CITY                     1	/* City, easy moving */
#define SECT_FIELD                    2	/* Field, easy moving */
#define SECT_FOREST                   3	/* Forest, tough going */
#define SECT_HILLS                    4	/* Hills, tough going */
#define SECT_MOUNTAIN                 5	/* Do not use.. broken */
#define SECT_WATER_SWIM               6	/* Swimable water */
#define SECT_WATER_NOSWIM             7	/* Unswimable water */
#define SECT_UNDERWATER               8	/* Underwater */
#define SECT_AIR                      9	/* Air sector */
#define SECT_DESERT                  10	/* Desert, -2 thirst, hot */
#define SECT_SNOW                    11	/* Hard moving, cold */
#define SECT_TROPICAL                12	/* Tropical, hot */
#define SECT_JAVA		     13 /* Java sector for looks only */
#define SECT_ICE		     14 /* Ice sector.. slippery footing */
#define SECT_MARSH		     15 /* Marsh sector.. no blood trails */
#define SECT_MAX                     16


/* ------------------------------------------------------------------------- */
/* Wear locations compat with Theisles  (big sacrifice with this method
   is only one possible place to wear each object.  However, I guess the
   compatibility is worth it...) */
/* ------------------------------------------------------------------------- */
#define WEAR_NONE                    -1
#define WEAR_FINGER_L                 0
#define WEAR_FINGER_R                 1
#define WEAR_NECK_1                   2
#define WEAR_NECK_2                   3
#define WEAR_BODY                     4
#define WEAR_HEAD                     5
#define WEAR_LEGS                     6
#define WEAR_FEET                     7
#define WEAR_HANDS                    8
#define WEAR_ARMS                     9
#define WEAR_SHIELD                  10
#define WEAR_ABOUT                   11
#define WEAR_WAIST                   12
#define WEAR_WRIST_L                 13
#define WEAR_WRIST_R                 14
#define WEAR_FLOATING                15
#define WEAR_BELT_1                  16
#define WEAR_BELT_2                  17
#define WEAR_BELT_3                  18
#define WEAR_BELT_4                  19
#define WEAR_BELT_5                  20
#define WEAR_HOLD_1                  21
#define WEAR_HOLD_2                  22
#define WEAR_SHOULDER_L              23
#define WEAR_SHOULDER_R              24
#define WEAR_FACE                    25
#define WEAR_EAR_1                   26
#define WEAR_EAR_2                   27
#define WEAR_ANKLE_1                 28
#define WEAR_ANKLE_2                 29
#define MAX_WEAR                     30

/* ----------------- */
/* Cool extra skills */
/* ----------------- */
#define COOL_SKILL_MARTIAL_ARTIST    0x00000001	/* Kicks do extra dam */
#define COOL_SKILL_ARCHMAGE          0x00000002	/* Less casting time */
#define COOL_SKILL_NO_HUNGER         0x00000004	/* Never gets hungry */	
#define COOL_SKILL_NO_THIRST         0x00000008	/* Never gets thirsty */
#define COOL_SKILL_CHEAP_RECALL      0x00000010	/* Cheap recall costs */
#define COOL_SKILL_VIEW_MOBS         0x00000020	/* Sees mobs on overhead mapping */
#define COOL_SKILL_NO_PKILL          0x00000040	/* Cannot be pkilled */

/* ----------------- */
/* Cool skill checks */
/* ----------------- */
#define MARTIAL_ARTIST(ch)      (IS_SET((ch)->pcdata->cool_skills,COOL_SKILL_MARTIAL_ARTIST))
#define ARCHMAGE(ch)            (IS_SET((ch)->pcdata->cool_skills,COOL_SKILL_ARCHMAGE))
#define NO_THIRST(ch)           (IS_SET((ch)->pcdata->cool_skills,COOL_SKILL_NO_THIRST))
#define NO_HUNGER(ch)           (IS_SET((ch)->pcdata->cool_skills,COOL_SKILL_NO_HUNGER))
#define CHEAP_RECALL(ch)        (IS_SET((ch)->pcdata->cool_skills,COOL_SKILL_CHEAP_RECALL))
#define VIEW_MOBS(ch)           (IS_SET((ch)->pcdata->cool_skills,COOL_SKILL_VIEW_MOBS))
#define NO_PKILL(ch)            (IS_SET((ch)->pcdata->cool_skills,COOL_SKILL_NO_PKILL))


/* -------------------------------------- */
/* Conditions compat with mortal conquest */
/* -------------------------------------- */
#define COND_DRUNK                    0
#define COND_FULL                     1
#define COND_THIRST                   2
#define COND_STARVING                 3

/* ---------------------- */
/* Internal use for ident */
/* ---------------------- */
#define WRITE_AUTH 1
#define AUTH       2

/* -------------------- */
/* Guild flags and info */
/* -------------------- */
#define GUILD_TINKER   0x00000010
#define GUILD_WARRIOR  0x00000020
#define GUILD_THIEFG   0x00000040
#define GUILD_HEALER   0x00000080
#define GUILD_WIZARD   0x00000100
#define GUILD_RANGER   0x00000200
#define GUILD_ASSASSIN 0x00000400

/* -------------------------------- */
/* Minimum level to join each guild */
/* -------------------------------- */
#define LEVEL_TINKER   14
#define LEVEL_WARRIOR  15
#define LEVEL_THIEFG   14
#define LEVEL_HEALER   17
#define LEVEL_WIZARD   20
#define LEVEL_RANGER   16
#define LEVEL_ASSASSIN 24

/* ----------------------- */
/* Cost to join each guild */
/* ----------------------- */
#define COST_TINKER    17500
#define COST_WARRIOR   14000
#define COST_THIEFG    19000
#define COST_HEALER    27000
#define COST_WIZARD    21000
#define COST_RANGER    15050
#define COST_ASSASSIN  43000


/* ------------------------------------------------------------------------ */
/* Positions... the first few positions, I tried to maintain compatibility
   with mortal conquest/theisles. After that, anything goes. */
/* ------------------------------------------------------------------------ */
#define POSITION_DEAD                      0
#define POSITION_MORTAL                    1	/* Mortally wounded */
#define POSITION_INCAP                     2	/* Incapacitated */
#define POSITION_STUNNED                   3	/* Stunned */
#define POSITION_SLEEPING                  4	/* Sleeping */
#define POSITION_RESTING                   5	/* Resting */
#define POSITION_FIGHTING                  7	/* Fighting */
#define POSITION_CIRCLE                    8	/* Circling */
#define POSITION_BASHED                    9	/* Bashed to ground */
#define POSITION_GROUNDFIGHTING           10	/* Groundfighting */
#define POSITION_FALLING                  11	/* Falling! */
#define POSITION_STANDING                 12	/* Standing, not fighting */
#define POSITION_RUNNING                  13	/* Running */
#define POSITION_SEARCHING                14	/* Searching for exit/item */
#define POSITION_BACKSTAB                 15	/* Backstab preparation */
#define POSITION_MEDITATING               16	/* Meditating */
#define POSITION_INVEST                   17	/* Investigating */
#define POSITION_CASTING                  18	/* Casting a spell */


/* ---------------- */
/* Player set bits. */
/* ---------------- */
#define PLR_HOLYLIGHT        0x00000004	/* Can see in the dark, invis, etc */
#define PLR_LOG              0x00000010	/* Keep logs of this player's commands */
#define PLR_DENY             0x00000020	/* Deny this character from logging in */
#define PLR_FREEZE           0x00000040	/* Freeze this character */
#define PLR_HOLYPEACE        0x00010000	/* Nobody can attack anyone while in the
					   room with this immortal. */
#define PLR_HOLYWALK         0x00020000	/* Can walk through anything, anywhere */
#define PLR_HOLYLAG          0x00100000	/* Is this immortal delayed on delayed
					   commands like mortals? */

/* -------------------------------------- */
/* Bits for immort notification on events */
/* -------------------------------------- */
#define WIZ_NOTIFY           0x00000080
#define WIZ_NOTIFY_1         0x00000100
#define WIZ_NOTIFY_2         0x00000200
#define WIZ_NOTIFY_LOGIN     0x00000400
#define WIZ_NOTIFY_DEATH     0x00000800
#define WIZ_NOTIFY_BUG       0x00001000
#define WIZ_NOTIFY_LOG       0x00002000
#define WIZ_NOTIFY_SCRIPT    0x00004000

/* --------------------- */
/* Internal channel ID's */
/* --------------------- */
#define CHANNEL_AUCTION      0x00000001
#define CHANNEL_CHAT         0x00000002
#define CHANNEL_CLANTALK     0x00000004
#define CHANNEL_IMMTALK      0x00000008
#define CHANNEL_NOTIFY       0x00000010
#define CHANNEL_YELL         0x00000080
#define CHANNEL_GODTALK      0x00000100

/* --------------------------------------------------------------- */
/* Auto's conforming to theisles 1.0 and mortal conquest standards */
/* --------------------------------------------------------------- */
#define PLR_AUTOGOLD         0x00000100	/* Gets gold from kills */
#define PLR_AUTOEXIT         0x00000200	/* Displays exits in room desc */
#define PLR_AUTOLOOT         0x00000400	/* Loots all kills */
#define PLR_AUTOSAC          0x00000800	/* Sacs corpses of all kills */
#define PLR_BLANK            0x00001000	/* Blank line before prompt */
#define PLR_BRIEF            0x00002000	/* Brief mode - no long room descs */
#define PLR_COMBINE          0x00004000	/* Combine object listings */
#define PLR_PROMPT           0x00008000	/* Prompt is on/off */
#define PLR_TELNET_GA        0x00010000 /* Non-compat, but same name!  Warning */
#define PLR_ASSIST           0x00020000	/* Auto-assists people in group against
					   mobs.  To assist against other players,
					   you must manually type assist. */
#define PLR_AUTOSPLIT        0x00040000	/* auto-splits any cash looted */

#define PLR_SILENCE          0x00080000	/* Player cannot use channels */

#define PLR_ANSI             0x00400000	/* Ansi is on/off for this player? */
#define PLR_VT100            0x00800000	/* Masks PLR_ANSI */

#define PLR_BLANKPROMPT      0x04000000	/* Floating prompts */
#define PLR_PROMPT_UP        0x08000000	/* Prompt with map or down below? */

/* ---------------------------------------------------------------------- */
/* Mana types retain full compatibility with Mortal conquest and Theisles */
/* ---------------------------------------------------------------------- */
#define MANA_ANY           -1
#define MANA_NONE           0
#define MANA_EARTH          1
#define MANA_AIR            2
#define MANA_FIRE           4
#define MANA_WATER          8


/* ------------------- */
/* Spelltype targets.. */
/* ------------------- */
#define TAR_IGNORE                  0x00000000	/* No target needed */
#define TAR_CHAR_OFFENSIVE          0x00000001	/* Offensive spell */
#define TAR_CHAR_DEFENSIVE          0x00000002	/* Defensive spell */
#define TAR_CHAR_SELF               0x00000004	/* Self only */
#define TAR_OBJ_INV                 0x00000008	/* Object in inventory */
#define TAR_ALL_IN_ROOM             0x00000010	/* Everyone in room */

#ifdef WINDOWS
#define PLAYER_DIR      "..\\plr\\"
#define PLAYER_DIR_2    "..\\plr\\"
#define NULL_FILE       "..\\src\\EmlenMud"
#else
#define PLAYER_DIR      "../plr/"
#define PLAYER_DIR_2    "../plr/"
#define NULL_FILE       "/dev/null"
#endif

#define AREA_LIST       "playarea.lst"
#define NOTE_FILE       "plnotes.txt"

extern char *globalalias_name[200];
extern char *globalalias_expansion[200];

struct scriptassoc {
	SA	*next;
	char	*flagname;
	char	*flagtext;
};

extern SA *sa_head[27];  /* 1=A, 26=Z */

/* ----------------------------------------------------------------- */
/* This reads from dam.dat.  Allows for configurable damage messages */
/* ----------------------------------------------------------------- */
struct dammsg_data
  {
    short generic_range[20][2];
    short generic_percent[20][2];
    char *gen_m[20][2];
    char *gen_m1[20][2];
    char *gen_m2[20][2];
    short body_range[20][2];
    short body_percent[20][2];
    char *body_m[20][2];
    char *body_m1[20][2];
    char *body_m2[20][2];
    short head_range[20][2];
    short head_percent[20][2];
    char *head_m[20][2];
    char *head_m1[20][2];
    char *head_m2[20][2];
    short leg_range[20][2];
    short leg_percent[20][2];
    char *leg_m[20][2];
    char *leg_m1[20][2];
    char *leg_m2[20][2];
    short arm_range[20][2];
    short arm_percent[20][2];
    char *arm_m[20][2];
    char *arm_m1[20][2];
    char *arm_m2[20][2];
  };

/* ----------------------------------------------------------------------- */
/* This reads from power.dat.  It can be used to configure the entire mud. */
/* ----------------------------------------------------------------------- */
struct power_data
  {
    bool professions;		/* Professions used or disabled? */
    bool tps;			/* Use travel point system? */
    bool evil_good;		/* Evil/Good conflict? */
    short initial_hp[2];	/* Initial hit points for newbies */
    short remort_hp[2];		/* Remort initial hit points */
    short initial_mv[2];	/* Initial move points for newbies */
    short remort_mv[2];		/* Remort initial move points */
    short hitgain[10][5];	/* Hit gains in a given level range */
    short rem_hitgain[10][5];	/* Remort hit gains in a given level range */
    short movegain[10][4];	/* Move gains in a given level range */
    short rem_movegain[10][4];	/* Remort move gains in a given level range */
    int must_be_in_room;	/* Must be in this room to remort */
    bool add_to_stats;		/* Remorts add stats? */
    short max_remorts;		/* Maximum remorts */
    short remort_level;		/* Level you must be to remort */
    bool vaporize_inv;		/* Vaporize inventory when remorting? */
    bool vaporize_all;		/* Vaporize everything when remorting? */
    short race_change;		/* Change races when remorting? */
    int beams_to_room;		/* Jump to this room after remorting? */
    bool weather;		/* Weather effects on/off */
    bool allow_recall;		/* Allow use of the recall command? */
    bool choose_evil_races;	/* Choose evil races at newbie creation? */
    bool player_prompt;		/* Player defined prompts? */
    bool skill_loss_on_mob_death; /* skills lost on mob death? */
    bool skill_loss_on_pk_death;  /* skills lost on pk death? */
    int amount_lost_on_death;	  /* Actual skill amount lost on death */
    bool login_menu;		/* Use login menu?  unused... */
    bool arena_on;		/* Arena active? */
    bool arena_good_evil;	/* Good/Evil fights in arena? */
    bool validation;		/* Validation system on/off */
    char email_to[50];		/* Email to here for validation */
    bool old_attack;		/* Old attack type? */
    bool easier_moves;		/* Easier movement method */
    int max_prac_spells;	/* Maximum spell percentage you can practice to */
    int max_prac_skills;	/* Maximum skill percentage you can practice to */
    int newbie_object[10];	/* Newbies start with these objects */
    bool allow_where;		/* Allow use of 'where' command? */
    int space_needed;		/* Shared string space needed on bootup. */
    bool allow_who_in_login;	/* Allow "who" in greeting screen. */
    bool old_creation_method;	/* Old question-based creation method? */
    bool evil_can_cast;		/* Evil can cast spells? */
    short practice_percent;	/* Use to scale practices per level */
    short repair_weapons[3];	/* Costs to repair weapons */
    short repair_armors;	/* Costs to repair armor */
    short tinker_discount;	/* Discount for tinker guild members */
    short resize_divisor;	/* Resize divisor for resize cost */
    short groundfight_stand;	/* Chance of standing in a groundfight */
    bool equip_in_combat;	/* Equip armor in combat? */
    bool remove_while_fighting;	/* Remove armor while fighting? */
    bool score_while_fighting;	/* Use score while fighting? */
    bool give_while_fighting;	/* Give objects while fighting? */
    char *god_names[5];		/* Holds the name of mudgods. */
    bool auto_auction;		/* Allow auto-auction? */
    int level_to_see_numeric_stats; /* Level to see numeric stats, unused. */
    short base_hp_regen;	/* Base hp regen per heartbeat */
    short base_mp_regen;	/* Base mp regen per heartbeat */
    short hp_bonus_resting;	/* Hp regen bonus for resting */
    short hp_bonus_sleeping;	/* Hp regen bonus for sleeping */
    short mp_bonus_resting;	/* Move bonus for resting */
    short mp_bonus_sleeping;	/* Move bonus for sleeping */
    short med_mana_regen_bonus;	/* Meditating regen for mana */
    short base_mana_regen_bonus; /* Non-meditating regen for mana */
    bool tackle_with_weapon;	/* Allow tackling with a weapon? */
    bool tackle_person_with_weapon; /* Allow tackling a person with a weapon? */
    bool allow_rerolls;		/* Allow rerolls in old creation method? */
    short flurry_mps;		/* Move point cost for flurry */
    char *learned[20];		/* Description of how well you know spells/skills */
    short low_range[20];	/* Range for learned */
    short high_range[20];	/* Range for learned */
    char *exp_to_level;		/* Interpretted exp to level. */
    short prereq;		/* Minimum you must know a given skill for it
				   to count as a satisfied prerequisite. */
    char *mob_exp;		/* Mob exp to level, interpretted. */
    short armor_lev_min[20];	/* Armor level range */
    short armor_lev_max[20];	/* Armor level range */
    char *armor_lev_word[20];	/* Armor level range descriptions. */
    bool restore_when_level;	/* Free restore when you level? */
    bool can_summon_mobs;	/* Does the game allow mob summoning? */
    bool morts_use_color_chat;	/* Can morts use colors in channels? */
    bool show_race_select_info;	/* Shows race stats to newbies? */
    char flee_chance;		/* Percent chance that fleeing will fail */
    bool bash_slip_to_tackle;	/* Can a bash slip into a groundfight? */
    bool penalize_evil_in_sun;	/* Penalize evil in direct sunlight? */
    bool get_from_corpse_while_in_combat; /* Loot corpses while fighting? */
    char plague_chance;		/* Chance others in the room will catch
				   plague from you, if infected. */
    char *gods;			/* Gods who run the place */

    int  max_level;		/* maximum level, cannot exceed 90 */
    bool can_fight_self;	/* Can fight yourself? */
    char loot_level;		/* What level can you loot a corpse? */
    bool auction_lag;		/* PK Quit lag applied to auctions? */

	bool good_kill_good;
	bool evil_kill_evil;
	
  };

/* ------------------------------- */
/* For use with syslag, sysfinger. */
/* ------------------------------- */
struct shell_command
  {
    SHELL *next;
    char caller[50];
    char fname[20];
    int wait;
  };

/* ---------------- */
/* Banned site data */
/* ---------------- */
struct ban_data
  {
    BAN_DATA *next;
    char *name;		/* Numeric site ban */
    bool newbie;	/* Newbie banned?  If so, people from this site
			   must go through email validation to play! */
  };

/* ---------------------- */
/* Combat Field Structure */
/* ---------------------- */
struct combat_field
  {
	COMBAT_FIELD *next;
	CHAR_DATA *map[7][7];
	
  };

extern COMBAT_FIELD *field_list;
extern COMBAT_FIELD *free_field_list;

/* -------------------------------- */
/* Damages.. partially implimented. */
/* -------------------------------- */
struct damages_struct
  {
    char *kick_dam;
  };

/* ------------------------------ */
/* The key to the spell editor... */
/* ------------------------------ */
struct spell_data
  {
    SPELL_DATA *next;		/* Next spell, hashed by number */
    SPELL_DATA *next_a;		/* Next spell, hashed by spell name */
    int slot;			/* Slot, unused! */
    int gsn;			/* General slot number.  internal use */
    int spell_type;		/* Offensive, defensive, etc... */
    int spell_bits;		/* SPELL_SUMMON, etc.. */
    char *spell_name;		/* The spell's name */
    char *spell_funky_name;	/* Should match spell_name.  Basically unused. */
    int spell_level;		/* Minimum level to cast this spell */
    char *prereq_1;		/* Spell prereq #1 */
    char *prereq_2;		/* Spell prereq #2 */
    char *noun_damage;		/* Noun damage for offensive combat spells */
    char *act_to_ch_1;		/* Shown to character when he/she casts */
    char *act_to_ch_2;		/* Just another line to show to char */
    char *act_to_vict_1;	/* To victim */
    char *act_to_vict_2;
    char *act_to_notvict_1;	/* To everyone in room besides char + vict */
    char *act_to_notvict_2;
    int location;		/* Modifies this location (str, dex, etc) */
    char *duration;		/* Needs to be a string so we can have vars */
    char *modifier;		/* Amount to modify location */
    int bitvector;		/* Bitvector for modification */
    char *damage;		/* If combat spell, how much dam (w/vars) */
    int mana;			/* Minimum Mana cost */
    int mana_type;		/* Mana type */
    int casting_time;		/* Casting delay time. 10 = 1 combat round */
    int position;		/* Position you must be in to cast */
    char *wear_off_msg;		/* When the spell wears off, this msg is disp'd */
    int creates_obj;		/* Creates this object vnum */
    int values[10];		/* Uses these values on creates_obj... UNUSED! */
    				/* -9 means use creates_obj base value */
    unsigned char min_int;	/* Minimum int to learn the spell fully */
    unsigned char min_wis;	/* Minimum wis to learn the spell fully */
				/* These flags are used as con/str for skills */
    char *linked_to;		/* Linked to this spell; when you cast spell
				   A, spell B is also cast.  */
    int bitvector2;		/* More effects */
  };


/* ------------------------- */
/* Where a blow is struck... */
/* ------------------------- */
#define STRIKE_BODY   1
#define STRIKE_HEAD   2
#define STRIKE_LEGS   3
#define STRIKE_ARMS   4

/* ------------------------- */
/* Structure that armor has. */
/* ------------------------- */
struct item_armor
  {
    char tag;
    signed char warmth;		/* v9 */
    signed char protects_legs;	/* v0 */
    signed char protects_body;	/* v1 */
    signed char protects_head;	/* v2 */
    signed char protects_arms;	/* v3 */
    signed char pound_rating;	/* v4 */
    signed char slash_rating;	/* v5 */
    signed char pierce_rating;	/* v8 */
    signed char max_condition;	/* v6 */
    signed char condition_now;	/* v7 */
  };

/* ---------------------------- */
/* Weapons have these values.   */
/* ---------------------------- */
struct item_weapon
  {
    char tag;
    signed char firstdice;	/* v7 */
    signed char seconddice;	/* v8 */
    signed char attack_type;	/* v3 */
    signed char damage_p;	/* v0 */
    signed char strength;	/* v1 */
  };

/* ---------------------------- */
/* Drink containers' values...  */
/* ---------------------------- */
struct item_drink_container
  {
    char tag;
    signed char max_liquid;	/* v1 */
    signed char liquid_now;	/* v0 */
    signed char liquid_type;	/* v2 */
    signed char not_poison;	/* v3 */
  };

/* ------------------- */
/* A light's values... */
/* ------------------- */
struct item_light
  {
    char tag;
    signed char light_lit;	/* v3 */
    signed char light_now;	/* v0 */
    signed char max_light;	/* v1 */
    signed char light_fillable;	/* v2 */
  };

/* etc.. */

struct item_tool
  {
    char tag;
    signed char tool_type;	/* v0 */
    signed char uses;		/* v1 */
    signed char max_uses;	/* v2 */
  };

struct item_vehicle
  {
    char tag;
    signed char sector_use;	/* v0 */
  };

struct item_fountain
  {
    char tag;
    signed short liquid;	/* v0 */
    signed short spells[3];	/* v1-> */
  };

struct item_potion
  {				/* Scrolls/pills/potions */
    char tag;
    unsigned char spell_level;	/* v0 */
    signed short spells[3];	/* v1-> */
  };


/* ---------------------------- */
/* For spray bottles/repellants */
/* ---------------------------- */
struct item_spray
  {
    char tag;
    signed char sprays;	/* How many charges left */
    int repels[9];	/* Repels mobs of these vnums */
  };

struct item_food
  {
    char tag;
    signed char hours;		/* v0 */
    signed char not_poison;	/* v3 */
  };

struct item_gem
  {
    char tag;
    signed short gem_type;	/* v0 */
    signed short mana_now;	/* v1 */
    signed short max_mana;	/* v2 */
    unsigned char max_level;	/* v3 */
  };

struct item_wand
  {				/* Wands/staffs */
    char tag;
    unsigned char spell_level;	/* v0 */
    signed char max_charges;	/* v1 */
    signed char current_charges;	/* v2 */
    signed short spells[3];	/* v3-> */
  };

struct item_furniture
  {
    char tag;
    signed char type;		/* v0 */
    int to_room_vnum;		/* v1 */
    signed char strip_possessions;	/* v5 */
  };

struct item_container
  {
    char tag;
    int max_weight;		/* v0 */
    int flags;			/* v1 */
    int key_vnum;		/* v2 */
    int money;			/* v8 */
    char reason_for_death[30];
    char looted_by[30];
    char looted_by_two[30];
  };

struct item_climbable
  {
    char tag;
    signed char up_down;	/* v0 */
    int above;			/* v2 */
    int below;			/* v3 */
  };

struct item_book
  {
    char tag;
    signed short teaches;	/* v0 */
  };

struct item_blood
  {
    char tag;
    char door;			/* v0 */
  };

struct time_info_data
  {
    short year;
    short month;
    short hour;
    short day;
  };



/* ---------------------------------------------------------------------- */
/* Weather compatibility followed from Theisles.. may be different than
   expected though... warning! :) */
/* ---------------------------------------------------------------------- */
struct weather_data
  {
    int mmhg;		/* Mercury mm */
    short temperature;	/* Farenheight temp */
    int change;		/* Last change */
    short sky;		/* Sky value */
    short sunlight;	/* Sunlight value */
    short winddir;	/* Wind direction */
    short windspeed;	/* Wind speed */
  };


/* ----------------------------------------------------------------------- */
/* The bidding is messy, but it's a port from long ago when I wrote it for
   midpoint void... */
/* ----------------------------------------------------------------------- */
struct bid_data
  {
    char fighters[2][17];	/*[0] and [1] hold the two fighters' names */
    char bidders[50][17];	/*Character names of bidders (didn't to structs cuz 
				   of quitting/etc */
    long bids[50];		/*actually monetary bid */
    bool bidfor[50];		/*FALSE for fighter 0, TRUE for fighter 1 */
    bool taking_bids;		/*Are we still up for bidding or has the fight begun? */
    int waitticks;
  };

/* --------------------------------------- */
/* Topten structure holds top ten pkillers */
/* --------------------------------------- */
struct topten_data
  {
    char topten_name[10][17];
    int topten_warpoints[10];
    bool topten_good[10];
  };

/* --------------------------------------- */
/* Rating data holds top 10 rated players  */
/* --------------------------------------- */
struct rating_data
  {
    char rating_name[10][17];
    int rating_rating[10];
    bool rating_good[10];
  };

/* ---------------------------------------------------------------- */
/* Stores 20,000 vnums of limited items, how many objects can exist
   in the world. */
/* ---------------------------------------------------------------- */
#define MAX_LIMITED 20000
struct limited_data
  {
    short limited_array[MAX_LIMITED];
  };


/* --------------------------------------------------------- */
/* Semi-compatibility with Theisles, but nothing guarenteed! */
/* --------------------------------------------------------- */
struct descriptor_data
  {
    socket_t descriptor;		/* Actual file descriptor number */
    DESCRIPTOR_DATA *next;
    DESCRIPTOR_DATA *snoop_by;	/* Snooping by another descriptor */
    CHAR_DATA *original;	/* Original, for use in switching into mobs */
    CHAR_DATA *character;	/* player this descriptor is attached to */
    int timeout_counter;	/* Login screen timeout counter */
    short connected;		/* Connect state */
    int atimes;			/* Authorization ident attempts */
    socket_t auth_fd;		/* Authorization ident file desc */
    int auth_state;		/* Authorization state */
    int auth_inc;
    char abuf[100];		/* Authorization buffer for in/out */
    char host[30];		/* Hostname this player comes from */
    char hosttwo[30];		/* Host prefix for extra checking */
    char *hostname;		/* Hostname.  Unused due to slow dns lookups */
    char *username;		/* Username result from ident */
    bool tpcommand;		/* Command typed in? */
    int max_outbuf;		/* Maximum outbuffer size used so far.  Outbuffer
				   is allocated in 256 byte chunks, and can
				   grow depending on how much text needs to
				   be in the buffer at once. */
    char inbuf[2002];		/* Input buffer */
    char incomm[2004];		/* Input command buffer */
    char inlast[2004];		/* Last Input buffer contents */
    int repeat;			/* Repeat count; catch spammers */
    bool wrong_pw;		/* Wrong password attempt last time! */
    char *outbuf;		/* Output buffer pointer */
    char *showstr_head;		/* Head of string pausing */
    char *showstr_point;	/* Pointer to showstring string pausing */
    void *pEdit;		/* Pointer to structure currently editing */
    int outsize;		/* Output size */
    int outtop;			/* Output max */
    bool insert;		/* In insert mode in fullscreen */
    int location;		/* Location in fullscreen editor */
    char **pString;		/* Pointer to string currently editing */
    int fdpair[2];		/* File desc pair for shelling */
    bool java;			/* Using the java interface? */
    short pic_wait;		/* Picture wait ticks */
  };


/* --------------------------------------------------------------------- */
/* Theisles and mortal conquest compat.  Yes, I copied their file parsing
   and general helpfile format ideas!  However, since it's not the exact
   same code, I can't guarentee files will be compat... */
/* --------------------------------------------------------------------- */

struct help_data
  {
    HELP_DATA *next;
    short level;	/* Minimum level to see this helpfile */
    char *keyword;	/* Keyword list to get this helpfile */
    char *text;		/* Actual help text */
  };

/* ----------------- */
/* CHANNELS follow.. */
/* ----------------- */

#define SAME_ALIGN 1
#define TO_GOOD 2
#define TO_EVIL 3
#define TO_BOTH 4

struct channel_type
  {
    CHANNEL *next;
    bool clan;		/* Clan channel? */
    bool clan2;		/* Sect channel? */
    char *channel_name;	/* Channel name */
    char *commands[3];	/* Commands to use this channel */
    int level;		/* Level to use this channel */
    int to_level;	/* Channel is seen by all higher than this level */
    char *color;	/* Color of this channel for newbies */
    int moves;		/* Takes this amount of moves to use channel */
    char to_align;		/* 1 = same align as you  2 = good  3 = evil
				   4 = both aligns */
  };

/* ---------- */
/* Non-compat */
/* ---------- */
struct shop_data
  {
    SHOP_DATA *next;
    int keeper;			/* Vnum of shopkeeper */
    short buy_type[MAX_TRADE]; 	/* What a shopkeeper will buy */
    short profit_buy;		/* Buying profit, in percent */
    short decrease;		/* Decrease percent for multiple items */
    short items_until_decrease;	/* Decrease percent after this many items */
    short profit_sell;		/* Selling profit, in percent */
    unsigned char open_hour;	/* Time the shop opens */
    unsigned char close_hour;	/* Time the shop closes */
    int creates_vnum;		/* Shopkeeper makes this object */
    short creates_hours;	/* ever creates_hours hours. */
    char *creates_message;	/* display this message when he/she creates */
  };


struct clan_data
  {
    CLAN_DATA *next;		/* Next Clan in List */
    short vnum;			/* Clan vnum */
    char leader[20];		/* Name of Clan's Leader/Owner */
    char name[60];		/* Name of Clan Itself */
    int start_vnum;		/* Starting vnum of where clanhouse begins */
    short alignment;		/* 1=good,2=evil,0=neut,3=special */
    short minlev;		/* Minlevel of new members */
    char *members[100];		/* Clan members */
    SINGLE_OBJECT *storage[MAX_CLAN_STORAGE]; /* Clan storage */
  };


/* -------------------------- */
/* Race data for player races */
/* -------------------------- */
struct race_data
  {
    char name[20];	/* Name of the race */
    short bonus[5];	/* Initial stat bonuses */
    short limits[5];	/* Stat limits */
    int start_room;	/* Starting room, 99 or 100.. 99=evil 100=good */
    int max_skills;	/* Max skills */
    int max_spells;	/* Max spells */
    short height_min;	/* Minimum height */
    short height_max;	/* Maximum height */
    int affect_bits;	/* Natural abilities */
    int natarmor;	/* Natural skin armor class */
    int regen_hit_percent; /* Hit point regeneration percent */
    int regen_move_percent; /* Move point regenration percent */
    bool poison_immunity; /* Is this race immune to poison? */
    bool plague_immunity; /* Is this race immune to plague? */
    bool switch_aligns;   /* Can this race switch alignment? */
  };

/* --------------------------- */
/* Compat with mortal conquest */
/* --------------------------- */
struct color_data
  {
    char code[10];
    char act_code[5];
    char name[15];
    int number;
  };

struct material_data
  {
   char *name;
   short weight;  /* /4 for body, /5 for legs, /6 for arms, /7 for head,
		     /7 for feet, /9 for gloves */
   char strength; /* the armor durability/hp value */
   short armor;
   short a_slash; /* This armorval for slash */
   short a_pierce;
   short a_pound;
   short pointcost; /* amount of creation points it costs */
   char *desc;
   short min_level;
   bool disabled;
   bool s_bplate_etc;
   int initflags;
   int cost;	/* /3 for body, /5 for legs, /5 for arms, /6 for head
		   /7 for feet, /8 for gloves, etc */
  };

/* ----------------------------------- */
/* Flag data for online creation flags */
/* ----------------------------------- */
struct flag_data
  {
    bool shown_in_help;		/* Should this flag be available in helpfiles? */
    char what_you_type[50];	/* What you type to get the flag toggled */
    char how_it_appears[50];	/* How the flag display appears */
    int flagname;		/* The actual FLAG */
    char what_it_does[255];	/* Help for what it does. */
  };

/* ------------------------------------------------- */
/* Note data base is compatible with mortal conquest */
/* ------------------------------------------------- */
struct note_data
  {
    NOTE_DATA *next;
    char *sender;	/* Note's sender */
    char *date;		/* Date it was sent */
    char *to_list;	/* List of people it is to */
    char *subject;	/* Subject of the note */
    char *text;		/* The actual note text */
    int lines;		/* Lines of text in the note */
    time_t date_stamp;	/* Date stamp for unread notes */
    int board_num;	/* Game Board number this note is located on */
  };


/* ----------------------------------------------------------------------- */
/* Affect data - I tried to keep it compat with diku, however no code was
   copied, and I'm only human!  I take no responsibilities for general
   differences that may cause problems in porting code back and forth!! */
/* ----------------------------------------------------------------------- */
struct affect_data
  {
    AFFECT_DATA *next;
    short type;		/* Affect type (gsn) */
    int bitvector;	/* bitvector affects #1 */
    int bitvector2;	/* bitvector affects #2 */
    short modifier;	/* numeric modified */
    short location;	/* locatino modified */
    short duration;	/* duration of affect */
  };


/* ------------------------------------------------------------------- */
/* Compat with mortal conquest/Theisles, but not meant for use in this
   codebase */
/* ------------------------------------------------------------------- */
struct attack_type
  {
    char *name;
    int hit_type;
  };

struct int_apply_type {
short learn;
};

struct con_apply_type {
short hit;
};

struct str_apply_type {
short dam;
};

struct wis_apply_type {
short practice;
};


/* --------------- */
/* Useful macros!! */
/* --------------- */

#ifdef NEW_WORLD
#define IS_IN_BOAT(ch)		FALSE
#else
#define IS_IN_BOAT(ch)        ( (ch)->ced->in_boat != NULL )
#endif

/* -------------------------------------------- */
/* Is the character builder in a specific area? */
/* -------------------------------------------- */
#define IS_BUILDER(ch, area)  ( (LEVEL(ch)>=LEVEL_IMMORTAL && area->open!=1 && \
				(ch->pcdata->security <= area->security \
				|| strstr( area->builders, ch->pcdata->name ) != NULL \
				|| strstr( area->builders, "All" ) != NULL \
				)) \
				|| LEVEL(ch)>=MAX_LEVEL)

#define HUNTING(ch)           ((ch)->fgt ? (ch)->fgt->hunting : NULL)

/* --------------------------- */
/* OLD script format.  Unused. */
/* --------------------------- */
struct script_data
  {
    SCRIPT_DATA *next;
    char *command;
  };


/* ------------------------------------------- */
/* Basic mob prototype used to create mobiles! */
/* ------------------------------------------- */
struct mob_proto_data
  {
    MOB_PROTOTYPE *next;
    char *name;			/* Keywords used to talk about this mob */	
    char *short_descr;		/* short description "a giant cow", etc.. */
    char *long_descr;		/* Long description, shown to room */
    char *description;    	/* Full textual description */
    SPEC_FUNCTION *spec_fun;	/* Special function pointer, compat with diku */
    char *spec_name;		/* Special function name */
    char *script_fn;		/* Script function, old format scripts */
    SHOP_DATA *pShop;		/* Shop data, if attached to mob */
    AREA_DATA *area;		/* The area this mob saves in */
    OPTIONAL_DATA *opt;		/* Optional mob data */
    TRIGGER_DATA *triggers;	/* for OLD scripts */
    TRIGGY_DATA *trig_list;	/* for OLD scripts */
    char *attackname;		/* Attack name, NULL for default attack type */
    short max_in_world;		/* Maximum of this mob in the world at once */
    int yeller_number;		/*This is a unique number that
				   can be used to match a help-yeller
				   with its helper(s) in the area.
				 */
    char will_help;		/*Will this mob set it's hunting
				   string to the char name if another
				   mob with the same yeller_number in
				   the area recieves a yell_message?
				 */
    int vnum;			/* The vnum of this mob */
    unsigned char sex;		/* Mob's sex */
    short count;		/* How many mobs are there of this type? */
    short killed;		/* How many times has this mob been killed since reboot? */
    short level;		/* Mob's level */
    short timer;		/* Mob's timer.  Disappears after this many ticks */
    char clan_guard_1;		/* Guards for this clan */
    char clan_guard_2;		/* Guards for this sect */
    int act;			/* Action template */
    int act3;			/* Action template for act3 bit */
    int act4;			/* Action template for act4 bit */
    int affected_by;		/* Affected by these bits */
    int more_affected_by;	/* More affected by bits */
    short alignment;		/* Alignment of the mob */
    short money;		/* The amount of copper this mob has */
    short height;		/* The height of this mob, or 0 for
				   default height for mob type */
    signed char mobtype;	/* Mob type for this mob */
    short hpmult;		/* Hit point and experience multiplier. */
    short armcls;		/* Armor class. 101 = default for level */
    int race_hate;		/* Hate bits for race specific attacks */
    int alt_vnum;		/* Alters into this vnum.. UNUSED! */
    int guard;			/* Guards this direction, this mob vnum, or
			 	   this obj vnum, depends on flags. */
    unsigned char hitroll;	/* Extra hitroll. */
    signed char damroll;	/* Extra damroll.  Can be - or + */
    unsigned char dodge;	/* Extra dodge bonus. */
    unsigned char parry;	/* Extra parry bonus, for mobs with weapons */
    char java[2];	        /* 2 java code bytes for picture */
    int points;			/* Points for obj creation. */
  };

/* --------------------------------- */
/* Character extended data structure */
/* --------------------------------- */
struct ced
  {
    CED_DATA *next;
    CHAR_DATA *attackers[4];	/* Melee attackers */

#ifndef NEW_WORLD
    SINGLE_OBJECT *in_boat;	/* In an OLD format boat? */
    SINGLE_OBJECT *came_from_boat; /* Came from this OLD format boat? */
#endif

    int wasroom;		/* Was in room before arena */
    NOTE_DATA *pnote;		/* Writing this temp note */
    CHAR_DATA *original;	/* Original data for switching */
    bool has_yelled;		/* TRUE if victim has yelled already */
    bool scanning;		/* Internal use with scan function */
    ROOM_DATA *was_in_room;	/* Was in this room before battleground */
    CHAR_DATA *reply;		/* Last person who sent him/her a tell */
    int fight_ops;		/* Fighting options, via 'fight' command */
    short ground_pos;		/* Groundfight position */
    short wimpy;		/* Flee at this many hit points */

/* OLD script format */

    int cur_line;		/*The scriptline that just was run */
    short scr_wait;		/*Wait for the script to continue */
    signed char wait_type;	/*How "wait" is counted down */

  };

/* OLD script wait types */
#define WAIT_TYPE_CHAR_TICK    1
#define WAIT_TYPE_COMBAT_TICK  2
#define WAIT_TYPE_SMALL_TICK   3
#define WAIT_TYPE_PULSE        4


/* -------------------------------- */
/* Track data for tracking, hunting */
/* -------------------------------- */
struct track_data
  {
    CHAR_DATA *ch;			/* Character whose tracks these are */
    signed char dir_came;		/* Came from direction */
    signed char dir_left;		/* Left in this direction */
    TRACK_DATA *next_track_in_room;	/* Linked list in room */
  };

/* ---------------------------------------------------------------- */
/* Temporary fight structure, for use with players or fighting mobs */
/* ---------------------------------------------------------------- */
struct fight_data
  {
    short ears;			/* Ears left, and internally used */
    bool attacker_turn;		/* Internal use */
    char attacks;		/* Internal use */
    int wasroomtwo;		/* Internal use */
    bool upd;			/* Internal use */
    bool in_battle;		/* Is this guy in the battleground? */
    signed char challenge;	/* Has this bloke been challenged to arena fight? */
    CHAR_DATA *leader;		/* Leader, for following */
    CHAR_DATA *master;		/* Master, for grouping, charming */
    CHAR_DATA *riding;		/* Riding for mounts */
    CHAR_DATA *mounted_by;	/* Mounted by */
    char *hunting;		/* Hunting for/tracking */
    CHAR_DATA *fighting;	/* Currently fighting */
    short combat_delay_count;	/* Delay ticks, internal use */

    /* Built-in script stuff below - goes in fgt.  OOOLD format! */
    short script_delay;
    CHR_FUNCTION *running_char_function;
    short tag_in_proc;
    CHAR_DATA *caller;
    char *argy;

    COMBAT_FIELD *field;
    char pos_x;
    char pos_y;
    char field_ticks;
    char *next_command;
    char auto_toggles;
  };

/* ------------------------------------------------ */
/* Internal use flags for list maintenance/checking */
/* ------------------------------------------------ */
#define ISMOB                 0x01	/* Is this a mob? */
#define IS_IN_FIGHTING_LIST   0x02	/* Is this person in the fighting list? */
#define IS_IN_AGGRO_LIST      0x04	/* Is this mob in the aggro list? */
#define ACTION_OFF            0x08	/* Are actions disabled? */
#define CHAR_MODE             0x10	/* Is this player in character mode? */

/* ----------------------------------------------------------------- */
/* The main character data for mob characters and player characters! */
/* ----------------------------------------------------------------- */
struct char_data
  {
    signed char data_type;
    char special;		/* Contains ismob, is_in_fighting_list, etc */
    CHAR_DATA *next_fighting;	/* Next in fighting list */
    DESCRIPTOR_DATA *desc;	/* Descriptor for players, NULL for mobs */
    CHAR_DATA *gen_next;	/* General next, for AGGRO list */
    CED_DATA *ced;		/* Character extended data */
    CHAR_DATA *next;		/* Next in global character list */
    CHAR_DATA *next_in_room;	/* Next person in room list */
    REALCHAR_DATA *pcdata;	/* Player Character Data pointer */
    MOB_PROTOTYPE *pIndexData;	/* Mob prototype reference.  Kept it like DIKU
				   pIndexData so people can port code easier!
				   grr.. how annoying. */
    AFFECT_DATA *affected;	/* Linked list of affects */
    SINGLE_OBJECT *carrying;	/* Objects carrying */
    ROOM_DATA *in_room;		/* Current room character is in */
    FGT *fgt;			/* Fight data */
    int act;			/* Action bits 1 */
    int affected_by;		/* Affected bits 1 */
    int more_affected_by;	/* Affected bits 2 */
    short height;		/* Height */
    short timer;		/* Timer, AFK for players, destroy for mobs */
    short wait;			/* Wait state */
    short max_hit;		/* Maximum hit points */
    short hit;			/* Hit points now */
    short max_move;		/* Maximum move points */
    short move;			/* Move points now */
    short hitroll;		/* Hitroll */
    short damroll;		/* Damroll */
    short armor;		/* General skin armor */
    signed char position;	/* Physical position */
    int copper;			/* Amount of copper */
    int gold;			/* Amount of gold */
    unsigned long exp;		/* Experience, or experience worth for mobs */
  };

/* Is the person in the battleground? */
#define IN_BATTLE(ch)           ((ch)->fgt ? (ch)->fgt->in_battle : FALSE)

/* Is the person in the arena? */
#define CHALLENGE(ch)           ((ch)->fgt ? (ch)->fgt->challenge : 0)

/* Long description of this char? */
#define LD(ch)                  (IS_PLAYER((ch)) ? (ch)->pcdata->long_descr : (ch)->pIndexData->long_descr)

/* Short description of this char? */
#define SD(ch)                  (IS_PLAYER((ch)) ? (ch)->pcdata->short_descr : (ch)->pIndexData->short_descr)

/* Description of this char? */
#define DSC(ch)                 (IS_PLAYER((ch)) ? (ch)->pcdata->description : (ch)->pIndexData->description)


/* OLD script deal ... bad.. */
struct script_dat
  {
    int label;			/*Line label, for "if's" "goto's" etc... */
    char *to_do;		/*Text to be interpretted */
    char *player;		/*Holds the player's name */
    SCRIPT_DAT *next;		/*Next 'line' */
  };

/* OLD trigger method... baad */
struct triggy
  {

    SCRIPT_DAT *head;		/*Points to the begginning of the script code */
    int type;			/*When this trigger is checked.. see list */
    char *scriptline;		/*The actual "if" line */
    TRIGGY_DATA *next;		/*The next trigger on this mob */
    bool active;		/*Is the script still active? */

  };

#define CHECK_ENTER_ROOM 0x00000001	/*1 */
#define CHECK_MOVE       0x00000002	/*2 */
#define CHECK_GIVEN_OBJ  0x00000004	/*4 */
#define CHECK_COMBAT     0x00000008	/*8 */
#define CHECK_TELL       0x00000010	/*16 */
#define CHECK_SAY        0x00000020	/*32 */
#define CHECK_SHORT_TICK 0x00000040	/*64 */
#define CHECK_SOCIAL     0x00000080	/*128 */


/* -------------------------------------------------------------------------- */
/* Temp_str holds delayed command targets for spells, searching, backstabbing,
   etc... */
/* -------------------------------------------------------------------------- */
struct temp_str
  {
    TEMP_STR *next;		/* List for free temp_str */
    char temp_string[1024];	/* The actual string */
  };


/* ----------------------------------------- */
/* The main player character data structure! */
/* This is the place to SPLURGE on memory... */
/* ----------------------------------------- */
struct pc_data
  {
    signed char data_type;
    REALCHAR_DATA *next;	/* Next player character data */
    char *pwd;			/* Password */
    char *rpwd;			/* Internal use */
    char *title;		/* Character's title */
    SINGLE_OBJECT *storage[MAXST]; /* Storage objects in the bank */
    short bounty;		/* bounty.. UNUSED */
    char prompt;		/* prompt selection char */
    char *rprompt;		/* Real string prompt */
    char *ignore[10];		/* Ignored character list */
    char *beamin;		/* Beam in message (immorts) */
    char *beamout;		/* Beam out message (immorts) */
    char *oldgrep;		/* Last grep'd command (immorts) */
    short security;		/* Security level.. UNUSED */
    short wizinvis;		/* WizInvis level */
    short deaf;			/* Deaf to these channels */
    int chan_ignore;		/* Deaf to these new style channels */
    char chan_color[30][10];	/* Channel colors */
    short pray_points;		/* Pray points, unused. */
    bool kk;			/* Show descripted rooms on maps */
    bool mb;			/* Show mobs on maps */
    bool noibm;			/* No IBM chars on maps */
    bool dbs;			/* Double space on maps? */
    char maxx;			/* Max X display on maps */
    long played;		/* Second played */
    int hours_purchased;	/* Total Hours purchased */
    bool hours_expired;		/* Hours expired? */
    short monthly_pass;		/* Monthly passes */
    int monthly_expired;	/* Monthly pass key of last expiration. */
    int profession_flag;	/* Profession flags */
    short n_mana;		/* Natural mana */
    short n_max_mana;		/* Natural Max mana */
    short saving_throw;		/* Saving throw for spells */
    int cool_skills;		/* Cool extra skills/abilities */

#ifdef NEW_WORLD
    unsigned short killed_mobs[MAX_MOB_TRO];	/* Mob trophies */
#endif

    signed char resist_summon;	/* Resistance to summon value */
    signed char plus_kick;	/* Extra kick bonus value */
    signed char plus_sneak;	/* Extra sneak bonus value */
    signed char plus_hide;	/* Extra hide bonus value */
    int donated;		/* Donated value */
    int transport_quest;	/* Unused!!  Used internally */
    bool listen_auction;	/* Listening to the current auction bidding? */
    short colors[MAX_COLORS];	/* Colors for old style channels */
    short practice;		/* Practice sessions left. */
    short learn;		/* Learn points left. */
    bool new_exp;		/* New experience format?  Internal use */
    int voting_on;		/* Unused.. internal use */
    short nat_armor;		/* Natural armor class for skin */
    int nat_abilities;		/* Natural abilities */
    time_t logon;		/* Logon time */
    time_t last_note;		/* Last note read date-time stamp */
    char convo[200];		/* Convo 199 is cur cursor pos */
    short pet_move[20];		/* Pets' move points */
    short pet_hps[20];		/* Pets' hit points */
    short pet_temp[20];		/* Pet's temp values */
    bool temp_flag[200];	/* Temp flags for OLD quest method */
    bool in_progress[1000];	/* Temp flags for OLD quest method */
    bool complete[1000];	/* Temp flags for OLD quest method */
    bool bgf;			/* Battleground flag, internal use */

    char *script_flags[3000];	/* Actual new script language flags. */

    char email[45];		/* Email address */
    int questflag;		/* Questflag, internal use */
    int tps;			/* Travel points */
    char remort_times;		/* Remort times.. */
    short tickcounts;		/* Spell delay, internal use */
    unsigned short warpoints;	/* War points */
    bool challenge_on;		/* Arena challenges on/off? */
    int arena_msg;		/* Arena message status */
    bool challenged;		/* Has been challenged? */
    char *challenged_by;	/* Challenged by whom? */
    short challenge_time;	/* Challenge time counter */
    TEMP_STR *temp;		/* Temp string for delay command use */
    char number_pets;		/* Number of current pets */
    short pagelen;		/* Physical page length */
    int raceflag;		/* Race flag for current race */
    int guilds;			/* Guild flags */
    short warned;		/* Warned, for old style JAIL */
    int jail_served;		/* Jail hours served. */
    char no_quit;		/* No_quit timer values */
    char no_quit_pk;		/* No_quit timer values for PK fight */
    char trophy_name[15][18];	/* PKill trophy storage */
    short trophy_times[15];	/* Times PKilled these people */
    unsigned char trophy_level[15]; /* Level at which you last pk'd them */
    char perm_str;		/* Permanent strength */
    char perm_int;		/* Perm intelligence */
    char perm_wis;		/* Perm wisdom */
    char perm_dex;		/* Perm dexterity */
    char perm_con;		/* Perm constitution */
    signed char tmp_str;	/* Temp str */
    signed char tmp_int;	/* temp int */
    signed char tmp_wis;	/* temp wis */
    signed char tmp_dex;	/* temp dex */
    signed char tmp_con;	/* temp con */
    signed char mod_str;	/* Strength modifier */
    signed char mod_int;	/* Int modifier */
    signed char mod_wis;	/* Wis modifier */
    signed char mod_dex;	/* Dex modifier */
    signed char mod_con;	/* Con modifier */
    short condition[3];		/* Drunk,Thirsty,Hungry stats */
    signed char learned[SKILL_COUNT];	/* Learned level for skills and spells */
    unsigned long bank;		/* Money in the bank, in copper */
    int totalkills;		/* Total kills */
    int killpoints;		/* Kill points */
    int deaths;			/* Times the player has died */
    signed char no_spam;	/* NOspam setting */
    short quiet;		/* In quite mode/busy mode/normal mode */
    bool show_lev;		/* Show level in 'who' list? */
    bool just_investigated;	/* Just investigated a corpse recently? */
    char *aliasname[MAXALIAS];	/* Alias names */
    char *alias[MAXALIAS];	/* Alias expansion */

/* Unused or disabled for the moment.. */

    char *wvar;			/* Word variable */
    int nvar;			/* Number variable */
    char *actionname[MAXALIAS];	/* Action trigger */
    char *action[MAXALIAS];	/* Action response */

/* Additions */
    char implants_1;		/* Implants for aliens */
    char implants_2;		/* Implants for aliens */
    char *name;			/* Name of player */
    char *short_descr;		/* Short description of player */
    char *long_descr;		/* Long description of player */
    char *description;		/* Textual description of player */
    short alignment;		/* Player's alignment */
    int act2;			/* Player's act2, special bits */
    int act3;			/* act3 */
    int act4;			/* act4 */
    short level;		/* Player's level */
    short carry_weight;		/* Player's current carrying weight */
    short carry_number;		/* Carrying this amount of items */
    char sex;			/* Male/female */
    short race;			/* Player race this character is */

    char *last_tells[15];	/* Circular list of last tells */
    short tell_counter;		/* Tell counter "head" */

    ROOM_DATA *temp_room;	/* Temporary room, internal use */
    char maxy;			/* Max Y display on maps */

  };

#define PKF(ch)  (FIGHTING((ch)) && (IS_PLAYER(FIGHTING((ch)))))

/* -------- */
/* Implants */
/* -------- */
#define IMPLANT_ARMS  0x0001
#define IMPLANT_LEGS  0x0002
#define IMPLANT_HEAD  0x0004
#define IMPLANT_FEET  0x0008
#define IMPLANT_HANDS 0x0010
#define IMPLANT_BODY  0x0020

#define HAS_ARMS_STRENGTH_IMPLANT(ch)   ( ((IS_MOB((ch)) || (PKF((ch)))) ? FALSE : (IS_SET((ch)->pcdata->implants_1, IMPLANT_ARMS))) )
#define HAS_LEGS_STRENGTH_IMPLANT(ch)   ( ((IS_MOB((ch)) || (PKF((ch)))) ? FALSE : (IS_SET((ch)->pcdata->implants_1, IMPLANT_LEGS))) )
#define HAS_HANDS_STRENGTH_IMPLANT(ch)  ( ((IS_MOB((ch)) || (PKF((ch)))) ? FALSE : (IS_SET((ch)->pcdata->implants_1, IMPLANT_HANDS))) )
#define HAS_BODY_STRENGTH_IMPLANT(ch)   ( ((IS_MOB((ch)) || (PKF((ch)))) ? FALSE : (IS_SET((ch)->pcdata->implants_1, IMPLANT_BODY))) )

#define HAS_ARMS_DEXTERITY_IMPLANT(ch)  ( ((IS_MOB((ch)) || (PKF((ch)))) ? FALSE : (IS_SET((ch)->pcdata->implants_2, IMPLANT_ARMS))) )
#define HAS_LEGS_RUNNING_IMPLANT(ch)    ( ((IS_MOB((ch)) || (PKF((ch)))) ? FALSE : (IS_SET((ch)->pcdata->implants_2, IMPLANT_LEGS))) )
#define HAS_HEAD_BRAIN_IMPLANT(ch)      ( ((IS_MOB((ch)) || (PKF((ch)))) ? FALSE : (IS_SET((ch)->pcdata->implants_2, IMPLANT_HEAD))) )
#define HAS_FEET_IMPLANT(ch)            ( ((IS_MOB((ch)) || (PKF((ch)))) ? FALSE : (IS_SET((ch)->pcdata->implants_2, IMPLANT_FEET))) )
#define HAS_HANDS_ARMOR_IMPLANT(ch)     ( ((IS_MOB((ch)) || (PKF((ch)))) ? FALSE : (IS_SET((ch)->pcdata->implants_2, IMPLANT_HANDS))) )
#define HAS_BODY_ARMOR_IMPLANT(ch)      ( ((IS_MOB((ch)) || (PKF((ch)))) ? FALSE : (IS_SET((ch)->pcdata->implants_2, IMPLANT_BODY))) )

/* ----------------------- */
/* PROFESSION definitions! */
/* ----------------------- */
#define PROF_HEALER       1
#define PROF_WIZARD       2
#define PROF_KNIGHT       4
#define PROF_BARBARIAN    8
#define PROF_RANGER       16
#define PROF_PALADIN      32
#define PROF_DRUID        64
#define PROF_ARCHMAGE     128
#define PROF_ASSASSIN     256
#define PROF_MONK         512
#define PROF_BARD         8192

#define PROF_ATURION_HUNTER        1024
#define PROF_ATURION_ENGINEER      2048
#define PROF_ATURION_PHILOSOPHER   4096

#define PROFESSION_LIST_HUMANOID  {"Healer","Wizard","Knight","Barbarian","Ranger","Paladin","Assassin","Monk","Bard","end"}
#define SECONDARY_PROF_LIST       {"Druid","Archmage","end"}
#define PROFESSION_LIST_ATURION   {"Hunter","Engineer","Philosopher","end"}

#define IS_PROF(ch,prof)   (IS_SET((ch)->pcdata->profession_flag, (prof) ) )
#define ADD_PROF(ch,prof)  (SET_BIT((ch)->pcdata->profession_flag, (prof) ) )
#define CAN_LEARN(ch,skl)        ( !pow.professions || ((skl)->values[0]) & ((ch)->pcdata->profession_flag) )

#define S_HEALER(arg,bit)    if (!str_cmp("healer",(arg))) SET_BIT((bit),PROF_HEALER);
#define S_WIZARD(arg,bit)    if (!str_cmp("wizard",(arg))) SET_BIT((bit),PROF_WIZARD);
#define S_KNIGHT(arg,bit)    if (!str_cmp("knight",(arg))) SET_BIT((bit),PROF_KNIGHT);
#define S_BARBARIAN(arg,bit) if (!str_cmp("barbarian",(arg))) SET_BIT((bit),PROF_BARBARIAN);
#define S_RANGER(arg,bit)    if (!str_cmp("ranger",(arg))) SET_BIT((bit),PROF_RANGER);
#define S_PALADIN(arg,bit)   if (!str_cmp("paladin",(arg))) SET_BIT((bit),PROF_PALADIN);
#define S_DRUID(arg,bit)     if (!str_cmp("druid",(arg))) SET_BIT((bit),PROF_DRUID);
#define S_ARCHMAGE(arg,bit)  if (!str_cmp("archmage",(arg))) SET_BIT((bit),PROF_ARCHMAGE);
#define S_ASSASSIN(arg,bit)  if (!str_cmp("assassin",(arg))) SET_BIT((bit),PROF_ASSASSIN);
#define S_MONK(arg,bit)      if (!str_cmp("monk",(arg))) SET_BIT((bit),PROF_MONK);
#define S_BARD(arg,bit)      if (!str_cmp("bard",(arg))) SET_BIT((bit),PROF_BARD);
#define S_HUNTER(arg,bit)    if (!str_cmp("hunter",(arg))) SET_BIT((bit),PROF_ATURION_HUNTER);
#define S_ENGINEER(arg,bit)  if (!str_cmp("engineer",(arg))) SET_BIT((bit),PROF_ATURION_ENGINEER);
#define S_PHILOSOPHER(arg,bit) if (!str_cmp("philosopher",(arg))) SET_BIT((bit),PROF_ATURION_PHILOSOPHER);

#define S_ALL(arg,bit)  S_HEALER((arg),(bit)) S_WIZARD((arg),(bit)) S_KNIGHT((arg),(bit)) S_BARBARIAN((arg),(bit)) S_RANGER((arg),(bit)) S_PALADIN((arg),(bit)) S_DRUID((arg),(bit)) S_ARCHMAGE((arg),(bit)) \
						S_ASSASSIN((arg),(bit)) S_MONK((arg),(bit)) S_BARD((arg),(bit)) S_HUNTER((arg),(bit)) S_ENGINEER((arg),(bit)) S_PHILOSOPHER((arg),(bit))

/* -------------------------------- */
/* Optional data for mob_prototypes */
/* -------------------------------- */
struct optional_data
  {
    short skltaught[30];	/* Skills this mob teaches */
    char *cast_spells[10];	/* Casts up to 10 spells */
    signed char cast_percent;	/* Percent he/she will cast a spell */
    bool kicks;			/* Mob randomly kicks */
    bool tackles;		/* Mob attempts to tackle */
    bool flurries;		/* Mob flurries */
    signed char warrior_percent; /* Percent the mob will try a kick/tackle/flurry */
  };


/* ------------------------------------------------------------------ */
/* Liquid idea from mortal conquest, and basic compatibility was kept */
/* ------------------------------------------------------------------ */
#define LIQ_WATER        0
#define LIQ_MAX         16

struct liq_type
  {
    char *liq_name;
    char *liq_color;
    short liq_affect[3];	/* 1=drunk 2=food 3=thirst */
  };

/* ----------------------------------------- */
/* Extra descriptions for objects and rooms! */
/* ----------------------------------------- */
/* Once again.. I detest structure names like extra_descr_data, but
   for diku coders' sake, I made it the same as diku since the structure
   is the same (I think).  I woulda called it edd :) */

struct extra_descr_data
  {
    DESCRIPTION_DATA *next;
    char *description;		/* The actual extra description */
    char *keyword;		/* Keyword list to see this desc */
  };

/*------------------------------------- */
/* Evil bits to set.. Aturion muds only */
/*------------------------------------- */
#define SUCK_ALL_MANA            1
#define SUCK_HALF_MANA           2
#define REMOVE_ALL_SPELLS        4
#define SUCK_HALF_HITS           8
#define SUCK_HALF_MOVES         16
#define DESTROY_OBJECT          32
#define DESTROY_RANDOM_OBJECT   64

/* ------------------------------- */
/* The main object prototype data! */
/* ------------------------------- */
struct obj_proto_data
  {
    OBJ_PROTOTYPE *next;
    DESCRIPTION_DATA *extra_descr;	/* Extra description list */
    AFFECT_DATA *affected;		/* Affected by these extra affects */
    AREA_DATA *area;			/* Saves in this area */
    char *name;				/* Keyword list to access object */
    short how_many;			/* How many can exist at once */
    char *short_descr;			/* Short description "a longsword" */
    char *description;			/* Description seen when on ground */
    char *action_descr[3];		/* Action description, Aturion only */
    int vnum;				/* Object vnum */
    int item_type;			/* The item type */
    short max_in_room;			/* Maximum that will pop in 1 room */
    short timer;			/* Object timer for disappearing objs */
    int extra_flags;			/* Extra object flags, bonuses, etc */
    int wear_flags;			/* Where can this be worn? */
    int cost;				/* Cost of the object */
    short count;			/* internal use */
    short weight;			/* Weight of the object */
    short level;			/* Unused! */
    int value[10];		/* If trash, then v0 = north
				   v1 = east
				   v2 = south
				   v3 = west
				   v4 = up
				   v5 = down
				   if v6=1 then restrict by level HIGH
				   if v6=2 then restrict by race #
				   if v6=3 then restrict by clan #
				   if v6=4 then restrict by sect #
				   if v6=5 then restrict to only donators
				   if v6=6 then restrict by only people
				   who have object vnum.
				   if v6=7 then restrict by level LOW

				   v7 holds value specified in v6.

				 */

    short values_2[10];
    /* v0 - does 1-v0 damage with v1 percent */
    /* v1 - percent out of 1000 it does damage */
    /* v2 - spell number it casts */
    /* v3 - percent out of 1000 it casts this spell */
    /* v4 - This level spell is cast... if 0,
       then it's 1/2 the char's level */
    /* v5 - 1 = suck all mana
       2 = suck 1/2 mana
       4 = removes all other spells
       8 = suck 1/2 hit points
       16 = suck 1/2 movement pts
       32 = destroys the object
       64 = destroys random object */
    /* v6 - spell it casts on ya when casting */
    /* v7 - percent out of 1000 that v5 happens  */
    /* v8 - percent you attack a random mob */
    /*      out of 1000 */
    /* v9 - percent that when you repair this
       object, it breaks!!!!!
       out of 1000 */
    
    unsigned char size;	/* Default Size of the object */
    int effects;	/* Default effects.. unused */
    char java[2];	/* 2 java code bytes for picture */
/* NEW */
    char made_of;	/* Material made of */
  };


/* --------------------------------------------------------- */
/* Playerbase data, to finger old chars, player cleanup, etc */
/* --------------------------------------------------------- */
struct playerbase_data
  {
    PLAYERBASE_DATA *next;
    char player_name[17];	/* Player's name */
    time_t player_last_login;	/* Last login date-time stamp */
    bool player_good;		/* Is good or evil? */
    short player_level;		/* Current player level */
    bool player_nodelete;	/* Nodelete flag? */
    char email_address[45];	/* Player's email addy */
  };

/* ------------------------------ */
/* Linked boat list for old boats */
/* ------------------------------ */
struct b_list
  {
    int vnum;
    BLIST *next;
  };

/* ------------- */
/* OLD boat type */
/* ------------- */
struct obj_boat
  {
    CHAR_DATA *in_boat[8];
    CHAR_DATA *navigator;
  };

/* ----------------------- */
/* A single object's data. */
/* ----------------------- */
struct obj_data
  {
    signed char data_type;
    SINGLE_OBJECT *next;
    SINGLE_OBJECT *next_content; /* Generic 'next'/containers, etc */
    SINGLE_OBJECT *contains;	/* For containers */
    SINGLE_OBJECT *in_obj;	/* Inside of object reference */
    CHAR_DATA *carried_by;	/* Carried by this player */
    OBJ_BOAT *boat;		/* OLD boat data */
    OBJ_PROTOTYPE *pIndexData;	/* Reference to object prototype */
    ROOM_DATA *in_room;		/* On the ground in this room? */
    char *short_descr;		/* Short description of the object */
    char *description;		/* 'On ground' description of the object */
    int extra_flags;		/* Extra object flags */
    int cost;			/* Object cost.  Change to ref back to proto */
    int wear_loc;		/* Location object is being worn */
    short timer;		/* Timer on this specific object */
    unsigned char size;		/* Size of this specific object */
    void *more;			/* More data.. armor/weapon data, etc */

  };


/* ------------------------------------------ */
/* An exit.  Very small for low memory usage. */
/* ------------------------------------------ */
struct exit_data
  {
    int vnum;		/* Vnum this exit leads to */
    ROOM_DATA *to_room;	/* Room data this exit leads to */
    DOOR_DATA *d_info;	/* Optional door info structure */
  };

/* -------------------------------------- */
/* Door info structure, optional on exits */
/* -------------------------------------- */
struct door_data
  {
    short exit_info;	/* Exit flags, mostly compat with diku */
    short key;		/* Key required to open the door */
    char *keyword;	/* keyword for exit description */
    char *description;	/* Exit description */
    signed char maxstr; /* Maximum door strength */
    signed char str;	/* Door strength */
    int rs_flags;	/* Reset Flags for doors, etc */
  };

/* ------------------------------------------------------------------ */
/* A single 'reset'.  SHOULD be compat with merc.. no promises though */
/* ------------------------------------------------------------------ */
struct reset_data
  {
    RESET_DATA *next;
    char command;	/* command (Object Mob, etc) */
    int rs_vnum;	/* Reset vnum */
    int loc;		/* Location or amount for shopkeeprs */
    short percent;	/* Percent chance of pop */
    int vnum;		/* Vnum it pops */
    short arg1;
    short arg2;
    short arg3;
  };

/* -------------------------------------------------------------------------- */
/* All reset values modelled from mortal conquest/theisles values, as to allow
   compatibility in converting areas, if annyone so desires to one day write
   the program the converts */
/* -------------------------------------------------------------------------- */

#define RESET_LOC_INOBJ    -3
#define RESET_LOC_ONOBJ    -4
#define RESET_LOC_INROOM   -5
#define RESET_LOC_PREVOBJ  -6

/* ------------------- */
/* The basic AREA data */
/* ------------------- */
struct area_data
  {
    AREA_DATA *next;
    RESET_DATA *reset_first;	/* First reset in this area */
    RESET_DATA *reset_last;	/* Last reset in this area */
    char *name;			/* Area name */
    char *repop;		/* Repop message */
    int jail;			/* Jail vnum (unused) */
    int outjail;		/* Out Jail vnum (unused) */
    char can_quit;		/* Can_quit status; quit rules */
    short desc_rooms;		/* Descripted room count */
    bool has_popped_this_reboot; /* Has repop'd this reboot */
    bool clanzone;		/* Is this a clan zone?  unused */
    short weather_change;	/* Weather change.  unused */
    bool more_rainy;		/* Not implimented */
    bool more_dry;		/* Not implimented */ 
    bool more_fog;		/* Not implimented */ 
    short open;			/* Open to mortals? */
    int area_flags;		/* Area flags, changed, etc */
    short security;		/* Security, unused */
    char *builders;		/* Builder list */
    int lvnum;			/* Lower vnum */
    int uvnum;			/* Upper vnum */
    short nplayer;		/* players in area */
    char *filename;		/* Area filename */
    int vnum;			/* Vnum of area */
    int room_count;		/* Rooms in area */
    int mob_count;		/* Mobs in area */
    int obj_count;		/* Objs in area */
    int repop_rate;		/* Repop rate in hours */
    int repop_counter;		/* Current repop counter */
  };

/* ----------------------- */
/* A single room structure */
/* ----------------------- */
struct room_data
  {
    signed char data_type;
    bool shade;			/* Is this room shaded? */
    ROOM_DATA *next;		/* Next in hashed room list */
    ROOM_DATA *linkage;		/* Vehicles in the room */
    AREA_DATA *area;		/* Room this area is in */
    EXIT_DATA *exit[MAX_DIR];	/* Exits from this room */
    int vnum;			/* The room's vnum */
    char *name;			/* Name of the room */
    char *description;		/* The room description */
    int room_flags;		/* Room flags */
    int room_flags_2;		/* More Room flags and dynamic desc flags */
    short tps;			/* Travel points in this room */
    short light;		/* Light value of the room */
    short sector_type;		/* The type of sector this room is */
    TRACK_DATA *tracks;		/* Tracks in this room */
    ROOM_MORE *more;		/* more room data */
    char a;			/* Overhead mapping ascii override */
    char c;			/* Overhead mapping color override */
    signed short x;		/* X coordinate of room */
    signed short y;		/* Y coordinate of room */
    signed char z;		/* Z coordinate of room */
    char img[2];		/* Image code, 2 ascii chars */
  };



/* ----------------------- */
/* Extended data for ROOMS */
/* ----------------------- */
struct room_extended
  {
    RESET_DATA *reset_first;	/* First reset in room */
    RESET_DATA *reset_last;	/* Last reset in room */
    SINGLE_OBJECT *contents;	/* Object contents of room */
    short pcs;			/* Player characters in room */
    CHAR_DATA *people;		/* People list in room */
    signed char move_dir;	/* Moving direction for 'currents' */
    char *move_message;		/* moving message for 'currents' */
    int copper;			/* Copper in room */
    int gold;			/* Gold in room */
    DESCRIPTION_DATA *extra_descr;	/* Extra descriptions in room */

/* --------------------------- */
/* Below are for room VEHICLES */
/* --------------------------- */
    int can_travel_sectors;	/* Can travel through these sectors */
    ROOM_DATA *linked_to;	/* Linked to this room */
    char *obj_description;	/* Description of this vehicle */
    int orig_room;		/* Default room it is linked to */
  };

/* --------------------- */
/* Is a room descripted? */
/* --------------------- */
#define DESCRIPTED(room)   ( (room->room_flags_2 != 0) || (room->description && room->description[0]!='\0') )

/* --------------------- */
/* A single command link */
/* --------------------- */
struct cmd_type
  {
    char *name;		/* Name of the command */
    char *help;		/* Help text on the command */
    DO_COMMAND *do_fun; /* Command executes this function */
    short level;	/* Minimum level you must be to execute command */
    short position;	/* Minimum physical position to execute command */
    short log;		/* Log command status */
    COMMAND *next;	/* hashed by starting letter */ 
  };


/* --------------------------------------------------------------------- */
/* Social structure compat with theisles.. please note that the way they
   are saved/edited dynamically is VERY different!!! */
/* --------------------------------------------------------------------- */
struct social_type
  {
    char name[20];
    char *char_no_arg;
    char *others_no_arg;
    char *char_found;
    char *others_found;
    char *vict_found;
    char *char_not_found;
    char *char_auto;
    char *others_auto;
    SOCIAL *next;
    SOCIAL *next_hashed;
  };


/* ------------------------------------------------------------------- */
/* Maximum scrollback for channels, and maximum random pop structures. */
/* ------------------------------------------------------------------- */
#define MAX_SCROLLBACK 20
#define MAX_RANDOMPOP  250

/* Some ideas below from theisles, but I can't guarentee they are exactly
   the same! */

#define RIDING(ch)              ((ch)->fgt ? (ch)->fgt->riding : NULL)
#define MOUNTED_BY(ch)          ((ch)->fgt ? (ch)->fgt->mounted_by : NULL)
#define MASTER(ch)              ((ch)->fgt ? (ch)->fgt->master : NULL)
#define LEADER(ch)              ((ch)->fgt ? (ch)->fgt->leader : NULL)

#define LEVEL(ch)               (IS_MOB((ch)) ? (ch)->pIndexData->level : (ch)->pcdata->level)
#define UMIN(a, b)              ((a)<(b) ? (a):(b))
#define UMAX(a, b)              ((a)>(b) ? (a):(b))
#define URANGE(a, b, c)         ((b)<(a) ? (a):((b)>(c) ? (c) : (b)))
#define LOWER(c)                ((c)>='A'&&(c)<='Z' ? (c)+'a'-'A' :(c))
#define UPPER(c)                ((c)>='a'&&(c)<='z' ? (c)+'A'-'a' :(c))
#define IS_SET(flag, bit)       ((flag)&(bit))
#define SET_BIT(var, bit)       ((var)|=(bit))
#define REMOVE_BIT(var, bit)    ((var)&=~(bit))
#define TOGGLE_BIT(var, bit)    ((var)^=(bit))
#define RNAME(ch)               (IS_PLAYER((ch)) ? (ch)->pcdata->name : (ch)->pIndexData->name)
#define OOSTR(dat, field)       (( (dat)->field != NULL            \
					  ? (dat)->field                \
					  : (dat)->pIndexData->field ))
#define STR(dat, field)         (( (dat)->field != NULL                    \
						  ? (dat)->field                \
						  : (dat)->pIndexData->field ))
#define NST(pointer)            (pointer == NULL ? "" : pointer)
#define MARK( room )          ( SET_BIT( ( room )->room_flags, R_MARK))
#define UNMARK( room )        ( REMOVE_BIT( ( room )->room_flags, R_MARK))
#define IS_MARKED( room )     ( IS_SET( ( room )->room_flags, R_MARK))
#define TOROOM( room, y )     ( ((ROOM_DATA *) ( room )->exit[ ( y ) ]->to_room ))
#define IS_CLOSED( room, y )  ( IS_SET( ( room )->exit[( y )]->exit_info, \
				EX_CLOSED))

#define VALID_EDGE( room, y )                                              \
			      ( ( room )->exit[( y )] &&                   \
					( TOROOM(( room ), ( y ) ) != NULL ) &&   \
			      ( !IS_MARKED( TOROOM( ( room ), ( y ) ) ) ) )


/* These are the same as found in theisles.  Act codes were designed to be
   almost exactly the same as to allow easier code porting from base to base. */

#define SEX(ch)              (IS_PLAYER((ch)) ? (ch)->pcdata->sex : (ch)->pIndexData->sex)
#define HE_SHE(ch)           ((SEX((ch)) == SEX_MALE  ) ? "he"   :  \
				(  (SEX((ch)) == SEX_FEMALE) ? "she"  : "it" ) )
#define HIS_HER(ch)          ((SEX((ch)) == SEX_MALE  ) ? "his"  :  \
				(  (SEX((ch)) == SEX_FEMALE) ? "her"  : "its" ) )
#define HIM_HER(ch)          ((SEX((ch)) == SEX_MALE  ) ? "him"  :  \
				(  (SEX((ch)) == SEX_FEMALE) ? "her"  : "it" ) )
#define IN_SUN(ch)         ((ch)->in_room && \
			   !IS_SET((ch)->in_room->room_flags,ROOM_INDOORS) && \
			   (weather_info.sunlight == SUN_LIGHT || \
				 weather_info.sunlight == SUN_RISE  || \
			    weather_info.sunlight == SUN_SET) && \
			   weather_info.sky!=SKY_RAINING && \
			   weather_info.sky!=SKY_FOGGY && \
			   weather_info.sky!=SKY_CLOUDY && \
			   !(ch)->in_room->shade)


#define MASTER(ch)              ((ch)->fgt ? (ch)->fgt->master : NULL)
#define FIGHTING(ch)            ((ch)!=NULL ? ((ch)->fgt ? (ch)->fgt->fighting : NULL) : NULL)
#define IS_AWAKE(ch)            ((ch)->position > POSITION_SLEEPING || (ch)->position<0)
#define IS_MOB(ch)              (IS_SET((ch)->special,ISMOB))
#define IS_PLAYER(ch)           (!IS_SET((ch)->special,ISMOB))
#define IS_IMMORTAL(ch)         (LEVEL((ch)) >= LEVEL_IMMORTAL)
#define IS_GOD(ch)              (LEVEL((ch)) == TOP_LEVEL)
#define IS_AFFECTED(ch, sn)     ((IS_SET((ch)->affected_by, (sn))))
#define IS_AFFECTED_EXTRA(ch, sn)     ((IS_SET((ch)->more_affected_by, (sn))))
#define ALIGN(ch)               (IS_MOB((ch)) ? (ch)->pIndexData->alignment : (ch)->pcdata->alignment)
#define IS_GOOD(ch)             (ALIGN((ch)) >= 150)
#define IS_EVIL(ch)             (ALIGN((ch)) <= -150)
#define IS_NEUTRAL(ch)          (!IS_GOOD(ch) && !IS_EVIL(ch))
#define GET_AC(ch)              ((ch)->armor - (IS_MOB((ch)) ? 0 : (100 - (ch)->pcdata->nat_armor)))
#define GET_HTROLL(ch)         ((ch)->hitroll + (HAS_ARMS_DEXTERITY_IMPLANT((ch)) ? 8 : 0))
#define GET_DMROLL(ch)         ( (is_member((ch),GUILD_WARRIOR) ? 3 : 0) + (HAS_ARMS_STRENGTH_IMPLANT((ch)) ? 3 : 0) + \
				  (ch)->damroll+str_app[get_curr_str(ch)].dam )
#define IS_OUTSIDE(ch)          (!IS_SET(                                   \
				    (ch)->in_room->room_flags,              \
				    ROOM_INDOORS)                         \
				  && ch->in_room->sector_type != SECT_INSIDE)
#define WAIT_STATE(ch, npulse)  ((ch)->wait = ( ((ch)->position==POSITION_CASTING) ? ((ch)->wait): (UMAX((ch)->wait, (npulse)) ) ))
#define STRING_HITS(ch)         (percent_hit[ (URANGE(0,(PERCENTAGE((ch)->hit, (ch)->max_hit)),101))/10 ]  )

#define STRING_MOVES(ch)        (percent_tired[ (URANGE(0,(PERCENTAGE((ch)->move, (ch)->max_move)),101))/10 ]  )
#ifdef NEW_WORLD
#define FIND_EXP(lv, r)         ((long) ( lv>99 ? 99999 : exp_table[lv] ))
#define FIND_TPS(lv, r)         ( pow.tps ? (lv>99 ? 99999 : tps_table[lv] ) : 0)
#else
#define FIND_TPS(lv, r)         ( pow.tps ? ((lv < 5) ? 0 : ((lv-4)*(lv-3)*(3)*(lv>24 ? 2 : 1))) : 0 )
#define FIND_EXP(lv, r)         ( lv>89 ? 999999 : (translate(pow.exp_to_level,lv,NULL)) )
#endif

#define FIRSTDICE(obj)          ( (obj)->pIndexData->value[7] )
#define SECONDDICE(obj)         ( (obj)->pIndexData->value[8] )
#define MANANOW(obj)            ( ((I_GEM *) (obj)->more)->mana_now )

#define CHAR_OBJ_SIZE(ch)       ( (ch)->height<40 ? 1 :                  \
				  ( (ch)->height<55 ? 2 :                \
				    ( (ch)->height<66 ? 3 :              \
				      ( (ch)->height<75 ? 4 :            \
					( (ch)->height<88 ? 5 :          \
					  ( (ch)->height<114 ? 6 : 7 )   \
					 )                               \
				       )                                 \
				     )                                   \
				   )                                     \
				 )

#define SET_OBJ_SIZE(ch,obj)    ( (obj)->size = CHAR_OBJ_SIZE(ch) )
#define GET_OBJ_SIZE(ch)        ( (obj)->size )
#define OBJ_TOO_BIG(obj,ch)     ( (obj)->size > CHAR_OBJ_SIZE(ch) )
#define OBJ_TOO_SMALL(obj,ch)   ( (obj)->size < CHAR_OBJ_SIZE(ch) )
#define OBJ_FITABLE(obj)        ( (obj)->size == 0 )
#define OBJ_ANYSIZE(obj)        ( (obj)->size == 8 )
#define OBJ_FITS(obj,ch)        ( ((obj)->size   == CHAR_OBJ_SIZE(ch) || \
				   (obj)->size+1 == CHAR_OBJ_SIZE(ch) || \
				   (obj)->size-1 == CHAR_OBJ_SIZE(ch) || \
				  OBJ_ANYSIZE((obj))) )
#define CAN_WEAR(obj, part)     (IS_SET((obj)->pIndexData->wear_flags,  part))
#define IS_OBJ_STAT(obj, stat)  (IS_SET((obj)->pIndexData->extra_flags, stat))
#define IS_REAL_GOD(ch)         ((IS_PLAYER((ch)) && LEVEL((ch))>109) )
#ifdef OLD_FIGHT
#define IS_IN_MELEE(ch,victim)  (!FIGHTING((ch)) || (ch)->position==POSITION_STANDING || \
				 (victim)->ced->attackers[0]==(ch) || \
				 (victim)->ced->attackers[1]==(ch) || \
				 (victim)->ced->attackers[2]==(ch) || \
				 (victim)->ced->attackers[3]==(ch))
#else
#define IS_IN_MELEE(ch,victim)   (TRUE)
#endif

#define NOT_WORN( obj )         ((obj)->wear_loc == WEAR_NONE   ||     \
				 (obj)->wear_loc == WEAR_BELT_1 ||     \
				 (obj)->wear_loc == WEAR_BELT_2 ||     \
				 (obj)->wear_loc == WEAR_BELT_5    )
#define IS_LIT( obj )           ( (obj)->pIndexData->item_type==ITEM_LIGHT && ((I_LIGHT *) (obj)->more)->light_now > 0 &&  \
				 IS_SET( ((I_LIGHT *) (obj)->more)->light_lit, LIGHT_LIT) )
#define NAME( ch )              (( IS_PLAYER( ch ) ? (ch)->pcdata->name : ch->pIndexData->short_descr ))
#define PERS(ch, looker)     ( (can_see_nextdoor( looker, (ch) ) || can_see( looker, (ch) )) ? NAME(ch) : "someone" )
#define TPERS(ch, looker)   (can_see(looker, (ch) ) ? NAME(ch) : "Someone")
#define NOTIFY(buf, lvl, tog)       ( do_global( buf, lvl, tog | WIZ_NOTIFY ) )


/* Old Theisles and MC flag compatability... for the most part */

#define         AREA_NONE       0
#define         SEX_NONE        4
#define         AREA_CHANGED    1
#define         AREA_ADDED      2
#define         ACT_NONE        0
#define         DIR_MAX         6
#define         ROOM_NONE       0
#define         EXTRA_NONE      0
#define         EX_NONE         0
#define         ITEM_WEAR_NONE  0
#define         ITEM_NONE       0
#define         AFFECT_NONE     0

#define SPELL_HASH 24

#define LOG_ALWAYS 0
#define LOG_NEVER  1
#define LOG_NORMAL 2

/* Allows for module interface without 'command' recompile!!!!!!!! */

#ifdef WINDOWS
#define DEFINE_COMMAND(chars,function,pos,lvl,loglvl,help) \
		static bool dun=FALSE; \
		if (!dun) { \
			add_to_list((chars),(function),(pos),(lvl),(loglvl),(help)); \
			dun=TRUE; return; \
			} \
		strcpy(cl,(chars)); strcat(cl,":"); \
		if (ch) { \
			strcat(cl,NAME(ch)); \
			}	\
		if (argy) {strcat(cl,":");strcat(cl,argy);}
#else
#define DEFINE_COMMAND(chars,function,pos,lvl,loglvl,help) static bool dun=FALSE; \
		if (!dun) { \
			add_to_list((chars),(function),(pos),(lvl),(loglvl),(help)); \
			dun=TRUE; return; \
		} 
/*
		strcpy(cl,(chars)); strcat(cl,":"); \
		if (ch) { \
			strcat(cl,NAME(ch)); \
			if (argy) { \
				strcat(cl,":"); \
				strcat(cl,argy); \
			} \
		if (ch->in_room) strcat(cl,itoa(ch->in_room->vnum)); \
			else strcat(cl,"NULLROOM"); \
		} 
*/
#endif

/*
#define MARK_DEBUG(chars) strcpy(cl,(chars));
#define MARK_CHAR_DEBUG(chars,ch) \
	strcpy(cl,(chars)); strcat(cl,":"); \
	if (ch) {strcat(cl,NAME(ch)); strcat(cl,":");}
*/
#define MARK_DEBUG(c)
#define MARK_CHAR_DEBUG(c,ch)

/* Short configurability macros!! */

/* #define ALLOW_WHERE */

#define CAN_DROP_ITEMS_IN_ARENA(yn)    if ( !(yn) && CHALLENGE(ch)==10) {send_to_char("You may not drop anything in the arena.\n\r",ch); return;}
#define CAN_GIVE_ITEMS_IN_ARENA(yn)    if ( !(yn) && CHALLENGE(ch)==10) {send_to_char("You may not give anything to anyone in the arena.\n\r",ch); return;}
#define CAN_DROP_ITEMS_IN_BGROUND(yn)  if ( !(yn) && IN_BATTLE(ch)) {send_to_char("You may not drop items in the battleground.\n\r",ch); return;}
#define CAN_GIVE_ITEMS_IN_BGROUND(yn)  if ( !(yn) && IN_BATTLE(ch)) {send_to_char("You may not give annything to anyone inn the battleground.\n\r",ch); return;}

#define BUILDERS_CAN_GIVE(yn)        if ( !(yn) && IS_PLAYER(ch) && ch->pcdata->level>99 && ch->pcdata->level<110 ) {send_to_char("Builders cannot use the 'give' command, sorry.\n\r",ch); return;}
#define CAN_FILL_LIGHT_WHILE_LIT(yn) if ( !(yn) && IS_SET(lg->light_lit, LIGHT_LIT) ) {send_to_char("That's not a very good idea when it's lit...\n\r",ch); return;}

#define ALLOW_UNMOTIVATED_PK(yn)  if ( !(yn) && IS_PLAYER(ch) && IS_PLAYER(victim) && !IS_EVIL(ch) && !IS_EVIL(victim)) return TRUE;

#define PLAYERS_DONT_GET_A_CORPSE(yn)  if ( (yn) && IS_PLAYER(ch) )

/* OF INTEREST TO SCRIPTWRITERS, SEE ALSO script.doc!!! */

#define STRENGTH(ch)         ( (ch)->pcdata->perm_str )		/* Strength */
#define INTELLIGENCE(ch)     ( (ch)->pcdata->perm_int )		/* Intelligence */
#define WISDOM(ch)           ( (ch)->pcdata->perm_wis )		/* Wisdom */
#define DEXTERITY(ch)        ( (ch)->pcdata->perm_dex )		/* Dexterity */
#define CONSTITUTION(ch)     ( (ch)->pcdata->perm_con )		/* Constitution */
#define TPS(ch)              ( (ch)->pcdata->tps )	/* Travel points */
#define HP_NOW(ch)           ( (ch)->hit )	/* Hit points now */
#define HP_MAX(ch)           ( (ch)->max_hit )	/* Max Hit points */
#define PC(ch)               ( IS_PLAYER(ch) )	/* Is it a player? */
#define MOVES_NOW(ch)        ( (ch)->move )	/* Moves now */
#define MOVE_NOW(ch)         ( (ch)->move )
#define MV_NOW(ch)           ( (ch)->move )
#define MOVES_MAX(ch)        ( (ch)->max_move )		/* Max moves */
#define MOVE_MAX(ch)         ( (ch)->max_move )
#define MV_MAX(ch)           ( (ch)->max_move )
#define IS_RIDING(ch)        ( (ch)->riding!=NULL )	/* CH riding? */
#define BEING_RIDDEN(ch)     ( (ch)->mounted_by!=NULL )		/* CH being ridden? */
#define IS_FIGHTING(ch)      ( (ch)->fighting!=NULL )	/* CH is fighting? */
#define IN_BATTLEGROUND(ch)  ( (ch)->in_battle )	/* In battleground? */
#define ALIEN(ch)            ( IS_EVIL(ch) )	/* Is CH an alien? */
#define HUMANOID(ch)         ( !IS_EVIL(ch) )	/* Is CH a humanoid? */

#define IN_BOAT(ch)          ( ( (ch)->ced==NULL ? 0 : (IS_IN_BOAT( (ch) ) ) ) )
							 /* Is CH in a boat? */

#define STOP_FIGHTING(ch)             ( stop_fighting( (ch), FALSE ) )
#define STOP_BOTH_FIGHTING(ch)        ( stop_fighting( (ch), TRUE ) )
#define STOP_ALL_IN_ROOM_FIGHTING(ch) ( do_peace( (ch), "") )
#define START_FIGHTING(ch, opponent)  ( multi_hit( (ch), (opponent), TYPE_UNDEFINED) )
#define FLEE(ch)                      ( do_flee( (ch), "") )
#define DELAY_CHAR(ch, val)           ( (ch)->wait+=(val) )
#define DSAY(n, ch, text)             MARK_CHUNK((n)){do_say((ch),(text));DELAY_SCRIPT(2);}
#define SAY(ch, text)                 ( do_say( (ch), (text) ) )
#define DO_TELL(ch, recipient, text)  sprintf(tmpt,"%s %s", NAME( (recipient) ), (text)); do_tell( (ch), tmpt )
#define TELL(ch, recipient, text)     sprintf(tmpt,"%s %s", NAME( (recipient) ), (text)); do_tell( (ch), tmpt )
#define DTELL(n, ch, recipient, text) MARK_CHUNK((n)){TELL((ch),(recipient),(text));DELAY_SCRIPT(2);}
#define SOCIAL_TO(ch, to, social)     sprintf(tmpt,"%s %s", (social), NAME( (to) )); interpret( (ch), tmpt )
#define SOCIAL(ch, social)            interpret( (ch), (social) )
#define SET(thing,value)              ( (thing) = (value) )
#define ONE_COMBAT_ROUND              (  3 )
#define ONE_SECOND                    (  1 )

#define WORKS_ON_MOBS_ONLY     if (IS_PLAYER(ch)) return
#define WORKS_ON_PLAYERS_ONLY  if (IS_MOB(ch)) return

#define INTEGER(name)        static int (name)
#define TEMPSTRING(name)     char (name)[512]
#define STRING(name)         static char (name)[1024]
#define OBJECT(name)         static SINGLE_OBJECT (name)
#define PLAYER(name)         static CHAR_DATA (name)
#define MOB(name)            static CHAR_DATA (name)

#define WRITELN(text,ch)       send_to_char((text),(ch)); send_to_char("\n\r",(ch))
#define WRITE(text,ch)         send_to_char((text),(ch))
#define SHOW_TO_ROOM(text,ch)  do_recho( (ch), (text) )
#define SHOW_TO_OTHERS(text,ch) act((text),mob,NULL,ch,TO_NOTVICT)
#define EXECUTE_COMMAND(ch,text) interpret( (ch), (text) )
#define TEMPFLAG(num)           (ch->pcdata->tempflag[(num)])
#define FLAG(num)               (ch->pcdata->complete[(num)])
#define DESTROY(ch,vnum)        do_destroy( (ch), (vnum) )
#define NUM(str)                (atoi((str)))
#define AWARDXP(ch,amt)         sprintf(tmpt,"pset %s addxp %d", NAME( (ch) ), (amt)); interpret( findmob(), tmpt )
#define AWARDTP(ch,amt)         sprintf(tmpt,"pset %s addtp %d", NAME( (ch) ), (amt)); interpret( findmob(), tmpt )
#define AWARDTPS(ch,amt)        sprintf(tmpt,"pset %s addtp %d", NAME( (ch) ), (amt)); interpret( findmob(), tmpt )
#define COINS(ch,amt)           sprintf(tmpt,"coins %d", (amt) ); interpret(ch,tmpt)
#define GIVECOINS(from,ch,amt)       sprintf(tmpt,"give %s %s", (amt), capitalize(NAME( (ch) )) ); interpret(from,tmpt)
#define CREATEOBJ(ch,vnum)      createobject((ch),(vnum))
#define GIVEITEM(from,to,item)  sprintf(tmpt,"give %s %s",(item), NAME( (to) )); interpret(from,tmpt)
#define CONTAINS(looking,str)   (!str_infix( (looking), (str) ) )
#define AWARDSKILL(ch,skill,amt) sprintf(tmpt,"award %s '%s' %d",NAME( (ch) ), (skill), (amt) ); interpret(findmob(), tmpt )
#define RAND(min,max)           ( number_range( (min), (max) ) )
#define IS_WINTER               ((time_info.month<=3 || time_info.month>19))
#define IS_SPRING               ((time_info.month>3 && time_info.month<=7))
#define IS_SUMMER               ((time_info.month>7 && time_info.month<=12))
#define IS_AUTUMN               ((time_info.month>12 && time_info.month<=19))
#define IS_RAINING              ((weather_info.sky==SKY_RAINING))
#define IS_CLEARSKY             ((weather_info.sky==SKY_CLOUDLESS))
#define IS_CLOUDY               ((weather_info.sky==SKY_CLOUDY))
#define IS_STORM                ((weather_info.sky==SKY_LIGHTNING))
#define IS_NIGHT                ((time_info.hour>=21 || time_info.hour<7))
#define IS_DAY                  (!IS_NIGHT)

/* Utility Defines */

/* With loop, 'next' argument must be like "obj->next", or "obj_next" */
/* Example: LOOP(ch,char_list,ch->next) { blah } */

#define LOOP(thing,initial,next)  for ((thing)=(initial);(thing)!=NULL;(thing)=(next))


/* For timing; defines */
#define FIGHT_LOOP	0
#define CHAR_ONLY_UPD	1
#define MOBILE_UPD	2
#define FIGHT_UPD	3
#define TRANSPORT_UPD	4
#define CHAR_UPDATE	5
#define OBJ_UPDATE	6
#define AGGRO_UPDATE	7
#define INTERPRETTED	8
#define SCRIPT_INT	9
#define ALL_UPD		10
#define MT 		20
/* ------------------- */

/* ------------------- */
/* All globals below!! */
/* ------------------- */
extern long average_time[MT];
extern long times_through[MT];
extern long total_time[MT];
extern long temp_time[MT];
extern long this_time[MT];
extern bool closeto;
extern int monthly_key;
extern bool hitop;
extern char cl[10024];
extern int main_control;
extern bool kk;
extern bool noibm;
extern bool mb;
extern bool dbs;
extern ROOM_DATA *iir;
extern unsigned short g_obj_pop[MAX_RANDOMPOP];
extern unsigned char g_percent[MAX_RANDOMPOP];
extern unsigned short g_moblist[MAX_RANDOMPOP][10];
extern bool g_mobpop[10000];
extern SOCIAL *social_list;
extern SOCIAL *social_hashed[255];
extern DESCRIPTOR_DATA *connectiond[5];
extern int outgoing[5];
extern char connection_names[5][5];
extern char *chan[2][30][MAX_SCROLLBACK];
extern short chan_count[2][30];
extern bool action_off;
extern bool supress_prompt_newline;
extern unsigned long exp_table[100];
extern int tps_table[100];
extern bool allow_anything;
extern char grep[500];
extern int bytes_saved;
extern scrn[80][25][9];
extern int total_fgt;
extern bool yes_log_all;
extern CHAR_DATA *orn;
extern CHAR_DATA *smack;
extern CHAR_DATA *palio;
extern FILE *ffg;
extern FILE *fft;
extern CHAR_DATA *f_first;
extern char *string_space;
extern char *top_string;
extern CHAR_DATA *aggro_check;
extern int ti;
extern bool oldflag;
extern DAM_MSG dmsg;
extern POWER pow;
extern SHELL *shell_first;
extern char *good;
extern char *evil;
extern CHANNEL *chan_first;
extern bool wwrap;
extern char *score;
extern char *sh_score;
extern char *info;
extern char reasonfd[30];
extern TO_FREE *head;
extern bool is_equipwipe;
extern CHR_FUNCTION *cf;
extern int room_chunk;
extern int obj_chunk;
extern int mob_chunk;
extern char tmpt[2048];
extern bool quit_flag;
extern bool pet_flag;
extern bool got;
extern char *questname[100];
extern char hugebuf_o[30000];
extern bool refresh_oldchars;
extern int current_vnum;
extern bool builder_port;
extern AREA_DATA *saving;
extern int max_connected;
extern short top_temp;
extern short top_ced;
extern CED_DATA *ced_first;
extern CED_DATA *ced_free;
extern bool translate_on;
extern short combat_state;
extern PERCENT_STRUCT prcnt;
extern DAM_STRUCT damt;
extern long chars_sent;
extern bool setskills;
extern bool state_var_1;
extern char *target_name;
extern bool fBootDb;
extern int meg_sent;
extern CHAR_DATA *pedit_found;
extern int area_this_reboot;
extern int pulse_timer;
extern int min_level;
extern int max_level;
extern long day_counter;
extern int cons_damage;
extern char *const color_name[];
extern char *const where_name[];
extern char *const dist_name[];
extern char *const percent_ded[];
extern int top_vnum_room;
extern int arena_timelimit;
extern REALCHAR_DATA base_pc;
extern PLAYERBASE_DATA *playerbase_zero;
extern ITEM_CHECK itemcheck;
extern char condition_var[500];
extern char auction_item[500];
extern int ticks_to_reboot;
extern int ticks_to_battlefield;
extern int prize_vnum_1;
extern int prize_vnum_2;
extern SINGLE_OBJECT *auction_item_g;
extern SINGLE_OBJECT *e_auction_item_e;
extern bool changed_spells;
extern int auction_minbid;
extern int auction_bid;
extern char e_auction_item[500];
extern int e_auction_minbid;
extern int e_auction_bid;
extern BID_DATA biddata;
extern TOPTEN_DATA topten;
extern RATING_DATA ratingd;
extern LIMITED_DATA limited;
extern short auction_going;
extern short e_auction_going;
extern CLAN_DATA *clan_index_free_2;
extern CLAN_DATA *clan_index_free;
extern CHAR_DATA *auction_char;
extern CHAR_DATA *auction_tochar;
extern CHAR_DATA *e_auction_char;
extern CHAR_DATA *e_auction_tochar;
extern bool auto_xfer;
extern bool e_auto_xfer;
extern int e_bidders;
extern int g_bidders;
extern CHAR_DATA *e_auction_lastbidder;
extern CHAR_DATA *auction_lastbidder;
extern short gsn_laser;
extern short gsn_tap;
extern short gsn_disembowel;
extern short gsn_elbow;
extern short gsn_headbutt;
extern short gsn_bodyslam;
extern short gsn_berserk;
extern short gsn_grunt;
extern short gsn_invest;
extern short gsn_riding;
extern short gsn_backstab;
extern short gsn_penetration;
extern short gsn_swim;
extern short gsn_butcher;
extern short gsn_dodge;
extern short gsn_hide;
extern short gsn_peek;
extern short gsn_pick_lock;
extern short gsn_sneak;
extern short gsn_steal;
extern short gsn_bash;
extern short gsn_track;
extern short gsn_circle;
extern short gsn_disarm;
extern short gsn_enhanced_damage;
extern short gsn_kick;
extern short gsn_parry;
extern short gsn_shield_block;
extern short gsn_rescue;
extern short gsn_second_attack;
extern short gsn_third_attack;
extern short gsn_dual_wield;
extern short gsn_pierce;
extern short gsn_light_slash;
extern short gsn_concussion;
extern short gsn_whip;
extern short gsn_heavy_slash;
extern short gsn_slashing;
extern short gsn_search;
extern short gsn_blindness;
extern short gsn_charm_person;
extern short gsn_curse;
extern short gsn_invis;
extern short gsn_mass_invis;
extern short gsn_poison;
extern short gsn_sleep;
extern short gsn_plague;
extern const struct attack_type attack_table[];
extern const struct liq_type liq_table[];
extern char *const dir_name[];
extern const short rev_dir[];
extern const short movement_loss[SECT_MAX];
extern char reasonone[30];
extern HELP_DATA *help_first;
extern HELP_DATA *help_last;
extern SHOP_DATA *shop_first;
extern SHOP_DATA *shop_last;
extern TEMP_STR *temp_first;
extern TEMP_STR *temp_free;
extern BLIST *base_blist;
extern BAN_DATA *ban_list;
extern CHAR_DATA *char_list;
extern SPELL_DATA *spell_list[SPELL_HASH];
extern SPELL_DATA *spell_list_2[SPELL_HASH];
extern int top_spell;
extern DESCRIPTOR_DATA *descriptor_list;
extern NOTE_DATA *note_list;
extern SINGLE_OBJECT *object_list;
extern AFFECT_DATA *affect_free;
extern RESET_DATA *reset_free;
extern SCRIPT_DATA *script_free;
extern BAN_DATA *ban_free;
extern CHAR_DATA *char_free;
extern DESCRIPTOR_DATA *descriptor_free;
extern DESCRIPTION_DATA *extra_descr_free;
extern NOTE_DATA *note_free;
extern SINGLE_OBJECT *obj_free;
extern REALCHAR_DATA *pcdata_free;
extern MOB_DATA *npcdata_free;
extern char bug_buf[];
extern time_t current_time;
extern bool fLogAll;
//extern FILE *fpReserve;
extern char log_buf[];
extern TIME_INFO_DATA time_info;
extern WEATHER_DATA weather_info;
extern MOB_PROTOTYPE *mob_index_hash[HASH_MAX];
extern OBJ_PROTOTYPE *obj_index_hash[HASH_MAX];
extern ROOM_DATA *room_hash[HASH_MAX];
extern CLAN_DATA *clan_index_hash[20];
extern CLAN_DATA *clan_index_hash_2[20];
extern char *string_hash[HASH_MAX];
extern AREA_DATA *area_first;
extern AREA_DATA *area_last;
extern int top_affect;
extern int top_area;
extern int top_ed;
extern int top_exit;
extern int top_help;
extern int top_clan;
extern int top_clan_2;
extern int top_mob_index;
extern int top_obj_index;
extern int top_reset;
extern int top_room;
extern int top_shop;

extern int top_vnum_mob;
extern int top_vnum_obj;
extern int top_vnum_room;

extern char str_empty[1];

extern int FORCE_LEVEL;
extern int LOG_LEVEL;

void load_random_pops(void);
void load_new_socials(void);

void menu_interp(CHAR_DATA *,char *);
void check_background_processes(void);
void save_tps(void);
void save_char_tro(CHAR_DATA *);
void do_answer (CHAR_DATA *, char *);
void do_mplay (CHAR_DATA *, char *);
void do_sing (CHAR_DATA *, char *);
void do_berserk (CHAR_DATA *, char *);
void do_recallc (CHAR_DATA *, char *);
void do_investigate (CHAR_DATA *, char *);
void do_mobscatter (CHAR_DATA *, char *);
void do_scatter (CHAR_DATA *, char *);
void relocate_rooms (CHAR_DATA *, char *);
void do_reload_help (CHAR_DATA *, char *);
void do_anon (CHAR_DATA *, char *);
void do_gic (CHAR_DATA *, char *);
void do_eic (CHAR_DATA *, char *);
void do_ic (CHAR_DATA *, char *);
void do_list_done_quests (CHAR_DATA *, char *);
void do_setroom (CHAR_DATA *, char *);
void do_drag (CHAR_DATA *, char *);
void do_catps (CHAR_DATA *, char *);
void do_yes (CHAR_DATA *, char *);
void do_dam (CHAR_DATA *, char *);
void do_beep (CHAR_DATA *, char *);
void do_levels (CHAR_DATA *, char *);
void disengage (CHAR_DATA *, char *);
void do_disembark (CHAR_DATA *, char *);
void do_board (CHAR_DATA *, char *);
void drawit (CHAR_DATA *, char *);
void do_drawmort (CHAR_DATA *, char *);
void do_drawmini (CHAR_DATA *, char *);
void do_drawtop (CHAR_DATA *, char *);
void do_drawrooms (CHAR_DATA *, char *);
void do_resize (CHAR_DATA *, char *);
void clean_blank_rooms (CHAR_DATA *, char *);
void do_setlevels (CHAR_DATA *, char *);
void do_battleground (CHAR_DATA *, char *);
void do_secretlog (CHAR_DATA *, char *);
void do_clanbuy (CHAR_DATA *, char *);
void do_purgearea (CHAR_DATA *, char *);
void do_mreset (CHAR_DATA *, char *);
void do_oreset (CHAR_DATA *, char *);
void do_topten (CHAR_DATA *, char *);
void do_rating (CHAR_DATA *, char *);
void do_clanstore (CHAR_DATA *, char *);
void do_prereqs (CHAR_DATA *, char *);
void do_clanunstore (CHAR_DATA *, char *);
void do_store (CHAR_DATA *, char *);
void do_unstore (CHAR_DATA *, char *);
void do_world (CHAR_DATA *, char *);
void do_preset (CHAR_DATA *, char *);
void do_trophy (CHAR_DATA *, char *);
void do_cadd (CHAR_DATA *, char *);
void do_butcher (CHAR_DATA *, char *);
void do_scan (CHAR_DATA *, char *);
void do_cremove (CHAR_DATA *, char *);
void do_clan (CHAR_DATA *, char *);
void do_clan_notify (CHAR_DATA *, char *);
void do_clantalk (CHAR_DATA *, char *);
void do_tackle (CHAR_DATA *, char *);
void do_repair (CHAR_DATA *, char *);
void do_guild (CHAR_DATA *, char *);
void do_clear (CHAR_DATA *, char *);
void do_skill (CHAR_DATA *, char *);
void do_flurry (CHAR_DATA *, char *);
void syslag (CHAR_DATA *, char *);
void do_delete (CHAR_DATA *, char *);
void do_empty (CHAR_DATA *, char *);
void do_bid (CHAR_DATA *, char *);
void do_surrender (CHAR_DATA *, char *);
void do_bbounty (CHAR_DATA *, char *);
void do_2forward (CHAR_DATA *, char *);
void do_2backward (CHAR_DATA *, char *);
void do_forward (CHAR_DATA *, char *);
void do_backward (CHAR_DATA *, char *);
void do_exchange (CHAR_DATA *, char *);
void do_meditate (CHAR_DATA *, char *);
void do_bash (CHAR_DATA *, char *);
void do_coins (CHAR_DATA *, char *);
void do_ansi (CHAR_DATA *, char *);
void do_fight (CHAR_DATA *, char *);
void do_fire (CHAR_DATA *, char *);
void do_advance (CHAR_DATA *, char *);
void do_allow (CHAR_DATA *, char *);
void do_areas (CHAR_DATA *, char *);
void do_at (CHAR_DATA *, char *);
void do_tauction (CHAR_DATA *, char *);
void do_break (CHAR_DATA *, char *);
void do_alias (CHAR_DATA *, char *);
void do_auto (CHAR_DATA *, char *);
void do_autosac (CHAR_DATA *, char *);
void do_assist (CHAR_DATA *, char *);
void do_autosplit (CHAR_DATA *, char *);
void do_autoloot (CHAR_DATA *, char *);
void do_autoexit (CHAR_DATA *, char *);
void do_autogold (CHAR_DATA *, char *);
void do_backstab (CHAR_DATA *, char *);
void do_circle (CHAR_DATA *, char *);
void do_beamin (CHAR_DATA *, char *);
void do_beamout (CHAR_DATA *, char *);
void do_ban (CHAR_DATA *, char *);
void do_nban (CHAR_DATA *, char *);
void do_blank (CHAR_DATA *, char *);
void do_bounty (CHAR_DATA *, char *);
void do_brief (CHAR_DATA *, char *);
void do_brandish (CHAR_DATA *, char *);
void do_buck (CHAR_DATA *, char *);
void do_buy (CHAR_DATA *, char *);
void do_cast (CHAR_DATA *, char *);
void do_channels (CHAR_DATA *, char *);
void do_gen_gos (CHAR_DATA *, char *);
void do_chat (CHAR_DATA *, char *);
void do_climb (CHAR_DATA *, char *);
void do_close (CHAR_DATA *, char *);
void do_commands (CHAR_DATA *, char *);
void do_compare (CHAR_DATA *, char *);
void do_config (CHAR_DATA *, char *);
void do_consider (CHAR_DATA *, char *);
void do_group_consider (CHAR_DATA *, char *);
void do_count (CHAR_DATA *, char *);
void do_credits (CHAR_DATA *, char *);
void do_deny (CHAR_DATA *, char *);
void do_description (CHAR_DATA *, char *);
void do_disarm (CHAR_DATA *, char *);
void do_disconnect (CHAR_DATA *, char *);
void do_dismount (CHAR_DATA *, char *);
void do_down (CHAR_DATA *, char *);
void do_draw (CHAR_DATA *, char *);
void do_drink (CHAR_DATA *, char *);
void do_drop (CHAR_DATA *, char *);
void do_east (CHAR_DATA *, char *);
void do_eat (CHAR_DATA *, char *);
void do_echo (CHAR_DATA *, char *);
void do_emote (CHAR_DATA *, char *);
void do_enter (CHAR_DATA *, char *);
void do_equipment (CHAR_DATA *, char *);
void do_examine (CHAR_DATA *, char *);
void do_extinguish (CHAR_DATA *, char *);
void do_fill (CHAR_DATA *, char *);
void do_flee (CHAR_DATA *, char *);
void do_fly (CHAR_DATA *, char *);
void do_follow (CHAR_DATA *, char *);
void do_sforce (CHAR_DATA *, char *);
void do_force (CHAR_DATA *, char *);
void do_freeze (CHAR_DATA *, char *);
void do_finger (CHAR_DATA *, char *);
void do_get (CHAR_DATA *, char *);
void do_give (CHAR_DATA *, char *);
void do_godtalk (CHAR_DATA *, char *);
void do_goto (CHAR_DATA *, char *);
void do_group (CHAR_DATA *, char *);
void do_gtell (CHAR_DATA *, char *);
void do_help (CHAR_DATA *, char *);
void do_events (CHAR_DATA *, char *);
void do_news (CHAR_DATA *, char *);
void do_changes (CHAR_DATA *, char *);
void do_hide (CHAR_DATA *, char *);
void do_hire (CHAR_DATA *, char *);
void do_holylag (CHAR_DATA *, char *);
void do_holyear (CHAR_DATA *, char *);
void do_holylight (CHAR_DATA *, char *);
void do_holywalk (CHAR_DATA *, char *);
void do_idea (CHAR_DATA *, char *);
void do_immtalk (CHAR_DATA *, char *);
void do_inventory (CHAR_DATA *, char *);
void do_invis (CHAR_DATA *, char *);
void do_kick (CHAR_DATA *, char *);
void do_kill (CHAR_DATA *, char *);
void do_language (CHAR_DATA *, char *);
void do_learn (CHAR_DATA *, char *);
void do_unlearn (CHAR_DATA *, char *);
void do_levels (CHAR_DATA *, char *);
void do_list (CHAR_DATA *, char *);
void do_light (CHAR_DATA *, char *);
void do_lock (CHAR_DATA *, char *);
void do_log (CHAR_DATA *, char *);
void do_memory (CHAR_DATA *, char *);
void do_mfind (CHAR_DATA *, char *);
void do_mload (CHAR_DATA *, char *);
void do_mount (CHAR_DATA *, char *);
void do_mset (CHAR_DATA *, char *);
void do_mstat (CHAR_DATA *, char *);
void do_mwhere (CHAR_DATA *, char *);
void do_murde (CHAR_DATA *, char *);
void do_murder (CHAR_DATA *, char *);
void do_pray (CHAR_DATA *, char *);
void do_noemote (CHAR_DATA *, char *);
void do_north (CHAR_DATA *, char *);
void do_note (CHAR_DATA *, char *);
void do_notell (CHAR_DATA *, char *);
void do_notify (CHAR_DATA *, char *);
void do_ofind (CHAR_DATA *, char *);
void do_oload (CHAR_DATA *, char *);
void do_open (CHAR_DATA *, char *);
void do_order (CHAR_DATA *, char *);
void do_oset (CHAR_DATA *, char *);
void do_ostat (CHAR_DATA *, char *);
void do_owhere (CHAR_DATA *, char *);
void do_pagelen (CHAR_DATA *, char *);
void do_password (CHAR_DATA *, char *);
void no_spam (CHAR_DATA *, char *);
void spam (CHAR_DATA *, char *);
void do_glance (CHAR_DATA *, char *);
void do_prompt (CHAR_DATA *, char *);
void do_peace (CHAR_DATA *, char *);
void do_pick (CHAR_DATA *, char *);
void do_practice (CHAR_DATA *, char *);
void do_pset (CHAR_DATA *, char *);
void do_pstat (CHAR_DATA *, char *);
void do_purge (CHAR_DATA *, char *);
void do_put (CHAR_DATA *, char *);
void do_quaff (CHAR_DATA *, char *);
void do_qui (CHAR_DATA *, char *);
void do_quit (CHAR_DATA *, char *);
void do_reboo (CHAR_DATA *, char *);
void do_reboot (CHAR_DATA *, char *);
void do_recall (CHAR_DATA *, char *);
void do_recho (CHAR_DATA *, char *);
void do_recite (CHAR_DATA *, char *);
void do_remove (CHAR_DATA *, char *);
void do_rent (CHAR_DATA *, char *);
void do_reply (CHAR_DATA *, char *);
void do_report (CHAR_DATA *, char *);
void do_rescue (CHAR_DATA *, char *);
void do_rest (CHAR_DATA *, char *);
void do_return (CHAR_DATA *, char *);
void do_rfind (CHAR_DATA *, char *);
void do_rstat (CHAR_DATA *, char *);
void do_run (CHAR_DATA *, char *);
void do_sacrifice (CHAR_DATA *, char *);
void do_save (CHAR_DATA *, char *);
void do_say (CHAR_DATA *, char *);
void do_quickscore (CHAR_DATA *, char *);
void do_purse (CHAR_DATA *, char *);
void do_score (CHAR_DATA *, char *);
void do_info (CHAR_DATA *, char *);
void do_affect (CHAR_DATA *, char *);
void do_search (CHAR_DATA *, char *);
void do_sell (CHAR_DATA *, char *);
void do_sheath (CHAR_DATA *, char *);
void do_shout (CHAR_DATA *, char *);
void do_shutdow (CHAR_DATA *, char *);
void do_shutdown (CHAR_DATA *, char *);
void do_silence (CHAR_DATA *, char *);
void do_sit (CHAR_DATA *, char *);
void do_sla (CHAR_DATA *, char *);
void do_slay (CHAR_DATA *, char *);
void do_sleep (CHAR_DATA *, char *);
void do_slist (CHAR_DATA *, char *);
void do_slookup (CHAR_DATA *, char *);
void do_sneak (CHAR_DATA *, char *);
void do_snoop (CHAR_DATA *, char *);
void do_socials (CHAR_DATA *, char *);
void do_south (CHAR_DATA *, char *);
void do_speak (CHAR_DATA *, char *);
void do_armor (CHAR_DATA *, char *);
void do_split (CHAR_DATA *, char *);
void do_spells (CHAR_DATA *, char *);
void do_sset (CHAR_DATA *, char *);
void do_allsave (CHAR_DATA *, char *);
void do_stand (CHAR_DATA *, char *);
void do_steal (CHAR_DATA *, char *);
void do_string (CHAR_DATA *, char *);
void do_switch (CHAR_DATA *, char *);
void do_tell (CHAR_DATA *, char *);
void do_time (CHAR_DATA *, char *);
void do_title (CHAR_DATA *, char *);
void do_track (CHAR_DATA *, char *);
void do_track_t (CHAR_DATA *, char *);
void do_train (CHAR_DATA *, char *);
void do_transfer (CHAR_DATA *, char *);
void do_trust (CHAR_DATA *, char *);
void do_unlock (CHAR_DATA *, char *);
void do_up (CHAR_DATA *, char *);
void do_users (CHAR_DATA *, char *);
void do_value (CHAR_DATA *, char *);
void do_visible (CHAR_DATA *, char *);
void do_wake (CHAR_DATA *, char *);
void do_wear (CHAR_DATA *, char *);
void do_headbutt (CHAR_DATA *, char *);
void do_bite (CHAR_DATA *, char *);
void do_tap (CHAR_DATA *, char *);
void do_grunt (CHAR_DATA *, char *);
void do_weather (CHAR_DATA *, char *);
void do_west (CHAR_DATA *, char *);
void do_where (CHAR_DATA *, char *);
void do_who (CHAR_DATA *, char *);
void do_wimpy (CHAR_DATA *, char *);
void do_wizhelp (CHAR_DATA *, char *);
void do_wizify (CHAR_DATA *, char *);
void do_wizlock (CHAR_DATA *, char *);
void do_wizlist (CHAR_DATA *, char *);
void do_wizprompt (CHAR_DATA *, char *);
void do_wp (CHAR_DATA *, char *);
void do_yell (CHAR_DATA *, char *);
void do_study (CHAR_DATA *, char *);
void do_zap (CHAR_DATA *, char *);
void do_spray (CHAR_DATA *, char *);
void do_deposit (CHAR_DATA *, char *);
void do_withdraw (CHAR_DATA *, char *);
void do_balance (CHAR_DATA *, char *);
void do_prof (CHAR_DATA *, char *);
void do_quiet (CHAR_DATA *, char *);
void do_convert (CHAR_DATA *, char *);
void do_award_skill (CHAR_DATA *, char *);
void do_asave (CHAR_DATA *, char *);
void do_astat (CHAR_DATA *, char *);
void do_mindex (CHAR_DATA *, char *);
void do_oindex (CHAR_DATA *, char *);
void do_cindex (CHAR_DATA *, char *);
void do_aedit (CHAR_DATA *, char *);
void do_redit (CHAR_DATA *, char *);
void do_sedit (CHAR_DATA *, char *);
void do_oedit (CHAR_DATA *, char *);
void do_medit (CHAR_DATA *, char *);
void do_set_fighters (CHAR_DATA *, char *);
void do_cancel (CHAR_DATA *, char *);
void do_challenge (CHAR_DATA *, char *);
void do_acceptc (CHAR_DATA *, char *);
void do_decline (CHAR_DATA *, char *);
void do_bet (CHAR_DATA *, char *);
void do_arena (CHAR_DATA *, char *);
void do_ignore (CHAR_DATA *, char *);
void do_clan_quit (CHAR_DATA *, char *);
void do_attribute (CHAR_DATA *, char *);
void do_ggossip (CHAR_DATA *, char *);
void do_egossip (CHAR_DATA *, char *);
void do_weight (CHAR_DATA *, char *);
void do_alien (CHAR_DATA *, char *);
void do_remort (CHAR_DATA *, char *);
void do_nodelete (CHAR_DATA *, char *);
void do_minmana (CHAR_DATA *, char *);
void do_limited (CHAR_DATA *, char *);
void do_noaffect (CHAR_DATA *, char *);
void do_results (CHAR_DATA *, char *);
void do_afk (CHAR_DATA *, char *);
void do_busy (CHAR_DATA *, char *);
void do_ditch (CHAR_DATA *, char *);
void do_query (CHAR_DATA *, char *);
void do_pedit (CHAR_DATA *, char *);
void do_cedit (CHAR_DATA *, char *);
void mana (CHAR_DATA *, char *);
void do_players (CHAR_DATA *, char *);
void do_pdelete (CHAR_DATA *, char *);
void do_resets (CHAR_DATA *, char *);
void do_scriptr (CHAR_DATA *, char *);
void do_mark (CHAR_DATA *, char *);
void spell_locate_person (int, int, CHAR_DATA *, void *);
void spell_scry (int sn, int level, CHAR_DATA * ch, void *vo);
void spell_charm_person (int sn, int level, CHAR_DATA * ch, void *vo);
void spell_control_weather (int sn, int level, CHAR_DATA * ch, void *vo);
void spell_identify (int sn, int level, CHAR_DATA * ch, void *vo);
void spell_locate_object (int sn, int level, CHAR_DATA * ch, void *vo);
void spell_summon (int sn, int level, CHAR_DATA * ch, void *vo);
void spell_acid_breath (int sn, int level, CHAR_DATA * ch, void *vo);
void spell_fire_breath (int sn, int level, CHAR_DATA * ch, void *vo);
void spell_message (int sn, int level, CHAR_DATA * ch, void *vo);
char *star_a (int, int);
char *star_b (int, int);
ROOM_DATA *find_coord (short, short, char);

/* I included many standard prototypes here, although not all are implimented
   as of now... */

bool spec_breath_any (CHAR_DATA * ch);
bool spec_breath_acid (CHAR_DATA * ch);
bool spec_breath_fire (CHAR_DATA * ch);
bool spec_breath_frost (CHAR_DATA * ch);
bool spec_breath_gas (CHAR_DATA * ch);
bool spec_breath_lightning (CHAR_DATA * ch);
bool spec_eatcorpse (CHAR_DATA * ch);
bool spec_guard (CHAR_DATA * ch);
bool spec_janitor (CHAR_DATA * ch);
bool spec_poison (CHAR_DATA * ch);
bool spec_thief (CHAR_DATA * ch);
bool spec_warrior (CHAR_DATA * ch);


char *crypt (const char *key, const char *salt);

/* Thanks to Cym of delta.misha.net for helping me make the mud SYSV/SUN
   compatible */

#if     defined(sun)
int fclose (FILE * stream);
int fprintf (FILE * stream, const char *format,...);
#if     defined(SYSV)
size_t fread (void *ptr, size_t size, size_t n, FILE * stream);
#else
int fread (void *ptr, int size, int n, FILE * stream);
#endif
int fseek (FILE * stream, long offset, int ptrname);
void perror (const char *s);
int ungetc (int c, FILE * stream);
#endif

#if     defined(NOCRYPT)
#define crypt(s1, s2)   (s1)
#endif


void add_follower (CHAR_DATA *, CHAR_DATA *);
bool is_note_to (CHAR_DATA *, NOTE_DATA *);
void set_title (CHAR_DATA *, char *);
bool move_char (CHAR_DATA * ch, int door);
void make_blood (CHAR_DATA * ch, int door);
CHAR_DATA *find_keeper (CHAR_DATA * ch);
CHAR_DATA *find_repair (CHAR_DATA * ch, int rnum);
int get_cost (CHAR_DATA *, SINGLE_OBJECT *, bool);
void wear_obj (CHAR_DATA *, SINGLE_OBJECT *, bool, int);
ROOM_DATA *find_location (CHAR_DATA *, char *);
void die_follower (CHAR_DATA *);
char *get_ansi_spaces (char *);
int find_first_step (ROOM_DATA *, ROOM_DATA *);
void do_chan_notify (CHAR_DATA *, char *);
void do_restore (CHAR_DATA *, char *);
void stop_follower (CHAR_DATA *);
bool is_same_group (CHAR_DATA *, CHAR_DATA *);
void do_exits (CHAR_DATA *, char *);
void do_land (CHAR_DATA *, char *);
void do_look (CHAR_DATA *, char *);
void close_socket (DESCRIPTOR_DATA * dclose);
SHELL *new_shell (void);
void write_to_buffer (DESCRIPTOR_DATA *, const char *,
		      int);
void do_global (char *, int, int);
void send_to_char (const char *, CHAR_DATA * ch);
void page_to_char (char *, CHAR_DATA * ch);
void ansi_color (const char *, CHAR_DATA * ch);
void show_string (DESCRIPTOR_DATA *, char *);
void act (const char *, CHAR_DATA *,
	  const void *, const void *, int);
char *anseval (const char *, CHAR_DATA *);
void boot_db (void);
void area_update (void);
void room_update (void);
void reset_room (ROOM_DATA *);
CHAR_DATA *create_mobile (MOB_PROTOTYPE *);
SINGLE_OBJECT *create_object (OBJ_PROTOTYPE *, int);
void clear_data (void *thing);
REALCHAR_DATA *new_pc (void);
CHAR_DATA *new_char (void);
SINGLE_OBJECT *new_obj (void);
char *get_extra_descr (const char *, DESCRIPTION_DATA *);
int clan_number (CHAR_DATA *);
int clan_number_2 (CHAR_DATA *);
bool scan_clan (char *arg);
bool scan_clan_2 (char *arg);
CLAN_DATA *get_clan_index (int);
CLAN_DATA *get_clan_index_2 (int);
MOB_PROTOTYPE *get_mob_index (int);
OBJ_PROTOTYPE *get_obj_index (int);
ROOM_DATA *get_room_index (int);
SPELL_DATA *spell_lookup (char *txt, int sn);
void save_area (AREA_DATA *);
void save_boats (void);
void load_boats (void);
int lookup_gsn (char *nm);
int tally_skills (CHAR_DATA *);
int tally_spells (CHAR_DATA *);
void setup_skills (void);
void general_spell (SPELL_DATA *, int, CHAR_DATA *, void *);
void load_spells (void);
void sedit (CHAR_DATA * ch, char *argy);
void write_spells (void);
void read_damages (void);
void write_damages (void);
void read_config (void);
void write_config (void);
SPELL_DATA *new_spell (void);
long translate (char *line, int level, CHAR_DATA * ch);


/* These functions work similarly to the old Mortal Conquest ones.  they
   may not behave exactly the same... */

char fread_letter (FILE *);
int fread_number (FILE *);
char *fread_string2 (FILE *, CHAR_DATA *);
char *fread_string (FILE *, CHAR_DATA *);
char *fread_string_eol (FILE *);
void fread_to_eol (FILE *);
char *fread_word (FILE *);
void *alloc_mem (int);
void *alloc_perm (int);
void free_mem (void *, int);
char *str_dupn (const char *);
char *str_dup (const char *);
void free_string (char *);
int number_fuzzy (int);
int number_range (int, int);
int number_percent (void);
int number_door (void);
int number_bits (int);
int number_mm (void);
int dice (int, int);
void smash_tilde (char *);
bool str_cmp (const char *, const char *);
bool str_prefix (const char *, const char *);
bool str_infix (const char *, const char *);
bool str_suffix (const char *, const char *);
char *capitalize (const char *);
void append_file (CHAR_DATA *, char *, char *);
void bug (const char *, int);
void log_string (const char *);
bool is_safe (CHAR_DATA *, CHAR_DATA *);
void death_cry (CHAR_DATA * ch, bool flaggy);
void violence_update (bool flaggy);
void multi_hit (CHAR_DATA *, CHAR_DATA *, int);
void ground_hit (CHAR_DATA *, CHAR_DATA *, int);
void damage (CHAR_DATA *, CHAR_DATA *, int,
	     int);
ROOM_DATA *new_room (void);
void update_pos (CHAR_DATA *);
void stop_fighting (CHAR_DATA *, bool);
void raw_kill (CHAR_DATA *, bool);
void skill_gain (CHAR_DATA *, short, bool);
void do_mindexc (CHAR_DATA * ch, char *argy, bool windowed);
int get_age (CHAR_DATA * ch);
int get_curr_str (CHAR_DATA * ch);
int get_curr_int (CHAR_DATA * ch);
int get_curr_wis (CHAR_DATA * ch);
int get_curr_dex (CHAR_DATA * ch);
int get_curr_con (CHAR_DATA * ch);
bool is_name (const char *, char *);
void affect_to_char (CHAR_DATA *, AFFECT_DATA *);
void affect_remove (CHAR_DATA *, AFFECT_DATA *);
void affect_strip (CHAR_DATA *, int);
void affect_strip_bits (CHAR_DATA *, int);
bool is_affected (CHAR_DATA *, int);
bool is_affectedt (CHAR_DATA *, int);
void affect_join (CHAR_DATA *, AFFECT_DATA *);
void char_from_boat (CHAR_DATA *, SINGLE_OBJECT *);
void char_to_boat (CHAR_DATA *, SINGLE_OBJECT *);
bool has_boat_space (CHAR_DATA *, SINGLE_OBJECT *);
bool is_in_same_boat (CHAR_DATA *, CHAR_DATA *);
void char_from_room (CHAR_DATA *);
void char_to_room (CHAR_DATA *, ROOM_DATA *);
void u_char_to_room (CHAR_DATA *, ROOM_DATA *);
void obj_to (SINGLE_OBJECT *, void *);
void obj_from (SINGLE_OBJECT *);
void free_it (void *);
int apply_ac (SINGLE_OBJECT *, int);
SINGLE_OBJECT *get_eq_char (CHAR_DATA *, int);
void equip_char (CHAR_DATA *, SINGLE_OBJECT *, int);
SINGLE_OBJECT *get_item_held (CHAR_DATA *, int);

void NEW_POSITION(CHAR_DATA *, int);
void SUBHIT(CHAR_DATA *, int);
void ADDHIT(CHAR_DATA *, int);
void ADDMOVE(CHAR_DATA *, int);
void SUBMOVE(CHAR_DATA *, int);
void MAXHIT(CHAR_DATA *);
void MAXMOVE(CHAR_DATA *);
void check_fgt(CHAR_DATA *);

int hand_empty (CHAR_DATA *);
int belt_empty (CHAR_DATA *);
bool unequip_char (CHAR_DATA *, SINGLE_OBJECT *);
int count_obj_list (OBJ_PROTOTYPE *, SINGLE_OBJECT *);
void extract_char (CHAR_DATA *, bool);
CHAR_DATA *get_char_room (CHAR_DATA *, char *);
CHAR_DATA *get_char_world (CHAR_DATA *, char *);
CHAR_DATA *get_char_world_2 (CHAR_DATA *, char *);
SINGLE_OBJECT *get_obj_type (OBJ_PROTOTYPE *);
SINGLE_OBJECT *get_obj_list (CHAR_DATA *, char *,
			     SINGLE_OBJECT *);
SINGLE_OBJECT *get_obj_carry (CHAR_DATA *, char *);
SINGLE_OBJECT *get_obj_wear (CHAR_DATA *, char *);
SINGLE_OBJECT *get_obj_inv (CHAR_DATA *, char *argy);
SINGLE_OBJECT *get_obj_held (CHAR_DATA *, char *argy);
SINGLE_OBJECT *get_obj_here (CHAR_DATA *, char *argy, int);
SINGLE_OBJECT *get_obj_world (CHAR_DATA *, char *argy);
void create_amount (int, CHAR_DATA *,
		    ROOM_DATA *, SINGLE_OBJECT *);
int tally_coins (CHAR_DATA *);
char *name_amount (int);
char *sub_coins (int, CHAR_DATA *);

int get_obj_number (SINGLE_OBJECT * obj);
int get_obj_weight (SINGLE_OBJECT * obj);
int room_is_dark (ROOM_DATA *);
bool room_is_private (ROOM_DATA *);
bool can_see (CHAR_DATA *, CHAR_DATA *);
bool can_see_nextdoor (CHAR_DATA *, CHAR_DATA *);
bool can_see_obj (CHAR_DATA *, SINGLE_OBJECT *);
bool can_drop_obj (CHAR_DATA *, SINGLE_OBJECT *);
char *mob_type_name (int);
char *mob_type_attack (int);
char *item_type_name (int);
char *affect_loc_name (int);
char *affect_bit_name (int);
char *affect_bit_name_two (int);
void do_actual_circle (CHAR_DATA * ch, char *argy);
void do_actual_backstab (CHAR_DATA * ch, char *argy);
void do_actual_search (CHAR_DATA * ch, char *argy);
void do_actual_cast (CHAR_DATA * ch, char *argy);
bool find_vehicle (CHAR_DATA *, int);
void set_fighting (CHAR_DATA *, CHAR_DATA *);
void clan_check_align (CHAR_DATA *);
void clan_check_align_2 (CHAR_DATA *);
int max_mana (CHAR_DATA *);
int mana_now (CHAR_DATA *);
void natural_mana (CHAR_DATA *);
void upd_mps (CHAR_DATA * ch);
char *compr (char *txt);
char *translate_output (char *inpt);
void upd_xp (CHAR_DATA * ch);
void upd_hunger (CHAR_DATA * ch);
void upd_hungert (CHAR_DATA * ch);
void upd_thirst (CHAR_DATA * ch);
void nupd_mana (CHAR_DATA * ch);
void set_it_up (CHAR_DATA * ch);
void nupd_tps (CHAR_DATA * ch);
void nupd_hps (CHAR_DATA * ch);
void nupd_mps (CHAR_DATA * ch);
void upd_mana (CHAR_DATA * ch);
void scrn_upd (CHAR_DATA * ch);
void upd_hps (CHAR_DATA * ch);
void clan_notify (char *argy, int clan_num);
void clan_notify_2 (char *argy, int clan_num);
void group_notify (char *argy, CHAR_DATA * ch);
void save_clans (void);
void save_clans_2 (void);
void dummy_mid (void);
void dummy_npc (void);
void dummy_pc (void);
void save_playerbase (void);
void save_itemcheck (void);
void update_pbase (CHAR_DATA * ch);
int itemcheck_forchar (CHAR_DATA * ch);
void update_itemcheck (CHAR_DATA * ch);
void save_topten (void);
void save_day_counter (void);
void save_rating (void);
void save_banlist (void);
void save_limited (int vnum);
void update_weight_num (CHAR_DATA * ch);
void dummycall (void);
void check_add_trophy (CHAR_DATA * ch, CHAR_DATA * victim);
int free_trophy_slot (CHAR_DATA * ch, CHAR_DATA * victim);
int free_storage (CHAR_DATA * ch);
int free_clan_storage (CLAN_DATA * clan);
void load_corpse (CHAR_DATA * read_ch);
void save_corpse (CHAR_DATA * ch);
void check_topten (CHAR_DATA * ch);
void check_rating (CHAR_DATA * ch);
void raw_purge (ROOM_DATA * rid);
void bust_a_prompt (CHAR_DATA * ch);
void fwrite_clan_storage (int clan_num);
void fread_clan_storage (int clan_num);
void get_condition (SINGLE_OBJECT * obj);
char *strip_ansi_codes (char *txty);
void free_arena (void);
bool write_to_descriptor2 (DESCRIPTOR_DATA *, char *, int);
int get_bet_slot (char *charname);
char *bet_on (char *charname);
void end_arena (CHAR_DATA * winner, CHAR_DATA * loser);
void arena (void);
bool ignore (CHAR_DATA * blabber_char, CHAR_DATA * sent_tot);
int chars_in_group (CHAR_DATA * ch);
int rchars_in_group (CHAR_DATA * ch);
int tchars_in_group (CHAR_DATA * ch);
void check_write_limited (SINGLE_OBJECT * obji, int vnum);
void bansite (char *argy);
void nbansite (char *argy);
void do_arenaecho (CHAR_DATA * ch, char *argy, bool batspam);
void give_back_money (void);
void blank_prompt (CHAR_DATA * ch);

/* These should be compatable with theisles.  I can't guarentee they are
   implimented the same, but the passed parameters should be compat.. no
   guarentees!! */

char *format_obj_to_char (SINGLE_OBJECT *, CHAR_DATA *,
			  bool);
void show_list_to_char (SINGLE_OBJECT *, CHAR_DATA *,
			bool, bool);
void show_char_to_char_0 (CHAR_DATA *, CHAR_DATA *);
void show_char_to_char_1 (CHAR_DATA *, CHAR_DATA *);
void show_char_to_char (CHAR_DATA *, CHAR_DATA *);
void show_equipment (CHAR_DATA *, CHAR_DATA *);
bool check_blind (CHAR_DATA *);
int words (char *s);
char *ans_uppercase (const char *);
bool remove_obj (CHAR_DATA * ch, int, bool);

void syslag (CHAR_DATA * ch, char *argy);
bool check_dodge (CHAR_DATA * ch, CHAR_DATA * victim);
bool check_parry (CHAR_DATA * ch, CHAR_DATA * victim);
bool check_shield (CHAR_DATA * ch, CHAR_DATA * victim);

void dam_message (CHAR_DATA *, CHAR_DATA *, int,
		  int, int);
bool can_groundfight (CHAR_DATA * ch);
void death_cry (CHAR_DATA * ch, bool flaggy);
void group_gain (CHAR_DATA * ch, CHAR_DATA * victim);
int xp_compute (CHAR_DATA * gch, CHAR_DATA * victim);
bool is_safe (CHAR_DATA * ch, CHAR_DATA * victim);
void make_corpse (CHAR_DATA * ch);
void *mem_alloc (int);
void one_hit (CHAR_DATA *, CHAR_DATA *, int,
	      SINGLE_OBJECT *, bool);
void raw_kill (CHAR_DATA * victim, bool used_sword);
void set_fighting (CHAR_DATA * ch, CHAR_DATA * victim);
void disarm (CHAR_DATA * ch, CHAR_DATA * victim);
void trip (CHAR_DATA * ch, CHAR_DATA * victim);
void display_toggles (CHAR_DATA * ch);
PLAYERBASE_DATA *new_player (void);
MOB_PROTOTYPE *new_mob_index (void);
DOOR_DATA *new_door (void);
CED_DATA *new_ced (void);
TEMP_STR *new_temp (void);
void free_temp (CHAR_DATA * ch);
void check_temp (CHAR_DATA * ch);
void free_ced (CHAR_DATA * ch);
void check_ced (CHAR_DATA * ch);
EXIT_DATA *new_exit (void);
ROOM_DATA *new_room_index (void);
AREA_DATA *get_vnum_area (int vnum);
int strtoint (char *string);
bool not_is_same_align (CHAR_DATA * ch, CHAR_DATA * victim);
bool is_same_align (CHAR_DATA * ch, CHAR_DATA * victim);
bool is_cheating (CHAR_DATA * ch);
void hunt_victim (CHAR_DATA * ch);
CHAR_DATA *get_player_world (CHAR_DATA * ch, char *argy, bool need_see);
void do_auction (CHAR_DATA * ch, char *argy, bool to_all);
CLAN_DATA *new_clan_index (void);
CLAN_DATA *new_clan_index_2 (void);
int get_sector_number (char *argy);
void free_exit (EXIT_DATA *);
int get_exit_flag_number (char *arg);

/* Write to descriptor... Do NOT use this for output.  I leave this in only
   so that it's compat with a diku comm package... ALWAYS use write_to_
   descriptor2() ... never use just plain ole write_to_descriptor! */

bool write_to_descriptor (int, char *, int);
/*int     read             ( int, char *, int ); */

void free_affect (AFFECT_DATA *);
AFFECT_DATA *new_affect (void);
OBJ_PROTOTYPE *new_obj_index (void);
DESCRIPTION_DATA *new_extra_descr (void);
void free_extra_descr (DESCRIPTION_DATA *);
OPTIONAL_DATA *new_optional (void);
void new_shop (MOB_PROTOTYPE *);
void free_shop (SHOP_DATA *);
int get_mob_sex_number (char *);
SPEC_FUNCTION *get_mob_spec (char *arg);
int arg_count (char *);
int get_area_flags_number (char *argy);
AREA_DATA *new_area (void);
char *string_replace (char *orig, char *old, char *new);
char *string_unpad (char *argy);
char *string_proper (char *argy);
void mindex_window (CHAR_DATA * ch, MOB_PROTOTYPE * victim, int update);
int add_damroll (CHAR_DATA * ch);
int add_hitroll (CHAR_DATA * ch);
int GET_HITROLL (CHAR_DATA * ch);
int GET_DAMROLL (CHAR_DATA * ch);
void conv_height (CHAR_DATA * ch);
char *jumble_name (char *st, bool unjumble);
void jumble (char *name);
void unjumble (char *name, bool convert);
char *string_mana (int mana);
char *string_mana_p (int mana);
void fix_char (CHAR_DATA * ch);
bool check_body_temp (CHAR_DATA * ch);
int get_warmth (CHAR_DATA * ch);
bool too_warm (int warmth, CHAR_DATA * ch);
bool too_cold (int warmth, CHAR_DATA * ch);
void send_to_boat (CHAR_DATA * ch, SINGLE_OBJECT * boat, char *to_send);
bool is_boat_empty (SINGLE_OBJECT * boat);
void do_fatal (CHAR_DATA * victim, CHAR_DATA * ch, int dt);
bool IS_CORPSE_MOB (CHAR_DATA * ch);
void destroy_list (CHAR_DATA * ch);
char *rNAME (CHAR_DATA * to, CHAR_DATA * ch);
void find_people_n (CHAR_DATA * ch, int n);
char *wordwrap (char *txt, int);
void do_scriptline (CHAR_DATA * mob, CHAR_DATA * player, SINGLE_OBJECT * obj);
void check_given_script (CHAR_DATA * fch, CHAR_DATA * ch, int vnum);
void check_tell_script (CHAR_DATA * fch, CHAR_DATA * ch, char *txt);
void check_social_script (CHAR_DATA * fch, CHAR_DATA * ch, char *txt);
void check_say_script (CHAR_DATA * fch, CHAR_DATA * ch, char *txt);
void check_short_tick_script (CHAR_DATA * fch, CHAR_DATA * ch);
int lookup_questname (char *txt);
ROOM_DATA *find_room_tag (char *tag);
char *show_room_name (CHAR_DATA * ch, char *roomname);
void place_pets (CHAR_DATA * ch);
void clear_tracks (CHAR_DATA * ch);
CHAR_DATA *find_mob (void);
CHAR_DATA *findmob (void);
void createobject (CHAR_DATA * ch, int vnum);
void destroy (CHAR_DATA * mob, int i);
void do_destroy (CHAR_DATA * mob, int i);
void hardcode_give_scripts (CHAR_DATA *, CHAR_DATA *, char *);
void hardcode_move_scripts (CHAR_DATA *, CHAR_DATA *);
void hardcode_room_enter (CHAR_DATA *, ROOM_DATA *);
void hardcode_interpret_scripts (CHAR_DATA *, CHAR_DATA *, char *);
void hardcode_saytell_scripts (CHAR_DATA *, CHAR_DATA *, char *);
/*char *itoa(int); */
void allocate_correct_datatype (SINGLE_OBJECT *, int *);
void free_m (void *);
void print_reasons (CHAR_DATA * ch, SINGLE_OBJECT * container);
char *interpret_line (char *, CHAR_DATA *);
char *natural_abilities (int);
void show_remort (CHAR_DATA *);
void set_initial_hp (CHAR_DATA *);
void remove_from_aggro_list (CHAR_DATA *);
void add_to_fighting_list (CHAR_DATA *);
void add_to_aggro_list (CHAR_DATA *);
void set_default_prompt (CHAR_DATA *, char);
void read_power_data (void);
void read_race_info (void);
void read_channel_data (void);
void read_conflict_data (void);
void read_score (CHAR_DATA *, char *);
bool check_pr (char *);
void read_power_dat (void);

void read_command_levels (void);
void add_level_bonuses (CHAR_DATA *, int);
int new_damage (CHAR_DATA *, int, int, int);
void channel_function (CHAR_DATA *, char *, CHANNEL *, int, char *);
void fcheck_pbase (char *);
void conv_race (CHAR_DATA * ch);
void area_sort (AREA_DATA *);
void save_area_list (void);
char *parse_txt (char *, CHAR_DATA *);
char *format_obj_to (SINGLE_OBJECT *, CHAR_DATA *, bool);
char *how_good (int);
void check_clear_more (ROOM_DATA * room);
void check_room_more (ROOM_DATA * room);
void display_room (CHAR_DATA * ch, ROOM_DATA * rid, int x, int y, short came_from, bool);
void strip_nonworn (CHAR_DATA * ch);
void pc_death_penalty (CHAR_DATA * ch, CHAR_DATA * victim);
int rating (CHAR_DATA * ch);
int free_bet_slot (void);
void make_corpse (CHAR_DATA * ch);
void racehate_message (CHAR_DATA * ch);
bool can_yell (CHAR_DATA * ch);
bool check_clan (CLAN_DATA * clan, char *argy);
bool check_clan_2 (CLAN_DATA * clan, char *argy);
int clan_free (CLAN_DATA * clan);
int clan_free_2 (CLAN_DATA * clan);
bool is_member (CHAR_DATA * ch, int guildflag);
bool locate_person (CHAR_DATA * ch, int level, char *argy);
bool scry (CHAR_DATA * ch, int level, char *argy);
int get_race_look (char *argy);
bool pkill (CHAR_DATA * ch, CHAR_DATA * victim);
void check_pkill (CHAR_DATA * ch, CHAR_DATA * victim);
void get_obj (CHAR_DATA * ch, SINGLE_OBJECT * obj, SINGLE_OBJECT * container);
int addoffense (CHAR_DATA * ch, SINGLE_OBJECT * obj);
char *extra_bit_name (int extra_flags);
char *room_bit_name (int room_flags);
char *act_bit_name (int act);
char *act3_bit_name (int act);
char *act4_bit_name (int act);
char *race_bit_name (int);
char *plr_bit_name (int);
char *wear_bit_name (int);
char *wear_loc_name (int);

int mob_name_type (char *name);
int item_name_type (char *name);
int affect_name_loc (char *name);
int affect_name_bit (char *buf);
int affect_name_bit_two (char *buf);
int extra_name_bit (char *buf);
int room_name_bit (char *buf);
int act_name_bit (char *buf);
int race_name_bit (char *buf);
int wear_name_bit (char *buf);
int wear_name_loc (char *buf);


char *is_are (char *);
char *format_string (char *);
char *replace_string (char *orig, char *old, char *new);
char *get_extra_descr (const char *name, DESCRIPTION_DATA * ed);
bool use_tool (SINGLE_OBJECT * obj, int bit);
int PERCENTAGE (int amount, int max);

void free_trigger (TRIGGER_DATA * trig);
void free_variable (VARIABLE_DATA * var);
void free_script (SCRIPT_DATA * scr);

void interpret (CHAR_DATA * ch, char *argy);
bool is_number (char *arg);
int num_args (char *argy);
int number_argy (char *argy, char *arg);
char *one_argy (char *argy, char *arg_first);
char *one_argcase (char *argy, char *);
bool check_social (CHAR_DATA *, char *, char *);
SPELL_DATA *skill_lookup (char *, int);
int slot_lookup (int);
bool saves_spell (int, CHAR_DATA *);
void obj_cast_spell (int, int, CHAR_DATA *,
		     CHAR_DATA *, SINGLE_OBJECT *);
void aedit (CHAR_DATA * ch, char *argy);
void redit (CHAR_DATA * ch, char *argy);
void renew_affect (CHAR_DATA * ch, AFFECT_DATA * aff);
void oedit (CHAR_DATA * ch, char *argy);
void medit (CHAR_DATA * ch, char *argy);
void pedit (CHAR_DATA * ch, char *argy);
void cedit (CHAR_DATA * ch, char *argy);
void string_append (CHAR_DATA * ch, char **pString);
void fullscreen_editor (CHAR_DATA * ch, char **pString);
AREA_DATA *get_area_data (int vnum);
char *fix_string (const char *str);
void string_add (CHAR_DATA * ch, char *argy);
void character_add (CHAR_DATA * ch, char *to_add);
void save_char_obj (CHAR_DATA * ch);
bool load_char_obj (DESCRIPTOR_DATA * d, char *name, bool ped);
int cur_temp (CHAR_DATA * ch);
char *first_arg (char *, char *, bool);
SPEC_FUNCTION *spec_lookup (const char *);
void advance_level (CHAR_DATA *);
void gain_exp (CHAR_DATA *, int);
void award_tps (CHAR_DATA *, int);
void gain_condition (CHAR_DATA *, int, int value);
void update_handler (void);
char *get_sector_name (int sector_type);
int get_direction_number (char *arg);
void load_helps (FILE * fp);
int system (const char *);
bool find_str (char *, char *);
bool process_output (DESCRIPTOR_DATA *, bool);
void strrepl (char *s, char new, char old);
char *first (char *s);
bool strsub (char *s, char *old, char *new);
char *ans_uppercase (const char *string);
bool aliasok (char *aliasname, char *s);
void add_to_list (char *, DO_COMMAND, int, int, int, char *);
void scanthru_commands (void);
char *decompress (char *s);
char *compress (char *s, long len);
/* Tried to keep similar names to other codebases so people don't have
   to relearn a whole new system... no guarentees at being the same
   as expected from other codebases! */

extern const struct material_data materials[];
extern const struct str_apply_type str_app[31];
extern struct int_apply_type int_app[31];
extern struct wis_apply_type wis_app[31];
extern const struct dex_apply_type dex_app[31];
extern struct con_apply_type con_app[31];

extern const struct color_data color_table[];
extern struct race_data race_info[RACE_COUNT];
extern const struct flag_data affect_flags_2[];
extern const struct flag_data affect_flagss[];
extern const struct flag_data room_flagss[];
extern const struct flag_data act_1[];
extern const struct flag_data act_3[];
extern const struct flag_data act_4[];
extern const struct flag_data extra_flagss[];
extern char *const percent_hit[];
extern char *const percent_tired[];



extern COMMAND *command_hash[256];
extern int commands;




#include "script.h"

#define IS_JAVA(ch)         ((ch) && (ch)->desc && (ch)->desc->java)
#define FIXIT(ch)   if ((ch)->in_room && IS_SET((ch)->in_room->room_flags,ROOM_INDOORS) && IS_SET((ch)->affected_by,AFF_FLYING)) (ch)->affected_by^=AFF_FLYING;