/* File: defines.h */

/*
 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
 *
 * This software may be copied and distributed for educational, research,
 * and not for profit purposes provided that this copyright and statement
 * are included in all such copies.  Other copyrights may also apply.
 *
 * UnAngband (c) 2001-2009 Andrew Doull. Modifications to the Angband 2.9.6
 * source code are released under the Gnu Public License. See www.fsf.org
 * for current GPL license details. Addition permission granted to
 * incorporate modifications in all Angband variants as defined in the
 * Angband variants FAQ. See rec.games.roguelike.angband for FAQ.
 */


/*
 * Do not edit this file unless you know *exactly* what you are doing.
 *
 * Some of the values in this file were chosen to preserve game balance,
 * while others are hard-coded based on the format of old save-files, the
 * definition of arrays in various places, mathematical properties, fast
 * computation, storage limits, or the format of external text files.
 *
 * Changing some of these values will induce crashes or memory errors or
 * savefile mis-reads.  Most of the comments in this file are meant as
 * reminders, not complete descriptions, and even a complete knowledge
 * of the source may not be sufficient to fully understand the effects
 * of changing certain definitions.
 *
 * Lastly, note that the code does not always use the symbolic constants
 * below, and sometimes uses various hard-coded values that may not even
 * be defined in this file, but which may be related to definitions here.
 * This is of course bad programming practice, but nobody is perfect...
 *
 * For example, there are MANY things that depend on the screen being
 * 80x24, with the top line used for messages, the bottom line being
 * used for status, and exactly 22 lines used to show the dungeon.
 * Just because your screen can hold 46 lines does not mean that the
 * game will work if you try to use 44 lines to show the dungeon.
 *
 * You have been warned.
 */


/*
 * Name of the version/variant
 */
#define VERSION_NAME "Unangband"


/*
 * Current version string
 */
#define VERSION_STRING	"0.6.4"

/*
 * Hack -- note use of new version name/string but old version
 * major/minor/patch numbers.
 */


/*
 * Current version numbers
 */
#define VERSION_MAJOR	0
#define VERSION_MINOR	6
#define VERSION_PATCH	4
#define VERSION_EXTRA	3

/*
 * Oldest version number that can still be imported
 */
#define OLD_VERSION_MAJOR	0
#define OLD_VERSION_MINOR	6
#define OLD_VERSION_PATCH	2
#define OLD_VERSION_EXTRA	20


/*
 * Number of grids in each block (vertically)
 * Probably hard-coded to 11, see "generate.c"
 */
#define BLOCK_HGT	11

/*
 * Number of grids in each block (horizontally)
 * Probably hard-coded to 11, see "generate.c"
 */
#define BLOCK_WID	11


/*
 * Number of grids in each panel (vertically)
 * Must be a multiple of BLOCK_HGT
 */

#define PANEL_HGT	(use_trptile ? 3 : (use_dbltile ? 5 : 11))

/*
 * Number of grids in each panel (horizontally)
 * Must be a multiple of BLOCK_WID
 */
#define PANEL_WID ((use_trptile && use_bigtile) ?  5 : (use_trptile ? 11 : \
		((use_dbltile && use_bigtile) ? 8 : ((use_dbltile || use_bigtile) ? 16 : 33))))

/*
 * Number of spaces used by the sidebar
 * This is normally 13, unless the sidebar is disabled in which case it is 0.
 * XXX Note, however, that we have to make it be a neat multiplier of 2 or 3 (or 4 or 6)
 * in double tile and triple tile mode (with big tile) or we get ugly black spacing running
 * into the main window. So in these instances, we cheat, and shrink it slightly to 12.
 *
 */
#define SIDEBAR_WID		(show_sidebar ? (use_dbltile || use_trptile ? 12 : 13) : 0)


#define ROW_MAP			1
#define COL_MAP			SIDEBAR_WID

/*
 * Number of grids in each screen (vertically)
 * Must be a multiple of PANEL_HGT (at least 2x)
 */
#define SCREEN_HGT	(((Term->hgt - ROW_MAP - 2)) / \
				(use_trptile ? 3 : (use_dbltile ? 2 : 1)) - (show_itemlist ? 1 : 0))

/*
 * Number of grids in each screen (horizontally)
 * Must be a multiple of PANEL_WID (at least 2x)
 */
#define SCREEN_WID	((Term->wid - COL_MAP - (show_sidebar ? 1 : 0)) / ((use_trptile && use_bigtile) ?  6 : (use_trptile ? 3 : \
			((use_dbltile && use_bigtile) ? 4 :((use_dbltile || use_bigtile) ? 2 : 1)))))


/*
 * Number of rooms to attempt to generate in dungeon.
 *
 */
#define DUN_ROOMS       16

/*
 * Number of grids in each dungeon (horizontally)
 * Must be a multiple of SCREEN_HGT
 * Must be less or equal to 256
 */
#define DUNGEON_HGT		66

/*
 * Number of grids in each dungeon (vertically)
 * Must be a multiple of SCREEN_WID
 * Must be less or equal to 256
 */
#define DUNGEON_WID		198

#define TOWN_WID 66
#define TOWN_HGT 21

/*
 * Maximum numbers of rooms along each axis (currently 6x18)
 * Now defined in defines.h
 */
#define MAX_ROOMS_ROW   (DUNGEON_HGT / BLOCK_HGT)
#define MAX_ROOMS_COL   (DUNGEON_WID / BLOCK_WID)

/*
 * Maximum amount of Angband windows.
 */
#define ANGBAND_TERM_MAX 8


/*
 * Total number of stores per town (see "store.c", etc)
 */
#define MAX_STORES	8

/*
 * Total number of items in home (see "store.c", etc)
 */
#define MAX_INVENTORY_HOME	24


/*
 * Store index definitions (see "store.c", etc)
 */

#define STORE_HOME		0	/* Doesn't stock items, store items here freely, shared location */
#define STORE_STORAGE           1	/* Store items here freely */
#define STORE_QUEST_REWARD      2	/* Quest rewards, store items here freely */
#define STORE_GENERAL		3
#define STORE_ARMOR		4
#define STORE_WEAPON		5
#define STORE_TEMPLE		6
#define STORE_ALCHEMY		7
#define STORE_MAGIC		8
#define STORE_B_MARKET		9	/* Doesn't stock services, higher prices, random contents */
#define STORE_LIBRARY		10	/* Doesn't stock services */

#define STORE_MIN_BUY_SELL      3

/*
 * Maximum number of player "sex" types (see "table.c", etc)
 */
#define MAX_SEXES	    2


/*
 * Maximum amount of starting equipment
 */
#define MAX_CLASS_ITEMS	10
#define MAX_COMMON_ITEMS 16


/*
 * Hack -- Maximum number of quests
 */
#define MAX_Q_IDX	100

/*
 * Maximum number of high scores in the high score file
 */
#define MAX_HISCORES	100


/*
 * Maximum dungeon level.  The player can never reach this level
 * in the dungeon, and this value is used for various calculations
 * involving object and monster creation.  It must be at least 100.
 * Setting it below 128 may prevent the creation of some objects.
 */
#define MAX_DEPTH	128


/*
 * Maximum size of the "view" array (see "cave.c")
 * Note that the "view radius" will NEVER exceed 20, and even if the "view"
 * was octagonal, we would never require more than 1520 entries in the array.
 */
#define VIEW_MAX 1536

/*
 * Maximum size of the "temp" array (see "cave.c")
 * Note that we must be as large as "VIEW_MAX" for proper functioning
 * of the "update_view()" function, and we must also be as large as the
 * largest illuminatable room, but no room is larger than 800 grids.  We
 * must also be large enough to allow "good enough" use as a circular queue,
 * to calculate monster flow, but note that the flow code is "paranoid".
 */
#define TEMP_MAX 1536

/*
 * Maximum size of the "dyna" array (see "cave.c")
 * Note that the "dyna radius" will NEVER exceed 20, and even if the "dyna"
 * was octagonal, we would never require more than 1520 entries in the array.
 */
#define DYNA_MAX 1536


/*
 * OPTION: Maximum number of macros (see "util.c")
 * Default: assume at most 256 macros are used
 */
#define MACRO_MAX	256

/*
 * OPTION: Maximum number of "quarks" (see "util.c")
 * Default: assume at most 2048 different inscriptions and tips are used
 */
#define QUARK_MAX	2048

/*
 * OPTION: Maximum total number of "tips" (see "files.c")
 * in the lib/file/ directory
 */
#define TIPS_MAX	1024


/*
 * OPTION: Maximum number of messages to remember (see "util.c")
 * Default: assume maximal memorization of 2048 total messages
 */
#define MESSAGE_MAX	2048

/*
 * OPTION: Maximum space for the message text buffer (see "util.c")
 * Default: assume that each of the 2048 messages is repeated an
 * average of three times, and has an average length of 48
 */
#define MESSAGE_BUF	32768

/*
 * Menu identifiers for simple selectable menu lists (see cmd4.c, do_cmd_menu)
 */
#define MENU_OPTIONS 1
#define MENU_KNOWLEDGE 2


/*
 * Maximum value storable in a "byte" (hard-coded)
 */
#define MAX_UCHAR       255

/*
 * Maximum value storable in a "s16b" (hard-coded)
 */
#define MAX_SHORT       32767


/*
 * Store constants
 */
#define STORE_INVEN_MAX	24		/* Max number of discrete objs in inven */
#define STORE_CHOICES	32		/* Number of items to choose stock from */
#define STORE_WILL_BUY	16		/* Number of different tvals the store will buy */
#define STORE_OBJ_LEVEL	5		/* Magic Level for normal stores */
#define STORE_TURNOVER	9		/* Normal shop turnover, per day */
#define STORE_MIN_KEEP	6		/* Min slots to "always" keep full */
#define STORE_MAX_KEEP	18		/* Max slots to "always" keep full */
#define STORE_SHUFFLE	25		/* 1/Chance (per day) of an owner changing */
#define STORE_TURNS		1000	/* Number of turns between turnovers */


/*
 * Misc constants
 */
#define TOWN_DAWN		11520			/* Number of turns per day */
#define DAY                     11520                   /* Number of turns per day */
#define YEAR                    (DAY * 365)             /* Number of turns per year */
#define HOUR                    (DAY / 24)              /* Number of turns per hour */
#define MINUTE                  (HOUR / 60)             /* Number of turns per minute */
#define SUNRISE                 6			/* Sunrise */
#define SUNSET                  18			/* Sunset */
#define MIDDAY			12			/* Midday */
#define MIDNIGHT		24			/* Midnight */
#define START_YEAR              2890                    /* Bilbo's birthday year */
#define START_DAY               (DAY * (42 + 127))      /* Bilbo's birthday */

#define BREAK_GLYPH		550		/* Rune of protection resistance */
#define BTH_PLUS_ADJ    2       /* Adjust BTH per plus-to-hit */
#define BTH_RANGE_ADJ	3		/* Minus to hit for each range grid */
#define MON_MULT_ADJ	8		/* High value slows multiplication */
#define MON_SUMMON_ADJ	2		/* Adjust level of summoned creatures */
#define MON_DRAIN_LIFE	2		/* Percent of player exp drained per hit */
#define USE_DEVICE      10		/* x> Harder devices x< Easier devices */

/*
 * There is a 1/20 (5%) chance of inflating the requested object_level
 * during the creation of an object (see "get_obj_num()" in "object.c").
 * Lower values yield better objects more often.
 */
#define GREAT_OBJ	20

/*
 * There is a 1/20 (5%) chance that ego-items with an inflated base-level are
 * generated when an object is turned into an ego-item (see make_ego_item()
 * in object2.c). As above, lower values yield better ego-items more often.
 */
#define GREAT_EGO	20

/*
 * There is a small chance of inflating the requested monster_level
 * during the creation of a monsters (see "get_mon_num()" in "monster.c").
 * Lower values yield harder monsters more often.
 */
#define NASTY_MON	30		/* 1/chance of inflated monster level */

/*
 * Maximum amount of sections in room description.
 */
#define ROOM_DESC_SECTIONS 50

/*
 * Dungeon room types
 */
enum
{
	ROOM_NONE = 0, ROOM_NORMAL, ROOM_NORMAL_WALLS, ROOM_NORMAL_CENTRE, ROOM_LARGE_WALLS,
	ROOM_LARGE_CENTRE, ROOM_HUGE_CENTRE, ROOM_CHAMBERS, ROOM_INTERESTING, ROOM_LESSER_VAULT, ROOM_GREATER_VAULT,
	ROOM_STAR_BURST, ROOM_HUGE_STAR_BURST, ROOM_FRACTAL, ROOM_LARGE_FRACTAL, ROOM_HUGE_FRACTAL, ROOM_LAIR,
	ROOM_MAZE, ROOM_LARGE_MAZE, ROOM_HUGE_MAZE, ROOM_CELL_CAVE, ROOM_LARGE_CAVE, ROOM_HUGE_CAVE, ROOM_BURROW,
	ROOM_LARGE_BURROW, ROOM_HUGE_BURROW, ROOM_MONSTER_PIT, ROOM_MONSTER_TOWN, ROOM_NORMAL_CONCAVE, ROOM_LARGE_CONCAVE,
	ROOM_HUGE_CONCAVE, ROOM_LAKE, ROOM_HUGE_LAKE, ROOM_TOWER, ROOM_MONSTER_TOWN_SUBROOM, 
	ROOM_MAX
};


/*
 * Refueling constants
 */
#define FUEL_TORCH	5000	/* Maximum amount of fuel in a torch */
#define FUEL_LAMP	15000   /* Maximum amount of fuel in a lantern */
#define FUEL_LOW	1500    /* Point below which torch lit dims */

/*
 * More maximum values
 */
#define MAX_SIGHT	20	/* Maximum view distance */
#define MAX_RANGE	18	/* Maximum range (spells, etc) */

/*
 * Monsters will run up to 25 grids away
 */
#define FLEE_RANGE      MAX_SIGHT + 5

/*
 * Hack -- Panicked monsters will run far, far away
 */
#define PANIC_RANGE      100


/*
 * There is a 1/200 chance per round base chance of creating a new monster
 */
#define MAX_M_ALLOC_CHANCE	200

/*
 * Normal levels get at least 14 monsters
 */
#define MIN_M_ALLOC_LEVEL	14


/*
 * The town starts out with 4 residents during the day
 */
#define MIN_M_ALLOC_TD		4

/*
 * The town starts out with 8 residents during the night
 */
#define MIN_M_ALLOC_TN		8


/*
 * Maximum size of a group of monsters
 */
#define GROUP_MAX       18


/*
 * A monster can only "multiply" (reproduce) if there are fewer than 100
 * monsters on the level capable of such spontaneous reproduction.  This
 * is a hack which prevents the "m_list[]" array from exploding due to
 * reproducing monsters.  Messy, but necessary.
 */
#define MAX_REPRO	100

/*
 * Maximum distance from the character to store flow (noise) information
 */
#define NOISE_STRENGTH 45

/*
 * Character turns it takes for smell to totally dissipate
 */
#define SMELL_STRENGTH 60

/*
 * Player constants
 */
#define PY_MAX_EXP	99999999L	/* Maximum exp */
#define PY_MAX_GOLD	999999999L	/* Maximum gold */
#define PY_MAX_LEVEL	50		/* Maximum level */
#define PY_MAX_STAT_GAIN	5	/* Maximum number of stat improvements per level gain */

/*
 * Player "food" crucial values
 */
#define PY_FOOD_MAX		15000	/* Food value (Bloated) */
#define PY_FOOD_FULL	10000	/* Food value (Normal) */
#define PY_FOOD_ALERT	2000	/* Food value (Hungry) */
#define PY_FOOD_WEAK	1000	/* Food value (Weak) */
#define PY_FOOD_FAINT	500		/* Food value (Fainting) */
#define PY_FOOD_STARVE	100		/* Food value (Starving) */

/*
 * Player "rest" crucial values
 */
#define PY_REST_MAX     600    /* Rest value (Maximum) */
#define PY_REST_FULL    500    /* Rest value (Normal) */
#define PY_REST_ALERT   300    /* Rest value (Tired) */
#define PY_REST_WEAK    200    /* Rest value (Weak) */
#define PY_REST_FAINT   100     /* Rest value (Fainting) */

#define PY_REST_RATE    30

/*
 * Player "sleep" crucial values
 */
#define PY_SLEEP_MAX    	4800   /* Rest value (Maximum) */
#define PY_SLEEP_RECOVER    	2400   /* Rest value (Recover) */
#define PY_SLEEP_ASLEEP    	10    /* Rest value (Asleep) */
#define PY_SLEEP_DROWSY   	5     /* Rest value (Drowsy) */


/*
 * Player regeneration constants
 */
#define PY_REGEN_NORMAL		197		/* Regen factor*2^16 when full */
#define PY_REGEN_WEAK		98		/* Regen factor*2^16 when weak */
#define PY_REGEN_FAINT		33		/* Regen factor*2^16 when fainting */
#define PY_REGEN_HPBASE		1442	/* Min amount hp regen*2^16 */
#define PY_REGEN_MNBASE		524		/* Min amount mana regen*2^16 */


/*
 * Maximum number of players spells
 */
#define PY_MAX_SPELLS 128


/*
 * Maximum number of "normal" pack slots, and the index of the "overflow"
 * slot, which can hold an item, but only temporarily, since it causes the
 * pack to "overflow", dropping the "last" item onto the ground.  Since this
 * value is used as an actual slot, it must be less than "INVEN_WIELD" (below).
 * Note that "INVEN_PACK" is probably hard-coded by its use in savefiles, and
 * by the fact that the screen can only show 23 items plus a one-line prompt.
 */
#define INVEN_PACK		23


/*
 * Maximum number of books the player can study from
 *
 * This is artificially limited so the player cannot consume more than half
 * their inventory with study slots. The actual limit is INVEN_PACK.
 */
#define MAX_STUDY_BOOK	(INVEN_PACK / 2)



/*
 * Maximum number of "bag" slots. This is limited by the fact the screen can
 * only show 23 items plus a one-line prompt.
 */
#define INVEN_BAG_TOTAL		23


/*
 * Indexes used for various "equipment" slots (hard-coded by savefiles, etc).
 */
#define INVEN_WIELD	    24
#define INVEN_BOW       25
#define INVEN_LEFT      26
#define INVEN_RIGHT     27
#define INVEN_NECK      28
#define INVEN_LITE      29
#define INVEN_BODY      30
#define INVEN_OUTER     31
#define INVEN_ARM       32
#define INVEN_HEAD      33
#define INVEN_HANDS     34
#define INVEN_FEET      35

/* The end of the equipment (old INVEN_TOTAL, before quiver) */
#define END_EQUIPMENT	36

/*
 * Blank line between equipment and quiver
 */
#define INVEN_BLANK	36

/*
 * First slot of the quiver
 */
#define INVEN_QUIVER	37

/*
 * The number of quiver slots
 */
#define MAX_QUIVER	10

/*
 * The end of the quiver
 */
#define END_QUIVER	(INVEN_QUIVER + MAX_QUIVER)

/*
 * Total number of inventory slots (hard-coded).
 */
#define INVEN_TOTAL	END_QUIVER

/*
 * Total number of inventory slots (hard-coded).
 */
#define INVEN_SELF	END_QUIVER

/*
 * Total number of show item slots (hard-coded).
 */
#define SHOWN_TOTAL	END_QUIVER

/*
 * Fake slot for selecting gold
 */
#define INVEN_GOLD (END_QUIVER + 1)

/*
 * Used to determine if a slot is a quiver slot.
 */
#define IS_QUIVER_SLOT(slot) \
(((slot) >= INVEN_QUIVER) && ((slot) < INVEN_QUIVER + MAX_QUIVER))




/*
 * A "stack" of items is limited to less than 100 items (hard-coded).
 */
#define MAX_STACK_SIZE			100


/*
 * Maximum number of objects allowed in a single dungeon grid.
 *
 * The main-screen has a minimum size of 24 rows, so we can always
 * display 23 objects + 1 header line.
 */
#define MAX_FLOOR_STACK			23





/*
 * Indexes of various commands.
 */
enum
{
	COMMAND_ITEM_EAT = 1, COMMAND_ITEM_QUAFF, COMMAND_ITEM_READ, COMMAND_ITEM_USE, COMMAND_ITEM_AIM,
	COMMAND_ITEM_ZAP, COMMAND_ITEM_ASSEMBLE, COMMAND_ITEM_ASSEMBLY, COMMAND_ITEM_ACTIVATE, COMMAND_ITEM_APPLY,
	COMMAND_ITEM_APPLY_RUNE, COMMAND_ITEM_APPLY_COAT, COMMAND_ITEM_WIELD, COMMAND_ITEM_WIELD_OFF, COMMAND_ITEM_READY,
	COMMAND_ITEM_TAKEOFF, COMMAND_ITEM_DROP, COMMAND_ITEM_DESTROY, COMMAND_ITEM_EXAMINE, COMMAND_ITEM_UNINSCRIBE,
	COMMAND_ITEM_INSCRIBE, COMMAND_ITEM_FUEL, COMMAND_ITEM_FILL, COMMAND_ITEM_FUEL_TORCH, COMMAND_ITEM_FUEL_LAMP,
	COMMAND_ITEM_FILL_FIREARM, COMMAND_ITEM_LITE, COMMAND_ITEM_MAGIC_TRAP, COMMAND_ITEM_THROW, COMMAND_ITEM_FIRE_SLING,
	COMMAND_ITEM_FIRE_BOW, COMMAND_ITEM_FIRE_XBOW, COMMAND_ITEM_FIRE_GUN, COMMAND_ITEM_CAST_SPELL, COMMAND_ITEM_STUDY,
	COMMAND_ITEM_BROWSE, COMMAND_ITEM_OFFER, COMMAND_ITEM_TRADE, COMMAND_ITEM_STEAL, COMMAND_ITEM_HANDLE,
	COMMAND_ITEM_SET_TRAP_OR_SPIKE,
	
	MAX_COMMANDS
};



/*
 * Conditional checks to ensure player status does not prevent commands.
 *
 * Note the timed effects below form a separate 'timed conditions' set of
 * restrictions.
 */
#define CONDITION_LITE			0x00000001L	/* Player has enough light to read by */
#define CONDITION_NO_WIND		0x00000002L	/* Player is not in a windy location */
#define CONDITION_SKILL_FIRE		0x00000004L	/* Player has enough skill to fire weapon */
#define CONDITION_SKILL_THROW	0x00000008L	/* Player has enough skill to throw weapons */
#define CONDITION_GUN_CHARGED	0x00000010L	/* Player's gun is loaded with a charge of gunpowder */
#define CONDITION_LITERATE		0x00000020L	/* Player can read books */
#define CONDITION_HOLD_SONG		0x00000040L	/* Player can choose to change the song they're singing */
#define CONDITION_NEED_SPELLS	0x00000080L	/* Player must have new spells to learn */
#define CONDITION_NO_SNEAKING	0x00000100L	/* Player must not be sneaking */
#define CONDITION_SHOOTING		0x00000200L	/* Player must be using the matching shooting item */




/*** Constants for accessing the player struct ***/

/*
 * Timed effects
 *
 * Only the first 32 timed effects can be used to restrict some commands from
 * being used.
 */
enum
{
	TMD_INC_STR = 0, TMD_INC_INT, TMD_INC_WIS, TMD_INC_DEX, TMD_INC_CON, TMD_INC_CHR, TMD_INC_AGI, TMD_INC_SIZ,
	TMD_DEC_STR, TMD_DEC_INT, TMD_DEC_WIS, TMD_DEC_DEX, TMD_DEC_CON, TMD_DEC_CHR, TMD_DEC_AGI, TMD_DEC_SIZ,
	TMD_FAST, TMD_SLOW, TMD_BLIND, TMD_PARALYZED, TMD_CONFUSED,
	TMD_AFRAID, TMD_IMAGE, TMD_POISONED, TMD_CUT, TMD_STUN, TMD_CURSED, TMD_AMNESIA, TMD_PETRIFY, TMD_STASTIS,
	TMD_MSLEEP, TMD_PSLEEP, TMD_PROTEVIL, TMD_INVIS, TMD_HERO, TMD_BERSERK, TMD_SHIELD, TMD_BLESSED, TMD_SEE_INVIS,
	TMD_INFRA, TMD_OPP_ACID, TMD_OPP_ELEC, TMD_OPP_FIRE, TMD_OPP_COLD, TMD_OPP_POIS, TMD_OPP_LAVA, TMD_OPP_WATER, TMD_OPP_CONF,
	TMD_SLOW_POISON, TMD_SLOW_DIGEST, TMD_WORD_RECALL, TMD_WORD_RETURN, TMD_DELAY_SPELL,
	TMD_FREE_ACT, TMD_TELEPATHY, TMD_STONESKIN, TMD_TERROR, TMD_SPRINT,

	TMD_MAX
};

#define TMD_CONDITION_MAX 32


/*
 * Skill indexes
 */
enum
{
	SKILL_DISARM,			/* Skill: Disarming */
	SKILL_DEVICE,			/* Skill: Magic Devices */
	SKILL_SAVE,				/* Skill: Saving throw */
	SKILL_STEALTH,			/* Skill: Stealth factor */
	SKILL_SEARCH,			/* Skill: Searching frequency */
	SKILL_DIGGING,			/* Skill: Searching ability */
	SKILL_TO_HIT_THROW,		/* Skill: To hit (throw) */
	SKILL_TO_HIT_MELEE,		/* Skill: To hit (melee) */
	SKILL_TO_HIT_BOW,		/* Skill: To hit (bow) */

	SKILL_MAX
};


/*
 * Indexes of the various "stats" (hard-coded by savefiles, etc).
 */
enum
{
	A_STR = 0,
	A_INT,
	A_WIS,
	A_DEX,
	A_CON,
	A_CHR,
	A_AGI,
	A_SIZ,

	A_MAX
};


/*
 * Player sex constants (hard-coded by save-files, arrays, etc)
 */
#define SEX_FEMALE		0
#define SEX_MALE		1

/*
 * Player class constants - only one hard coded.
 */
#define CLASS_ISTARI	11

/*
 * Player race constants (hard-coded by save-files, arrays, etc)
 */
#define RACE_MAN_OF_BREE	0
#define RACE_WOOD_ELF		1
#define RACE_HOBBIT		2
#define RACE_SHADOW_FAIRY	3
#define RACE_DWARF		4
#define RACE_DUNADAN		5
#define RACE_HIGH_ELF		6
#define RACE_MAIA		7
#define RACE_ENT           	8
#define RACE_DRUADAN		9
#define RACE_MAN_OF_ERECH	10
#define RACE_MAN_OF_DALE	11
#define RACE_MAN_OF_ROHAN	12
#define RACE_MAN_OF_GONDOR	13
#define RACE_MAN_OF_HARAD	14
#define RACE_FORGE_GIANT	15
#define RACE_FIRE_GIANT		16
#define RACE_FROST_GIANT	17
#define RACE_BEORNING		18
#define RACE_WEREWOLF		19
#define RACE_VAMPIRE		20
#define RACE_GOBLIN		21
#define RACE_GOBLIN_MAN		22
#define RACE_ORC		23
#define RACE_HALF_ORC		24
#define RACE_STONE_TROLL	25
/* 26--28 free */
#define RACE_GOAT		29
#define RACE_BEAR		30
#define RACE_MOUSE		31
#define RACE_HOUND         	32
#define RACE_CHEETAH       	33
#define RACE_LION          	34
#define RACE_DRAGON        	35
#define RACE_WOLF         	36
#define RACE_BAT          	37
#define RACE_SERPENT          	38
#define RACE_CAT          	39


/*** Screen Locations ***/

#define BOTTOM_LINE  Term->hgt - (show_itemlist ? (use_trptile ? 4 : (use_dbltile ? 3 : 2)) : 1)
#define SECOND_FROM_BOTTOM  Term->hgt - (show_itemlist ? (use_trptile ? 5 : (use_dbltile ? 4 : 3)) : 2)


/*
 * Some screen locations for various display routines
 * Currently, row 8 and 15 are the only "blank" rows.
 * That leaves a "border" around the "stat" values.
 */

#define ROW_RACE		1
#define COL_RACE		0	/* <race name> */

#define ROW_CLASS		2
#define COL_CLASS		0	/* <class name> */

#define ROW_TITLE		3
#define COL_TITLE		0	/* <title> or <mode> */

#define ROW_LEVEL		(show_sidebar ? 4 : (BOTTOM_LINE))
#define COL_LEVEL		(show_sidebar ? 0 : 74)	/* "LEVEL xxxxxx" */

#define ROW_EXP			(show_sidebar ? 5 : (BOTTOM_LINE))
#define COL_EXP			(show_sidebar ? 0 : 64)	/* "EXP xxxxxxxx" */

#define ROW_GOLD		(show_sidebar ? 6 : (BOTTOM_LINE))
#define COL_GOLD		(show_sidebar ? 0 : 26)	/* "AU xxxxxxxxx" */

#define ROW_STAT		(show_sidebar ? 8 : (SECOND_FROM_BOTTOM))
#define COL_STAT	       0	/* "xxx   xxxxxx" */

#define ROW_AC			(show_sidebar ? 17 : (BOTTOM_LINE))
#define COL_AC			(show_sidebar ? 0 : 13)	/* "Cur AC xxxxx" */

#define ROW_MAXHP		(show_sidebar ? 18 : (BOTTOM_LINE))
#define COL_MAXHP		(show_sidebar ? 0 : 7)	/* "Max HP xxxxx" */

#define ROW_CURHP		(show_sidebar ? 19 : (BOTTOM_LINE))
#define COL_CURHP		(show_sidebar ? 0 : 0)	/* "Cur HP xxxxx" */

#define ROW_MAXSP		(show_sidebar ? 20 : (BOTTOM_LINE))
#define COL_MAXSP		(show_sidebar ? 0 : 20)	/* "Max SP xxxxx" */

#define ROW_CURSP		(show_sidebar ? 21 : (BOTTOM_LINE))
#define COL_CURSP		(show_sidebar ? 0 : 13)	/* "Cur SP xxxxx" */

#define ROW_INFO		(show_sidebar ? 22 : (BOTTOM_LINE))
#define COL_INFO		(show_sidebar ? 0 : 26)	/* "xxxxxxxxxxxx" */

#define ROW_HUNGRY		(show_sidebar ? (BOTTOM_LINE) : (BOTTOM_LINE))
#define COL_HUNGRY		(show_sidebar ? 0 : 59)	/* "Weak" / "Hungry" / "Full" / "Gorged" */

#define ROW_STATE	(show_sidebar ? (BOTTOM_LINE) : (BOTTOM_LINE))
#define COL_STATE		(show_sidebar ? (Term->wid >= 90  ? 69 : 60) : 39)	/* <state> */

#define ROW_SPEED	(show_sidebar ? (BOTTOM_LINE) : (BOTTOM_LINE))
#define COL_SPEED		(show_sidebar ? (Term->wid >= 90  ? 80 : 70) : 39)	/* "Slow (-NN)" or "Fast (+NN)" */

#define ROW_STUDY		(show_sidebar ? (Term->wid >= 96 ? (BOTTOM_LINE) : 16) \
					: (BOTTOM_LINE))
#define COL_STUDY		(show_sidebar ? (Term->wid >= 96 ? 91 : 0) : 53)	/* "Study" */

#define ROW_DEPTH		(show_sidebar ? (Term->wid >= 105 ? (BOTTOM_LINE) : 7) \
					: (SECOND_FROM_BOTTOM))
#define COL_DEPTH		(show_sidebar ? (Term->wid >= 105 ? 97 : 0) : 73)	/* "Lev NNN" / "NNNN ft" */

/*
 * From most likely to last long to least likely; SECOND_FROM_BOTTOM in !sidebar
 */

#define ROW_DISEASE		(show_sidebar ? (BOTTOM_LINE) : (SECOND_FROM_BOTTOM))
#define COL_DISEASE	(show_sidebar ? (Term->wid >= 90  ? 38 : 33) : 24)	/* "Disease" / "Dise" */

#define ROW_CURSED	(show_sidebar ? (BOTTOM_LINE) : (SECOND_FROM_BOTTOM))
#define COL_CURSED	(show_sidebar ? (Term->wid >= 90  ? 46 : 40) : 28)	/* "Cursed" / "Curs" */

#define ROW_AFRAID		(show_sidebar ? (BOTTOM_LINE) : (SECOND_FROM_BOTTOM))
#define COL_AFRAID		(show_sidebar ? (Term->wid >= 90  ? 22 : 19) : 32)	/* "Afraid" */

#define ROW_CUT			(show_sidebar ? 23 : (SECOND_FROM_BOTTOM))
#define COL_CUT			(show_sidebar ? 0 : 36)	/* <cut> */

#define ROW_STUN		(show_sidebar ? 24 : (SECOND_FROM_BOTTOM))
#define COL_STUN		(show_sidebar ? 0 : 40)	/* <stun> */

#define ROW_POISONED		(show_sidebar ? (BOTTOM_LINE) : (SECOND_FROM_BOTTOM))
#define COL_POISONED		(show_sidebar ? (Term->wid >= 90  ? 29 : 25) : 44)	/* "Poisoned" */

#define ROW_AMNESIA	(show_sidebar ? (BOTTOM_LINE) : (SECOND_FROM_BOTTOM))
#define COL_AMNESIA	(show_sidebar ? (Term->wid >= 90  ? 53 : 46) : 48)	/* "Amnesia" / "Forg" */

#define ROW_PETRIFY	(show_sidebar ? (BOTTOM_LINE) : (SECOND_FROM_BOTTOM))
#define COL_PETRIFY	(show_sidebar ? (Term->wid >= 90  ? 61 : 53) : 52)	/* "Petrify" / "Petr" */

#define ROW_CONFUSED		(show_sidebar ? (BOTTOM_LINE) : (SECOND_FROM_BOTTOM))
#define COL_CONFUSED		(show_sidebar ? (Term->wid >= 90  ? 13 : 11) : 56)	/* "Confused" */

#define ROW_BLIND		(show_sidebar ? (BOTTOM_LINE) : (SECOND_FROM_BOTTOM))
#define COL_BLIND		(show_sidebar ? (Term->wid >= 90  ? 7 : 6)  : 60)	/* "Blind" */


/*** General index values ***/


/*
 * Legal restrictions for "summon_specific()"
 */
#define SUMMON_KIN	1
#define RAISE_DEAD	2
#define ANIMATE_DEAD	3
/* XXX */
#define RAISE_MONSTER   6
#define ANIMATE_TREE	7
#define SUMMON_PLANT    8
#define SUMMON_INSECT   9
#define SUMMON_ANIMAL  10
#define SUMMON_HOUND   11
#define SUMMON_SPIDER  12
#define SUMMON_CLASS   13
#define SUMMON_RACE    14
#define SUMMON_GROUP   15
#define SUMMON_FRIEND  16
#define SUMMON_UNIQUE_FRIEND  17
#define SUMMON_ORC     18
#define SUMMON_TROLL   19
#define SUMMON_GIANT   20
#define SUMMON_DRAGON  21
#define SUMMON_HI_DRAGON  22
#define ANIMATE_ELEMENT   23
#define ANIMATE_OBJECT    24
#define SUMMON_DEMON      25
#define SUMMON_HI_DEMON   26
#define RAISE_UNIQUE      27
#define SUMMON_UNIQUE     28
#define SUMMON_HI_UNIQUE  29
#define SUMMON_UNDEAD     30
#define SUMMON_HI_UNDEAD  31
#define SUMMON_WRAITH     32
#define RAISE_HI_UNIQUE   33
#define SUMMON_COLOUR   34
#define SUMMON_PREFIX   35
#define SUMMON_SUFFIX   36		/* Not used. Use SUMMON_ALL_BUT_PREFIX */
#define SUMMON_ALL_BUT_PREFIX   37
#define SUMMON_INFIX_WYRM_OF   38
#define SUMMON_DRAGON_BREATH   39
#define SUMMON_ALIGN	40		/* Summon monsters which match living & evil flags */
#define SUMMON_LEVEL	41		/* Summon monsters specific to LF1_TERRAIN flags */


/*
 * Spell types used by project(), and related functions.
 */
#define GF_NOTHING      0
#define GF_STORM	1
#define GF_WIND		2
#define GF_HELLFIRE     3
#define GF_MANA		4
#define GF_HOLY_ORB     5
#define GF_LITE_WEAK    6
#define GF_DARK_WEAK    7
#define GF_WATER_WEAK   8
#define GF_PLASMA       9
#define GF_METEOR       10
#define GF_ICE		11
#define GF_GRAVITY      12
#define GF_INERTIA      13
#define GF_FORCE	14
#define GF_TIME		15
#define GF_ACID		16
#define GF_ELEC		17
#define GF_FIRE		18
#define GF_COLD		19
#define GF_POIS		20
#define GF_ANIM_DEAD	21
#define GF_LITE		22
#define GF_DARK		23
#define GF_WATER	24
#define GF_CONFUSION    25
#define GF_SOUND	26
#define GF_SHARD	27
#define GF_NEXUS	28
#define GF_NETHER       29
#define GF_CHAOS	30
#define GF_DISENCHANT   31
#define GF_EXPLODE      32
#define GF_KILL_WALL    33
#define GF_KILL_DOOR    34
#define GF_KILL_TRAP    35
#define GF_MAKE_WALL    36
#define GF_MAKE_DOOR    37
#define GF_MAKE_TRAP    38
#define GF_BRIDGE       39
#define GF_ANIM_ELEMENT	40
#define GF_AWAY_UNDEAD  41
#define GF_AWAY_EVIL    42
#define GF_AWAY_ALL	43
#define GF_TURN_UNDEAD  44
#define GF_TURN_EVIL    45
#define GF_FEAR_WEAK	46
#define GF_DISP_UNDEAD  47
#define GF_DISP_EVIL    48
#define GF_DISP_ALL	49
#define GF_ANIM_OBJECT	50
#define GF_CLONE    	51
#define GF_POLY		52
#define GF_HEAL		53
#define GF_HASTE    	54
#define GF_SLOW_WEAK	55
#define GF_CONF_WEAK	56
#define GF_SLEEP    	57
#define GF_DRAIN_LIFE   58
#define GF_BWATER  	59
#define GF_BMUD  	60
#define GF_HURT  	61
#define GF_LAVA  	62
#define GF_UN_BONUS     63
#define GF_UN_POWER     64
#define GF_EAT_GOLD     65
#define GF_EAT_ITEM     66
#define GF_EAT_FOOD     67
#define GF_EAT_LITE     68
#define GF_FALL  	69
#define GF_FALL_MORE    70
#define GF_FALL_SPIKE   71
#define GF_FALL_POIS    72
#define GF_BLIND  	73
#define GF_SLOW  	74
#define GF_TERRIFY      75
#define GF_PARALYZE     76
#define GF_LOSE_STR     77
#define GF_LOSE_INT     78
#define GF_LOSE_WIS     79
#define GF_LOSE_DEX     80
#define GF_LOSE_CON     81
#define GF_LOSE_CHR     82
#define GF_LOSE_ALL     83
#define GF_SHATTER      84
#define GF_EXP_10 	85
#define GF_EXP_20 	86
#define GF_EXP_40 	87
#define GF_EXP_80 	88
#define GF_RAISE	89
#define GF_LOWER	90
#define GF_PROBE	91
#define GF_LOCK_DOOR	92
#define GF_SALT_WATER	93
#define GF_HALLU	94
#define GF_FEATURE	95
#define GF_STEAM	96
#define GF_VAPOUR	97
#define GF_SMOKE	98
#define GF_SUFFOCATE 	99
#define GF_HUNGER	100
#define GF_DISEASE	101
#define GF_HURT_MANA	102
#define GF_WOUND	103
#define GF_BATTER	104
#define GF_BLIND_WEAK	105
#define GF_RAISE_DEAD	106
#define GF_GAIN_MANA	107
#define GF_FORGET	108
#define GF_CURSE	109
#define GF_DISPEL	110
#define GF_STASTIS	111
#define GF_PETRIFY	112
#define GF_WEB		113
#define GF_BLOOD	114
#define GF_SLIME	115
#define GF_RES_MAGIC	116
#define GF_FALL_LESS    117
#define GF_AWAY_DARK	118
#define GF_AWAY_JUMP	119
#define GF_HURT_WOOD	120
#define GF_AWAY_NATURE	121
#define GF_AWAY_FIRE	122
#define GF_ANIM_TREE	123
#define GF_CHARM_INSECT	124
#define GF_CHARM_ANIMAL	125
#define GF_CHARM_REPTILE	126
#define GF_CHARM_MONSTER	127
#define GF_CHARM_PERSON	128
#define GF_BIND_DEMON	129
#define GF_BIND_UNDEAD	130
#define GF_BIND_DRAGON	131
#define GF_BIND_FAMILIAR	132
#define GF_VAMP_DRAIN	133
#define GF_MANA_DRAIN	134
#define GF_MENTAL		135
#define GF_SNUFF		136
#define GF_RAGE			137
#define GF_HEAL_PERC	138
#define GF_GAIN_MANA_PERC	139
#define GF_TANGLE		140
#define GF_POISON_WATER	141
#define GF_INVISIBILITY	142
#define GF_DELAY_POISON	143
#define GF_STICKS_TO_SNAKES	144
#define GF_LOSE_MANA	145
#define GF_LOSE_MANA_PERC	146
#define GF_DESTROY	147
#define GF_QUAKE	148
#define GF_POISON_WEAK	149
#define GF_POISON_HALF	150
#define GF_HURT_POISON	151
#define GF_POTS	152
#define GF_CHARM_PLANT	153
#define GF_TANGLE_WEAK	154
#define GF_LITE_BODY	155
#define GF_IMAGE_ACID		156
#define GF_IMAGE_ELEC		157
#define GF_IMAGE_FIRE		158
#define GF_IMAGE_COLD		159
#define GF_IMAGE_POIS		160
#define GF_ILLUSION		161
#define GF_VAMP_DRAIN_FAMILIAR	162
#define GF_MANA_DRAIN_FAMILIAR	163
#define GF_DRAIN_LIFE_PERC   164
#define GF_DRAIN_BLOOD	165
#define GF_DRAIN_BLOOD_FAMILIAR	166
#define GF_VAMP_DRAIN_BLOOD	167



/*
 * Columns for the spell cost or damage flags
 */
#define COL_SPELL_MANA_COST		0
#define COL_SPELL_DAM_MULT		1
#define COL_SPELL_DAM_DIV		2
#define COL_SPELL_DAM_VAR		3
#define COL_SPELL_BEST_RANGE		4

/*
 * Number of keymap modes
 */
#define KEYMAP_MODES	2

/*
 * Mode for original keyset commands
 */
#define KEYMAP_MODE_ORIG	0

/*
 * Mode for roguelike keyset commands
 */
#define KEYMAP_MODE_ROGUE	1


/*
 * Maximum number of dungeons next to this one. Used in t_info.txt.
 */

#define MAX_NEARBY		 4


/*
 * Maximum number of zones in a dungeon. Used in t_info.txt.
 */

#define MAX_DUNGEON_ZONES	 4

/*
 * Number of feats we change to (Excluding default). Used in f_info.txt.
 */
#define MAX_FEAT_STATES	 8

/*
 * Maximum number of spell constants
 */
#define MAX_SPELL_APPEARS	10
#define MAX_SPELL_CASTERS	8
#define MAX_SPELL_PREREQUISITES	2


/*** Feature Indexes (see "lib/edit/feature.txt") ***/

/* Nothing */
#define FEAT_NONE		0x00

/* Various */
#define FEAT_FLOOR		0x01
#define FEAT_INVIS		0x02
#define FEAT_GLYPH		0x03
#define FEAT_OPEN		0x04
#define FEAT_BROKEN		0x05
#define FEAT_LESS		0x06
#define FEAT_MORE		0x07

/* Shops */
#define FEAT_HOME               0x0F

/* Doors */
#define FEAT_DOOR_CLOSED        0x20

/* Extra */
#define FEAT_SECRET		0x30
#define FEAT_RUBBLE		0x31

/* Seams */
#define FEAT_MAGMA		0x32
#define FEAT_QUARTZ		0x33
#define FEAT_MAGMA_H	0x34
#define FEAT_QUARTZ_H	0x35
#define FEAT_MAGMA_K	0x36
#define FEAT_QUARTZ_K	0x37

/* Walls */
#define FEAT_WALL_EXTRA	0x38
#define FEAT_WALL_INNER	0x39
#define FEAT_WALL_OUTER	0x3A
#define FEAT_WALL_SOLID	0x3B
#define FEAT_PERM_EXTRA	0x3C
#define FEAT_PERM_INNER	0x3D
#define FEAT_PERM_OUTER	0x3E
#define FEAT_PERM_SOLID	0x3F

/* Extra features (need colour) */
#define FEAT_UPPER_EXTRA 0x0040

/* More traps */
#define FEAT_TRAP_HEAD_2 0x0040
#define FEAT_TRAP_ROCK_NONE 0x005F
#define FEAT_TRAP_TAIL_2 0x005F

#define FEAT_RUBBLE_H    0x0060
#define FEAT_RUBBLE_K   0x0061
#define FEAT_DOOR_INVIS 0x0062

/* Trapped doors */
#define FEAT_DOOR_TRAP_HEAD  0x0063
#define FEAT_DOOR_TRAP_TAIL  0x006F

/* More wall types */
/* Can't be bothered counting in hex */

#define FEAT_LIMESTONE  111
#define FEAT_SANDSTONE  112
#define FEAT_WALL_C 113
#define FEAT_EARTH      114
#define FEAT_ICE_C      115
#define FEAT_ICE_GEOTH_HC  116
#define FEAT_ICE_GEOTH_KC   117
#define FEAT_UNDER_ICE_HC  118
#define FEAT_UNDER_ICE_KC   119
#define FEAT_UNDER_WATER_H 120
#define FEAT_UNDER_WATER_K 121
#define FEAT_SHALE      122
#define FEAT_COAL       123
#define FEAT_BCOAL      124
#define FEAT_ICE_FALLS  125
#define FEAT_WATER_FALLS 126
#define FEAT_ACID_FALLS 127

/* Even more traps */
#define FEAT_TRAP_HEAD_3 0x0080
#define FEAT_TRAP_TAIL_3 0x0084


/* More floor types */
#define FEAT_ICE_WATER_K  133
#define FEAT_FLOOR_DUST 134
#define FEAT_FLOOR_EARTH 135
#define FEAT_FLOOR_RUBBLE 136
#define FEAT_FLOOR_DUST_T 137
#define FEAT_FLOOR_EARTH_T 138
#define FEAT_FLOOR_CHASM  139

/* Bridges and terrain */

#define FEAT_BRIDGE_CHASM 140
#define FEAT_CHASM      141
#define FEAT_CHASM_E    142
#define FEAT_ICE_CHASM 143
#define FEAT_ICE_FALL   144
#define FEAT_FLOOR_ICE  145
#define FEAT_ICE_WATER_H 146
#define FEAT_BRIDGE_ICEW 147
#define FEAT_ICE 148
#define FEAT_ICE_GEOTH 149
#define FEAT_UNDER_ICE 150
#define FEAT_WATER_FALL 151
#define FEAT_BRIDGE_WATER 152
#define FEAT_WATER      153
#define FEAT_WATER_H    154
#define FEAT_WATER_K    155
#define FEAT_BRIDGE_ACID 156
#define FEAT_ACID       157
#define FEAT_ACID_H     158
#define FEAT_ACID_K     159
#define FEAT_BWATER_FALLS 160
#define FEAT_LAVA_FALLS 161


/* Dummy features */

#define FEAT_DUMMY_HEAD 0x00A1
#define FEAT_DUMMY_TAIL 0x00BF

/* More terrain */
#define FEAT_SAND       192
#define FEAT_SAND_H     193
#define FEAT_SAND_T     194
#define FEAT_SAND_HT    195
#define FEAT_QSAND_H    196
#define FEAT_QSAND_K    197
#define FEAT_BRIDGE_MUD 198
#define FEAT_MUD 199
#define FEAT_MUD_H      200
#define FEAT_MUD_K      201
#define FEAT_MUD_T      202
#define FEAT_MUD_HT     203
#define FEAT_BRIDGE_BMUD 204
#define FEAT_BMUD       205
#define FEAT_VENT_BWATER 206
#define FEAT_BRIDGE_BWATER 207
#define FEAT_BWATER     208
#define FEAT_GEOTH      209
#define FEAT_GEOTH_LAVA 210
#define FEAT_VENT_GAS   211
#define FEAT_VENT_STEAM 212
#define FEAT_VENT_LAVA  213
#define FEAT_LAVA_FALL  214
#define FEAT_BRIDGE_LAVA 215
#define FEAT_LAVA       216
#define FEAT_LAVA_H     217
#define FEAT_LAVA_K     218
#define FEAT_OIL 219
#define FEAT_BOIL       220
#define FEAT_FLOOR_COAL 221
#define FEAT_FLOOR_COAL_T 222
#define FEAT_FLOOR_BCOAL 223

/* More terrain */
#define FEAT_FLOOR_BLOOD_T 305
#define FEAT_FLOOR_SLIME_T 306
#define FEAT_FLOOR_WATER_T 307
#define FEAT_FLOOR_FIRE_T 308
#define FEAT_FLOOR_ACID_T 309

#define FEAT_FLOOR_WEB 446
#define FEAT_CHASM_WEB 459

#define FEAT_GROUND 407
#define FEAT_ROCK	409
#define FEAT_GROUND_EMPTY 414
#define FEAT_GRASS 411
#define FEAT_TREE      420
#define FEAT_TREE_SHADE   421
#define FEAT_TREE_APPLE  426
#define FEAT_TREE_BROKEN 427
#define FEAT_TREE_SHADE  421
#define FEAT_TREE_SHADE_C       456
#define FEAT_TREE_SHADE_W       453
#define FEAT_TREE_BIG_S  461
#define FEAT_TREE_SHADE_S       462

#define FEAT_BUSH       435
#define FEAT_BUSH_HURT  436
#define FEAT_BUSH_FOOD  440
#define FEAT_BUSH_HURT_P 441

#define FEAT_WEB	446
#define FEAT_WEB_WEAK	447
#define FEAT_SHALLOW_PIT 457

#define FEAT_ENTRANCE 471

#define FEAT_GEYSER 711
#define FEAT_WATER_SPOUT 714
#define FEAT_ERUPTING_LAVA 722
#define FEAT_CRUMBLING_FLOOR 873
#define FEAT_TREMBLING_RUBBLE 874
#define FEAT_PULSING_RUBBLE 875




/*Feature flags - should be used instead of feature indexes unless generating.*/


#define FF1_LOS  	0x00000001L
#define FF1_PROJECT     0x00000002L
#define FF1_MOVE 	0x00000004L
#define FF1_PLACE       0x00000008L
#define FF1_DROP 	0x00000010L
#define FF1_SECRET      0x00000020L
#define FF1_NOTICE      0x00000040L
#define FF1_REMEMBER    0x00000080L
#define FF1_OPEN 	0x00000100L
#define FF1_CLOSE       0x00000200L
#define FF1_BASH 	0x00000400L
#define FF1_SPIKE       0x00000800L
#define FF1_DISARM      0x00001000L
#define FF1_ENTER       0x00002000L
#define FF1_TUNNEL      0x00004000L
#define FF1_STREAMER    0x00008000L
#define FF1_HAS_GOLD    0x00010000L
#define FF1_HAS_ITEM    0x00020000L
#define FF1_DOOR 	0x00040000L
#define FF1_TRAP 	0x00080000L
#define FF1_STAIRS      0x00100000L
#define FF1_GLYPH       0x00200000L
#define FF1_LESS 	0x00400000L
#define FF1_MORE 	0x00800000L
#define FF1_RUN  	0x01000000L
#define FF1_FLOOR       0x02000000L
#define FF1_WALL 	0x04000000L
#define FF1_PERMANENT   0x08000000L
#define FF1_INNER       0x10000000L
#define FF1_OUTER       0x20000000L
#define FF1_SOLID       0x40000000L
#define FF1_HIT_TRAP    0x80000000L

#define FF2_PATH      0x00000001
#define FF2_RIVER       0x00000002
#define FF2_LAKE	0x00000004
#define FF2_COVERED     0x00000008
#define FF2_PUSH     0x00000010
#define FF2_GLOW	0x00000020
#define FF2_LAVA	0x00000040
#define FF2_WATER       0x00000080
#define FF2_FLAVOR	0x00000100
#define FF2_SHALLOW     0x00000200
#define FF2_DEEP 	0x00000400
#define FF2_FILLED      0x00000800
#define FF2_HURT_ROCK   0x00001000
#define FF2_HURT_FIRE   0x00002000
#define FF2_HURT_COLD   0x00004000
#define FF2_HURT_ACID   0x00008000
#define FF2_ICE  	0x00010000
#define FF2_ACID 	0x00020000
#define FF2_OIL  	0x00040000
#define FF2_CHASM       0x00080000
#define FF2_CAN_CLIMB   0x00100000
#define FF2_CAN_FLY     0x00200000
#define FF2_CAN_SWIM    0x00400000
#define FF2_CAN_PASS    0x00800000
#define FF2_CAN_OOZE    0x01000000
#define FF2_CAN_DIG     0x02000000
#define FF2_HIDE_ITEM   0x04000000
#define FF2_HIDE_SNEAK  0x08000000
#define FF2_HIDE_SWIM   0x10000000
#define FF2_HIDE_DIG    0x20000000
#define FF2_KILL_HUGE   0x40000000
#define FF2_KILL_MOVE   0x80000000

#define FF3_PICK_TRAP	0x00000001
#define FF3_PICK_DOOR	0x00000002
#define FF3_ALLOC       0x00000004
#define FF3_CHEST       0x00000008
#define FF3_DROP_1D2    0x00000010
#define FF3_DROP_1D3    0x00000020
#define FF3_DROP_GOOD   0x00000040
#define FF3_DROP_GREAT  0x00000080
#define FF3_HURT_POIS   0x00000100
#define FF3_HURT_ELEC   0x00000200
#define FF3_HURT_WATER  0x00000400
#define FF3_HURT_BWATER 0x00000800
#define FF3_USE_FEAT    0x00001000
#define FF3_GET_FEAT    0x00002000
#define FF3_GROUND      0x00004000
#define FF3_OUTSIDE     0x00008000
#define FF3_EASY_HIDE   0x00010000
#define FF3_EASY_CLIMB  0x00020000
#define FF3_MUST_CLIMB  0x00040000
#define FF3_LIVING      0x00080000
#define FF3_TREE	0x00100000
#define FF3_NEED_TREE	0x00200000
#define FF3_ATTR_LITE	0x00400000
#define FF3_ATTR_ITEM	0x00800000
#define FF3_ATTR_DOOR	0x01000000
#define FF3_ATTR_WALL 	0x02000000
#define FF3_INSTANT	0x04000000
#define FF3_ADJACENT 	0x08000000
#define FF3_TIMED       0x10000000
#define FF3_ERUPT       0x20000000
#define FF3_STRIKE      0x40000000
#define FF3_SPREAD      0x80000000

/* Which features are dynamic */
#define FF3_DYNAMIC_MASK \
 (FF3_INSTANT | FF3_ADJACENT | FF3_TIMED | FF3_ERUPT | FF3_STRIKE | FF3_SPREAD)

/* Feature actions -- used to define actions performed on features */

#define FS_FLAGS1       0
#define FS_SECRET       5
#define FS_OPEN  8
#define FS_CLOSE 9
#define FS_BASH  10
#define FS_SPIKE 11
#define FS_DISARM       12
#define FS_ENTER 13
#define FS_TUNNEL       14
#define FS_STREAMER	15
#define FS_DOOR  18
#define FS_TRAP  19
#define FS_STAIRS       20
#define FS_GLYPH 21
#define FS_LESS  22
#define FS_MORE  23
#define FS_RUN   24
#define FS_FLOOR 25
#define FS_INNER 28
#define FS_SOLID 30
#define FS_HIT_TRAP     31

#define FS_FLAGS2       32
#define FS_BRIDGE       32
#define FS_WATER 39
#define FS_LAVA  40
#define FS_SHALLOW      41
#define FS_DEEP  42
#define FS_FILLED       43
#define FS_HURT_ROCK    44
#define FS_HURT_FIRE    45
#define FS_HURT_COLD    46
#define FS_HURT_ACID    47
#define FS_ACID  48
#define FS_ICE   49
#define FS_OIL   50
#define FS_CHASM 51
#define FS_KILL_HUGE    62
#define FS_KILL_MOVE    63

#define FS_FLAGS3       64
#define FS_HURT_POIS	72
#define FS_HURT_ELEC	73
#define FS_HURT_WATER	74
#define FS_HURT_BWATER	75
#define FS_USE_FEAT	76
#define FS_GET_FEAT	77
#define FS_GROUND       79
#define FS_LIVING	83
#define FS_TREE		84
#define FS_NEED_TREE	85
#define FS_INSTANT	90
#define FS_ADJACENT	91
#define FS_TIMED	92
#define FS_ERUPT	93
#define FS_STRIKE	94
#define FS_SPREAD	95

#define FS_FLAGS_END    96


/*** Spell flags ***/
/* Also used for object/artifact effects */

/* SF1 - informational and prompted equipment */

#define SF1_DETECT_DOORS 	0x00000001
#define SF1_DETECT_TRAPS 	0x00000002
#define SF1_DETECT_STAIRS       0x00000004
#define SF1_DETECT_WATER 	0x00000008
#define SF1_DETECT_GOLD  	0x00000010
#define SF1_DETECT_OBJECT       0x00000020
#define SF1_DETECT_MAGIC 	0x00000040
#define SF1_DETECT_CURSE 	0x00000080
#define SF1_DETECT_POWER	0x00000100
#define SF1_DETECT_MONSTER      0x00000200
#define SF1_DETECT_EVIL  	0x00000400
#define SF1_DETECT_LIFE 	0x00000800
#define SF1_MAP_AREA     	0x00001000
#define SF1_WIZ_LITE     	0x00002000
#define SF1_LITE_ROOM    	0x00004000
#define SF1_DARK_ROOM    	0x00008000
#define SF1_FORGET       	0x00010000
#define SF1_SELF_KNOW    	0x00020000
#define SF1_IDENT 		0x00040000
#define SF1_IDENT_MAGIC   	0x00080000
#define SF1_IDENT_SENSE  	0x00100000
#define SF1_IDENT_GAUGE  	0x00200000
#define SF1_IDENT_RUNES  	0x00400000
#define SF1_IDENT_VALUE  	0x00800000
#define SF1_IDENT_RUMOR  	0x01000000
#define SF1_IDENT_FULLY  	0x02000000
#define SF1_ACQUIREMENT   	0x04000000
#define SF1_STAR_ACQUIREMENT    0x08000000
#define SF1_ENCHANT_TOH  	0x10000000
#define SF1_ENCHANT_TOD  	0x20000000
#define SF1_ENCHANT_TOA  	0x40000000
#define SF1_ENCHANT_HIGH 	0x80000000

/* SF2 - timed abilities and modifying level */

#define SF2_AGGRAVATE    0x00000001
#define SF2_SLOW_POIS	 0x00000002
#define SF2_SLOW_DIGEST  0x00000004
#define SF2_CREATE_STAIR 0x00000008
#define SF2_TELE_LEVEL   0x00000010
#define SF2_ALTER_LEVEL  0x00000020
#define SF2_BANISHMENT   0x00000040
#define SF2_MASS_BANISHMENT       0x00000080
#define SF2_CUT			 0x00000100
#define SF2_STUN		 0x00000200
#define SF2_POISON       0x00000400
#define SF2_PARALYZE     0x00000800
#define SF2_HALLUC       0x00001000
#define SF2_SLOW  		 0x00002000
#define SF2_BLIND 		 0x00004000
#define SF2_CONFUSE      0x00008000
#define SF2_FEAR  0x00010000
#define SF2_INFRA 0x00020000
#define SF2_HASTE 0x00040000
#define SF2_HERO  0x00080000
#define SF2_SHERO 0x00100000
#define SF2_BLESS 0x00200000
#define SF2_SHIELD       0x00400000
#define SF2_INVIS	     0x00800000
#define SF2_SEE_INVIS    0x01000000
#define SF2_PROT_EVIL    0x02000000
#define SF2_RECALL       0x04000000
#define SF2_OPP_FIRE     0x08000000
#define SF2_OPP_COLD     0x10000000
#define SF2_OPP_ACID     0x20000000
#define SF2_OPP_ELEC     0x40000000
#define SF2_OPP_POIS     0x80000000

/* SF3 - healing self and timed and untimed improvements */

#define SF3_INC_STR      0x00000001
#define SF3_INC_INT      0x00000002
#define SF3_INC_WIS      0x00000004
#define SF3_INC_DEX      0x00000008
#define SF3_INC_CON      0x00000010
#define SF3_INC_CHR      0x00000020
#define SF3_CURE_STR     0x00000040
#define SF3_CURE_INT     0x00000080
#define SF3_CURE_WIS     0x00000100
#define SF3_CURE_DEX     0x00000200
#define SF3_CURE_CON     0x00000400
#define SF3_CURE_CHR     0x00000800
#define SF3_INC_EXP      0x00001000
#define SF3_CURE_EXP     0x00002000
#define SF3_FREE_ACT     0x00004000
#define SF3_CURE_MEM     0x00008000
#define SF3_PFIX_CURSE   0x00010000
#define SF3_CURE_CURSE   0x00020000
#define SF3_PFIX_CUTS    0x00040000
#define SF3_CURE_CUTS    0x00080000
#define SF3_PFIX_STUN    0x00100000
#define SF3_CURE_STUN    0x00200000
#define SF3_CURE_POIS    0x00400000
#define SF3_CURE_CONF    0x00800000
#define SF3_CURE_FOOD    0x01000000
#define SF3_CURE_FEAR    0x02000000
#define SF3_CURE_BLIND   0x04000000
#define SF3_CURE_IMAGE   0x08000000
#define SF3_DEC_FOOD   	 0x10000000
#define SF3_DEC_EXP      0x20000000
#define SF3_HOLD_SONG    0x40000000
#define SF3_THAUMATURGY  0x80000000


#define DISEASE_LOSE_STR    	0x00000001
#define DISEASE_LOSE_INT 	0x00000002
#define DISEASE_LOSE_WIS  	0x00000004
#define DISEASE_LOSE_DEX 	0x00000008
#define DISEASE_LOSE_CON   	0x00000010
#define DISEASE_LOSE_CHR  	0x00000020
#define DISEASE_HUNGER     	0x00000040
#define DISEASE_THIRST       	0x00000080
#define DISEASE_CUT   		0x00000100
#define DISEASE_STUN  		0x00000200
#define DISEASE_POISON       	0x00000400
#define DISEASE_HALLUC       	0x00000800
#define DISEASE_SLOW  		0x00001000
#define DISEASE_BLIND 		0x00002000
#define DISEASE_CONFUSE      	0x00004000
#define DISEASE_FEAR  		0x00008000
#define DISEASE_AMNESIA		0x00010000
#define DISEASE_CURSE		0x00020000
#define DISEASE_DISPEL    	0x00040000
#define DISEASE_SLEEP		0x00080000
#define DISEASE_PETRIFY		0x00100000
#define DISEASE_PARALYZE     	0x00200000
#define DISEASE_STASTIS		0x00400000
#define DISEASE_DRAIN_HP 	0x00800000
#define DISEASE_DRAIN_MANA	0x01000000
#define DISEASE_DRAIN_EXP	0x02000000
#define DISEASE_DISEASE       	0x04000000
#define DISEASE_QUICK     	0x08000000
#define DISEASE_POWER     	0x10000000
#define DISEASE_LIGHT     	0x20000000
#define DISEASE_HEAVY     	0x40000000
#define DISEASE_PERMANENT    	0x80000000


/* Maximum number of disease flags that can randomly affect the player */
#define DISEASE_TYPES 17
#define DISEASE_BLOWS 23
#define DISEASE_DRAINING 23	/* Index of disease_drain_hp */
#define DISEASE_SPECIAL 25
#define DISEASE_TYPES_HEAVY 26

#define SPELL_RECHARGE   1
#define SPELL_IDENT_TVAL 2
#define SPELL_ENCHANT_TVAL      3
#define SPELL_BRAND_WEAPON      4
#define SPELL_BRAND_ARMOR       5
#define SPELL_BRAND_ITEM 6
#define SPELL_BRAND_AMMO       7
#define SPELL_WARD_GLYPH 8
#define SPELL_WARD_TRAP  9
#define SPELL_SUMMON     10
#define SPELL_SUMMON_RACE       11
#define SPELL_SUMMON_GROUP_IDX     12
#define SPELL_CREATE_KIND     13
#define SPELL_RAISE_RACE      14
#define SPELL_AIM_SUMMON     15
#define SPELL_CURE_DISEASE	16
#define SPELL_PFIX_CONF		17
#define SPELL_PFIX_POIS		18
#define SPELL_IDENT_PACK	19
#define SPELL_CHANGE_SHAPE	20
#define SPELL_REVERT_SHAPE	21
#define SPELL_DETECT_MIND	22
#define SPELL_REFUEL		23
#define SPELL_INVEN_WIELD      24
#define SPELL_INVEN_BOW       25
#define SPELL_INVEN_LEFT      26
#define SPELL_INVEN_RIGHT     27
#define SPELL_INVEN_NECK      28
#define SPELL_INVEN_LITE      29
#define SPELL_INVEN_BODY      30
#define SPELL_INVEN_OUTER     31
#define SPELL_INVEN_ARM       32
#define SPELL_INVEN_HEAD      33
#define SPELL_INVEN_HANDS     34
#define SPELL_INVEN_FEET      35
#define	SPELL_USE_OBJECT	  36
#define SPELL_IDENT_NAME		37
#define SPELL_RELEASE_CURSE		38
#define SPELL_CONCENTRATE_LITE	39
#define SPELL_CONCENTRATE_LIFE	40
#define SPELL_CONCENTRATE_WATER	41
#define SPELL_SET_RETURN		42
#define SPELL_SET_OR_MAKE_RETURN	43
#define SPELL_BLOOD_BOND		44
#define SPELL_MINDS_EYE			45
#define SPELL_LIGHT_CHAMBERS	46
#define SPELL_REST_UNTIL_DUSK	47
#define SPELL_REST_UNTIL_DAWN	48
#define SPELL_MAGIC_BLOW	49
#define SPELL_MAGIC_SHOT	50
#define SPELL_MAGIC_HURL	51
#define SPELL_ACCURATE_BLOW	52
#define SPELL_ACCURATE_SHOT	53
#define SPELL_ACCURATE_HURL	54
#define SPELL_DAMAGING_BLOW	55
#define SPELL_DAMAGING_SHOT	56
#define SPELL_DAMAGING_HURL	57
#define SPELL_CURSE_WEAPON	58
#define SPELL_CURSE_ARMOR	59
#define SPELL_REVEAL_SECRETS	60
#define SPELL_DETECT_FIRE	61
#define SPELL_REGION		62
#define SPELL_SET_TRAP		63
#define SPELL_DELAY_SPELL	64
#define SPELL_AIM_SUMMON_RACE    65
#define SPELL_AIM_SUMMON_GROUP_IDX    66
#define SPELL_CREATE     67
#define SPELL_CREATE_RACE       68
#define SPELL_CREATE_GROUP_IDX     69
#define SPELL_AIM_CREATE     70
#define SPELL_AIM_CREATE_RACE       71
#define SPELL_AIM_CREATE_GROUP_IDX     72
#define SPELL_SUMMONS     73
#define SPELL_SUMMONS_RACE       74
#define SPELL_SUMMONS_GROUP_IDX     75
#define SPELL_AIM_SUMMONS     76
#define SPELL_AIM_SUMMONS_RACE       77
#define SPELL_AIM_SUMMONS_GROUP_IDX     78


/*** Important artifact indexes (see "lib/edit/artifact.txt") ***/

#define ART_POWER			13
#define ART_MORGOTH			34
#define ART_GROND			111


/*
 * Maximum length of artifact names
 */
#define MAX_LEN_ART_NAME 30

#define S_WORD 26
#define E_WORD S_WORD

/*
 * Hack -- first "normal" artifact in the artifact list.  All of
 * the artifacts with indexes from 1 to 15 are "special" (lights,
 * rings, amulets), and the ones from 16 to 127 are "normal".
 */
#define ART_MIN_NORMAL		16



/*** Ego-Item indexes (see "lib/edit/ego_item.txt") ***/


/* Nothing */
/* xxx */
/* xxx */
/* xxx */

/* Body Armor */
#define EGO_RESIST_ACID		4
#define EGO_RESIST_ELEC		5
#define EGO_RESIST_FIRE		6
#define EGO_RESIST_COLD		7
#define EGO_RESISTANCE		8
#define EGO_ELVENKIND		9
#define EGO_ARMR_VULN		10
#define EGO_PERMANENCE		11
#define EGO_ARMR_DWARVEN	12
/* xxx */
/* xxx */
/* xxx */

/* Shields */
#define EGO_ENDURE_ACID		16
#define EGO_ENDURE_ELEC		17
#define EGO_ENDURE_FIRE		18
#define EGO_ENDURE_COLD		19
#define EGO_ENDURANCE		20
#define EGO_SHIELD_ELVENKIND	21
#define EGO_SHIELD_PRESERVATION	22
#define EGO_SHIELD_VULN		23

/* Crowns and Helms */
#define EGO_INTELLIGENCE	24
#define EGO_WISDOM			25
#define EGO_BEAUTY			26
#define EGO_MAGI			27
#define EGO_MIGHT			28
#define EGO_LORDLINESS		29
#define EGO_SEEING			30
#define EGO_INFRAVISION		31
#define EGO_LITE			32
#define EGO_TELEPATHY		33
#define EGO_REGENERATION	34
#define EGO_TELEPORTATION	35
#define EGO_STUPIDITY		36
#define EGO_NAIVETY			37
#define EGO_UGLINESS		38
#define EGO_SICKLINESS		39

/* Cloaks */
#define EGO_PROTECTION		40
#define EGO_STEALTH			41
#define EGO_AMAN			42
#define EGO_CLOAK_MAGI		43
#define EGO_ENVELOPING		44
#define EGO_VULNERABILITY	45
#define EGO_IRRITATION		46
/* xxx */

/* Gloves */
#define EGO_POWER			51
#define EGO_GLOVES_THIEVERY	52
#define EGO_GAUNTLETS_COMBAT	53
/* xxx */

/* Boots */
#define EGO_SLOW_DESCENT	56
#define EGO_QUIET			57
#define EGO_MOTION			58
#define EGO_SPEED			59
#define EGO_STABILITY		60
#define EGO_NOISE			61
#define EGO_SLOWNESS		62
#define EGO_ANNOYANCE		63

/* Weapons */
#define EGO_HA				64
#define EGO_DF				65
#define EGO_BLESS_BLADE		66
#define EGO_GONDOLIN		67
#define EGO_WEST			68
#define EGO_ATTACKS			69
#define EGO_FURY			70
/* xxx */
#define EGO_BRAND_ACID		72
#define EGO_BRAND_ELEC		73
#define EGO_BRAND_FIRE		74
#define EGO_BRAND_COLD		75
#define EGO_BRAND_POIS		76
/* xxx */
/* xxx */
/* xxx */
#define EGO_SLAY_ANIMAL		80
#define EGO_SLAY_EVIL		81
#define EGO_SLAY_UNDEAD		82
#define EGO_SLAY_DEMON		83
#define EGO_SLAY_ORC		84
#define EGO_SLAY_TROLL		85
#define EGO_SLAY_GIANT		86
#define EGO_SLAY_DRAGON		87
#define EGO_KILL_ANIMAL		88
#define EGO_KILL_EVIL		89
#define EGO_KILL_UNDEAD		90
#define EGO_KILL_DEMON		83
#define EGO_KILL_ORC		84
#define EGO_KILL_TROLL		85
#define EGO_KILL_GIANT		86
#define EGO_KILL_DRAGON		95
/* xxx */
/* xxx */
/* xxx */
/* xxx */
#define EGO_DIGGING			100
#define EGO_DIGGER_EARTHQUAKE		101
#define EGO_MORGUL			102
/* xxx */

/* Bows */
#define EGO_ACCURACY		104
#define EGO_VELOCITY		105
#define EGO_BOW_LORIEN		106
#define EGO_CROSSBOW_HARAD	107
#define EGO_EXTRA_MIGHT		108
#define EGO_EXTRA_SHOTS		109
#define EGO_SLING_BUCKLAND	110
#define EGO_NAZGUL			111

/* Ammo */
#define EGO_HURT_ANIMAL		112
#define EGO_HURT_EVIL		113
#define EGO_HURT_UNDEAD		114
#define EGO_HURT_DEMON		115
#define EGO_HURT_ORC		116
#define EGO_HURT_TROLL		117
#define EGO_HURT_GIANT		118
#define EGO_HURT_DRAGON		119
#define EGO_AMMO_HOLY		120
#define EGO_AMMO_VENOM		121
#define EGO_FLAME			122
#define EGO_FROST			123
#define EGO_WOUNDING		124
#define EGO_BACKBITING		125
#define EGO_SHATTERED		126
#define EGO_BLASTED			127



/*** Object "tval" and "sval" codes ***/


/*
 * Used for uncontrolled objects
 */
#define UNCONTROLLED_CHANCE		100	/* Chance in 1 in x chance of uncontrolled object activating */
#define UNCONTROLLED_CONTROL	50	/* Number of random activations before controlling this object */


/*
 * XXX XXX XXX Do not use these hard-coded values.
 */
#define OBJ_GOLD_LIST   480     /* First "gold" entry */
#define MAX_GOLD        18      /* Number of "gold" entries */

/*
 * The values for the "tval" field of various objects.
 *
 * This value is the primary means by which items are sorted in the
 * player inventory, followed by "sval" and "cost".
 *
 * Note that a "BOW" with tval = 19 and sval S = 10*N+P takes a missile
 * weapon with tval = 16+N, and does (xP) damage when so combined.  This
 * fact is not actually used in the source, but it kind of interesting.
 *
 * Note that as of 2.7.8, the "item flags" apply to all items, though
 * only armor and weapons and a few other items use any of these flags.
 */

#define TV_BONE   1      /* Bones/Skeletons ('~') */
#define TV_HOLD   2      /* Containers (Bottles etc). ('~') */
#define TV_JUNK   3      /* Sticks, Pottery, etc ('~') */
#define TV_SPIKE  5      /* Spikes ('~') */
#define TV_BODY   6      /* Body Parts ('~') */
#define TV_CHEST  7      /* Chest -- no longer used */
#define TV_SKIN   8      /* Skin/Feathers/Scales ('~') */
#define TV_EGG    9      /* Eggs ('~') */
#define TV_SPELL 10      /* Magic spells (varies) */
#define TV_STATUE       11      /* Statues ('~') */
#define TV_ASSEMBLY	12	/* Assemblys ('~') */
#define TV_ROPE		14	/* Ropes or chains ('~') */
#define TV_SHOT   16      /* Ammo for slings */
#define TV_ARROW 17      /* Ammo for bows */
#define TV_BOLT  18      /* Ammo for x-bows */
#define TV_BOW   19      /* Slings/Bows/Xbows */
#define TV_DIGGING      20      /* Shovels/Picks */
#define TV_HAFTED       21      /* Priest Weapons */
#define TV_POLEARM      22      /* Axes and Pikes */
#define TV_SWORD 23      /* Edged Weapons */
#define TV_INSTRUMENT   24      /* Musical instruments */
#define TV_FIREARM 25		/* Guns */
#define TV_BLESSED 26	/* Fake tval to indicate temple will buy blessed weapons */
#define TV_BOOTS 30      /* Boots */
#define TV_GLOVES       31      /* Gloves */
#define TV_HELM  32      /* Helms */
#define TV_CROWN 33      /* Crowns */
#define TV_SHIELD       34      /* Shields */
#define TV_CLOAK 35      /* Cloaks */
#define TV_SOFT_ARMOR   36      /* Soft Armor */
#define TV_HARD_ARMOR   37      /* Hard Armor */
#define TV_DRAG_ARMOR   38      /* Dragon Scale Mail */
#define TV_LITE  39      /* Lites (including Specials) */
#define TV_AMULET       40      /* Amulets (including Specials) */
#define TV_RING  45      /* Rings (including Specials) */
#define TV_STAFF 55
#define TV_WAND  65
#define TV_ROD   66
#define TV_SCROLL       70
#define TV_MAP		72
#define TV_POTION       75
#define TV_FLASK 77
#define TV_MUSHROOM	79
#define TV_FOOD  80
#define TV_STUDY	85
#define TV_MAGIC_BOOK   90
#define TV_PRAYER_BOOK  91
#define TV_SONG_BOOK    92
#define TV_RUNESTONE    93
#define TV_TATTOO		94
#define TV_RACE	 97	/* Used for racial activations */
#define TV_BAG		98	/* Containers for other items */
#define TV_SERVICE	99	/* Services have special meanings in stores */
#define TV_GOLD  100     /* Gold or higher tvals can only be picked up by players */
#define TV_GEMS  101

/* The "sval" codes for TV_BONE */
#define SV_BONE_SKULL 1
#define SV_BONE_BONE  2
#define SV_BONE_SKELETON     3
#define SV_BONE_TEETH 4

/* The "sval" codes for TV_HOLD */
#define SV_HOLD_BOTTLE       1
#define SV_HOLD_BOX   3
#define SV_HOLD_CAGE  4

/* The "sval" codes for TV_JUNK */
#define SV_JUNK_PEBBLE	     0
#define SV_JUNK_ROCK	     1
#define SV_JUNK_SHARD 3
#define SV_JUNK_STICK	     6
#define SV_JUNK_STUMP	     7
#define SV_JUNK_BRANCH	     8
#define SV_JUNK_SAND  9
#define SV_JUNK_EARTH 10
#define SV_JUNK_MUD   11
#define SV_JUNK_DUST  12
#define SV_JUNK_ICE   13

/* The "sval" codes for TV_BODY */
#define SV_BODY_CORPSE       1
#define SV_BODY_HEAD  2
#define SV_BODY_HAND  3
#define SV_BODY_ARM   4
#define SV_BODY_LEG   6
#define SV_BODY_WING  7
#define SV_BODY_CLAW  12
#define SV_BODY_HEADLESS  13
#define SV_BODY_BUTCHERED  14
#define SV_BODY_MEAT 15

/* The "sval" codes for TV_SPELL */
#define SV_SPELL_COUNTER	1

/* The "sval" codes for TV_STATUE */
#define SV_STATUE_STONE       2
#define SV_STATUE_WOOD		3
#define SV_STATUE_POT		16

/* The "sval" codes for TV_ASSEMBLY */
#define SV_ASSEMBLY_NONE   	 1
#define SV_ASSEMBLY_ARM_L	 2
#define SV_ASSEMBLY_PART_ARM_L 	 3
#define SV_ASSEMBLY_ARM_R	 4
#define SV_ASSEMBLY_PART_ARMS	 5
#define SV_ASSEMBLY_HAND_L	 6
#define SV_ASSEMBLY_MISS_HAND_R  7
#define SV_ASSEMBLY_HAND_R       8
#define SV_ASSEMBLY_PART_HANDS   9
#define SV_ASSEMBLY_LEG_L	 10
#define SV_ASSEMBLY_PART_LEG_L	 11
#define SV_ASSEMBLY_LEG_R	 12
#define SV_ASSEMBLY_PART_LEGS	 13
#define SV_ASSEMBLY_HEAD	 14
#define SV_ASSEMBLY_FULL         15
#define SV_ASSEMBLY_ARMS	 16
#define SV_ASSEMBLY_HANDS   	 17
#define SV_ASSEMBLY_PART_HAND_L  18
#define SV_ASSEMBLY_PART_ARM_R   19
#define SV_ASSEMBLY_PART_HAND_R  20
#define SV_ASSEMBLY_MISS_HAND_L  21
#define SV_ASSEMBLY_LEGS	 22
#define SV_ASSEMBLY_PART_LEG_R	 23
#define SV_MAX_ASSEMBLY		24

/* The "sval" codes for TV_ROPE */
#define SV_ROPE_ROPE	1
#define SV_ROPE_CHAIN	2
#define SV_ROPE_ELVEN	4

/* The "sval" codes for TV_SKIN */
#define SV_SKIN_SKIN  1
#define SV_SKIN_SCALES 2
#define SV_SKIN_FEATHERS      3
#define SV_SKIN_FURS   4
#define SV_SKIN_SCALE_COAT 5
#define SV_SKIN_FEATHER_COAT      6
#define SV_SKIN_FUR_COAT   7

/* The "sval" codes for TV_EGG */
#define SV_EGG_EGG    1
#define SV_EGG_SPORE  2
#define SV_EGG_SEED  3
#define SV_EGG_CHRYSALIS	4

/* The "sval" codes for TV_SPELL */
/*
 * Note these probably will have to not conflict with the sval for
 * the normal item(s) in the same slot. Thus the non-contiguous svals.
 */
#define SV_LITE_WIZARD		10
#define SV_PSYCHIC_CROWN	13
#define SV_HAMMER_UNDEAD	25
#define SV_HAMMER_DEMON		26
#define SV_QUARTERSTAFF_RUNE	30
#define SV_BLADE_ACID		31
#define SV_BLADE_ELEC		32
#define SV_BLADE_FIRE		33
#define SV_BLADE_COLD		34
#define SV_STONESKIN		35
#define SV_DRAGONSCALES  36

#define SV_RUNIC_TATTOO		0
#define SV_WOAD				2




/* The "sval" codes for TV_SHOT/TV_ARROW/TV_BOLT */
#define SV_AMMO_LIGHT		0	/* pebbles */
#define SV_AMMO_NORMAL		1	/* shots, arrows, bolts */
#define SV_AMMO_HEAVY		2	/* seeker arrows and bolts */
#define SV_AMMO_SPECIAL		3	/* special arrows and bolts */
#define SV_AMMO_STEEL		5	/* steel arrows and bolts */
#define SV_AMMO_GRAPPLE		6	/* grapple arrows and bolts */

/* The "sval" codes for TV_BOW */
#define SV_SLING			2
#define SV_SHORT_BOW		12
#define SV_LONG_BOW			13
#define SV_HAND_XBOW		22
#define SV_LIGHT_XBOW		23
#define SV_HEAVY_XBOW		24

/* The "sval" codes for TV_DIGGING */
#define SV_SHOVEL			1
#define SV_GNOMISH_SHOVEL	2
#define SV_DWARVEN_SHOVEL	3
#define SV_PICK				4
#define SV_ORCISH_PICK		5
#define SV_DWARVEN_PICK		6
#define SV_MATTOCK			7

/* The "sval" values for TV_HAFTED */
#define SV_THROWING_HAMMER    	        1	/* 2d4 */
#define SV_WHIP					2	/* 1d4 */
#define SV_QUARTERSTAFF			3	/* 1d9 */
#define SV_BATON				4	/* 1d5 */
#define SV_MACE					5	/* 2d4 */
#define SV_BALL_AND_CHAIN		6	/* 2d4 */
#define SV_WAR_HAMMER			8	/* 3d3 */
#define SV_LUCERN_HAMMER		10	/* 2d5 */
#define SV_MORNING_STAR			12	/* 2d6 */
#define SV_FLAIL				13	/* 2d6 */
#define SV_LEAD_FILLED_MACE		15	/* 3d4 */
#define SV_TWO_HANDED_MACE		16	/* 4d4 */
#define SV_TWO_HANDED_FLAIL		18	/* 3d6 */
#define SV_MACE_OF_DISRUPTION	20	/* 5d8 */
#define SV_GROND				50	/* 3d4 */

/* The "sval" values for TV_POLEARM */
#define SV_DART					1
#define SV_JAVELIN				2	/* 1d6 */
#define SV_AWL_PIKE				4	/* 1d8 */
#define SV_SPEAR  				5	/* 1d8 */
#define SV_HARPOON				6	/* 1d8 */
#define SV_PIKE					8	/* 2d5 */
#define SV_BEAKED_AXE			10	/* 2d6 */
#define SV_BROAD_AXE			11	/* 2d6 */
#define SV_GLAIVE				13	/* 2d6 */
#define SV_TRIDENT			14	/* 3d4 */
#define SV_HALBERD			15	/* 3d5 */
#define SV_SCYTHE				17	/* 5d3 */
#define SV_TWO_HANDED_SPEAR		20	/* 2d8 */
#define SV_BATTLE_AXE			22	/* 2d8 */
#define SV_GREAT_AXE			25	/* 4d4 */
#define SV_LANCE				27	/* 3d8 */
#define SV_LOCHABER_AXE			28	/* 3d8 */
#define SV_SCYTHE_OF_SLICING	30	/* 8d4 */

/* The "sval" codes for TV_SWORD */
#define SV_BROKEN_DAGGER		3	/* 1d1 */
#define SV_BROKEN_SWORD			2	/* 1d2 */
#define SV_DAGGER				4	/* 1d4 */
#define SV_MAIN_GAUCHE			5	/* 1d5 */
#define SV_RAPIER				7	/* 1d6 */
#define SV_SMALL_SWORD			8	/* 1d6 */
#define SV_SHORT_SWORD			10	/* 1d7 */
#define SV_SABRE				11	/* 1d7 */
#define SV_CUTLASS				12	/* 1d7 */
#define SV_TULWAR				15	/* 2d4 */
#define SV_BROAD_SWORD			16	/* 2d5 */
#define SV_LONG_SWORD			17	/* 2d5 */
#define SV_SCIMITAR				18	/* 2d5 */
#define SV_KATANA				20	/* 3d4 */
#define SV_BASTARD_SWORD		21	/* 3d4 */
#define SV_TWO_HANDED_SWORD		25	/* 3d6 */
#define SV_EXECUTIONERS_SWORD	28	/* 4d5 */
#define SV_BLADE_OF_CHAOS		30	/* 6d5 */

/* The "sval" codes for TV_SHIELD */
#define SV_SMALL_LEATHER_SHIELD		2
#define SV_SMALL_METAL_SHIELD		3
#define SV_LARGE_LEATHER_SHIELD		4
#define SV_LARGE_METAL_SHIELD		5
#define SV_SHIELD_OF_DEFLECTION		10

/* These are correct */
/* The "sval" codes for TV_HELM */
#define SV_HARD_LEATHER_CAP		2
#define SV_METAL_CAP			3
#define SV_IRON_HELM			5
#define SV_STEEL_HELM			6
#define SV_IRON_CROWN			10
#define SV_GOLDEN_CROWN			11
#define SV_JEWELED_CROWN		12
#define SV_MORGOTH				50

/* The "sval" codes for TV_BOOTS */
#define SV_PAIR_OF_SOFT_LEATHER_BOOTS	2
#define SV_PAIR_OF_HARD_LEATHER_BOOTS	3
#define SV_PAIR_OF_METAL_SHOD_BOOTS		6

/* The "sval" codes for TV_CLOAK */
#define SV_CLOAK					1
#define SV_TABARD				3
#define SV_LEATHER_COAT				5
#define SV_SHADOW_CLOAK				6
#define SV_RIVETED_LEATHER_COAT			8
#define SV_CHAIN_MAIL_COAT			13

/* The "sval" codes for TV_GLOVES */
#define SV_SET_OF_LEATHER_GLOVES	1
#define SV_SET_OF_GAUNTLETS			2
#define SV_SET_OF_CESTI				5

/* The "sval" codes for TV_SOFT_ARMOR */
#define SV_FILTHY_RAG				1
#define SV_ROBE						2
#define SV_SOFT_LEATHER_ARMOR		4
#define SV_SOFT_STUDDED_LEATHER		5
#define SV_HARD_LEATHER_ARMOR		6
#define SV_HARD_STUDDED_LEATHER		7
#define SV_LEATHER_SCALE_MAIL		11

/* The "sval" codes for TV_HARD_ARMOR */
#define SV_RUSTY_CHAIN_MAIL			1	/* 14- */
#define SV_METAL_SCALE_MAIL			3	/* 13 */
#define SV_CHAIN_MAIL				4	/* 14 */
#define SV_AUGMENTED_CHAIN_MAIL		6	/* 16 */
#define SV_DOUBLE_CHAIN_MAIL		7	/* 16 */
#define SV_BAR_CHAIN_MAIL			8	/* 18 */
#define SV_METAL_BRIGANDINE_ARMOUR	9	/* 19 */
#define SV_PARTIAL_PLATE_ARMOUR		12	/* 22 */
#define SV_METAL_LAMELLAR_ARMOUR	13	/* 23 */
#define SV_FULL_PLATE_ARMOUR		15	/* 25 */
#define SV_RIBBED_PLATE_ARMOUR		18	/* 28 */
#define SV_MITHRIL_CHAIN_MAIL		20	/* 28+ */
#define SV_MITHRIL_PLATE_MAIL		25	/* 35+ */
#define SV_ADAMANTITE_PLATE_MAIL	30	/* 40+ */

/* The "sval" codes for TV_DRAG_ARMOR */
#define SV_DRAGON_BLACK		1
#define SV_DRAGON_BLUE		2
#define SV_DRAGON_WHITE		3
#define SV_DRAGON_RED		4
#define SV_DRAGON_GREEN		5
#define SV_DRAGON_MULTIHUED	6
#define SV_DRAGON_ETHER		10
#define SV_DRAGON_LAW		12
#define SV_DRAGON_COPPER	13
#define SV_DRAGON_BRONZE	14
#define SV_DRAGON_SILVER	15
#define SV_DRAGON_GOLD		16
#define SV_DRAGON_BRASS		17
#define SV_DRAGON_CHAOS   	18
#define SV_DRAGON_BALANCE	20
#define SV_DRAGON_POWER		30

/* These are correct */
/* The "sval" codes for TV_LITE */
#define SV_LITE_TORCH		0
#define SV_LITE_LANTERN		1
#define SV_LITE_GALADRIEL	4
#define SV_LITE_ELENDIL		5
#define SV_LITE_THRAIN		6
#define SV_LITE_PALANTIR	7

/* The "sval" codes for TV_AMULET */
#define SV_AMULET_DOOM			0
#define SV_AMULET_TELEPORT		1
#define SV_AMULET_ADORNMENT		2
#define SV_AMULET_SLOW_DIGEST	3
#define SV_AMULET_RESIST_ACID	4
#define SV_AMULET_SEARCHING		5
#define SV_AMULET_WISDOM		6
#define SV_AMULET_CHARISMA		7
#define SV_AMULET_THE_MAGI		8
#define SV_AMULET_SUSTENANCE	9
#define SV_AMULET_CARLAMMAS		10
#define SV_AMULET_INGWE			11
#define SV_AMULET_DWARVES		12
#define SV_AMULET_ESP			13
#define SV_AMULET_RESIST		14
#define SV_AMULET_REGEN			15
#define SV_AMULET_ELESSAR		16
#define SV_AMULET_EVENSTAR		17
#define SV_AMULET_DEVOTION		18
#define SV_AMULET_WEAPONMASTERY	19
#define SV_AMULET_TRICKERY		20
#define SV_AMULET_INFRAVISION		21
#define SV_AMULET_RESIST_LIGHTNING  22
#define SV_AMULET_SERPENTS      23

/* These may be incorrect */
/* The "sval" codes for TV_RING */
#define SV_RING_WOE				0
#define SV_RING_AGGRAVATION		1
#define SV_RING_WEAKNESS		2
#define SV_RING_STUPIDITY		3
#define SV_RING_TELEPORTATION	4
/* xxx */
#define SV_RING_SLOW_DIGESTION	6
#define SV_RING_FEATHER_FALL	7
#define SV_RING_RESIST_FIRE		8
#define SV_RING_RESIST_COLD		9
#define SV_RING_SUSTAIN_STR		10
#define SV_RING_SUSTAIN_INT		11
#define SV_RING_SUSTAIN_WIS		12
#define SV_RING_SUSTAIN_DEX		13
#define SV_RING_SUSTAIN_CON		14
#define SV_RING_SUSTAIN_CHR		15
#define SV_RING_PROTECTION		16
#define SV_RING_ACID			17
#define SV_RING_FLAMES			18
#define SV_RING_ICE				19
#define SV_RING_RESIST_POIS		20
#define SV_RING_FREE_ACTION		21
#define SV_RING_SEE_INVIS		22
#define SV_RING_SEARCHING		23
#define SV_RING_STR				24
#define SV_RING_INT				25
#define SV_RING_DEX				26
#define SV_RING_CON				27
#define SV_RING_ACCURACY		28
#define SV_RING_DAMAGE			29
#define SV_RING_SLAYING			30
#define SV_RING_SPEED 			31
#define SV_RING_BARAHIR			32
#define SV_RING_TULKAS			33
#define SV_RING_NARYA			34
#define SV_RING_NENYA			35
#define SV_RING_VILYA			36
#define SV_RING_POWER			37
#define SV_RING_LIGHTNING		38


/* The "sval" codes for TV_STAFF */
#define SV_STAFF_DARKNESS		0
#define SV_STAFF_SUMMONING		3
#define SV_STAFF_TELEPORTATION	4
#define SV_STAFF_STARLITE		7
#define SV_STAFF_LITE			8
#define SV_STAFF_MAPPING		9
#define SV_STAFF_CURING			17
#define SV_STAFF_HEALING		18
#define SV_STAFF_THE_MAGI		19
#define SV_STAFF_SPEED			22
#define SV_STAFF_DISPEL_EVIL	24
#define SV_STAFF_POWER			25
#define SV_STAFF_HOLINESS		26
#define SV_STAFF_BANISHMENT		27
#define SV_STAFF_EARTHQUAKES	28
#define SV_STAFF_DESTRUCTION	29
#define SV_STAFF_CURE_SERIOUS	31
#define SV_STAFF_CURE_MORTAL	32
#define SV_STAFF_PERILOUS_SUMMONING 33

/* The "sval" codes for TV_WAND */
#define SV_WAND_HEAL_MONSTER	0
#define SV_WAND_HASTE_MONSTER	1
#define SV_WAND_CLONE_MONSTER	2
#define SV_WAND_TELEPORT_AWAY	3
#define SV_WAND_DISARMING		4
#define SV_WAND_TRAP_DOOR_DEST	5
#define SV_WAND_STONE_TO_MUD	6
#define SV_WAND_LITE			7
#define SV_WAND_SLEEP_MONSTER	8
#define SV_WAND_SLOW_MONSTER	9
#define SV_WAND_CONFUSE_MONSTER	10
#define SV_WAND_FEAR_MONSTER	11
#define SV_WAND_DRAIN_LIFE		12
#define SV_WAND_POLYMORPH		13
#define SV_WAND_STINKING_CLOUD	14
#define SV_WAND_MAGIC_MISSILE	15
#define SV_WAND_ACID_BOLT		16
#define SV_WAND_ELEC_BOLT		17
#define SV_WAND_FIRE_BOLT		18
#define SV_WAND_COLD_BOLT		19
#define SV_WAND_ACID_BALL		20
#define SV_WAND_ELEC_BALL		21
#define SV_WAND_FIRE_BALL		22
#define SV_WAND_COLD_BALL		23
#define SV_WAND_WONDER			24
#define SV_WAND_ANNIHILATION	25
#define SV_WAND_DRAGON_FIRE		26
#define SV_WAND_DRAGON_COLD		27
#define SV_WAND_DRAGON_BREATH	28

/* The "sval" codes for TV_ROD */
#define SV_ROD_HASTE_MONSTERS	0
#define SV_ROD_DETECT_CURSE		1
#define SV_ROD_DETECT_GOLD		2
#define SV_ROD_DETECT_ITEM		3
#define SV_ROD_SLOW_MONSTERS	4
#define SV_ROD_SLEEP_MONSTERS	5
#define SV_ROD_CURE_MODERATE_WOUNDS	6
#define SV_ROD_DETECT_LIFE		7
#define SV_ROD_REMOVE_CURSE		8
#define SV_ROD_DETECT_EVIL		9
#define SV_ROD_DETECT_TRAP		10
#define SV_ROD_DETECT_DOOR		11
#define SV_ROD_DETECT_MAGIC		12
#define SV_ROD_RECALL			13
#define SV_ROD_ILLUMINATION		14
#define SV_ROD_MAPPING			15
#define SV_ROD_DETECTION		16
#define SV_ROD_GAUGE_MAGIC    	17 /* Was probing */
#define SV_ROD_CURING			18
#define SV_ROD_HEALING			19
#define SV_ROD_RESTORATION		20
#define SV_ROD_SPEED			21
#define SV_ROD_DOWSING			22
#define SV_ROD_FEEDBACK			23
#define SV_ROD_DISARMING		24
#define SV_ROD_LITE			25
#define SV_ROD_SLEEP_MONSTER		26
#define SV_ROD_SLOW_MONSTER		27
#define SV_ROD_DRAIN_LIFE		28
#define SV_ROD_POLYMORPH		29
#define SV_ROD_ACID_BOLT		30
#define SV_ROD_ELEC_BOLT		31
#define SV_ROD_FIRE_BOLT		32
#define SV_ROD_COLD_BOLT		33
#define SV_ROD_ACID_BALL		34
#define SV_ROD_ELEC_BALL		35
#define SV_ROD_FIRE_BALL		36
#define SV_ROD_COLD_BALL		37
#define SV_ROD_TELEPORT_AWAY		38


/* The "sval" codes for TV_SCROLL */

#define SV_SCROLL_DARKNESS				0
#define SV_SCROLL_AGGRAVATE_MONSTER		1
#define SV_SCROLL_CURSE_ARMOR			2
#define SV_SCROLL_CURSE_WEAPON			3
#define SV_SCROLL_SUMMON_MONSTER		4
#define SV_SCROLL_SUMMON_UNDEAD			5
/* xxx (summon?) */
#define SV_SCROLL_TRAP_CREATION			7
#define SV_SCROLL_PHASE_DOOR			8
#define SV_SCROLL_TELEPORT				9
#define SV_SCROLL_TELEPORT_LEVEL		10
#define SV_SCROLL_WORD_OF_RECALL		11
#define SV_SCROLL_IDENTIFY				12
#define SV_SCROLL_STAR_IDENTIFY			13
#define SV_SCROLL_REMOVE_CURSE			14
#define SV_SCROLL_STAR_REMOVE_CURSE		15
#define SV_SCROLL_ENCHANT_ARMOR			16
#define SV_SCROLL_ENCHANT_WEAPON_TO_HIT	17
#define SV_SCROLL_ENCHANT_WEAPON_TO_DAM	18
/* xxx enchant missile? */
#define SV_SCROLL_STAR_ENCHANT_ARMOR	20
#define SV_SCROLL_STAR_ENCHANT_WEAPON	21
#define SV_SCROLL_RECHARGING			22
/* xxx */
#define SV_SCROLL_LIGHT					24
#define SV_SCROLL_MAPPING				25
#define SV_SCROLL_DETECT_GOLD			26
#define SV_SCROLL_DETECT_ITEM			27
#define SV_SCROLL_DETECT_TRAP			28
#define SV_SCROLL_DETECT_DOOR			29
#define SV_SCROLL_DETECT_INVIS			30
#define SV_SCROLL_DETECT_MAGIC			31
#define SV_SCROLL_SATISFY_HUNGER		32
#define SV_SCROLL_BLESSING				33
#define SV_SCROLL_HOLY_CHANT			34
#define SV_SCROLL_HOLY_PRAYER			35
/* xxx was monster confusion */
#define SV_SCROLL_PROTECTION_FROM_EVIL	37
#define SV_SCROLL_RUNE_OF_PROTECTION	38
#define SV_SCROLL_TRAP_DOOR_DESTRUCTION	39
#define SV_SCROLL_DETECT_CURSE   40
#define SV_SCROLL_STAR_DESTRUCTION		41
#define SV_SCROLL_DISPEL_UNDEAD			42
/* xxx */
#define SV_SCROLL_BANISHMENT				44
#define SV_SCROLL_MASS_BANISHMENT			45
#define SV_SCROLL_ACQUIREMENT			46
#define SV_SCROLL_STAR_ACQUIREMENT		47
#define SV_SCROLL_LEGEND_LORE			48
#define SV_SCROLL_ENCHANT_ARMOR_BRAND    49
#define SV_SCROLL_ENCHANT_WEAPON_BRAND   50
#define SV_SCROLL_ENCHANT_WEAPON_BLESS   51

/* The "sval" codes for TV_POTION */
#define SV_POTION_WATER				0
#define SV_POTION_APPLE_JUICE		1
#define SV_POTION_SLIME_MOLD		2
/* xxx (fixed color) */
#define SV_POTION_SLOWNESS			4
#define SV_POTION_SALT_WATER		5
#define SV_POTION_POISON			6
#define SV_POTION_BLINDNESS			7
/* xxx */
#define SV_POTION_CONFUSION			9
/* xxx */
#define SV_POTION_SLEEP				11
/* xxx */
#define SV_POTION_LOSE_MEMORIES		13
/* xxx */
#define SV_POTION_RUINATION			15
#define SV_POTION_DEC_STR			16
#define SV_POTION_DEC_INT			17
#define SV_POTION_DEC_WIS			18
#define SV_POTION_DEC_DEX			19
#define SV_POTION_DEC_CON			20
#define SV_POTION_DEC_CHR			21
#define SV_POTION_DETONATIONS		22
#define SV_POTION_DEATH				23
#define SV_POTION_INFRAVISION		24
#define SV_POTION_DETECT_INVIS		25
#define SV_POTION_SLOW_POISON		26
#define SV_POTION_CURE_POISON		27
#define SV_POTION_BOLDNESS			28
#define SV_POTION_SPEED				29
#define SV_POTION_RESIST_HEAT		30
#define SV_POTION_RESIST_COLD		31
#define SV_POTION_HEROISM			32
#define SV_POTION_BERSERK_STRENGTH	33
#define SV_POTION_CURE_LIGHT		34
#define SV_POTION_CURE_SERIOUS		35
#define SV_POTION_CURE_CRITICAL		36
#define SV_POTION_HEALING			37
#define SV_POTION_STAR_HEALING		38
#define SV_POTION_LIFE				39
#define SV_POTION_RESTORE_MANA		40
#define SV_POTION_RESTORE_EXP		41
#define SV_POTION_RES_STR			42
#define SV_POTION_RES_INT			43
#define SV_POTION_RES_WIS			44
#define SV_POTION_RES_DEX			45
#define SV_POTION_RES_CON			46
#define SV_POTION_RES_CHR			47
#define SV_POTION_INC_STR			48
#define SV_POTION_INC_INT			49
#define SV_POTION_INC_WIS			50
#define SV_POTION_INC_DEX			51
#define SV_POTION_INC_CON			52
#define SV_POTION_INC_CHR			53
/* xxx */
#define SV_POTION_AUGMENTATION			55
#define SV_POTION_ENLIGHTENMENT			56
#define SV_POTION_STAR_ENLIGHTENMENT	57
#define SV_POTION_SELF_KNOWLEDGE		58
#define SV_POTION_EXPERIENCE			59

/* These are correct */
/* The "sval" codes for TV_FLASK */
#define SV_FLASK_OIL      0
#define SV_FLASK_GUNPOWDER      1
#define SV_FLASK_ACID     2
#define SV_FLASK_BLOOD	  3
#define SV_FLASK_SLIME	  4
#define SV_FLASK_BILE	  7
#define SV_FLASK_WEB	  15

/* The sval codes for containers */
/* The "sval" codes for TV_HOLD */
#define SV_HOLD_FLASK    2


/* These may be incorrect */
/* The "sval" codes for TV_FOOD */
#define SV_FOOD_POISON			0
#define SV_FOOD_BLINDNESS		1
#define SV_FOOD_PARANOIA		2
#define SV_FOOD_CONFUSION		3
#define SV_FOOD_HALLUCINATION	4
#define SV_FOOD_PARALYSIS		5
#define SV_FOOD_WEAKNESS		6
#define SV_FOOD_SICKNESS		7
#define SV_FOOD_STUPIDITY		8
#define SV_FOOD_NAIVETY			9
#define SV_FOOD_UNHEALTH		10
#define SV_FOOD_DISEASE			11
#define SV_FOOD_CURE_POISON		12
#define SV_FOOD_CURE_BLINDNESS	13
#define SV_FOOD_CURE_PARANOIA	14
#define SV_FOOD_CURE_CONFUSION	15
#define SV_FOOD_CURE_SERIOUS	16
#define SV_FOOD_RESTORE_STR		17
#define SV_FOOD_RESTORE_CON		18
#define SV_FOOD_RESTORING		19
#define SV_FOOD_MANA                    20
#define SV_FOOD_HASTE			26
/* many missing mushrooms */

/* These are correct */
#define SV_FOOD_BISCUIT			32
#define SV_FOOD_JERKY			33
#define SV_FOOD_COOKED_MEET	34
#define SV_FOOD_RATION			35
#define SV_FOOD_SLIME_MOLD		36
#define SV_FOOD_WAYBREAD		37
#define SV_FOOD_APPLE 		        39
#define SV_FOOD_PINT_OF_ALE		40
#define SV_FOOD_PINT_OF_WINE	        41
#define SV_FOOD_PINT_OF_SPIRITS	        42
#define SV_FOOD_SPRIG_OF_ATHELAS	        43




/*
 * Special "sval" limit -- last "normal" lite
 */
#define SV_LITE_MAX_LITE	32

/*
 * Special "sval" limit -- first "aimed" rod
 */
#define SV_ROD_MIN_DIRECTION	24

/*
 * Special "sval" limit -- first "large" chest
 */
#define SV_CHEST_MIN_LARGE	4

/*
 * Special "sval" limit -- last "good" magic/prayer book
 */
#define SV_BOOK_MAX_GOOD	52

/*
 * How many books in a school?
 */
#define SV_BOOK_SCHOOL		5

/*
 * Special "sval" limit -- maximum number of bags
 */
#define SV_BAG_MAX_BAGS		29
#define SV_BAG_HARMFUL_MUSHROOMS 1

/*
 * Special "sval" value -- unknown "sval"
 */
#define SV_UNKNOWN			255


/*** Monster blow constants ***/


/*
 * Maximum number of blow descriptions
 */
#define MAX_METHOD_DESCRIPTIONS	10

/*
 * New monster blow methods
 */
#define RBM_HIT		1
#define RBM_TOUCH		2
#define RBM_PUNCH		3
#define RBM_KICK		4
#define RBM_CLAW 		5
#define RBM_BITE 		6
#define RBM_STING       7
#define RBM_VOMIT       8
#define RBM_BUTT 		9
#define RBM_CRUSH       10
#define RBM_ENGULF      11
#define RBM_PECK		12
#define RBM_CRAWL       13
#define RBM_DROOL       14
#define RBM_SLIME		15
#define RBM_SPIT		16     /* Minimum ranged attacks */
#define RBM_GAZE 		17
#define RBM_WAIL 		18
#define RBM_SPORE       19
#define RBM_LASH		20
#define RBM_BEG  		21
#define RBM_INSULT      22
#define RBM_MOAN 		23
#define RBM_SING		24	/* Maximum normal attacks */
#define RBM_TRAP 		25
#define RBM_BOULDER       26
#define RBM_AURA 		27
#define RBM_SELF 		28
#define RBM_ADJACENT    29
#define RBM_HANDS       30
#define RBM_MISSILE     31
#define RBM_BOLT_10     32		/* Spell bolt - 10% chance of beam*/
#define RBM_BOLT 		33	/* Spell bolt */
#define RBM_BEAM 		34
#define RBM_BLAST       35
#define RBM_WALL 		36
#define RBM_BALL 		37
#define RBM_CLOUD       38
#define RBM_STORM       39
#define RBM_BREATH      40
#define RBM_AREA 		41
#define RBM_LOS  		42
#define RBM_LINE 		43
#define RBM_AIM  		44
#define RBM_ORB  		45
#define RBM_STAR 		46
#define RBM_SPHERE	47
#define RBM_PANEL		48
#define RBM_LEVEL		49
#define RBM_CROSS       50
#define RBM_STRIKE      51
#define RBM_EXPLODE	52
#define RBM_ARROW	53
#define RBM_XBOLT	54		/* Crossbow bolt */
#define RBM_DART	55
#define RBM_DAGGER	56
#define RBM_SHOT 	57
#define RBM_ARC_20	58
#define RBM_ARC_30	59
#define RBM_ARC_40	60
#define RBM_ARC_50	61
#define RBM_ARC_60	62
#define RBM_FLASK	63
#define RBM_TRAIL	64
#define RBM_SHRIEK	65
#define RBM_BOLT_MINOR	66
#define RBM_BALL_MINOR	67
#define RBM_BALL_II	68
#define RBM_BALL_III	69
#define RBM_AURA_MINOR	70
#define RBM_8WAY	71
#define RBM_8WAY_II	72
#define RBM_8WAY_III	73
#define RBM_SWARM	74
#define RBM_SPIKE	75
#define RBM_AIM_AREA	76
#define RBM_SCATTER		77
#define RBM_HOWL 		78

#define RBM_MAX_NORMAL  24
#define RBM_MIN_RANGED  16


/*** Function flags ***/

#define PROJECT_NO          0
#define PROJECT_NOT_CLEAR   1
#define PROJECT_CLEAR       2




/*
 * Bit flags for the "project()", the "projectable()", and/or the
 * "project_path()" functions.
 *
 *   BEAM:  Work as a beam weapon (affect every grid passed through)
 *   ARC:   Act as an arc spell (a portion of a caster-centered ball)
 *   STAR:  Act as a starburst - a randomized ball
 *   BOOM:  Explode in some way
 *   WALL:  Affect one layer of any wall, even if not passable
 *   PASS:  Ignore walls entirely
 *   GRID:  Affect each grid in the "blast area" in some way
 *   ITEM:  Affect each object in the "blast area" in some way
 *   KILL:  Affect each monster in the "blast area" in some way
 *   PLAY:  Explicitly affect the player
 *   SAFE:  Hack -- do not affect monsters of caster's type
 *   HIDE:  Hack -- disable graphical effects of projection
 *   STOP:  Stop as soon as we hit a monster
 *   JUMP:  Jump directly to the target location
 *   THRU:  Continue "through" the target (used for projectiles)
 *   CHCK:  Note occupied grids, but do not stop at them
 *   ORTH:  Projection cannot move diagonally (used for wall spells)
 */

/* Projection types */
#define PROJECT_BEAM         0x00000001
#define PROJECT_ARC          0x00000002
#define PROJECT_STAR         0x00000004
#define PROJECT_4WAY         0x00000008 /* + */
#define PROJECT_4WAX         0x00000010 /* x */

/* What projections do */
#define PROJECT_FLOW	     0x00000020  /* Flows around corners */
#define PROJECT_BOOM         0x00000040
#define PROJECT_WALL         0x00000080	 /* Include walls */
#define PROJECT_PASS         0x00000100  /* Pass through walls*/
#define PROJECT_MISS         0x00000200  /* Pass through the first target*/
#define PROJECT_AREA         0x00000400  /* Applies damage evenly at all ranges */

/* What projections affect */
#define PROJECT_GRID         0x00000800
#define PROJECT_ITEM         0x00001000
#define PROJECT_KILL         0x00002000
#define PROJECT_PLAY         0x00004000
#define PROJECT_SELF         0x00008000
#define PROJECT_LITE         0x00010000 /* Temporarily lites up grids */
#define PROJECT_MAGIC        0x00020000 /* Resistable by monsters with resist magic */

/* Graphics */
#define PROJECT_HIDE         0x00040000
#define PROJECT_NO_REDRAW    0x00080000

/* How projections travel */
#define PROJECT_SAFE         0x00100000 /* Projection doesn't affect caster */
#define PROJECT_STOP         0x00200000 /* Stop at first target */
#define PROJECT_JUMP         0x00400000
#define PROJECT_THRU         0x00800000
#define PROJECT_CHCK         0x01000000
#define PROJECT_ORTH         0x02000000 /* Projection cannot move diagonally */
#define PROJECT_LOS		     0x04000000 /* Travel through LOS grids */
#define PROJECT_EXPAND       0x08000000 /* Spreads further in tight spaces */

/* Random projections */
#define PROJECT_FORK         0x10000000 /* Forks like lightning, 33% grids affected */
#define PROJECT_MYST         0x20000000 /* 66% grids affected */

/* Projections that don't use projection function */
#define PROJECT_TEMP		 0x40000000 /* Retain temporary effects on grid for later */
#define PROJECT_EDGE         0x80000000 /* Only affect outmost 2 radius bands */


/* Melee specific flags */
#define PR2_MELEE        0x00000001
#define PR2_RANGED       0x08000002
#define PR2_BREATH       0x00000004
#define PR2_INNATE       0x00000008
#define PR2_CUTS         0x00000010
#define PR2_STUN         0x00000020
#define PR2_SHRIEK       0x00000040
#define PR2_SLIME        0x00000080
#define PR2_TOUCH        0x00000100

/* Nonstandard projections */
#define PR2_ALL_IN_LOS   0x00000200
#define PR2_DIR_STOP     0x00000400 /* If fired in a direction, stop at the first target */
#define PR2_PANEL		 0x00000800
#define PR2_LEVEL		 0x00001000

/* Attack text modifiers */
#define PR2_ALTERNATE			0x00002000
#define PR2_HEARD				0x00004000
#define PR2_INDIRECT			0x00008000

/* Attack special effects */
#define PR2_LIGHTNING_STRIKE	0x00010000
#define PR2_CONCENTRATE_LITE	0x00020000
#define PR2_BEAM_CHANCE			0x00040000
#define PR2_SCALE_RADIUS		0x00080000
#define PR2_LARGE_RADIUS		0x00100000
#define PR2_MAGIC_MISSILE		0x00200000
#define PR2_POWER_ARC			0x00400000
#define PR2_ADD_AMMO	 		0x00800000

/* Attack can fail */
#define PR2_FAIL				0x01000000
#define PR2_EYESIGHT			0x02000000
#define PR2_SCALE_AMMO			0x04000000

/* Irregular attacks */
#define PR2_SPECIAL_CASE		0x08000000	/* Special case in the code */
#define PR2_SCATTER				0x10000000
#define PR2_AUTOMATIC			0x20000000
#define PR2_SUMMON				0x40000000
#define PR2_NO_ECOLOGY			0x80000000	/* Switch off monster ecology */


/* Flags for regions */
#define RE1_TRIGGER_MOVE		0x00000001	/* Trigger attack when moving into region */
#define RE1_LINGER				0x00000002	/* Trigger one grid when moving into region */
#define RE1_TRIGGERED			0x00000004	/* Region has been triggered this turn, and therefore ages */
#define RE1_AUTOMATIC			0x00000008	/* Automatically apply effect every update */

#define RE1_SHINING				0x00000010	/* Region is visible in darkness */
#define RE1_WALL				0x00000020	/* Advancing 'wall' of effect */
#define RE1_SEEKER				0x00000040	/* Seeker effect which hunts down targets */
#define RE1_PROJECTION			0x00000080	/* Grids affected are defined and updated as a projection */

#define RE1_SCALAR_FEATURE		0x00000100	/* Region scalar encodes a feature */
#define RE1_SCALAR_DAMAGE		0x00000200	/* Region scalar encodes damage */
#define RE1_SCALAR_VECTOR		0x00000400	/* Region scalar encodes direction and speed */
#define RE1_SCALAR_DISTANCE		0x00000800	/* Region scalar encodes distance */

#define RE1_MOVE_SOURCE			0x00001000	/* If moving region, move the source as well */
#define RE1_ATTR_EFFECT			0x00002000	/* Use attribute of effect */
#define RE1_HIT_TRAP			0x00004000	/* Handle this region as a trap */
#define RE1_RANDOM				0x00008000	/* Target a random grid in the region */

#define RE1_ACCELERATE			0x00010000	/* Delay decreases with age. If DECREASE defined, delay bottoms out at 1/2 lifespan, then increases. */
#define RE1_DECELERATE			0x00020000	/* Delay increases with age. If INCREASE defined, delay bottoms out at 1/2 lifespan, then increases. */
#define RE1_INVERSE				0x00040000	/* Invert source and target when spawning attack/subsequent region */
#define RE1_NOTICE				0x00080000	/* Noticed region? */

#define RE1_CHAIN				0x00100000	/* Set region target to be triggering location and recompute affected area. Do source as well if inversed. */
#define RE1_TRIGGER_DROP		0x00200000	/* Trigger if something dropped into the region */
#define RE1_FIXED				0x00400000	/* Ignores triggering location when triggered and use original target. */
#define RE1_SPREAD				0x00800000	/* Region pieces drift randomly. Affected by the wind. */

#define RE1_CLOCKWISE			0x01000000	/* Rotates clockwise every turn. If both, randomly choose one. */
#define RE1_COUNTER_CLOCKWISE	0x02000000	/* Rotates counter-clockwise every turn. If both, randomly choose one. */
#define RE1_TRIGGER_OPEN		0x04000000	/* Triggered by being 'opened' */
#define RE1_TRIGGER_CLOSE		0x08000000	/* Triggered by being 'closed'. Note that closing a region makes it age backwards */

#define RE1_BACKWARDS			0x10000000	/* Region ages backwards instead of forwards */
#define RE1_SOURCE_FEATURE		0x20000000	/* Attacks occur from all features in the region that match the source feature */
#define	RE1_ROOM				0x40000000	/* Region fills a room */
#define RE1_DISPLAY				0x80000000	/* Display region */


#define RE2_AUTO_LITE			0x00000000	/* Automatically apply update if in perma light  */
#define RE2_HIDE_LITE			0x00000000	/* Don't display region in perma light */
#define RE2_AIMED				0x00000000	/* Update destination if player aims while on source */
#define RE1_CLOSEST_MON			0x00000000





/* Actual projections */
#define PR1_PROJECT 0xFFFFFFFF
#define PR2_PROJECT	(PR2_ALL_IN_LOS | PR2_PANEL | PR2_LEVEL | PR2_SCATTER)


/*
 * Flags for attack descriptions.
 */
#define ATK_DESC_PRIMARY	0x0001
#define ATK_DESC_ALTERNATE	0x0002
#define ATK_DESC_HEARD		0x0004
#define ATK_DESC_INDIRECT	0x0008
#define ATK_DESC_SELF		0x0010
#define ATK_DESC_TENSE		0x0020
#define ATK_DESC_LAST		0x0040
#define ATK_DESC_EXCLAIM	0x0080	/* Finish end of sentence with excalamation mark */
#define ATK_DESC_NO_STOP	0x0100	/* Don't punctuate end of sentence */




/*Who caused the projection*/
#define SOURCE_MONSTER_START	0 /*Greater than 0 monster is the source*/

#define SOURCE_SELF				0	/* Monster targetting itself */
#define SOURCE_OBJECT			-1	/* Source is an object on floor/monster inventory */
#define SOURCE_FEATURE			-2	/* Source is a feature */
#define SOURCE_SPELL			-3	/* Source is a spell */
#define SOURCE_DISEASE			-4	/* Source is a disease */
#define SOURCE_DAYLIGHT			-5	/* Source is the sun */
#define SOURCE_BIRTH			-6	/* Source is birth of monster race */
#define SOURCE_CUTS				-7	/* Source is accumulated cuts */
#define SOURCE_POISON			-8	/* Source is accumulated poison */
#define SOURCE_HUNGER			-9	/* Source is hunger */
#define SOURCE_CURSED_ITEM		-10	/* Source is a cursed item that drains you */
#define SOURCE_ENTOMB			-11	/* Source is a feature that crushes you */
#define SOURCE_BLOOD_DEBT		-12	/* Source is a blood debt */
#define SOURCE_PLAYER_ALLY		-13
#define SOURCE_PLAYER_ATTACK	-14
#define SOURCE_PLAYER_SHOT		-15
#define SOURCE_PLAYER_THROW		-16
#define SOURCE_PLAYER_TRAP		-17
#define SOURCE_PLAYER_BREAK		-18
#define SOURCE_PLAYER_SPORE		-19
#define SOURCE_PLAYER_COATING	-20
#define SOURCE_PLAYER_EAT_MONSTER	-21
#define SOURCE_PLAYER_VAMP_DRAIN	-22
#define SOURCE_PLAYER_EAT_UNKNOWN	-23
#define SOURCE_PLAYER_QUAFF_UNKNOWN	-24
#define SOURCE_PLAYER_READ_UNKNOWN	-25
#define SOURCE_PLAYER_EAT		-26
#define SOURCE_PLAYER_QUAFF		-27
#define SOURCE_PLAYER_AIM		-28	/* Wands */
#define SOURCE_PLAYER_ZAP		-29	/* Rods - with target specified */
#define SOURCE_PLAYER_ZAP_NO_TARGET		-30	/* Rods - with no target specified */
#define SOURCE_PLAYER_READ		-31
#define SOURCE_PLAYER_USE		-32	/* Staffs*/
#define SOURCE_PLAYER_ACT_ARTIFACT	-33
#define SOURCE_PLAYER_ACT_EGO_ITEM	-34
#define SOURCE_PLAYER_ACTIVATE	-35
#define SOURCE_PLAYER_SERVICE	-36
#define SOURCE_PLAYER_WIZARD	-37
#define SOURCE_PLAYER_CAST		-38
#define SOURCE_PLAYER_END		-39

#define SOURCE_PREFIX			-11	/* Less than here or equal to here, we suffix the string, otherwise we prefix it */
#define SOURCE_PLAYER_START		-13	/* Less than here or equal to here, player is the source, and gets experience */
#define SOURCE_PLAYER_SAFE		-28	/* Less than here or equal to here, player cannot hurt themselves with safe attacks */
#define SOURCE_PLAYER_NO_TARGET	-30	/* Less than here or equal to here, no target is specified and some messages are suppressed.
									 * Note that all items less than here that could specify a target always have a 'known' effect. */

#define SOURCE_MESSAGES	4

/*
 * An arc with a width (in degrees) less than this value will lose less
 * power over distance.
 */
#define ARC_STANDARD_WIDTH     90


/*
 * Bit flags for the "enchant()" function
 */
#define ENCH_TOHIT   0x01
#define ENCH_TODAM   0x02
#define ENCH_TOAC    0x04


/*
 * Bit flags for the "target_set" function
 *
 *	KILL: Target monsters
 *	LOOK: Describe grid fully
 *	NEAR: Target monsters near the location
 *	GRID: Select from all grids
 *	PATH: Computer path instead of projection.
 *	PEEK: Describe without waiting for keypress.
 *  KIND: Target monsters of the same kind.
 *  EASY: If target is killed/lost, find another.
 *  LOST: Retargetting because killed/lost target.
 */
#define TARGET_KILL		0x0001
#define TARGET_LOOK		0x0002
#define TARGET_NEAR		0x0004
#define TARGET_GRID		0x0008
#define TARGET_PATH		0x0010
#define TARGET_PEEK		0x0020
#define TARGET_EASY		0x0040
#define TARGET_LOST		0x0080
#define TARGET_ALLY		0x0100




/*
 * Bit flags for the "monster_desc" function
 */
#define MDESC_OBJE		0x01	/* Objective (or Reflexive) */
#define MDESC_POSS		0x02	/* Possessive (or Reflexive) */
#define MDESC_IND1		0x04	/* Indefinites for hidden monsters */
#define MDESC_IND2		0x08	/* Indefinites for visible monsters */
#define MDESC_PRO1		0x10	/* Pronominalize hidden monsters */
#define MDESC_PRO2		0x20	/* Pronominalize visible monsters */
#define MDESC_HIDE		0x40	/* Assume the monster is hidden */
#define MDESC_SHOW		0x80	/* Assume the monster is visible */


/*
 * Bit flags for the "get_item" function
 */
#define USE_EQUIP		0x00000001L	/* Allow equip items */
#define USE_INVEN		0x00000002L	/* Allow inven items */
#define USE_FLOOR		0x00000004L	/* Allow floor items */
#define USE_FEATU		0x00000008L	/* Allow features (usable) */
#define USE_FEATG		0x00000010L	/* Allow features (gettable) */
#define USE_QUIVER		0x00000020L	/* Allow quiver items, forbid classic equipment */
#define USE_SELF		0x00000040L	/* Allow selection of player */
#define USE_FEATH		0x00000080L	/* Allow features (hurt by fire) */
#define USE_BAGC		0x00000100L	/* Allow bag contents */
#define USE_BAGS		0x00000200L	/* Allow whole of bag */
#define USE_SKIN		0x00000400L	/* Allow bare skin */
#define USE_ALLY		0x00000800L	/* Allow items carried by allies */
#define USE_TARGET		0x00001000L	/* Allow items carried by target */
#define USE_RANGE		0x00002000L	/* Allow ranged targets and/or allies */
#define USE_KNOWN		0x00004000L	/* Allow known targets and/or allies */
#define USE_GOLD		0x00008000L	/* Allow gold - note this is unsafe for the 'default' way of handling items. See player_drop for changes. */
#define USE_HANDLE		0x00010000L	/* Allow this command do be displayed as an option for the 'handle' command */


/*** Player flags ***/


/*
 * Bit flags for the "p_ptr->notice" variable
 */
#define PN_COMBINE		0x00000001L	/* Combine the pack */
#define PN_REORDER		0x00000002L	/* Reorder the pack */
#define PN_PICKUP       0x00000008L	/* Pick stuff up */
/* xxx (many) */


/*
 * Bit flags for the "p_ptr->update" variable
 */
#define PU_BONUS		0x00000001L	/* Calculate bonuses */
#define PU_TORCH		0x00000002L	/* Calculate torch radius */
/* xxx (many) */
#define PU_HP			0x00000010L	/* Calculate chp and mhp */
#define PU_MANA			0x00000020L	/* Calculate csp and msp */
#define PU_SPELLS		0x00000040L	/* Calculate spells */
/* xxx (many) */
#define PU_FORGET_VIEW	0x00010000L	/* Forget field of view */
#define PU_UPDATE_VIEW	0x00020000L	/* Update field of view */
/* xxx (many) */
#define PU_FORGET_FLOW	0x00100000L	/* Forget flow data */
#define PU_UPDATE_FLOW	0x00200000L	/* Update flow data */
/* xxx (many) */
#define PU_MONSTERS		0x10000000L	/* Update monsters */
#define PU_DISTANCE		0x20000000L	/* Update distances */
#define PU_ROOM_INFO     0x40000000L     /* Display room description */
#define PU_PANEL		0x80000000L	/* Update panel */


/*
 * Bit flags for the "p_ptr->redraw" variable
 */
#define PR_MISC			0x00000001L	/* Display Race/Class */
#define PR_TITLE		0x00000002L	/* Display Title */
#define PR_LEV			0x00000004L	/* Display Level */
#define PR_EXP			0x00000008L	/* Display Experience */
#define PR_STATS		0x00000010L	/* Display Stats */
#define PR_ARMOR		0x00000020L	/* Display Armor */
#define PR_HP			0x00000040L	/* Display Hitpoints */
#define PR_MANA			0x00000080L	/* Display Mana */
#define PR_GOLD			0x00000100L	/* Display Gold */
#define PR_DEPTH		0x00000200L	/* Display Depth */
/* xxx */
#define PR_HEALTH		0x00000800L	/* Display Health Bar */
#define PR_CUT			0x00001000L	/* Display Extra (Cut) */
#define PR_STUN			0x00002000L	/* Display Extra (Stun) */
#define PR_HUNGER		0x00004000L	/* Display Extra (Hunger) */
/* xxx */
#define PR_BLIND		0x00010000L	/* Display Extra (Blind) */
#define PR_CONFUSED		0x00020000L	/* Display Extra (Confused) */
#define PR_AFRAID		0x00040000L	/* Display Extra (Afraid) */
#define PR_POISONED		0x00080000L	/* Display Extra (Poisoned) */
#define PR_STATE		0x00100000L	/* Display Extra (State) */
#define PR_SPEED		0x00200000L	/* Display Extra (Speed) */
#define PR_STUDY		0x00400000L	/* Display Extra (Study) */
#define PR_EXTRA		0x01000000L	/* Display Extra Info */
#define PR_BASIC		0x02000000L	/* Display Basic Info */
#define PR_ITEM_LIST		0x04000000L     /* Display Item List */
#define PR_MAP			0x08000000L	/* Display Map */
#define PR_DISEASE		0x10000000L	/* Display Extra (Disease) */
#define PR_AMNESIA		0x20000000L	/* Display Extra (Cursed) */
#define PR_CURSED		0x40000000L	/* Display Extra (Amnesia) */
#define PR_PETRIFY		0x80000000L	/* Display Extra (Petrify) */

/*
 * Bit flags for the "p_ptr->window" variable (etc)
 */
#define PW_INVEN	   	0x00000001L /* Display inven/equip */
#define PW_EQUIP	    	0x00000002L /* Display equip/inven */
#define PW_PLAYER_0	 	0x00000004L /* Display player (basic) */
#define PW_PLAYER_1	 	0x00000008L /* Display player (extra) */
#define PW_PLAYER_2         	0x00000010L /* Display player (compact) */
#define PW_PLAYER_3            	0x00000020L /* Display player (status) */
#define PW_MESSAGE	  	0x00000040L /* Display messages */
#define PW_OVERHEAD	 	0x00000080L /* Display overhead view */
#define PW_MAP           	0x00000100L /* Display dungeon map */
#define PW_MONSTER	  	0x00000200L /* Display monster recall */
#define PW_OBJECT	   	0x00000400L /* Display object recall */
#define PW_FEATURE		0x00000800L /* Display feature */
#define PW_ROOM_INFO	    	0x00001000L /* Display room description */
#define PW_SNAPSHOT	 	0x00002000L /* Display snap-shot */
#define PW_MONLIST          	0x00004000L /* Display monster list */
#define PW_ITEMLIST		0x00008000L	/* Display item list */
#define PW_HELP			0x00010000L	/* Display help */
#define PW_SELF_KNOW	0x00020000L /* Display self-knowledge */

#define PW_MAX_FLAGS		16

/*** Cave flags ***/


/*
 * Special cave grid flags
 */
#define CAVE_GLOW		0x01	/* self-illuminating */
#define CAVE_ROOM		0x02	/* part of a room */
#define CAVE_DLIT		0x04	/* lit by daylight during daytime */
#define CAVE_HALO		0x08	/* lit by glowing feature */
#define CAVE_TLIT		0x10	/* lit by a monster or player */
#define CAVE_CLIM		0x20	/* location is 'climbable' */
#define CAVE_XLOF		0x40	/* blocks line of fire */
#define CAVE_XLOS		0x80	/* blocks line of sight */

/* Cave lit by any form of light - except player torch */
#define CAVE_LITE		(CAVE_GLOW | CAVE_DLIT | CAVE_TLIT | CAVE_HALO)

/*
 * Special player grid flags
 */
#define PLAY_MARK		0x01 	/* memorized feature */
#define PLAY_SAFE		0x02 	/* detected as safe */
#define PLAY_REGN		0x04 	/* player can see "region" here */
#define PLAY_LITE		0x08 	/* lit by the player */
#define PLAY_SEEN		0x10 	/* seen flag */
#define PLAY_TEMP		0x20 	/* temp flag */
#define PLAY_VIEW		0x40 	/* view flag */
#define PLAY_FIRE		0x80 	/* fire flag */


/*
 * Special flow values
 */
#define FLOW_WALK_WALL		0
#define FLOW_WALK_OOZE		1
#define FLOW_WALK_BASH_OPEN	2
#define FLOW_WALK_BASH		3
#define FLOW_WALK_OPEN		4
#define FLOW_WALK		5
#define FLOW_WALK_FLY		6
#define FLOW_WALK_CLIMB		7
#define FLOW_FLY		8	/* Must fly */
#define FLOW_WALK_SWIM		9
#define FLOW_SWIM		10	/* Must swim */
#define FLOW_WALK_DIG		11
#define FLOW_WALK_ACID		12
#define FLOW_WALK_COLD		13
#define FLOW_WALK_ELEC		14
#define FLOW_WALK_FIRE		15
#define FLOW_WALK_FIRE_DIG	16
#define FLOW_WALK_FIRE_SWIM	17
#define FLOW_WALK_NONLIVING	18
#define FLOW_ACID		19	/* Fleeing/stays at range + immune acid */
#define FLOW_COLD		20	/* Fleeing/stays at range + immune cold */
#define FLOW_DIG		21	/* Fleeing/stays at range + can dig */
#define FLOW_FIRE		22	/* Fleeing/stays at range + immune fire */
#define FLOW_FIRE_DIG		23	/* Fleeing/stays at range + immune fire + can dig */
#define FLOW_FIRE_SWIM		24	/* Fleeing/stays at range + immune fire + can swim */
#define FLOW_FLY_CHASM		25	/* Fleeing/stays at range + can fly */
#define FLOW_SWIM_DEEP		26	/* Fleeing/stays at range + can swim */
#define FLOW_HURT_FIRE		27	/* Hurt_fire --> Blow:FIRE + Adjacent */
#define FLOW_HURT_WATER		28	/* Hurt_water --> Blow:WATER + Adjacent */

#define MAX_FLOWS		29


/* Level flags - extracted from feature flags */
#define LF1_WATER 	0x00000001L
#define LF1_LAVA  	0x00000002L
#define LF1_ICE   	0x00000004L
#define LF1_ACID  	0x00000008L
#define LF1_OIL   	0x00000010L
#define LF1_CHASM 	0x00000020L
#define LF1_DESTROYED	0x00000040L
#define LF1_LIVING  	0x00000080L
#define LF1_SEWER 	0x00000100L
#define LF1_SURFACE	0x00000200L	/* 'Surface' level - can see stuff in the distance */
#define LF1_DAYLIGHT	0x00000400L
#define LF1_TOWER	0x00000800L	/* Ascend instead of descend */
#define LF1_BATTLE	0x00001000L	/* Battlefield */
#define LF1_POLYGON	0x00002000L	/* Polygon level */
#define LF1_DUNGEON	0x00004000L	/* Dungeon level */
#define LF1_STRONGHOLD	0x00008000L	/* Stronghold (giant/dwarf) level */
#define LF1_CRYPT	0x00010000L	/* Crypt level */
#define LF1_MINE	0x00020000L	/* Lair level */
#define LF1_BURROWS	0x00040000L	/* Burrows level */
#define LF1_CAVE	0x00080000L	/* Cave level */
#define LF1_TOWN	0x00100000L	/* Town level */
#define LF1_WILD	0x00200000L	/* Wilderness level */
#define LF1_LABYRINTH	0x00400000L	/* Labyrinth level */
#define LF1_CAVERN	0x00800000L	/* Cavernous level */
#define LF1_ISLANDS	0x01000000L	/* Islands level */
#define LF1_DARK	0x02000000L	/* Dark room */
#define LF1_QUEST	0x04000000L	/* Quest level */
#define LF1_GUARDIAN	0x08000000L	/* Guarded level */
#define LF1_ROOMS	0x10000000L	/* Level has rooms */
#define LF1_TUNNELS	0x20000000L	/* Level has corridors */
#define LF1_LESS	0x40000000L	/* Level goes up */
#define LF1_MORE	0x80000000L	/* Level goes down */


#define LF1_THEME \
	(LF1_DESTROYED | LF1_POLYGON | LF1_DUNGEON | LF1_STRONGHOLD | \
	LF1_CRYPT | LF1_MINE | LF1_BURROWS | LF1_CAVE | LF1_WILD | \
	LF1_SEWER | LF1_LABYRINTH | LF1_CAVERN)

#define LF1_TERRAIN \
	(LF1_WATER | LF1_LAVA | LF1_ICE | LF1_ACID | LF1_OIL | LF1_CHASM | LF1_LIVING)

/* Room generation flags */
#define RG1_NORTH	0x00000001L	/* Place in north */
#define RG1_SOUTH	0x00000002L	/* Place in south */
#define RG1_WEST	0x00000004L	/* Place in east */
#define RG1_EAST	0x00000008L	/* Place in west */
#define RG1_CENTRE	0x00000010L	/* Place in centre */
#define RG1_EDGE	0x00000020L	/* Place on edge */
#define RG1_PLACE	0x00000040L	/* Place now */
#define RG1_ALLOC	0x00000080L	/* Pick one only */
#define RG1_CHECKER	0x00000100L	/* Place as checkered */
#define RG1_SCATTER	0x00000200L	/* Place as scattered */
#define RG1_OUTER	0x00000400L	/* Place as outer wall */
#define RG1_RANDOM	0x00000800L	/* Place 60% of the time */
#define RG1_HAS_ITEM	0x00001000L	/* Drop object */
#define RG1_HAS_GOLD	0x00002000L	/* Drop gold */
#define RG1_TRAIL	0x00004000L	/* Place trail */
#define RG1_INNER	0x00008000L	/* Place as edge of inner room */
#define RG1_ROWS	0x00010000L	/* Place rows */
#define RG1_COLS	0x00020000L	/* Place columns */
#define RG1_MAZE_PATH	0x00040000L	/* Place as a path in a maze, use inner walls for walls */
#define RG1_MAZE_WALL	0x00080000L	/* Place as a wall in a maze, use edge or floors for path */
#define RG1_MAZE_DECOR	0x00100000L	/* Place as a path in a maze, use floors for walls */
#define RG1_2X2		0x00200000L	/* Place in 2x2 grids */
#define RG1_3X3		0x00400000L	/* Place in 3x3 grids */
#define RG1_8WAY	0x00800000L	/* Place 8 ways */
#define RG1_DOORWAY	0x01000000L	/* Place a doorway */
#define RG1_3X3HIDDEN	0x02000000L	/* Place 3x3 with hollow inside and doorway */
#define RG1_STARBURST	0x04000000L	/* Place starburst in centre */
#define RG1_BRIDGE_EDGE	0x08000000L	/* Replace edges of room with bridges */
#define RG1_IGNORE_EDGE	0x10000000L	/* Ignore edges, run terrain to edge of room */
#define RG1_BRIDGE_IN	0x20000000L	/* Run bridges into the centre of the room */
#define RG1_LITE	0x40000000L	/* Place in lit rooms */
#define RG1_DARK	0x80000000L	/* Place in dark rooms */


/*** Room flags ***/

/*
 * Special room flags
 */
#define ROOM_SEEN 	0x00000001L    /* room has been seen */
#define ROOM_HEARD	0x00000002L	   /* room has been heard */
#define ROOM_ENTERED	0x00000004L	   /* room has been entered */
#define ROOM_QUEST	0x00000008L	   /* room is a quest */
#define ROOM_BRIDGED	0x00000010L	   /* room must be bridged */
#define ROOM_EDGED	0x00000020L	   /* room doesn't have 'outer' terrain */
#define ROOM_LANGUAGE	0x00000040L	   /* room has language inscriptions */
#define ROOM_FLOODED	0x00000080L	   /* room is flooded with terrain */
#define ROOM_DAYLITE	0x00000100L	   /* room is lit during daytime */
#define ROOM_ICKY 	0x00000200L    /* room cannot be teleport target */
#define ROOM_BLOODY	0x00000400L    /* room causes wounds/poison to become worse */
#define ROOM_CURSED	0x00000800L    /* room causes items to not provide bonuses (except artifacts) */
#define ROOM_GLOOMY	0x00001000L	/* room is never wholely lit by light */
#define ROOM_PORTAL	0x00002000L	/* room teleports you randomly */
#define ROOM_SILENT	0x00004000L	/* room is magically silent, stopping spells/songs */
#define ROOM_STATIC	0x00008000L    /* room causes rods/staffs/wands to fail */
#define ROOM_STATIS	0x00010000L	   /* room causes monsters to be in statis */
#define ROOM_SEALED	0x00020000L    /* room causes features to be unalterable */
#define ROOM_HIDDEN	0x00040000L	   /* room cannot be detected */
#define ROOM_ANCHOR	0x00080000L	   /* room is anti-teleportation */
#define ROOM_ECHOES	0x00100000L	   /* room is anti-stealth */
#define ROOM_STENCH	0x00200000L	   /* room prevents monsters flow by smell */
#define ROOM_NOISY	0x00400000L	   /* room prevents monsters flow by sound */
#define ROOM_WINDY	0x00800000L	   /* room prevents missiles/thrown items */
#define ROOM_GRAVE	0x01000000L	   /* room brings monsters back to life */
#define ROOM_STORE	0x02000000L	   /* room prevents objects being taken */
#define ROOM_TOWN	0x04000000L	   /* room is part of a town */
#define ROOM_RANDOM	0x08000000L	   /* room activates randomly for effect */
#define ROOM_PUZZLE	0x10000000L	   /* room requires features contained destroyed */
#define ROOM_GUARD	0x20000000L	   /* room requires monsters contained destroyed */
#define ROOM_OBJECT	0x40000000L	   /* room requires objects contained destroyed */
#define ROOM_SIMPLE	0x80000000L	   /* room has simple corridor to other simple rooms */


/*** Quest flags ***/

/*
 * Quest event flags
 */
#define EVENT_TRAVEL		0x00000001L	/* Travels to a location */
#define EVENT_LEAVE		0x00000002L	/* Leave a location */
#define EVENT_STAY		0x00000004L	/* Stay in location a minimum amount of time */
#define EVENT_PASS_QUEST	0x00000008L	/* Valid after this quest completed */
#define EVENT_FAIL_QUEST	0x00000010L	/* Valid after this quest failed */
#define EVENT_FIND_ROOM		0x00000020L	/* Locate room */
#define EVENT_FLAG_ROOM		0x00000040L	/* Add flags to room*/
#define EVENT_UNFLAG_ROOM	0x00000080L	/* Remove flags from room */
#define EVENT_ALTER_FEAT	0x00000100L	/* Alters a feature */
#define EVENT_DEFEND_FEAT	0x00000200L	/* Don't alter a feat */
#define EVENT_FIND_ITEM		0x00000400L	/* Find an item */
#define EVENT_GET_ITEM		0x00000800L	/* Get an item */
#define EVENT_LOSE_ITEM		0x00001000L	/* Lose an item */
#define EVENT_DESTROY_ITEM	0x00002000L	/* Destroy an item behind */
#define EVENT_TALK_STORE	0x00004000L	/* Talks to the owner of a shop */
#define EVENT_BUY_STORE		0x00008000L	/* Buys an item from a shop */
#define EVENT_SELL_STORE	0x00010000L	/* Sells an item to a shop */
#define EVENT_GIVE_STORE	0x00020000L	/* Give an item to an owner of a shop */
#define EVENT_STOCK_STORE	0x00040000L	/* Stocks an item in a shop */
#define EVENT_GET_STORE		0x00080000L	/* Steal an item from a shop */
#define EVENT_DEFEND_STORE	0x00100000L	/* Defend a shop */
#define EVENT_TALK_RACE		0x00200000L	/* Talk to a race */
#define EVENT_GIVE_RACE		0x00400000L	/* Give an item to a race */
#define EVENT_GET_RACE		0x00800000L	/* Give an item to a monster */
#define EVENT_FIND_RACE		0x01000000L	/* Sees a monster race */
#define EVENT_KILL_RACE		0x02000000L	/* Kill a monster race */
#define EVENT_ALLY_RACE		0x04000000L	/* Befriend a monster race */
#define EVENT_HATE_RACE		0x08000000L	/* Make enemies with a monster race */
#define EVENT_FEAR_RACE		0x10000000L	/* Scares a monster race */
#define EVENT_HEAL_RACE		0x20000000L	/* Heals a monster race */
#define EVENT_BANISH_RACE	0x40000000L	/* Banish a monster race */
#define EVENT_DEFEND_RACE	0x80000000L	/* Defend a race */

/*** Quest event sequence ***/

#define QUEST_ASSIGN	0	/* Event describes quest assignment */
#define QUEST_ACTIVE	1	/* Event describes quest */
#define QUEST_ACTION	2	/* Event describes quest actions */
#define	QUEST_REWARD	3	/* Event describes quest reward requirements */
#define	QUEST_PAYOUT	4	/* Event describes quest reward */
#define	QUEST_FINISH	5	/* Event describes quest results after completion */
#define	QUEST_FAILED	6	/* Event describes quest failure requirements */
#define	QUEST_FORFEIT	7	/* Event describes quest penalty at completion */
#define	QUEST_PENALTY	8	/* Event describes quest penalty after completion */
#define MAX_QUEST_EVENTS 9	/* Maximum events in a quest */

/* When stage is 0, character has not been assigned quest.
   When stage is 1, character has been assigned quest, but not completed any actions
   When stage is 2, character has completed some actions
   When stage is 3, character has completed all the required actions, but not collected the reward
   When stage is 4, character has collected the reward
   When stage is 5, character has failed the quest
   When stage is 6, character has failed the quest, and the penalty has been applied */



/*** Object flags ***/


/*
 * Special Awareness Flags
 */
#define AWARE_SEEN		0x0001	/* Item "seen" this game. */
#define AWARE_FLAVOR	0x0002	/* Item "flavor" is known this game. */
#define AWARE_EXISTS	0x0004	/* Item is known to exist in a game. */
#define AWARE_TRIED		0x0008	/* Item has been tried. */
#define AWARE_RUNES		0x0010	/* Item runes are known. */
#define AWARE_RUNEX		0x0020	/* Item runes are known to be associated with a particular flavor. */
#define AWARE_MASTER	0x0040	/* Item has been mastered. */
#define AWARE_CLASS		0x0080	/* Item "flavor" will be known when the item is known to exist. */
#define AWARE_SENSE		0x0100	/* Item "sense" is known */
#define AWARE_SENSEX	0x0200	/* Item "sense" is known to be associated with a particular flavor. */



/*
 * Special Object Flags
 */
#define IDENT_SENSE	0x0001	/* Item has been "sensed" */
#define IDENT_FIXED	0x0002	/* Item has been "haggled" */
#define IDENT_BONUS	0x0004	/* Item bonuses are known */
#define IDENT_KNOWN	0x0008	/* Item abilities are known */
#define IDENT_STORE	0x0010	/* Item is in a store / item is 'stored' in terrain */
#define IDENT_MENTAL	0x0020	/* Item information is known */
#define IDENT_CURSED	0x0040	/* Item is temporarily cursed */
#define IDENT_BROKEN	0x0080	/* Item is permanently worthless */
#define IDENT_BREAKS	0x0100	/* Item will break next round */
#define IDENT_CHARGES	0x0200	/* Item charges are known */
#define IDENT_VALUE	0x0400	/* Item value is known */
#define IDENT_RUNES	0x0800	/* Item runes are known */
#define IDENT_NAME	0x1000	/* Item name is known */
#define IDENT_PVAL	0x2000	/* Item pval is known */
#define IDENT_MARKED	0x4000	/* Item is visible */
#define IDENT_FORGED	0x8000	/* Item has been forged by player */

/*
 * The special inscriptions.
 */
#define INSCRIP_NULL	    	0
#define INSCRIP_TERRIBLE	1
#define INSCRIP_WORTHLESS       2
#define INSCRIP_CURSED	  	3
#define INSCRIP_BROKEN	  	4
#define INSCRIP_EMPTY	 	5
#define INSCRIP_GOOD	    	6
#define INSCRIP_EXCELLENT       7
#define INSCRIP_SPECIAL	 	8
#define INSCRIP_UNCURSED	9  /* Uncursed, or has been detected to be not cursed */
#define INSCRIP_VERY_GOOD       10
#define INSCRIP_GREAT    	11
#define INSCRIP_SUPERB   	12
#define INSCRIP_UNBREAKABLE	13 /* Artifact */
#define INSCRIP_UNGETTABLE	14 /* Has flag preventing player / monster getting it */
#define INSCRIP_NONMAGICAL	15 /* Has been detected to be average, broken or cursed (includes cursed artifacts, ego items and magic items)*/
#define INSCRIP_MAGICAL		16 /* Has been detected to be better than average */
#define INSCRIP_MAGIC_ITEM	17 /* Unusual, but not ego item or artifact */
#define INSCRIP_EGO_ITEM	18 /* Has been detected to be ego item */
#define INSCRIP_HIGH_EGO_ITEM	19 /* Has been detected to be high ego item */
#define INSCRIP_ARTIFACT	20 /* Has been detected to be artifact */
#define INSCRIP_UNRUNED		21 /* Does not have any runes */
#define INSCRIP_RUNED		22 /* Does have runes */
#define INSCRIP_AVERAGE		23 /* Has been detected to be average */
#define INSCRIP_VALUABLE	24 /* Has been detected to be valuable */
#define INSCRIP_UNUSUAL		25 /* Has been detected to be not average */
#define INSCRIP_COATED		26 /* Has been coated with something */
#define INSCRIP_MIN_HIDDEN      27 /* Minimum inscription for hidden */

#define INSCRIP_USEFUL		16 /* TBD: Either good, very good or great without being an ego item or artifact */
#define INSCRIP_USELESS		9 /* TBD: Either average or broken, without being cursed */



/*
 * Number of special inscriptions, plus one.
 */
#define MAX_INSCRIP			42


/*
 * Some bit-flags for the "smart" field of "monster_type".
 *
 * Most of these map to the "TR2_xxx" flags.
 */
#define SM_OPP_ACID		0x00000001L
#define SM_OPP_ELEC		0x00000002L
#define SM_OPP_FIRE		0x00000004L
#define SM_OPP_COLD		0x00000008L
#define SM_OPP_POIS		0x00000010L
#define SM_OPP_FEAR		0x00000020L
#define SM_SEE_INVIS	0x00000040L
#define SM_GOOD_SAVE	0x00000080L
#define SM_PERF_SAVE	0x00000100L
#define SM_FREE_ACT		0x00000200L
#define SM_IMM_POIS		0x00000400L
#define SM_IMM_MANA		0x00000800L
#define SM_IMM_ACID		0x00001000L
#define SM_IMM_ELEC		0x00002000L
#define SM_IMM_FIRE		0x00004000L
#define SM_IMM_COLD		0x00008000L
#define SM_RES_ACID		0x00010000L
#define SM_RES_ELEC		0x00020000L
#define SM_RES_FIRE		0x00040000L
#define SM_RES_COLD		0x00080000L
#define SM_RES_POIS		0x00100000L
#define SM_RES_FEAR		0x00200000L
#define SM_RES_LITE		0x00400000L
#define SM_RES_DARK		0x00800000L
#define SM_RES_BLIND	0x01000000L
#define SM_RES_CONFU	0x02000000L
#define SM_RES_SOUND	0x04000000L
#define SM_RES_SHARD	0x08000000L
#define SM_RES_NEXUS	0x10000000L
#define SM_RES_NETHR	0x20000000L
#define SM_RES_CHAOS	0x40000000L
#define SM_RES_DISEN	0x80000000L


/*
 * As of 2.7.8, the "object flags" are valid for all objects, and as
 * of 2.7.9, these flags are not actually stored with the object, but
 * rather in the object_kind, ego_item, and artifact structures.
 *
 * Note that "flags1" contains all flags dependant on "pval" (including
 * stat bonuses, but NOT stat sustainers), plus all "extra attack damage"
 * flags (SLAY_XXX and BRAND_XXX).
 *
 * Note that "flags2" contains all "resistances" (including "sustain" flags,
 * immunity flags, and resistance flags).  Note that "free action" and "hold
 * life" are no longer considered to be "immunities".
 *
 * Note that "flags3" contains everything else (including eight good flags,
 * seven unused flags, four bad flags, four damage ignoring flags, six weird
 * flags, and three cursed flags).
 */

#define TR1_STR    0x00000001L     /* STR += "pval" */
#define TR1_INT    0x00000002L     /* INT += "pval" */
#define TR1_WIS    0x00000004L     /* WIS += "pval" */
#define TR1_DEX    0x00000008L     /* DEX += "pval"; AGI += "pval" */
#define TR1_CON    0x00000010L     /* CON += "pval" */
#define TR1_CHR    0x00000020L     /* CHR += "pval" */
#define TR1_SAVE   0x00000040L     /* Saves += "pval" */
#define TR1_DEVICE 0x00000080L     /* Devices += "pval" */
#define TR1_STEALTH  0x00000100L   /* Stealth += "pval" */
#define TR1_SEARCH 0x00000200L     /* Search += "pval" */
#define TR1_INFRA  0x00000400L     /* Infra += "pval" */
#define TR1_TUNNEL 0x00000800L     /* Tunnel += "pval" */
#define TR1_SPEED    0x00001000L   /* Speed += "pval" */
#define TR1_BLOWS  0x00002000L     /* Blows += "pval" */
#define TR1_SHOTS  0x00004000L     /* Shots += "pval" */
#define TR1_MIGHT  0x00008000L     /* Might += "pval" */
#define TR1_SLAY_NATURAL  0x00010000L     /* Weapon slays animals, plants, insects */
#define TR1_BRAND_HOLY    0x00020000L     /* Weapon has holy brand */
#define TR1_SLAY_UNDEAD  0x00040000L     /* Weapon slays undead */
#define TR1_SLAY_DEMON   0x00080000L     /* Weapon slays demon */
#define TR1_SLAY_ORC     0x00100000L     /* Weapon slays orc */
#define TR1_SLAY_TROLL   0x00200000L     /* Weapon slays troll */
#define TR1_SLAY_GIANT   0x00400000L     /* Weapon slays giant */
#define TR1_SLAY_DRAGON  0x00800000L     /* Weapon slays dragon */
#define TR1_KILL_DRAGON  0x01000000L     /* Weapon kills dragon */
#define TR1_KILL_DEMON   0x02000000L     /* Weapon kills demon */
#define TR1_KILL_UNDEAD   0x04000000L     /* Weapon kills undead */
#define TR1_BRAND_POIS   0x08000000L	 /* Weapon has poison brand */
#define TR1_BRAND_ACID   0x10000000L     /* Weapon has acid brand */
#define TR1_BRAND_ELEC   0x20000000L     /* Weapon has elec brand */
#define TR1_BRAND_FIRE   0x40000000L     /* Weapon has fire brand */
#define TR1_BRAND_COLD   0x80000000L     /* Weapon has cold brand */

#define TR2_SUST_STR     0x00000001L     /* Sustain STR */
#define TR2_SUST_INT     0x00000002L     /* Sustain INT */
#define TR2_SUST_WIS     0x00000004L     /* Sustain WIS */
#define TR2_SUST_DEX     0x00000008L     /* Sustain DEX and AGI */
#define TR2_SUST_CON     0x00000010L     /* Sustain CON */
#define TR2_SUST_CHR     0x00000020L     /* Sustain CHR */
#define TR2_IGNORE_ACID   0x00000040L     /* Item ignores Acid damage */
#define TR2_IGNORE_ELEC   0x00000080L     /* Item ignores Elec damage */
#define TR2_IGNORE_FIRE   0x00000100L     /* Item ignores Fire damage */
#define TR2_IGNORE_COLD   0x00000200L     /* Item ignores Cold damage */
#define TR2_IGNORE_WATER  0x00000400L     /* Item ignores Water damage */
#define TR2_IGNORE_THEFT  0x00000800L     /* Item ignores Theft */
#define TR2_IM_ACID       0x00001000L     /* Immunity to acid */
#define TR2_IM_ELEC       0x00002000L     /* Immunity to elec */
#define TR2_IM_FIRE       0x00004000L     /* Immunity to fire */
#define TR2_IM_COLD       0x00008000L     /* Immunity to cold */
#define TR2_RES_ACID     0x00010000L     /* Resist acid */
#define TR2_RES_ELEC     0x00020000L     /* Resist elec */
#define TR2_RES_FIRE     0x00040000L     /* Resist fire */
#define TR2_RES_COLD     0x00080000L     /* Resist cold */
#define TR2_RES_POIS     0x00100000L     /* Resist poison */
#define TR2_RES_FEAR     0x00200000L 	/* Resist fear */
#define TR2_RES_LITE     0x00400000L     /* Resist lite */
#define TR2_RES_DARK     0x00800000L     /* Resist dark */
#define TR2_RES_BLIND    0x01000000L     /* Resist blind */
#define TR2_RES_CONFU    0x02000000L     /* Resist confusion */
#define TR2_RES_SOUND    0x04000000L     /* Resist sound */
#define TR2_RES_SHARD    0x08000000L     /* Resist shards */
#define TR2_RES_NEXUS    0x10000000L     /* Resist nexus */
#define TR2_RES_NETHR    0x20000000L     /* Resist nether */
#define TR2_RES_CHAOS    0x40000000L     /* Resist chaos */
#define TR2_RES_DISEN    0x80000000L     /* Resist disenchant */

#define TR3_SLOW_DIGEST	0x00000001L     /* Resist water */
#define TR3_FEATHER      0x00000002L     /* Feather Falling */
#define TR3_LITE	0x00000004L     /* Perma-Lite */
#define TR3_REGEN_HP 	0x00000008L     /* Hp Regeneration */
#define TR3_TELEPATHY    0x00000010L     /* Telepathy */
#define TR3_SEE_INVIS    0x00000020L     /* See Invis */
#define TR3_FREE_ACT     0x00000040L     /* Free action */
#define TR3_HOLD_LIFE    0x00000080L     /* Hold life */
#define TR3_ESP_DEMON  	0x00000100L     /* Sense demons */
#define TR3_ESP_DRAGON  0x00000200L     /* Sense dragons */
#define TR3_ESP_GIANT  	0x00000400L     /* Sense giants */
#define TR3_ESP_ORC  	0x00000800L     /* Sense orcs */
#define TR3_ESP_TROLL    0x00001000L     /* Sense trolls */
#define TR3_ESP_UNDEAD   0x00002000L     /* Sense undead */
#define TR3_ESP_NATURE   0x00004000L     /* Sense natural */
#define TR3_REGEN_MANA   0x00008000L	 /* Mana regeneration */
#define TR3_DRAIN_HP     0x00010000L     /* Hit point drain */
#define TR3_DRAIN_MANA   0x00020000L     /* Mana drain */
#define TR3_DRAIN_EXP    0x00040000L     /* Experience drain */
#define TR3_AGGRAVATE    0x00080000L     /* Aggravate monsters */
#define TR3_UNCONTROLLED 0x00100000L     /* Item activates spontaneously if cursed */
#define TR3_ACT_ON_BLOW  0x00200000L 	 /* Item activates on powerful blows */
#define TR3_ACTIVATE     0x00400000L     /* Item can be activated */
#define TR3_BLESSED      0x00800000L     /* Item has been blessed */
#define TR3_FREE_HANDS   0x01000000L     /* Item does not inhibit hands */
#define TR3_HUNGER       0x02000000L     /* Item makes the user more hungry */
#define TR3_CHARGE       0x04000000L     /* Charging += "pval" */
#define TR3_HURL_NUM	 0x08000000L     /* Hurls += "pval" */
#define TR3_HURL_DAM	 0x10000000L     /* Throwing damage multiplier += "pval" */
#define TR3_LIGHT_CURSE  0x20000000L     /* Item has Light Curse */
#define TR3_HEAVY_CURSE  0x40000000L     /* Item has Heavy Curse */
#define TR3_PERMA_CURSE  0x80000000L     /* Item has Perma Curse */

#define TR4_BRAND_DARK	0x00000001L	/* Weapon has dark brand */
#define TR4_BRAND_LITE	0x00000002L	/* Weapon has lite brand */
#define TR4_HURT_LITE	0x00000004L     /* Item makes wielder vulnerable to lite */
#define TR4_HURT_WATER	0x00000008L     /* Item makes wielder vulnerable to water */
#define TR4_VAMP_HP   	0x00000010L     /* Weapon restores user hp when kills a creature with blood  */
#define TR4_VAMP_MANA  	0x00000020L     /* Weapon restores user sp when kills a creature with mana  */
#define TR4_IM_POIS   	0x00000040L     /* Immune to poison  */
#define TR4_RES_DISEASE 0x00000080L     /* Resistance to disease  */
#define TR4_RES_WATER   0x00000100L     /* Resistance to water */
#define TR4_SLAY_MAN 	0x00000200L     /* Weapon slays humans */
#define TR4_SLAY_ELF  	0x00000400L     /* Weapon slays elves */
#define TR4_SLAY_DWARF 	0x00000800L     /* Weapon slays dwarves */
#define TR4_ANCHOR  	0x00001000L     /* Item prevents teleportation */
#define TR4_SILENT  	0x00002000L     /* Item prevents spell casting*/
#define TR4_STATIC  	0x00004000L     /* Item prevents item activation */
#define TR4_WINDY  		0x00008000L     /* Item prevents missiles / thrown items */
#define TR4_ANIMAL  	0x00010000L     /* Item makes wielder animal */
#define TR4_EVIL    	0x00020000L     /* Item makes wielder evil */
#define TR4_UNDEAD  	0x00040000L     /* Item makes wielder undead */
#define TR4_DEMON   	0x00080000L     /* Item makes wielder demon */
#define TR4_ORC     	0x00100000L     /* Item makes wielder orc */
#define TR4_TROLL   	0x00200000L     /* Item makes wielder troll */
#define TR4_GIANT   	0x00400000L     /* Item makes wielder giant */
#define TR4_DRAGON  	0x00800000L     /* Item makes wielder dragon */
#define TR4_MAN     	0x01000000L     /* Item makes wielder man */
#define TR4_DWARF   	0x02000000L	/* Item makes wielder dwarf */
#define TR4_ELF   	0x04000000L	/* Item makes wielder elf */
#define TR4_HURT_POIS   0x08000000L     /* Item makes wielder vulnerable to acid */
#define TR4_HURT_ACID   0x10000000L     /* Item makes wielder vulnerable to acid */
#define TR4_HURT_ELEC   0x20000000L     /* Item makes wielder vulnerable to elec */
#define TR4_HURT_FIRE   0x40000000L     /* Item makes wielder vulnerable to fire */
#define TR4_HURT_COLD   0x80000000L     /* Item makes wielder vulnerable to cold */

#define TR5_SHOW_DD		0x00000001L	/* Show damage dice */
#define TR5_SHOW_WEAPON 0x00000002L /* Show "to-hit" and "to-dam" bonus */
#define TR5_SHOW_CHARGE 0x00000004L	/* Show charges */
#define TR5_SHOW_FUEL	0x00000008L	/* Show turns (of light) */
#define TR5_SHOW_AC		0x00000010L	/* Show armour class */
#define TR5_HAS_PVAL	0x00000020L	/* Item has varying pval */
#define TR5_HAS_BONUS	0x00000040L	/* Item has varying to-hit/to-dam/to-ac */
#define TR5_HAS_CHARGES 0x00000080L	/* Item has varying charges */
#define TR5_INSTA_ART   0x00000100L /* Item makes an artifact */
#define TR5_EXTRA_DAM	0x00000200L	/* Item can do extra damage from brands/slays (cmd1.c) */
#define TR5_EDGED		0x00000400L	/* Item does edged damage */
#define TR5_BLUNT		0x00000800L	/* Item does blunt damage */
#define TR5_DO_CUTS		0x00001000L	/* Item can do extra damage from cuts (cmd1.c) */
#define TR5_DO_STUN		0x00002000L	/* Item can do extra damage from stun (cmd1.c) */
#define TR5_DO_CRIT		0x00004000L	/* Item does extra damage */
#define TR5_DO_TRIP		0x00008000L	/* Item robs enemy of energy */
#define TR5_BREAK_100	0x00010000L	/* Breakage change 100% (cmd2.c) */
#define TR5_BREAK_50	0x00020000L	/* Breakage change 50% (cmd2.c) */
#define TR5_BREAK_25	0x00040000L	/* Breakage change 25% (cmd2.c) */
#define TR5_BREAK_10	0x00080000L	/* Breakage change 10% (cmd2.c) */
#define TR5_IS_JUNK		0x00100000L	/* Item is junk (cmd1.c) */
#define TR5_THROWING    0x00200000L	/* Item is hurl-able (gets throwing bonuses) */
#define TR5_AMMO    	0x00400000L	/* Item is branded in stacks */
#define TR5_GLOW		0x00800000L	/* Item glows if timed */
#define TR5_EXHAUST		0x01000000L	/* Item is destroyed at timeout */
#define TR5_RECHARGE	0x02000000L	/* Item recharges at timeout */
#define TR5_HURT_ACID	0x04000000L	/* Item can be destroyed by acid */
#define TR5_HURT_COLD	0x08000000L	/* Item can be destroyed by cold */
#define TR5_HURT_ELEC	0x10000000L	/* Item can be destroyed by electricity */
#define TR5_HURT_FIRE	0x20000000L	/* Item can be destroyed by fire */
#define TR5_HURT_WATER	0x40000000L	/* Item can be destroyed by water */
#define TR5_TRICK_THROW	0x80000000L	/* Item always does tricks if thrown */

#define TR6_WEAPON		0x00000001L	/* Item is a weapon */
#define TR6_ARMOUR		0x00000002L	/* Item is an armour */
#define TR6_FLAVOR		0x00000004L	/* Item is "flavoured" */
#define TR6_NAMED		0x00000008L	/* Item is "named" after monster */
#define TR6_SIMPLE		0x00000010L	/* Item has a 'simple' description */
#define TR6_RESEARCH	0x00000020L	/* Item is 'researched' */
#define TR6_SHOW_MULT	0x00000040L	/* Show bow multiplier */
#define TR6_NO_TIMEOUT	0x00000080L	/* Don't show timeout */
#define TR6_1_HANDED	0x00000100L	/* Item can be wielded 1-handed. (cmd3.c) */
#define TR6_2_HANDED	0x00000200L	/* Item can be wielded 2-handed. (cmd3.c) */
#define TR6_OFF_HAND	0x00000400L	/* Item can be wielded in off-hand (cmd3.c) */
#define TR6_W_SHIELD	0x00000800L	/* Item can be wielded with shield (cmd3.c) */
#define TR6_BACKSTAB	0x00001000L	/* Item can backstab opponents */
#define TR6_GOLD		0x00002000L	/* Item picked up for money only (cmd1.c) */
#define TR6_EAT_BODY	0x00004000L	/* Monster eats if has 'eat body' */
#define TR6_EAT_INSECT	0x00008000L	/* Monster eats if an insect */
#define TR6_EAT_ANIMAL	0x00010000L	/* Monster eats if an animal */
#define TR6_EAT_SMART	0x00020000L	/* Monster eats if smart (and hungry) */
#define TR6_EAT_HEAL	0x00040000L	/* Monster eats if looking for healing */
#define TR6_EAT_MANA	0x00080000L	/* Monster eats if looking for mana */
#define TR6_HAS_ROPE    0x00100000L	/* Item has rope attached (cmd2.c) */
#define TR6_HAS_CHAIN	0x00200000L	/* Item has randomly picked effect */
#define TR6_RANDOM		0x00400000L	/* Item has randomly picked effect */
#define TR6_BAD_THROW	0x00800000L	/* Item is hard to throw */
#define TR6_BREAK_THROW	0x01000000L	/* Item breaks when thrown */
#define TR6_TITLE		0x02000000L	/* Item has a random title */
#define TR6_ADD_NAME	0x04000000L	/* Add item name if aware */
#define TR6_MOD_NAME	0x08000000L	/* Use item name as 'modifier' */
#define TR6_PREPEND		0x10000000L	/* Prepend 'modifier' */
#define TR6_IN_FEET		0x20000000L	/* Treat as a collective noun */
#define TR6_FORCE_MOD	0x40000000L	/* Force display of modifier */
#define TR6_NO_TVAL		0x80000000L	/* Don't display base tval name */


/*
 * Indexes for incremental resists and other incremental abilities.
 */
#define INCR_RES_ACID     0     /* Resist acid */
#define INCR_RES_ELEC     1     /* Resist elec */
#define INCR_RES_FIRE     2     /* Resist fire */
#define INCR_RES_COLD     3     /* Resist cold */
#define INCR_RES_POIS     4     /* Resist poison */
#define INCR_RES_WATER	  5     /* Resist water */

#define MAX_INCR_RESISTS  6


/*
 * Hack -- flag set 1 -- mask for "pval-dependant" flags.
 * Note that all "pval" dependant flags must be in "flags1".
 */
#define TR1_PVAL_MASK \
	(TR1_STR | TR1_INT | TR1_WIS | TR1_DEX | \
	 TR1_CON | TR1_CHR | TR1_SAVE | TR1_DEVICE | \
	 TR1_STEALTH | TR1_SEARCH | TR1_INFRA | TR1_TUNNEL | \
	 TR1_SPEED | TR1_BLOWS | TR1_SHOTS | TR1_MIGHT)

/* Oops. Ended up with some pval dependent flags in TR3_
 * Ah well.  We need to reorganise the pvals anyway.
 */
#define TR3_PVAL_MASK \
	(TR3_LITE | TR3_REGEN_HP | TR3_REGEN_MANA)


/*
 * Flag set 2 -- mask for "ignore element" flags.
 */
#define TR2_IGNORE_MASK \
 (TR2_IGNORE_ACID | TR2_IGNORE_ELEC | TR2_IGNORE_FIRE | \
  TR2_IGNORE_COLD | TR2_IGNORE_WATER | TR2_IGNORE_THEFT)

/*
 * Flag set 3 -- mask for "sense" flags.
 */

#define TR3_SENSE_MASK \
	(TR3_TELEPATHY | TR3_ESP_DEMON | TR3_ESP_DRAGON | \
	 TR3_ESP_GIANT | TR3_ESP_ORC | TR3_ESP_TROLL | \
	 TR3_ESP_UNDEAD | TR3_ESP_NATURE | TR3_SEE_INVIS)



/*
 *  Hack -- exclude the following flags from equipment self-knowledge except weapons.
 */
#define TR1_WEAPON_FLAGS (TR1_SLAY_ORC | TR1_SLAY_TROLL | TR1_SLAY_GIANT |\
			TR1_SLAY_DRAGON | TR1_SLAY_UNDEAD | TR1_SLAY_DEMON |\
			TR1_SLAY_NATURAL | TR1_BRAND_HOLY | TR1_KILL_DRAGON |\
			TR1_KILL_UNDEAD | TR1_KILL_DEMON | TR1_BRAND_ACID |\
			TR1_BRAND_FIRE | TR1_BRAND_POIS | TR1_BRAND_ELEC |\
			TR1_BRAND_COLD)

#define TR2_WEAPON_FLAGS 0x0L

#define TR3_WEAPON_FLAGS (TR3_ACT_ON_BLOW | TR3_BLESSED | TR3_FREE_HANDS)

#define TR4_WEAPON_FLAGS (TR4_VAMP_HP | TR4_VAMP_MANA |\
			  TR4_BRAND_LITE | TR4_BRAND_DARK | TR4_SLAY_MAN | TR4_SLAY_ELF |\
			  TR4_SLAY_DWARF)
/*
 *  Hack -- exclude the following flags from equipment self-knowledge as they never apply
 *  directly to the player.
 */
#define TR1_IGNORE_FLAGS (TR1_WEAPON_FLAGS)

#define TR2_IGNORE_FLAGS (TR2_WEAPON_FLAGS | TR2_IGNORE_MASK)

#define TR3_IGNORE_FLAGS (TR3_WEAPON_FLAGS | TR3_ACTIVATE)

#define TR4_IGNORE_FLAGS (TR4_WEAPON_FLAGS)







/*
 * Hack -- special "xtra" object flag info (type)
 */
#define OBJECT_XTRA_MAX_HIDDEN 20

#define OBJECT_XTRA_MIN_RUNES    36
#define OBJECT_XTRA_MIN_COATS    70
#define MAX_RUNE_FLAGS    4

/* Total number of different slay types used */

#define SLAY_MAX 0x00200000L



/*** Monster flags ***/



/*
 * Hard coding for Sauron hack. Indexes into monster.txt
 *
 * Should really replace this with shapeshifting based on group or similar.
 */
#define SAURON_TRUE		546
#define SAURON_FORM		1367
#define MAX_SAURON_FORMS	5


/*
 * The minimum warning that 'town' monsters give before reverting to attack
 * the player.
 */
#define MIN_TOWN_WARNING	20


/*
 * Special Monster Flags (all temporary)
 */
/*
 * Special Monster Flags (some should be saved)
 */
#define MFLAG_VIEW      0x00000001    /* Monster is in line of sight */
#define MFLAG_HIDE      0x00000002    /* Monster is hiding in terrain */
#define MFLAG_OVER      0x00000004    /* Monster is flying over terrain*/
#define MFLAG_MADE      0x00000008    /* Monster is not carrying treasure */
#define MFLAG_MOVE		0x00000010    /* Monster has moved */
#define MFLAG_TOWN		0X00000020    /* Monster is using "townsman" AI */
#define MFLAG_SHOW      0x00000040    /* Monster is recently memorized */
#define MFLAG_MARK      0x00000080    /* Monster is currently memorized */

#define MFLAG_ACTV      0x00000100    /* Monster is currently active */
#define MFLAG_LITE      0x00000200    /* Monster is using a lite */
#define MFLAG_PUSH      0x00000400    /* Monster has pushed/been pushed aside */
#define MFLAG_CAST		0x00000800    /* Monster will cast spell at first opportunity */
#define MFLAG_LEADER	0x00001000    /* Monster is a 'leader-type' */
#define MFLAG_AGGR		0x00002000    /* Monster will act in aggressive manner */
#define MFLAG_HIT_RANGE	0x00004000    /* Monster has just been hit by ranged attack */
#define MFLAG_HIT_BLOW	0x00008000    /* Monster has just been hit by melee attack */

/* The following define racial variations, and the effects of stat potions */

#define MFLAG_SLOW	0x00010000    /* Monster is slower than average for race */
#define MFLAG_FAST	0x00020000    /* Monster is faster than average for race */
#define MFLAG_WEAK      0x00040000    /* Monster is weaker than average for race */
#define MFLAG_STRONG	0x00080000    /* Monster is stronger than average for race */
#define MFLAG_STUPID	0x00100000    /* Monster is dumber than average for race */
#define MFLAG_SMART	0x00200000    /* Monster is smarter than average for race */
#define MFLAG_NAIVE     0x00400000    /* Monster is more naive than average for race */
#define MFLAG_WISE	0x00800000    /* Monster is wiser than average for race */
#define MFLAG_CLUMSY	0x01000000    /* Monster is more clumsy than average for race */
#define MFLAG_SKILLFUL	0x02000000    /* Monster is more skillful than average for race */
#define MFLAG_SICK      0x04000000    /* Monster is sicker than average for race */
#define MFLAG_HEALTHY	0x08000000    /* Monster is healthier than average for race */
#define MFLAG_SHOT	0x10000000    /* Monster will shoot at first opportunity */
#define MFLAG_BREATH	0x20000000    /* Monster will breath at first opportunity */
#define MFLAG_ALLY	0x40000000    /* Monster is ally of player */
#define MFLAG_IGNORE	0x80000000    /* Monster will ignore the player until provoked */


/*
 * Monster movement (return from place_monster_on)
 */
#define MM_DROWN -2  /* Monster suffers continuously in terrain */
#define MM_TRAP	-1	 /* Monster suffers in terrain while moving */
#define MM_FAIL 0    /* Monster cannot occupy terrain */
#define MM_WALK 1    /* Monster will walk on terrain */
#define MM_FLY  2    /* Monster will fly on terrain */
#define MM_CLIMB 3   /* Monster will climb on terrain */
#define MM_SWIM 4    /* Monster will swim in terrain */
#define MM_DIG 5     /* Monster will dig through terrain */
#define MM_DEEP 6    /* Monster is deep in terrain */
#define MM_PASS 7    /* Monster is pass wall */
#define MM_OOZE 8     /* Monster will ooze through terrain */
#define MM_UNDER 9   /* Monster will walk under terrain */

/*
 * New monster race bit flags
 */
#define RF1_UNIQUE 0x00000001      /* Unique Monster */
#define RF1_QUESTOR       0x00000002      /* Quest Monster */
#define RF1_MALE   0x00000004      /* Male gender */
#define RF1_FEMALE 0x00000008      /* Female gender */
#define RF1_CHAR_CLEAR   0x00000010      /* Absorbs symbol */
#define RF1_CHAR_MULTI   0x00000020      /* Changes symbol */
#define RF1_ATTR_CLEAR   0x00000040      /* Absorbs color */
#define RF1_ATTR_MULTI   0x00000080      /* Changes color */
#define RF1_FORCE_DEPTH  0x00000100      /* Start at "correct" depth */
#define RF1_FORCE_MAXHP  0x00000200      /* Start with max hitpoints */
#define RF1_FORCE_SLEEP  0x00000400      /* Start out sleeping */
#define RF1_GUARDIAN     0x00000800      /* Dungeon guardian*/
#define RF1_FRIEND   0x00001000      /* Arrive with a friend */
#define RF1_FRIENDS       0x00002000      /* Arrive with some friends */
#define RF1_ESCORT 0x00004000      	/* Arrive with an escort */
#define RF1_ESCORTS       0x00008000      /* Arrive with some escorts */
#define RF1_NEVER_BLOW   0x00010000      /* Never make physical blow */
#define RF1_NEVER_MOVE   0x00020000      /* Never make physical move */
#define RF1_RAND_25       0x00040000      /* Moves randomly (25%) */
#define RF1_RAND_50       0x00080000      /* Moves randomly (50%) */
#define RF1_ONLY_GOLD    0x00100000      /* Drop only gold */
#define RF1_ONLY_ITEM    0x00200000      /* Drop only items */
#define RF1_DROP_30       0x00400000     /* Drop an item/gold (30%) */
#define RF1_DROP_60       0x00800000     /* Drop an item/gold (60%) */
#define RF1_DROP_90     0x01000000       /* Drop an item/gold (90%) */
#define RF1_DROP_1D2     0x02000000      /* Drop 1d2 items/gold */
#define RF1_DROP_1D3     0x04000000      /* Drop 1d3 items/gold */
#define RF1_DROP_1D4     0x08000000      /* Drop 1d4 items/gold */
#define RF1_DROP_GOOD    0x10000000      /* Drop good items */
#define RF1_DROP_GREAT   0x20000000      /* Drop great items */
#define RF1_DROP_USEFUL  0x40000000      /* Drop "useful" items */
#define RF1_DROP_CHOSEN  0x80000000      /* Drop "chosen" items */

/*
 * New monster race bit flags
 */
#define RF2_STUPID	0x00000001      /* Monster is stupid */
#define RF2_SMART	0x00000002      /* Monster is smart */
#define RF2_CAN_DIG	0x00000004      /* Monster can dig */
#define RF2_HAS_LITE	0x00000008      /* Monster has lite */
#define RF2_INVISIBLE	0x00000010      /* Monster avoids vision */
#define RF2_COLD_BLOOD	0x00000020      /* Monster avoids infra */
#define RF2_EMPTY_MIND	0x00000040      /* Monster avoids telepathy */
#define RF2_WEIRD_MIND	0x00000080      /* Some (80%) monsters avoid telepathy */
#define RF2_MULTIPLY	0x00000100      /* Monster reproduces */
#define RF2_REGENERATE	0x00000200      /* Monster regenerates */
#define RF2_CAN_SWIM	0x00000400      /* Monster can swim */
#define RF2_MUST_SWIM	0x00000800      /* Monster must swim */
#define RF2_POWERFUL	0x00001000      /* Monster has strong breath */
#define RF2_CAN_CLIMB	0x00002000      /* Monster can climb walls */
#define RF2_CAN_FLY	0x00004000      /* Monster can fly */
#define RF2_MUST_FLY    0x00008000      /* Monster must fly */
#define RF2_OPEN_DOOR	0x00010000      /* Monster can open doors */
#define RF2_BASH_DOOR	0x00020000      /* Monster can bash doors */
#define RF2_PASS_WALL	0x00040000      /* Monster can pass walls */
#define RF2_KILL_WALL	0x00080000      /* Monster can destroy walls */
#define RF2_ARCHER	0x00100000      /* Monster has extra ammo */
#define RF2_EAT_BODY	0x00200000      /* Monster can eat body parts */
#define RF2_TAKE_ITEM	0x00400000      /* Monster can pick up items */
#define RF2_TRAIL	0x00800000      /* Monster leaves a trail behind it */
#define RF2_SNEAKY 	0x01000000 	/* Monster hides a lot of actions */
#define RF2_ARMOR	0x02000000 	/* Monster is fully armoured (Reduces acid damage/stops some arrows) */
#define RF2_PRIEST 	0x04000000 	/* Monster has access to priest spells ? */
#define RF2_MAGE   	0x08000000 	/* Monster has access to mage spells ? */
#define RF2_HAS_AURA  	0x10000000 	/* Monster radiates an aura attack */
#define RF2_HAS_WEB	0x20000000 	/* Monster created in a web */
#define RF2_NEED_LITE	0x40000000 	/* Monster cannot see the player if player is not visible */
#define RF2_LOW_MANA_RUN	0x80000000	/* Monster will run if low on mana */

/*
 * New monster race bit flags
 */
#define RF3_ORC            0x00000001      /* Orc */
#define RF3_TROLL          0x00000002      /* Troll */
#define RF3_GIANT          0x00000004      /* Giant */
#define RF3_DRAGON         0x00000008      /* Dragon */
#define RF3_DEMON          0x00000010      /* Demon */
#define RF3_UNDEAD         0x00000020      /* Undead */
#define RF3_EVIL           0x00000040      /* Evil */
#define RF3_ANIMAL         0x00000080      /* Animal */
#define RF3_OOZE           0x00000100      /* Oozes through things */
#define RF3_HUGE           0x00000200      /* Huge (breaks things?) */
#define RF3_NONVOCAL       0x00000400      /* Non-Vocal */
#define RF3_NONLIVING      0x00000800      /* Non-Living */
#define RF3_HURT_LITE      0x00001000      /* Hurt by lite */
#define RF3_HURT_ROCK      0x00002000      /* Hurt by rock remover */
#define RF3_PLANT          0x00004000      /* Plant */
#define RF3_INSECT         0x00008000      /* Insect */
#define RF3_IM_ACID        0x00010000      /* Resist acid a lot */
#define RF3_IM_ELEC        0x00020000      /* Resist elec a lot */
#define RF3_IM_FIRE        0x00040000      /* Resist fire a lot */
#define RF3_IM_COLD        0x00080000      /* Resist cold a lot */
#define RF3_IM_POIS        0x00100000      /* Resist poison a lot */
#define RF3_RES_WATER      0x00200000      /* Resist water a lot */
#define RF3_RES_NETHR      0x00400000      /* Resist nether a lot */
#define RF3_RES_LAVA       0x00800000      /* Resist lava */
#define RF3_RES_PLAS       0x01000000      /* Resist plasma */
#define RF3_RES_NEXUS      0x02000000      /* Resist nexus */
#define RF3_RES_DISEN      0x04000000      /* Resist disenchantment */
#define RF3_HURT_WATER     0x08000000      /* Hurt by water remover */
#define RF3_NO_FEAR        0x10000000      /* Cannot be scared */
#define RF3_NO_STUN        0x20000000      /* Cannot be stunned */
#define RF3_NO_CONF        0x40000000      /* Cannot be confused */
#define RF3_NO_SLEEP       0x80000000      /* Cannot be slept */


/*
 * Monster racial flags - innate or physical ranged attacks
 * these spells do not have a failure rate - JG
 * other spells have a chance of failing
 */

#define RF4_BLOW_1	   0x00000001  /* 1st blow is ranged attack */
#define RF4_BLOW_2         0x00000002  /* 2nd blow is ranged attack */
#define RF4_BLOW_3         0x00000004  /* 3rd blow is ranged attack */
#define RF4_BLOW_4         0x00000008  /* 4th blow is ranged attack */
#define RF4_ADD_AMMO       0x00000010  /* Add ammunition */
#define RF4_QUAKE          0x00000020  /* Earthquake */
#define RF4_EXPLODE        0x00000040  /* Explode with radius 3 */
#define RF4_AURA           0x00000080  /* Radiate aura with radius 2 */
#define RF4_BRTH_ACID      0x00000100  /* Breathe Acid */
#define RF4_BRTH_ELEC      0x00000200  /* Breathe Elec */
#define RF4_BRTH_FIRE      0x00000400  /* Breathe Fire */
#define RF4_BRTH_COLD      0x00000800  /* Breathe Cold */
#define RF4_BRTH_POIS      0x00001000  /* Breathe Poison */
#define RF4_BRTH_PLAS      0x00002000  /* Breathe Plasma */
#define RF4_BRTH_LITE      0x00004000  /* Breathe Light */
#define RF4_BRTH_DARK      0x00008000  /* Breathe Dark */
#define RF4_BRTH_CONFU     0x00010000  /* Breathe Confusion */
#define RF4_BRTH_SOUND     0x00020000  /* Breathe Sound */
#define RF4_BRTH_SHARD     0x00040000  /* Breathe Shards */
#define RF4_BRTH_INERT     0x00080000  /* Breathe Inertia */
#define RF4_BRTH_GRAV      0x00100000  /* Breathe Gravity */
#define RF4_BRTH_WIND	   0x00200000  /* Breathe Wind */
#define RF4_BRTH_FORCE     0x00400000  /* Breathe Force */
#define RF4_BRTH_NEXUS     0x00800000  /* Breathe Nexus */
#define RF4_BRTH_NETHR     0x01000000  /* Breathe Nether */
#define RF4_BRTH_CHAOS     0x02000000  /* Breathe Chaos */
#define RF4_BRTH_DISEN     0x04000000  /* Breathe Disenchant */
#define RF4_BRTH_TIME      0x08000000  /* Breathe Time */
#define RF4_BRTH_MANA      0x10000000  /* Breathe Mana */
#define RF4_BRTH_HOLY      0x20000000  /* Breathe Holy Orb */
#define RF4_BRTH_FEAR      0x40000000  /* Breathe Fear */
#define RF4_BRTH_DISEA     0x80000000  /* Breathe Disease */


/*
 * Monster racial flags - defined-area projection spells
 */
#define RF5_BALL_ACID      0x00000001  /* Acid Ball -> Acid Storm */
#define RF5_BALL_ELEC      0x00000002  /* Elec Ball -> Elec Storm */
#define RF5_BALL_FIRE      0x00000004  /* Fire Ball -> Fire Storm */
#define RF5_BALL_COLD      0x00000008  /* Cold Ball -> Cold Storm */
#define RF5_BALL_POIS      0x00000010  /* Stinking Cloud -> Poison Storm */
#define RF5_BALL_LITE      0x00000020  /* Light Ball / Starburst */
#define RF5_BALL_DARK      0x00000040  /* Darkness Ball -> Dark Storm */
#define RF5_BALL_CONFU     0x00000080  /* Confusion Ball -> Conf Storm */
#define RF5_BALL_SOUND     0x00000100  /* Sound Ball -> Sound Storm */
#define RF5_BALL_SHARD     0x00000200  /* Shard Ball -> Shard Storm */
#define RF5_BALL_WIND      0x00000400  /* Wind Ball -> Hurricane */
#define RF5_BALL_STORM     0x00000800  /* Storm Ball -> Tempest */
#define RF5_BALL_NETHR     0x00001000  /* Nether Ball -> Nether Storm */
#define RF5_BALL_CHAOS     0x00002000  /* Chaos Ball -> Chaos Storm */
#define RF5_BALL_MANA      0x00004000  /* Mana Ball -> Mana Storm */
#define RF5_BALL_WATER     0x00008000  /* Water Ball */
#define RF5_BOLT_ACID      0x00010000  /* Acid Bolt */
#define RF5_BOLT_ELEC      0x00020000  /* Elec Bolt */
#define RF5_BOLT_FIRE      0x00040000  /* Fire Bolt */
#define RF5_BOLT_COLD      0x00080000  /* Cold Bolt */
#define RF5_BOLT_POIS      0x00100000  /* Poison Bolt */
#define RF5_BOLT_PLAS      0x00200000  /* Plasma Bolt */
#define RF5_BOLT_ICE       0x00400000  /* Ice Bolt */
#define RF5_BOLT_WATER     0x00800000  /* Water Bolt */
#define RF5_BOLT_NETHR     0x01000000  /* Nether Bolt */
#define RF5_BOLT_MANA      0x02000000  /* Magic Missile -> Mana Bolt */
#define RF5_HOLY_ORB       0x04000000  /* Orb of Draining */
#define RF5_BEAM_ELEC      0x08000000  /* Electric spark */
#define RF5_BEAM_ICE       0x10000000  /* Ice Lance */
#define RF5_BEAM_NETHR     0x20000000  /* Spear of Nether */
#define RF5_ARC_HFIRE	   0x40000000  /* Cone of hellfire */
#define RF5_ARC_FORCE      0x80000000  /* Cone of force */

/*
 * Monster racial flags - help self, hinder character, and special magics
 */

#define RF6_HASTE          0x00000001  /* Speed self */
#define RF6_ADD_MANA       0x00000002  /* Regain Mana */
#define RF6_HEAL           0x00000004  /* Heal self */
#define RF6_CURE           0x00000008  /* Cure self */
#define RF6_BLINK          0x00000010  /* Teleport Short */
#define RF6_TPORT          0x00000020  /* Teleport Long */
#define RF6_INVIS          0x00000040  /* Turn invisible */
#define RF6_TELE_SELF_TO   0x00000080  /* Teleport Self to Player */
#define RF6_TELE_TO        0x00000100  /* Move player to monster */
#define RF6_TELE_AWAY      0x00000200  /* Move player far away */
#define RF6_TELE_LEVEL     0x00000400  /* Move player vertically */
#define RF6_WRAITHFORM     0x00000800  /* Wraith form */
#define RF6_DARKNESS       0x00001000  /* Create Darkness */
#define RF6_TRAPS          0x00002000  /* Create Traps */
#define RF6_FORGET         0x00004000  /* Cause amnesia */
#define RF6_DRAIN_MANA     0x00008000  /* Drain Mana */
#define RF6_CURSE          0x00010000  /* Curse player */
#define RF6_DISPEL         0x00020000  /* Dispel player */
#define RF6_MIND_BLAST     0x00040000  /* Blast Mind  */
#define RF6_ILLUSION       0x00080000  /* Hallucinate player */
#define RF6_WOUND          0x00100000  /* Cause Wounds */
#define RF6_BLESS          0x00200000  /* Bless */
#define RF6_BERSERK         0x00400000  /* Berserk strength */
#define RF6_SHIELD         0x00800000  /* Shield */
#define RF6_OPPOSE_ELEM    0x01000000  /* Temporary elemental resist */
#define RF6_HUNGER         0x02000000  /* Make Player Hungry */
#define RF6_PROBE          0x04000000  /* Probe player for weakness */
#define RF6_SCARE          0x08000000  /* Frighten Player */
#define RF6_BLIND          0x10000000  /* Blind Player */
#define RF6_CONF           0x20000000  /* Confuse Player */
#define RF6_SLOW           0x40000000  /* Slow Player */
#define RF6_HOLD           0x80000000  /* Paralyze Player */


/*
 * Hack -- Bit masks to control what spells are considered
 * Monster racial flags - summons
 */

#define RF7_S_KIN          0x00000001  /* Summon Similar */
#define RF7_R_KIN          0x00000002  /* Raise Similar from dead*/
#define RF7_A_DEAD         0x00000004  /* Animate dead */
#define RF7_S_MONSTER      0x00000008  /* Summon Monster */
#define RF7_S_MONSTERS     0x00000010  /* Summon Monsters */
#define RF7_R_MONSTER      0x00000020  /* Raise Monster from dead */
#define RF7_R_MONSTERS     0x00000040  /* Raise Monsters from dead */
#define RF7_S_PLANT	   0x00000080  /* Summon Plants */
#define RF7_S_INSECT       0x00000100  /* Summon Insects */
#define RF7_S_ANIMAL       0x00000200  /* Summon Animals */
#define RF7_S_HOUND        0x00000400  /* Summon Hounds */
#define RF7_S_SPIDER       0x00000800  /* Summon Spiders */
#define RF7_S_CLASS        0x00001000  /* Summon Monsters of similar class (Warrior/Mage/Thief etc)*/
#define RF7_S_RACE         0x00002000  /* Summon Monsters of similar race (Elf/Man/Dwarf etc) */
#define RF7_S_GROUP        0x00004000  /* Summon Monsters of similar group (Fire/Water/Green etc) */
#define RF7_S_FRIEND       0x00008000  /* Summon a Friend */
#define RF7_S_FRIENDS      0x00010000  /* Summon Friends*/
#define RF7_S_ORC          0x00020000  /* Summon Orc */
#define RF7_S_TROLL        0x00040000  /* Summon Troll */
#define RF7_S_GIANT        0x00080000  /* Summon Giant */
#define RF7_S_DRAGON       0x00100000  /* Summon Dragon */
#define RF7_S_HI_DRAGON    0x00200000  /* Summon Ancient Dragons */
#define RF7_A_ELEMENT      0x00400000  /* Animate an element */
#define RF7_A_OBJECT       0x00800000  /* Animate an object */
#define RF7_S_DEMON        0x01000000  /* Summon Demon(s) */
#define RF7_S_HI_DEMON     0x02000000  /* Summon Greater Demons */
#define RF7_R_UNIQUE       0x04000000  /* Raise Unique Monster from dead */
#define RF7_S_UNIQUE       0x08000000  /* Summon Unique Monster */
#define RF7_S_HI_UNIQUE    0x10000000  /* Summon High Unique Monster */
#define RF7_S_UNDEAD       0x20000000  /* Summon Undead */
#define RF7_S_HI_UNDEAD    0x40000000  /* Summon Greater Undead */
#define RF7_S_WRAITH       0x80000000  /* Summon Unique Wraith */

/*
 * Monster racial flags - dropped objects and body parts
 */
#define RF8_HAS_SKULL      0x00000001
#define RF8_HAS_SKELETON   0x00000002
#define RF8_HAS_TEETH      0x00000004
#define RF8_HAS_CORPSE     0x00000008
#define RF8_HAS_HEAD       0x00000010
#define RF8_HAS_HAND       0x00000020
#define RF8_HAS_CLAW       0x00000040
#define RF8_HAS_ARM        0x00000080
#define RF8_HAS_LEG        0x00000100
#define RF8_HAS_WING       0x00000200
#define RF8_HAS_SKIN       0x00000400
#define RF8_HAS_SCALE      0x00000800
#define RF8_HAS_FEATHER    0x00001000
#define RF8_HAS_FUR        0x00002000
#define RF8_HAS_BLOOD      0x00004000      /* Leave bloody trails if injured */
#define RF8_HAS_SLIME      0x00008000      /* Leave slimy trails */
#define RF8_HAS_SPORE      0x00010000
#define RF8_DROP_CHEST     0x00020000      /* Chests ('&') */
#define RF8_DROP_MISSILE   0x00040000      /* Slings/Bows/Xbows/Ammo */
#define RF8_DROP_TOOL      0x00080000      /* Shovels/Picks/Spikes */
#define RF8_DROP_WEAPON    0x00100000      /* Weapons */
#define RF8_DROP_MUSIC     0x00200000      /* Musical instruments/Song books */
#define RF8_DROP_CLOTHES   0x00400000      /* Boots/Gloves/Cloaks/Soft Armor */
#define RF8_DROP_ARMOR     0x00800000      /* Hard Armor/Helms/Shields/Dragon Armor */
#define RF8_DROP_LITE      0x01000000      /* Lites/Flasks */
#define RF8_DROP_JEWELRY   0x02000000      /* Rings/Amulets/Crowns */
#define RF8_DROP_RSW       0x04000000      /* Rod/staff/wand */
#define RF8_DROP_WRITING   0x08000000      /* Books/scrolls */
#define RF8_DROP_POTION    0x10000000
#define RF8_DROP_FOOD      0x20000000
#define RF8_DROP_JUNK      0x40000000      /* Sticks, Pottery, etc ('~') */
#define RF8_ASSEMBLY       0x80000000	/* Assembly of component parts */


/*
 * Monster racial flags - extra flags from Sangband etc.
 */
#define RF9_LEVEL_CLASS    0x00000001      /* Levels up class deeper in the dungeon */
#define RF9_NEVER_MISS     0x00000002      /* Never miss when attacking */
#define RF9_LEVEL_SPEED    0x00000004      /* Levels up speed deeper in the dungeon */
#define RF9_EVASIVE        0x00000008      /* Evade melee blows / missiles / bolts */
#define RF9_SCENT          0x00000010      /* Track player by scent */
#define RF9_SUPER_SCENT    0x00000020      /* Track player by scent - better range */
#define RF9_WATER_SCENT    0x00000040      /* Track player by scent through water */
#define RF9_RES_BLIND      0x00000080      /* Resist blindness */
#define RF9_RES_LITE       0x00000100      /* Resist lite */
#define RF9_RES_DARK       0x00000200      /* Resist darkness */
#define RF9_RES_CHAOS      0x00000400      /* Resist chaos */
#define RF9_RES_TPORT      0x00000800      /* Resist teleportation */
#define RF9_RES_EDGED      0x00001000      /* Resist edged weapons */
#define RF9_RES_BLUNT      0x00002000      /* Resist blunt weapons */
#define RF9_IM_EDGED       0x00004000      /* Immune to edged weapons / resist shards*/
#define RF9_IM_BLUNT       0x00008000      /* Immune to blunt weapons / resist sound/force */
#define RF9_NO_CUTS        0x00010000      /* Cannot be cut */
#define RF9_NO_SLOW        0x00020000      /* Cannot be slowed / paralyzed */
#define RF9_RES_MAGIC      0x00040000      /* Resists magic */
#define RF9_GOOD           0x00080000      /* Good - never summon evil / never summoned by evil */
#define RF9_LEVEL_AGE      0x00100000      /* ??? */
#define RF9_DWARF          0x00200000      /* Hurt by slay dwarf */
#define RF9_ELF            0x00400000      /* Hurt by slay elf */
#define RF9_MAN            0x00800000      /* Hurt by slay man */
#define RF9_TOWNSFOLK      0x01000000      /* Use townsfolk AI */
#define RF9_DROP_ESSENCE   0x02000000      /* Drop essences */
#define RF9_DROP_MUSHROOM  0x04000000      /* Drop specific mushrooms */
#define RF9_DROP_MINERAL   0x08000000      /* Drop specific gold */
#define RF9_ATTR_METAL     0x10000000      /* Changes color 'brighter' */
#define RF9_ATTR_INDEX     0x20000000      /* Changes color by index */
#define RF9_LEVEL_SIZE     0x40000000      /* Levels up size deeper in the dungeon */
#define RF9_LEVEL_POWER    0x80000000	   /* Levels up power deeper in the dungeon */

/*
 * Some flags are obvious
 */
#define RF1_OBVIOUS_MASK \
	(RF1_UNIQUE | RF1_QUESTOR | RF1_MALE | RF1_FEMALE | \
	 RF1_GUARDIAN | RF1_FRIEND | RF1_FRIENDS | RF1_ESCORT | RF1_ESCORTS)

/*
 *  Match race, class or skin for summoning.
 */

/*
 * "race" flags
 */
#define RF3_RACE_MASK \
	(RF3_ORC | RF3_TROLL | RF3_GIANT | RF3_DRAGON | \
	 RF3_DEMON | RF3_UNDEAD | RF3_ANIMAL | \
	 RF3_INSECT | RF3_PLANT)

#define RF9_RACE_MASK \
	(RF9_DWARF | RF9_ELF | RF9_MAN)

/*
 * "class" flags
 */
#define RF2_CLASS_MASK \
	(RF2_ARMOR | RF2_SNEAKY | RF2_PRIEST | RF2_MAGE)


/*
 * "skin" flags - used for summon animal
 */
#define RF8_SKIN_MASK \
	(RF8_HAS_FUR | RF8_HAS_FEATHER | RF8_HAS_SCALE)


/*
 * "level" flags - used for scaling up monsters to match dungeon level
 */
#define RF9_LEVEL_MASK \
	(RF9_LEVEL_AGE | /* RF9_LEVEL_CLASS | */ RF9_LEVEL_POWER | RF9_LEVEL_SPEED | RF9_LEVEL_SIZE)



/*
 * Drop mask - used for hack_monster_equip. Note does not include DROP_CHEST or DROP_CLOTHES.
 *
 * This ensures that a monster drops a maximum of one of each 'slot' of item.
 */
#define RF8_DROP_MASK \
	(RF8_DROP_MISSILE | RF8_DROP_TOOL | RF8_DROP_WEAPON | RF8_DROP_MUSIC | \
		 RF8_DROP_ARMOR | RF8_DROP_LITE | RF8_DROP_JEWELRY | RF8_DROP_RSW |  \
		 RF8_DROP_WRITING | RF8_DROP_POTION | RF8_DROP_FOOD | RF8_DROP_JUNK)

/*
 * Elements - used for summon elemental
 */
#define ELEM_FIRE     0
#define ELEM_EARTH    1
#define ELEM_WATER    2
#define ELEM_AIR      3
#define ELEM_MAGMA    4
#define ELEM_OOZE     5
#define ELEM_ICE      6
#define ELEM_SMOKE    7
#define ELEM_LITE     8

#define MAX_ELEMENTS   8


/*
 * Languages - used for monster to monster communication
 */
#define LANG_COMMON	0
#define LANG_ELF	1
#define LANG_DWARF	2
#define LANG_ORC	3
#define LANG_TROLL	4
#define LANG_GIANT	5
#define LANG_DRAGON	6
#define LANG_DEMON	7
#define LANG_UNDEAD	8
#define LANG_ESP	9
#define LANG_FOREST	10
#define LANG_MUSHROOM	11
#define LANG_NATURAL	12
#define MAX_LANGUAGES	65


/*
 *  Ecologies - used for monster placement
 */
#define MIN_ECOLOGY_RACES	8	/* Minimum different races in ecology */
#define MAX_ECOLOGY_RACES	64	/* Maximum total races in ecology (including duplicates) */

#define MAX_ECOLOGIES		16	/* Maximum total ecologies */


/*
 * Hack -- Bit masks to control what spells are considered
 */

/*
 * Innate spells are controlled by chance innate, all others by chance cast
 */
#define RF4_INNATE_MASK (0xFFFFFFFFL)

#define RF5_INNATE_MASK (0L)

#define RF6_INNATE_MASK (0L)

#define RF7_INNATE_MASK (0L)



 /*
  * Attack spells.
  * Need special treatment in movement AI.
  */
#define RF4_BALL_MASK (0L)

#define RF5_BALL_MASK \
	(RF5_BALL_ACID | RF5_BALL_ELEC | RF5_BALL_FIRE | RF5_BALL_COLD | \
	 RF5_BALL_POIS | RF5_BALL_LITE | RF5_BALL_DARK | RF5_BALL_CONFU | \
	 RF5_BALL_SOUND | RF5_BALL_SHARD | RF5_BALL_STORM | RF5_BALL_NETHR | \
	 RF5_BALL_CHAOS | RF5_BALL_MANA | RF5_BALL_WATER | RF5_HOLY_ORB | \
	 RF5_BALL_WIND)

#define RF6_BALL_MASK (0L)

#define RF7_BALL_MASK (0L)

/*
 * Hack -- "bolt" spells that may hurt fellow monsters
 * Need special treatment in AI.
 */
#define RF4_BOLT_MASK \
   0L

#define RF5_BOLT_MASK \
	(RF5_BOLT_ACID | RF5_BOLT_ELEC | RF5_BOLT_FIRE | RF5_BOLT_COLD | \
	 RF5_BOLT_POIS | RF5_BOLT_NETHR | RF5_BOLT_WATER | RF5_BOLT_MANA | \
	 RF5_BOLT_PLAS | RF5_BOLT_ICE)

#define RF6_BOLT_MASK \
   0L


#define RF7_BOLT_MASK \
   0L

/*
 * Hack -- "beam" spells that go through fellow monsters
 */
#define RF4_BEAM_MASK   (0L)

#define RF5_BEAM_MASK 	(RF5_BEAM_ELEC | RF5_BEAM_ICE | RF5_BEAM_NETHR)

#define RF6_BEAM_MASK 	(0L)

#define RF7_BEAM_MASK 	(0L)

/*
 * Archery attacks
 * Need special treatment in AI.
  */
#define RF4_ARCHERY_MASK	(RF4_BLOW_1 | RF4_BLOW_2 | RF4_BLOW_3 | RF4_BLOW_4)

#define RF5_ARCHERY_MASK 	(0L)

#define RF6_ARCHERY_MASK 	(0L)

#define RF7_ARCHERY_MASK 	(0L)

/*
 * Arc attacks.
 * Need special treatment in movement AI.
 */

#define RF4_ARC_MASK \
        (0L)

#define RF5_ARC_MASK \
 	(RF5_ARC_HFIRE | RF5_ARC_FORCE)

#define RF6_ARC_MASK \
	(0L)

#define RF7_ARC_MASK \
	(0L)


/*
 * Breath attacks.
 * Need special treatment in movement AI.
 */

#define RF4_BREATH_MASK \
        (RF4_BRTH_ACID | RF4_BRTH_ELEC | RF4_BRTH_FIRE | RF4_BRTH_COLD | \
	 RF4_BRTH_POIS | RF4_BRTH_PLAS | RF4_BRTH_LITE | RF4_BRTH_DARK | \
         RF4_BRTH_CONFU | RF4_BRTH_SOUND | RF4_BRTH_SHARD | RF4_BRTH_INERT | \
         RF4_BRTH_GRAV | RF4_BRTH_FORCE | RF4_BRTH_NEXUS | RF4_BRTH_NETHR | \
         RF4_BRTH_CHAOS | RF4_BRTH_DISEN | RF4_BRTH_TIME | RF4_BRTH_MANA | \
	 RF4_BRTH_HOLY | RF4_BRTH_FEAR | RF4_BRTH_DISEA | RF4_BRTH_WIND)

#define RF5_BREATH_MASK \
 	(0L)

#define RF6_BREATH_MASK \
	(0L)

#define RF7_BREATH_MASK \
	(0L)

 /*
  * Attack spells.
  * Need special treatment in movement AI.
  */
#define RF4_ATTACK_MASK \
        (RF4_ARCHERY_MASK | RF4_BOLT_MASK | RF4_BEAM_MASK | RF4_BALL_MASK | \
	RF4_ARC_MASK)

#define RF5_ATTACK_MASK \
	(RF5_ARCHERY_MASK | RF5_BOLT_MASK | RF5_BEAM_MASK | RF5_BALL_MASK | \
	RF5_ARC_MASK)

#define RF6_ATTACK_MASK \
	(RF6_ARCHERY_MASK | RF6_BOLT_MASK | RF6_BEAM_MASK | RF6_BALL_MASK | \
	RF6_ARC_MASK | RF6_WOUND | RF6_MIND_BLAST)

#define RF7_ATTACK_MASK \
	(RF7_ARCHERY_MASK | RF7_BOLT_MASK | RF7_BEAM_MASK | RF7_BALL_MASK | \
	RF7_ARC_MASK)


/*
 * Harassment (not direct damage) attacks.
 * Need special treatment in AI.
 */
#define RF4_HARASS_MASK \
	(0L)

#define RF5_HARASS_MASK \
 	(0L)

#define RF6_HARASS_MASK \
	(RF6_DARKNESS | RF6_TRAPS | RF6_FORGET | RF6_HUNGER | RF6_DRAIN_MANA | \
         RF6_SCARE | RF6_BLIND | RF6_CONF | RF6_SLOW | RF6_HOLD | RF6_CURSE | \
	 RF6_DISEASE | RF6_DISPEL | RF6_ILLUSION)

#define RF7_HARASS_MASK \
	(0L)


/*
 * Summoning Spells
 * Need special treatment in AI.
  */
#define RF4_SUMMON_MASK \
        (0L)

#define RF5_SUMMON_MASK \
	(0L)

#define RF6_SUMMON_MASK \
	(0L)

#define RF7_SUMMON_MASK \
	(0xFFFFFFFFL)



/*
 * Spells that increase the caster's relative speed
 */
#define RF4_HASTE_MASK \
	(0L)

#define RF5_HASTE_MASK \
	(RF5_HOLD | RF5_SLOW)

#define RF6_HASTE_MASK \
	(RF6_HASTE)

#define RF7_HASTE_MASK \
	(0L)


/*
 * Self targeted spells - monsters can only cast these on self
 */
#define RF4_SELF_TARGET_MASK \
	(RF4_QUAKE)

#define RF5_SELF_TARGET_MASK \
	(0L)

#define RF6_SELF_TARGET_MASK \
        (RF6_ADD_MANA | \
	RF6_BLINK | RF6_TPORT | RF6_INVIS | RF6_WRAITHFORM | \
	RF6_BERSERK)

#define RF7_SELF_TARGET_MASK \
	(0L)


/*
 * Assist spells - monsters only cast these on self;
 * priests may also cast these on allies
 */
#define RF4_ASSIST_MASK \
	(0L)

#define RF5_ASSIST_MASK \
	(0L)

#define RF6_ASSIST_MASK \
        (RF6_HEAL | RF6_CURE | RF6_BLESS | RF6_TELE_SELF_TO | RF6_TELE_TO | RF6_SHIELD | \
			RF6_HASTE | RF6_OPPOSE_ELEM)

#define RF7_ASSIST_MASK \
	(0L)


/*
 * Spells that can be can cast without a player in sight
 * Need special treatment in AI.
 */
#define RF4_NO_PLAYER_MASK \
        (RF4_ASSIST_MASK | RF4_SELF_TARGET_MASK)

#define RF5_NO_PLAYER_MASK \
        (RF5_ASSIST_MASK | RF5_SELF_TARGET_MASK)

#define RF6_NO_PLAYER_MASK \
        (RF6_ASSIST_MASK | RF6_SELF_TARGET_MASK)

#define RF7_NO_PLAYER_MASK \
        (RF7_ASSIST_MASK | RF7_SELF_TARGET_MASK)


/*
 * Spells that improve the caster's tactical position
 */
#define RF4_TACTIC_MASK \
	(0L)

#define RF5_TACTIC_MASK \
	(0L)

#define RF6_TACTIC_MASK \
	(RF6_BLINK)


/*
 * Annoying spells
 */
#define RF4_ANNOY_MASK \
	(0L)

#define RF5_ANNOY_MASK \
	(RF5_SCARE | \
	 RF5_BLIND | RF5_CONF | RF5_SLOW | RF5_HOLD)

#define RF6_ANNOY_MASK \
	(RF6_DRAIN_MANA | RF6_TELE_TO | RF6_DARKNESS | RF6_TRAPS | RF6_FORGET)

#define RF7_ANNOY_MASK \
	(0L)


/*
 * Healing spells
 */
#define RF4_HEAL_MASK \
	(0L)

#define RF5_HEAL_MASK \
	(0L)

#define RF6_HEAL_MASK \
	(RF6_HEAL)

#define RF7_HEAL_MASK \
	(0L)


/*
 * Spells that can destroy doors
 */
#define RF4_DOOR_BREAKER_MASK \
	(RF4_BRTH_ACID | RF4_BRTH_FIRE | RF4_BRTH_PLAS)

#define RF5_DOOR_BREAKER_MASK \
	(RF5_BOLT_ACID | RF5_BOLT_FIRE)

#define RF6_DOOR_BREAKER_MASK \
	(0L)

#define RF7_DOOR_BREAKER_MASK \
	(0L)



/* Spell Desire Table Columns */
#define D_BASE     0
#define D_SUMM     1
#define D_HURT     2
#define D_MANA     3
#define D_ESC      4
#define D_TACT     5
#define D_RES      6
#define D_RANGE    7


/* Weapon style constants, see edit/style.txt */

#define WS_NONE		0
#define WS_UNARMED	1
#define WS_ONE_HANDED	2
#define WS_TWO_HANDED	3
#define WS_WEAPON_SHIELD	4
#define WS_TWO_WEAPON	5
#define WS_HAFTED		6
#define WS_SWORD		7
#define WS_POLEARM		8
#define WS_THROWN		9
#define WS_SLING		10
#define WS_BOW		11
#define WS_XBOW		12
#define WS_BACKSTAB		13
#define WS_MAGIC_BOOK   14
#define WS_PRAYER_BOOK  15
#define WS_SONG_BOOK    16
#define WS_INSTRUMENT   17
#define WS_POTION	18
#define WS_SCROLL	19
#define WS_AMULET	20
#define WS_RING		21
#define WS_WAND		22
#define WS_STAFF	23
#define WS_SLAY_ORC	24
#define WS_SLAY_TROLL	25
#define WS_SLAY_GIANT	26
#define WS_SLAY_DRAGON	27
#define WS_SLAY_EVIL	28
#define WS_SLAY_UNDEAD	29
#define WS_SLAY_ANIMAL	30
#define WS_SLAY_DEMON	31

#define MAX_WEAP_STYLES  32

#define WS_WIELD_FLAGS  0x003001FFL /* UNARMED--POLEARM + RING + AMULET + NONE*/
#define WS_LAUNCHER_FLAGS  0x00301C01L /* SLING--XBOW + RING + AMULET + NONE*/
#define WS_THROWN_FLAGS  0x00300201L /* THROWN + RING + AMULET + NONE*/
#define WS_AWARE_FLAGS  0x00FC0001L /* These increase players awareness of objects as he increases level --- why NONE here??? */
#define WS_NON_WIELD_FLAGS  0xFFCC2000L /* SLAY_ORC--SLAY_DEMON, STAFF, WAND, SCROLL, POTION, BACKSTAB
					   Its not possible to 'wield' any of these styles, so to compensate
					   they accrue the none benefits as well (for the moment) */


/* Weapon style improvements */
#define WB_NONE   0
#define WB_HIT    1
#define WB_DAM    2
#define WB_AC     3
#define WB_BLOW   4
#define WB_SHOT   5
#define WB_MIGHT  6
#define WB_CRITICAL      7
#define WB_ID     8
#define WB_POWER  9
#define WB_ICKY_HANDS    10
#define WB_ICKY_WIELD    11
#define WB_BLESSED       12
#define WB_HOLD_SONG     13
#define WB_RES_FEAR      14
#define MAX_WEAP_BENEFITS       15


/*
 * Monster race number for familiar
 */
#define FAMILIAR_BASE_IDX	329
#define FAMILIAR_IDX	330

/*
 * Maximum number of familiar types
 */
#define MAX_FAMILIARS 28


/*
 * Maximum number of familiar abilities
 */
#define MAX_FAMILIAR_ABILITIES 161

/*
 * Choices at each 'level' of picks
 */
#define FAMILIAR_CHOICES	10

/*
 * Picks before moving on to the next 'level' of choices
 */
#define FAMILIAR_PICKS		2

/*
 * Maximum number of times abilities can be picked
 */
#define MAX_FAMILIAR_GAINS	32

/*
 * Level at which all familiars get a melee attack
 */
#define FAMILIAR_FREE_BLOW	10



/*
 * Familiar benefits
 *
 * Note the first 288 benefits correspond to monster flags.
 */
#define FAMILIAR_AC	288
#define FAMILIAR_SPEED	289
#define FAMILIAR_POWER	290
#define FAMILIAR_HP	291
#define FAMILIAR_VISION	292
#define FAMILIAR_SIZE	293
#define FAMILIAR_MANA	294
#define FAMILIAR_SPIKE	295
#define FAMILIAR_SHOT	296
#define FAMILIAR_BLOW	297

/* And the remaining benefits correspond to modifying the blow effect */


/*** Macro Definitions ***/

/*
 * Hack -- The main "screen"
 */
#define term_screen	(angband_term[0])

/*
 * Determine if a given inventory item is "aware"
 */
#define object_aware_p(T) \
	(k_info[(T)->k_idx].flavor ? \
	  k_info[(T)->k_idx].aware & (AWARE_FLAVOR) : \
	  k_info[(T)->k_idx].aware & (AWARE_EXISTS))

/*
 * Determine if a given inventory item is "tried"
 */
#define object_tried_p(T) \
	(k_info[(T)->k_idx].aware & (AWARE_TRIED))


/*
 * Determine if a given inventory item is "known"
 */
#define object_known_p(T) \
	((T)->ident & (IDENT_KNOWN))

/*
 * Determine if a given inventory item is "named"
 * Test One -- Check for special "known" or "named" tags
 * Test Two -- Check for "Flavor" + "Aware"
 * Test Three -- Check for easily known items.
 * Test Four -- Check for named items where the monster is known.
 */
#define object_named_p(T) \
	(((T)->ident & (IDENT_KNOWN | IDENT_NAME)) || \
	 (k_info[(T)->k_idx].flavor  ? \
	  ((k_info[(T)->k_idx].aware & (AWARE_FLAVOR)) != 0) : \
		(((k_info[(T)->k_idx].flags6 & (TR6_MOD_NAME | \
				TR6_FORCE_MOD | TR6_SIMPLE)) != 0) || \
		(((k_info[(T)->k_idx].flags6 & (TR6_NAMED)) != 0) && \
				(!((T)->name3) || (l_list[(T)->name3].sights))))))


/*
 * Determine if a given inventory item charges are known
 * Test One -- Check for special "known" or "named" tags
 * Test Two -- Check for "Easy Know" + "Aware"
 */
#define object_charges_p(T) \
	(((T)->ident & (IDENT_KNOWN | IDENT_CHARGES)) != 0)


/*
 * Determine if a given inventory item charges are known
 * Test One -- Check for special "known" or "named" tags
 */
#define object_pval_p(T) \
	(((T)->ident & (IDENT_KNOWN | IDENT_PVAL)) != 0)


/*
 * Determine if a given inventory item has known bonuses
 * Test One -- Check for special "known" or "bonus" tags
 */
#define object_bonus_p(T) \
	(((T)->ident & (IDENT_KNOWN | IDENT_BONUS)) != 0)


/*
 * Return the "attr" for a given item.
 * Use "flavor" if available and not aware.
 * Default to user definitions.
 */
#define object_attr(T) \
	((k_info[(T)->k_idx].flavor && (view_flavors || !(k_info[(T)->k_idx].aware & (AWARE_FLAVOR)))) ? \
	 (x_info[k_info[(T)->k_idx].flavor].x_attr) : \
	 (k_info[(T)->k_idx].x_attr))

/*
 * Return the "char" for a given item.
 * Use "flavor" if available and not aware.
 * Default to user definitions.
 */
#define object_char(T) \
	((k_info[(T)->k_idx].flavor && (view_flavors || !(k_info[(T)->k_idx].aware & (AWARE_FLAVOR)))) ? \
	 (x_info[k_info[(T)->k_idx].flavor].x_char) : \
	 (k_info[(T)->k_idx].x_char))




/*
 * Artifacts use the "name1" field
 */
#define artifact_p(T) \
	((T)->name1 ? TRUE : FALSE)

/*
 * Ego-Items use the "name2" field
 */
#define ego_item_p(T) \
	((T)->name2 ? TRUE : FALSE)


/*
 * Broken items.
 */
#define broken_p(T) \
	((T)->ident & (IDENT_BROKEN))

/*
 * Cursed items.
 */
#define cursed_p(T) \
	((T)->ident & (IDENT_CURSED))

/*
 * Uninteresting items.
 */
#define uninteresting_p(T) \
	(((T)->feeling == INSCRIP_AVERAGE) || \
			 ((T)->feeling == INSCRIP_CURSED) || \
			 ((T)->feeling == INSCRIP_NONMAGICAL) || \
			 ((T)->feeling == INSCRIP_UNRUNED))

/*
 * Uncontrolled items.
 *
 * Note should always test for f3 & (TR3_UNCONTROLLED) in addition to this.
 */
#define uncontrolled_p(T) \
	(((T)->ident & (IDENT_CURSED)) || \
	((T)->usage <= (UNCONTROLLED_CONTROL)))


/*
 * Coated items.
 */
#define coated_p(T) \
	((T)->xtra1 >= OBJECT_XTRA_MIN_COATS)


/*
 * Ammo.
 */
#define ammo_p(T) \
	(((T)->tval == TV_BOLT) || ((T)->tval == TV_ARROW) || \
	((T)->tval == TV_SHOT))


/*
 * Convert an "attr"/"char" pair into a "pict" (P)
 */
#define PICT(A,C) \
	((((u16b)(A)) << 8) | ((byte)(C)))

/*
 * Convert a "pict" (P) into an "attr" (A)
 */
#define PICT_A(P) \
	((byte)((P) >> 8))

/*
 * Convert a "pict" (P) into an "char" (C)
 */
#define PICT_C(P) \
	((char)((byte)(P)))


/*
 * Convert a "location" (Y,X) into a "grid" (G)
 */
#define GRID(Y,X) \
	(256 * (Y) + (X))

/*
 * Convert a "grid" (G) into a "location" (Y)
 */
#define GRID_Y(G) \
	((int)((G) / 256U))

/*
 * Convert a "grid" (G) into a "location" (X)
 */
#define GRID_X(G) \
	((int)((G) % 256U))


/*
 * Convert a "key event" into a "location" (Y)
 */
#define KEY_GRID_Y(K) \
	((int) ((p_ptr->wy) + ( ((K.mousey) - ROW_MAP) / \
		(use_trptile ? 3 : (use_dbltile ? 2 : 1)) )))

/*
 * Convert a "key event" into a "location" (X)
 */
#define KEY_GRID_X(K) \
	((int) ((p_ptr->wx) + ( ((K.mousex) - COL_MAP) / \
		((use_trptile ? 3 : (use_dbltile ? 2 : 1)) * (use_bigtile ? 2 : 1)) )))

/*
 * Define which mouse buttons correspond to which actions
 *
 * 1 is usually left-mouse button
 * 2 is usually right-mouse button
 */
#define BUTTON_AIM		1
#define BUTTON_MOVE		2



/*
 * Determines if a map location is "meaningful"
 */
#define in_bounds(Y,X) \
	(((unsigned)(Y) < (unsigned)(DUNGEON_HGT)) && \
	 ((unsigned)(X) < (unsigned)(DUNGEON_WID)))

/*
 * Determines if a map location is fully inside the outer walls
 * This is more than twice as expensive as "in_bounds()", but
 * often we need to exclude the outer walls from calculations.
 */
#define in_bounds_fully(Y,X) \
	(((Y) > 0) && ((Y) < DUNGEON_HGT-1) && \
	 ((X) > 0) && ((X) < DUNGEON_WID-1))


/*
 * Determines if a map location is fully inside the outer walls
 * with an additional 1 unit threshold.
 *
 * This is for tunnels which we may widen after generation.
 */
#define in_bounds_fully_tunnel(Y,X) \
	(((Y) > 1) && ((Y) < DUNGEON_HGT-2) && \
	 ((X) > 1) && ((X) < DUNGEON_WID-2))

/*
 * Determines if a map location is currently "on screen"
 * Note that "panel_contains(Y,X)" always implies "in_bounds(Y,X)".
 * Pre-storing this into a cave_info flag would be nice.  XXX XXX
 */
#define panel_contains(Y,X) \
	(((unsigned)((Y) - p_ptr->wy) < (unsigned)(SCREEN_HGT)) && \
	 ((unsigned)((X) - p_ptr->wx) < (unsigned)(SCREEN_WID)))




/*
 * Determine if a "legal" grid is a "floor" grid
 *
 * Line 1 -- forbid doors, rubble, seams, walls
 *
 * Note the use of the new "CAVE_XLOS" flag.
 */
#define cave_floor_bold(Y,X) \
	(!(cave_info[Y][X] & (CAVE_XLOS)))


/*
 * Determine if a "legal" grid is not a "flag" grid
 *
 * Line 1 -- forbid flag
 */
#define cave_flag_bold(Y,X,FLG) \
	(!(cave_info[Y][X] & (FLG)))


/*
 * Determine if a "legal" grid is suitable for view
 *
 * Note the use of the new "CAVE_XLOS" flag.
 */
#define cave_los_bold(Y,X) \
	(!(cave_info[Y][X] & (CAVE_XLOS)))

/*
 * Determine if a "legal" grid is suitable for projections
 *
 * Note the use of the new "CAVE_XLOF" flag.
 */
#define cave_project_bold(Y,X) \
	(!(cave_info[Y][X] & (CAVE_XLOF)))


/*
 * Determine if a "legal" grid is suitable for projections.
 * Third parameter is the projection flags. We either check LOS if
 * PROJECT_LOS is set, otherwise we check line of fire. If
 * PROJECT_THRU is set this is always true.
 */
#define cave_passable_bold(Y,X,R) \
	((((R) & (PROJECT_THRU)) != 0) ? (TRUE) : \
	 (!(cave_info[(Y)][(X)] & (((R) & (PROJECT_LOS)) != 0 ? CAVE_XLOS : CAVE_XLOF))))



/*
 * Determine if a "legal" grid is a "clean" floor grid
 *
 * Line 1 -- forbid non-drops
 * Line 2 -- forbid permanents
 * Line 3 -- forbid normal objects
 * Line 4 -- forbid dangerous terrain
 * Line 5 -- forbid dangerous terrain
 */
#define cave_clean_bold(Y,X) \
	((f_info[cave_feat[Y][X]].flags1 & (FF1_DROP)) && \
	 !(f_info[cave_feat[Y][X]].flags1 & (FF1_PERMANENT)) && \
	!(f_info[cave_feat[Y][X]].blow.method) && \
	!(f_info[cave_feat[Y][X]].blow.effect) && \
	 (cave_o_idx[Y][X] == 0))

/*
 * Determine if a "legal" grid is an "empty" floor grid
 *
 * Line 1 -- forbid non-placement grids
 * Line 2 -- forbid player/monsters
 */
#define cave_empty_bold(Y,X) \
	((f_info[cave_feat[Y][X]].flags1 & (FF1_PLACE)) && \
	 (cave_m_idx[Y][X] == 0))

/*
 * Determine if a "legal" grid is a valid starting grid for player
 */
#define cave_start_bold(Y,X) \
	((f_info[cave_feat[Y][X]].flags1 & (FF1_MOVE)) && \
	 !(f_info[cave_feat[Y][X]].flags1 & (FF1_PERMANENT)) && \
	(((!(f_info[cave_feat[Y][X]].blow.method) && \
	!(f_info[cave_feat[Y][X]].spell))) || \
	(f_info[cave_feat[Y][X]].flags2 & (FF2_COVERED)) ) && \
	(cave_m_idx[Y][X] == 0))

/*
 * Determine if a "legal" grid is an "naked" floor grid
 *
 * Line 1 -- forbid non-placers
 * Line 2 -- forbid non-droppers
 * Line 3 -- forbid permanent
 * Line 4 -- forbid normal objects
 * Line 5 -- forbid player/monsters
 */
#define cave_naked_bold(Y,X) \
 ((f_info[cave_feat[Y][X]].flags1 & (FF1_PLACE)) && \
	 (f_info[cave_feat[Y][X]].flags1 & (FF1_DROP)) && \
	 !(f_info[cave_feat[Y][X]].flags1 & (FF1_PERMANENT)) && \
	 (cave_o_idx[Y][X] == 0) && \
	 (cave_m_idx[Y][X] == 0))

/*
 * Determine if a "legal" grid is an "nearly naked" grid
 *
 * This can help for placing stairs on completely flooded levels.
 *
 * Line 1 -- forbid non-placers
 * Line 2-4 -- require drop terrain, or shallow or easy climb
 * Line 5 -- forbid permanent
 * Line 6 -- forbid normal objects
 * Line 7 -- forbid player/monsters
 */
#define cave_nearly_naked_bold(Y,X) \
 ((f_info[cave_feat[Y][X]].flags1 & (FF1_PLACE)) && \
 	((f_info[cave_feat[Y][X]].flags1 & (FF1_DROP)) || \
 	(f_info[cave_feat[Y][X]].flags2 & (FF2_SHALLOW)) || \
 	(f_info[cave_feat[Y][X]].flags3 & (FF3_EASY_CLIMB))) && \
	 !(f_info[cave_feat[Y][X]].flags1 & (FF1_PERMANENT)) && \
	 (cave_o_idx[Y][X] == 0) && \
	 (cave_m_idx[Y][X] == 0))


/*
 * Determine if a "legal" grid is "permanent"
 *
 * Line 1 -- permanent flag
 */
#define cave_perma_bold(Y,X) \
 (f_info[cave_feat[Y][X]].flags1  & (FF1_PERMANENT))


/*
 * Get the index number of the room. Return 0 if not in a valid room.
 *
 * This should only be used once all rooms are initialised.
 */
#define room_idx(Y,X) \
 (((cave_info[Y][X] & (CAVE_ROOM)) != 0) ?\
 	((dun_room[Y/BLOCK_HGT][X/BLOCK_WID] < DUN_ROOMS) ? \
	 (dun_room[Y/BLOCK_HGT][X/BLOCK_WID]) : \
	 (0)) : (0))

/*
 * Get the index number of the room. Return 0 if not in a valid room.
 *
 * This should only be used once all rooms are initialised.
 */
#define room_idx_ignore_valid(Y,X) \
 ((dun_room[Y/BLOCK_HGT][X/BLOCK_WID] < DUN_ROOMS) ? \
	 (dun_room[Y/BLOCK_HGT][X/BLOCK_WID]) : \
	 (0))


/*
 * Determine if a "room" grid has a flag. If we
 * are not in a room, we check the dungeon instead.
 */
#define room_has_flag(Y,X,FLAG) \
 (((cave_info[Y][X] & (CAVE_ROOM)) != 0) &&\
 	(dun_room[Y/BLOCK_HGT][X/BLOCK_WID] < DUN_ROOMS) ? \
	 (room_info[dun_room[Y/BLOCK_HGT][X/BLOCK_WID]].flags & (FLAG)) : \
	 (room_info[0].flags & (FLAG)))



/*
 * Determine if near a "room" grid has a flag
 *
 * This is almost always used to check if we are in a 'town'-like area.
 */
#define room_near_has_flag(Y,X,FLAG) \
 ((dun_room[Y/BLOCK_HGT][X/BLOCK_WID] < DUN_ROOMS) ? \
	 (room_info[dun_room[Y/BLOCK_HGT][X/BLOCK_WID]].flags & (FLAG)) : \
	 (room_info[0].flags & (FLAG)))




/*
 * Determine if a "legal" grid is within "los" of the player
 *
 * Note the use of comparison to zero to force a "boolean" result
 */
#define player_has_los_bold(Y,X) \
	((play_info[Y][X] & (PLAY_VIEW)) != 0)


/*
 * Determine if a "legal" grid can be "seen" by the player
 *
 * Note the use of comparison to zero to force a "boolean" result
 */
#define player_can_see_bold(Y,X) \
	((play_info[Y][X] & (PLAY_SEEN)) != 0)

/*
 * Determine if a "legal" grid can be "shot" by the player
 *
 * Note the use of comparison to zero to force a "boolean" result
 */
#define player_can_fire_bold(Y,X) \
	((play_info[Y][X] & (PLAY_FIRE)) != 0)


/*
 * This gives either the zone guard, or a replacement guardian, if one is defined.
 */
#define actual_guardian(ZONE_GUARD, DUNGEON, ZONE)	 \
  ((ZONE) ? (ZONE_GUARD) : ((t_info[(DUNGEON)].replace_guardian) &&		\
		(t_info[t_info[(DUNGEON)].guardian_ifvisited].visited) ? \
			t_info[(DUNGEON)].replace_guardian : (ZONE_GUARD)))


/*
 * Hack -- Prepare to use the "Secure" routines
 */
#if defined(SET_UID) && defined(SECURE)
extern int PlayerUID;
# define getuid() PlayerUID
# define geteuid() PlayerUID
#endif



/*** Color constants ***/


/*
 * Angband "attributes" (with symbols, and base (R,G,B) codes)
 *
 * The "(R,G,B)" codes are given in "fourths" of the "maximal" value,
 * and should "gamma corrected" on most (non-Macintosh) machines.
 */
#define TERM_DARK		0	/* 'd' */	/* 0,0,0 */
#define TERM_WHITE		1	/* 'w' */	/* 4,4,4 */
#define TERM_SLATE		2	/* 's' */	/* 2,2,2 */
#define TERM_ORANGE		3	/* 'o' */	/* 4,2,0 */
#define TERM_RED		4	/* 'r' */	/* 3,0,0 */
#define TERM_GREEN		5	/* 'g' */	/* 0,2,1 */
#define TERM_BLUE		6	/* 'b' */	/* 0,0,4 */
#define TERM_UMBER		7	/* 'u' */	/* 2,1,0 */
#define TERM_L_DARK		8	/* 'D' */	/* 1,1,1 */
#define TERM_L_WHITE	9	/* 'W' */	/* 3,3,3 */
#define TERM_L_PURPLE	10	/* 'P' */	/* ??? */
#define TERM_YELLOW		11	/* 'y' */	/* 4,4,0 */
#define TERM_L_RED		12	/* 'R' */	/* 4,0,0 */
#define TERM_L_GREEN	13	/* 'G' */	/* 0,4,0 */
#define TERM_L_BLUE		14	/* 'B' */	/* 0,4,4 */
#define TERM_L_UMBER	15	/* 'U' */	/* 3,2,1 */

#define TERM_PURPLE     16	/* 'p' */
#define TERM_VIOLET     17	/* 'v' */
#define TERM_TEAL       18	/* 't' */
#define TERM_MUD        19	/* 'm' */
#define TERM_L_YELLOW   20	/* 'Y' */
#define TERM_MAGENTA    21	/* 'i' */
#define TERM_L_TEAL     22	/* 'T' */
#define TERM_L_VIOLET   23	/* 'V' */
#define TERM_L_PINK     24	/* 'I' */
#define TERM_MUSTARD    25	/* 'M' */
#define TERM_BLUE_SLATE 26	/* 'z' */
#define TERM_DEEP_L_BLUE 27	/* 'Z' */

#define BASE_COLORS 	28	/* Maximum 'normal' colours */
#define MAX_COLORS 		256	/* Maximum 'normal' colours */


#define ATTR_FULL		0	/* full color translation */
#define ATTR_MONO		1	/* mono color translation */
#define ATTR_VGA		2	/* 16 color translation */
#define ATTR_BLIND		3	/* "Blind" color translation */
#define ATTR_LITE		4	/* "Torchlit" color translation */
#define ATTR_DARK		5	/* "Dark" color translation */
#define ATTR_HIGH		6	/* "Highlight" color translation */
#define ATTR_METAL		7	/* "Metallic" color translation */
#define ATTR_MISC		8	/* "Miscellaneous" color translation - see misc_to_attr */

/* Strongly consider the following for accessibility reasons */
#define ATTR_COLOR_RG	9	/* Red/green colorblind users */
#define ATTR_CONTRAST	10	/* High contrast colors */

#define MAX_ATTR		9

/*** Message constants ***/

enum
{
	MSG_GENERIC       = 0,
	MSG_HIT           = 1,
	MSG_MISS          = 2,
	MSG_FLEE          = 3,
	MSG_DROP          = 4,
	MSG_KILL          = 5,
	MSG_LEVEL         = 6,
	MSG_DEATH         = 7,
	MSG_STUDY         = 8,
	MSG_TELEPORT      = 9,
	MSG_SHOOT         = 10,
	MSG_QUAFF         = 11,
	MSG_ZAP_ROD       = 12,
	MSG_WALK          = 13,
	MSG_TPOTHER       = 14,
	MSG_HITWALL       = 15,
	MSG_EAT           = 16,
	MSG_STORE1        = 17,
	MSG_STORE2        = 18,
	MSG_STORE3        = 19,
	MSG_STORE4        = 20,
	MSG_DIG           = 21,
	MSG_OPENDOOR      = 22,
	MSG_SHUTDOOR      = 23,
	MSG_TPLEVEL       = 24,
	MSG_BELL          = 25,
	MSG_NOTHING_TO_OPEN = 26,
	MSG_LOCKPICK_FAIL = 27,
	MSG_STAIRS_DOWN   = 28,
	MSG_HITPOINT_WARN = 29,
	MSG_ACT_ARTIFACT  = 30,
	MSG_USE_STAFF     = 31,
	MSG_DESTROY       = 32,
	MSG_MON_HIT       = 33,
	MSG_MON_TOUCH     = 34,
	MSG_MON_PUNCH     = 35,
	MSG_MON_KICK      = 36,
	MSG_MON_CLAW      = 37,
	MSG_MON_BITE      = 38,
	MSG_MON_STING     = 39,
	MSG_MON_BUTT      = 40,
	MSG_MON_CRUSH     = 41,
	MSG_MON_ENGULF    = 42,
	MSG_MON_CRAWL     = 43,
	MSG_MON_DROOL     = 44,
	MSG_MON_SPIT      = 45,
	MSG_MON_GAZE      = 46,
	MSG_MON_WAIL      = 47,
	MSG_MON_SPORE     = 48,
	MSG_MON_BEG       = 49,
	MSG_MON_INSULT    = 50,
	MSG_MON_MOAN      = 51,
	MSG_RECOVER       = 52,
	MSG_BLIND         = 53,
	MSG_CONFUSED      = 54,
	MSG_POISONED      = 55,
	MSG_AFRAID        = 56,
	MSG_PARALYZED     = 57,
	MSG_DRUGGED       = 58,
	MSG_SPEED         = 59,
	MSG_SLOW          = 60,
	MSG_SHIELD        = 61,
	MSG_BLESSED       = 62,
	MSG_HERO          = 63,
	MSG_BERSERK       = 64,
	MSG_PROT_EVIL     = 65,
	MSG_INVULN        = 66,
	MSG_SEE_INVIS     = 67,
	MSG_INFRARED      = 68,
	MSG_RES_ACID      = 69,
	MSG_RES_ELEC      = 70,
	MSG_RES_FIRE      = 71,
	MSG_RES_COLD      = 72,
	MSG_RES_POIS      = 73,
	MSG_STUN          = 74,
	MSG_CUT           = 75,
	MSG_STAIRS_UP     = 76,
	MSG_STORE_ENTER   = 77,
	MSG_STORE_LEAVE   = 78,
	MSG_STORE_HOME    = 79,
	MSG_MONEY1        = 80,
	MSG_MONEY2        = 81,
	MSG_MONEY3        = 82,
	MSG_SHOOT_HIT     = 83,
	MSG_STORE5        = 84,
	MSG_LOCKPICK      = 85,
	MSG_DISARM        = 86,
	MSG_IDENT_BAD     = 87,
	MSG_IDENT_EGO     = 88,
	MSG_IDENT_ART     = 89,
	MSG_BR_ELEMENTS   = 90,
	MSG_BR_FROST      = 91,
	MSG_BR_ELEC       = 92,
	MSG_BR_ACID       = 93,
	MSG_BR_GAS        = 94,
	MSG_BR_FIRE       = 95,
	MSG_BR_CONF       = 96,
	MSG_BR_DISENCHANT = 97,
	MSG_BR_CHAOS      = 98,
	MSG_BR_SHARDS     = 99,
	MSG_BR_SOUND      = 100,
	MSG_BR_LIGHT      = 101,
	MSG_BR_DARK       = 102,
	MSG_BR_NETHER     = 103,
	MSG_BR_NEXUS      = 104,
	MSG_BR_TIME       = 105,
	MSG_BR_INERTIA    = 106,
	MSG_BR_GRAVITY    = 107,
	MSG_BR_PLASMA     = 108,
	MSG_BR_FORCE      = 109,
	MSG_SUM_MONSTER   = 110,
	MSG_SUM_MAIA     = 111,
	MSG_SUM_UNDEAD    = 112,
	MSG_SUM_ANIMAL    = 113,
	MSG_SUM_SPIDER    = 114,
	MSG_SUM_HOUND     = 115,
	MSG_SUM_HYDRA     = 116,
	MSG_SUM_DEMON     = 117,
	MSG_SUM_DRAGON    = 118,
	MSG_SUM_HI_UNDEAD = 119,
	MSG_SUM_HI_DRAGON = 120,
	MSG_SUM_HI_DEMON  = 121,
	MSG_SUM_WRAITH    = 122,
	MSG_SUM_UNIQUE    = 123,
	MSG_WIELD         = 124,
	MSG_CURSED        = 125,
	MSG_PSEUDOID      = 126,
	MSG_HUNGRY        = 127,
	MSG_NOTICE        = 128,
	MSG_AMBIENT_DAY   = 129,
	MSG_AMBIENT_NITE  = 130,
	MSG_AMBIENT_DNG1  = 131,
	MSG_AMBIENT_DNG2  = 132,
	MSG_AMBIENT_DNG3  = 133,
	MSG_AMBIENT_DNG4  = 134,
	MSG_AMBIENT_DNG5  = 135,
	MSG_CREATE_TRAP   = 136,
	MSG_SHRIEK        = 137,
	MSG_CAST_FEAR     = 138,
	MSG_HIT_GOOD      = 139,
	MSG_HIT_GREAT     = 140,
	MSG_HIT_SUPERB    = 141,
	MSG_HIT_HI_GREAT  = 142,
	MSG_HIT_HI_SUPERB = 143,
	MSG_SPELL         = 144,
	MSG_PRAYER        = 145,
	MSG_KILL_UNIQUE   = 146,
	MSG_KILL_KING     = 147,
	MSG_DRAIN_STAT    = 148,
	MSG_MULTIPLY      = 149,
	MSG_SCREENDUMP	  = 150,

	MSG_MAX           = 151,
	SOUND_MAX         = MSG_MAX
};




/*** Sound constants ***/


/*
 * Mega-Hack -- some primitive sound support (see "main-win.c")
 *
 * Some "sound" constants for "Term_xtra(TERM_XTRA_SOUND, val)"
 *
 */

/*
 * Note that the MSG_ constans above are now used for all sounds.
 */


/*
 * Maximum known sounds
 *
 * Should be the same as MSG_MAX for compatibility reasons.
 */
#define SOUND_MAX MSG_MAX


/*** Hack ***/


/*
 * Hack -- attempt to reduce various values
 */
#ifdef ANGBAND_LITE
# undef MACRO_MAX
# define MACRO_MAX	128
# undef QUARK_MAX
# define QUARK_MAX	256
# undef MESSAGE_MAX
# define MESSAGE_MAX	128
# undef MESSAGE_BUF
# define MESSAGE_BUF	4096
#endif


/*
 * Mega-Hack -- maximum known sounds
 *
 * Should be the same as MSG_MAX for compatibility reasons.
 */
#define SOUND_MAX MSG_MAX



/*** Hack ***/


/*
 * Hack -- attempt to reduce various values
 */
#ifdef ANGBAND_LITE
# undef MACRO_MAX
# define MACRO_MAX	128
# undef QUARK_MAX
# define QUARK_MAX	256
# undef MESSAGE_MAX
# define MESSAGE_MAX	128
# undef MESSAGE_BUF
# define MESSAGE_BUF	4096
#endif


/*
 * Available graphic modes
 */
#define GRAPHICS_NONE           0
#define GRAPHICS_ORIGINAL       1
#define GRAPHICS_ADAM_BOLT      2
#define GRAPHICS_DAVID_GERVAIS  3
#define GRAPHICS_DAVID_GERVAIS_ISO	4

/*
 * List of commands that will be auto-repeated
 *
 * ToDo: This string should be user-configurable.
 */
#define AUTO_REPEAT_COMMANDS "TBDoc+"


/*
 * HACK - define if the source contains the cleanup_angband() function.
 */
#define HAS_CLEANUP


/*
 * Given an array, determine how many elements are in the array.
 */
#define N_ELEMENTS(a) (sizeof(a) / sizeof((a)[0]))



/* Utilitary macros for the grid queue type */

/* These two return the coordinates of the grid at the front of the queue */
/* THE QUEUE MUST CONTAIN AT LEAST ONE ELEMENT */
#define GRID_QUEUE_Y(Q) ((Q)->data[(Q)->head].y)
#define GRID_QUEUE_X(Q) ((Q)->data[(Q)->head].x)

/* Returns TRUE if the given queue is empty */
#define GRID_QUEUE_EMPTY(Q) ((Q)->head == (Q)->tail)

/* Returns TRUE if the given queue is full */
#define GRID_QUEUE_FULL(Q) ((((Q)->tail + 1) % (Q)->max_size) == (Q)->head)

/*Square a number*/
#define GET_SQUARE(X) 	((X) * (X))


/*
 * Maximum size around the player to consider in the pathfinder
 */
#define MAX_PF_RADIUS 50

/*
 * Maximum distance to consider in the pathfinder
 */
#define MAX_PF_LENGTH 250


/*
 * Objects in the quiver are stored in groups. Each group has its own set of tags ranging from 0 to 9.
 * The order of the groups is determined by the value of these constants
 */
enum
{
	QUIVER_GROUP_BOLTS = 0,
	QUIVER_GROUP_ARROWS,
	QUIVER_GROUP_SHOTS,
	QUIVER_GROUP_THROWING_WEAPONS,
	MAX_QUIVER_GROUPS
};

/*** Object origin kinds ***/
enum
{
 	ORIGIN_NONE = 0,
 	ORIGIN_MIXED,
 	ORIGIN_BIRTH,
 	ORIGIN_STORE,
 	ORIGIN_FLOOR,
 	ORIGIN_DROP,
	ORIGIN_DROP_UNKNOWN,
	ORIGIN_FEAT,
 	ORIGIN_ACQUIRE,
	ORIGIN_CHEAT,
	ORIGIN_CHEST,
	ORIGIN_STORE_REWARD,
	ORIGIN_STORE_STORAGE
};
