

/* File: types.h */

/*
 * Copyright (c) 1998 Julian Lighton, 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.
 */


/*
 * Note that "char" may or may not be signed, and that "signed char"
 * may or may not work on all machines.  So always use "s16b" or "s32b"
 * for signed values.  Also, note that unsigned values cause math problems
 * in many cases, so try to only use "u16b" and "u32b" for "bit flags",
 * unless you really need the extra bit of information, or you really
 * need to restrict yourself to a single byte for storage reasons.
 *
 * Also, if possible, attempt to restrict yourself to sub-fields of
 * known size (use "s16b" or "s32b" instead of "int", and "byte" instead
 * of "bool"), and attempt to align all fields along four-byte words, to
 * optimize storage issues on 32-bit machines.  Also, avoid "bit flags"
 * since these increase the code size and slow down execution.  When
 * you need to store bit flags, use one byte per flag, or, where space
 * is an issue, use a "byte" or "u16b" or "u32b", and add special code
 * to access the various bit flags.
 *
 * Many of these structures were developed to reduce the number of global
 * variables, facilitate structured program design, allow the use of ascii
 * template files, simplify access to indexed data, or facilitate efficient
 * clearing of many variables at once.
 *
 * Note that certain data is saved in multiple places for efficient access,
 * and when modifying the data in one place it must also be modified in the
 * other places, to prevent the creation of inconsistant data.
 */


/**** Available Types ****/


/*
 * An array of 256 byte's
 */
typedef byte byte_256[256];

/*
 * An array of 256 s16b's
 */
typedef s16b s16b_256[256];


/*
 * An array of DUNGEON_WID byte's
 */
typedef byte byte_wid[DUNGEON_WID];

/*
 * An array of DUNGEON_WID s16b's
 */
typedef s16b s16b_wid[DUNGEON_WID];

/**** Available Structs ****/


typedef struct header header;
typedef struct feature_type feature_type;
typedef struct object_kind object_kind;
typedef struct artifact_type artifact_type;
typedef struct ego_item_type ego_item_type;
typedef struct ego_item_alloc ego_item_alloc;
typedef struct monster_blow monster_blow;
typedef struct monster_race monster_race;
typedef struct vault_type vault_type;
typedef struct object_type object_type;
typedef struct monster_type monster_type;
typedef struct alloc_entry alloc_entry;
typedef struct quest quest;
typedef struct owner_type owner_type;
typedef struct store_type store_type;
typedef struct magic_type magic_type;
typedef struct player_magic player_magic;
typedef struct skill_type skill_type;
typedef struct skill_info skill_info;
typedef struct talent_type talent_type;
typedef struct player_sex player_sex;
typedef struct player_race player_race;
typedef struct player_other player_other;
typedef struct player_type player_type;



/**** Available structs ****/


/*
 * Template file header information (see "init.c").  16 bytes.
 *
 * Note that the sizes of many of the "arrays" are between 32768 and
 * 65535, and so we must use "unsigned" values to hold the "sizes" of
 * these arrays below.  Normally, I try to avoid using unsigned values,
 * since they can cause all sorts of bizarre problems, but I have no
 * choice here, at least, until the "race" array is split into "normal"
 * and "unique" monsters, which may or may not actually help.
 *
 * Note that, on some machines, for example, the Macintosh, the standard
 * "read()" and "write()" functions cannot handle more than 32767 bytes
 * at one time, so we need replacement functions, see "util.c" for details.
 *
 * Note that, on some machines, for example, the Macintosh, the standard
 * "malloc()" function cannot handle more than 32767 bytes at one time,
 * but we may assume that the "ralloc()" function can handle up to 65535
 * butes at one time.  We should not, however, assume that the "ralloc()"
 * function can handle more than 65536 bytes at a time, since this might
 * result in segmentation problems on certain older machines, and in fact,
 * we should not assume that it can handle exactly 65536 bytes at a time,
 * since the internal functions may use an unsigned short to specify size.
 *
 * In general, these problems occur only on machines (such as most personal
 * computers) which use 2 byte "int" values, and which use "int" for the
 * arguments to the relevent functions.
 */
struct header
{
	byte v_major;				/* Version -- major */
	byte v_minor;				/* Version -- minor */
	byte v_patch;				/* Version -- patch */
	byte v_extra;				/* Version -- extra */


	u16b info_num;				/* Number of "info" records */

	u16b info_len;				/* Size of each "info" record */


	u16b head_size;				/* Size of the "header" in bytes */

	u16b info_size;				/* Size of the "info" array in bytes */

	u16b name_size;				/* Size of the "name" array in bytes */

	u16b text_size;				/* Size of the "text" array in bytes */
};



/*
 * Information about terrain "features"
 */
struct feature_type
{
	u16b name;					/* Name (offset) */
	u16b text;					/* Text (offset) */

	byte mimic;					/* Feature to mimic */

	byte extra;					/* Extra byte (unused) */

	s16b unused;				/* Extra bytes (unused) */

	byte d_attr;				/* Object "attribute" */
	char d_char;				/* Object "symbol" */

	byte x_attr;				/* The desired attr for this feature */
	char x_char;				/* The desired char for this feature */
};


/*
 * Information about object "kinds", including player knowledge.
 *
 * Only "aware" and "tried" are saved in the savefile
 */
struct object_kind
{
	u16b name;					/* Name (offset) */
	u16b text;					/* Text (offset) */

	byte tval;					/* Object type */
	byte sval;					/* Object sub type */

	s16b pval;					/* Object extra info */

	s16b to_h;					/* Bonus to hit */
	s16b to_d;					/* Bonus to damage */
	s16b to_a;					/* Bonus to armor */

	s16b ac;					/* Base armor */

	byte dd, ds;				/* Damage dice/sides */

	s16b weight;				/* Weight */

	s32b cost;					/* Object "base cost" */

	u32b flags1;				/* Flags, set 1 */
	u32b flags2;				/* Flags, set 2 */
	u32b flags3;				/* Flags, set 3 */
	byte locale[4];				/* Allocation level(s) */
	byte chance[4];				/* Allocation chance(s) */

	byte level;					/* Level */
	s16b activate;				/* Activation */


	byte d_attr;				/* Default object attribute */
	char d_char;				/* Default object character */


	byte x_attr;				/* Desired object attribute */
	char x_char;				/* Desired object character */


	byte flavor;				/* Special object flavor (or zero) */

	bool easy_know;				/* This object is always known (if aware) */


	bool aware;					/* The player is "aware" of the item's effects */

	bool tried;					/* The player has "tried" one of the items */
};



/*
 * Information about "artifacts".
 *
 * Note that the save-file only writes "cur_num" to the savefile.
 *
 * Note that "max_num" is always "1" (if that artifact "exists")
 */
struct artifact_type
{
	u16b name;					/* Name (offset) */
	u16b text;					/* Text (offset) */

	byte tval;					/* Artifact type */
	byte sval;					/* Artifact sub type */

	s16b pval;					/* Artifact extra info */

	s16b to_h;					/* Bonus to hit */
	s16b to_d;					/* Bonus to damage */
	s16b to_a;					/* Bonus to armor */

	s16b ac;					/* Base armor */

	byte dd, ds;				/* Damage when hits */

	s16b weight;				/* Weight */

	s32b cost;					/* Artifact "cost" */

	u32b flags1;				/* Artifact Flags, set 1 */
	u32b flags2;				/* Artifact Flags, set 2 */
	u32b flags3;				/* Artifact Flags, set 3 */

	byte level;					/* Artifact level */
	byte rarity;				/* Artifact rarity */

	byte cur_num;				/* Number created (0 or 1) */
	byte max_num;				/* Unused (should be "1") */

	s16b activate;				/* Artifact activation */
};


/*
 * Information about "ego-items".
 */
struct ego_item_type
{
	u16b name;					/* Name (offset) */
	u16b text;					/* Text (offset) */

	byte slot;					/* Standard slot value */
	byte rating;				/* Rating boost */

	byte level;					/* Minimum level */
	byte alloc_group;			/* Allocation group */
	byte rarity;				/* Relative rarity of object */
	byte alloc_special;			/* Special conditions on allocation */

	byte max_to_h;				/* Maximum to-hit bonus */
	byte max_to_d;				/* Maximum to-dam bonus */
	byte max_to_a;				/* Maximum to-ac bonus */

	byte max_pval;				/* Maximum pval */

	s32b cost;					/* Ego-item "cost" */

	u32b flags1;				/* Ego-Item Flags, set 1 */
	u32b flags2;				/* Ego-Item Flags, set 2 */
	u32b flags3;				/* Ego-Item Flags, set 3 */
	u32b xtra;					/* Extra ability flags */

	s16b activate;				/* Activation */
};


/*
 * Ego-item allocation information.
 */
struct ego_item_alloc
{
	s16b slot;					/* What slot these ego-items go in. Currently 
								 * unused. */
	byte num_good;				/* How many good ego types there are */
	byte first_good;			/* index of the first good one */
	byte num_bad;				/* How many bad ego types there are */
	byte first_bad;				/* index of the first bad one */
};

/*
 * Monster blow structure
 *
 *   - Method (RBM_*)
 *   - Effect (RBE_*)
 *   - Damage Dice
 *   - Damage Sides
 */
struct monster_blow
{
	byte method;
	byte effect;
	byte d_dice;
	byte d_side;
};



/*
 * Monster "race" information, including racial memories
 *
 * Note that "d_attr" and "d_char" are used for MORE than "visual" stuff.
 *
 * Note that "x_attr" and "x_char" are used ONLY for "visual" stuff.
 *
 * Note that "cur_num" (and "max_num") represent the number of monsters
 * of the given race currently on (and allowed on) the current level.
 * This information yields the "dead" flag for Unique monsters.
 *
 * Note that "max_num" is reset when a new player is created.
 * Note that "cur_num" is reset when a new level is created.
 *
 * Note that several of these fields, related to "recall", can be
 * scrapped if space becomes an issue, resulting in less "complete"
 * monster recall (no knowledge of spells, etc).  All of the "recall"
 * fields have a special prefix to aid in searching for them.
 */
struct monster_race
{
	u16b name;					/* Name (offset) */
	u16b text;					/* Text (offset) */

	byte hdice;					/* Creatures hit dice count */
	byte hside;					/* Creatures hit dice sides */

	s16b ac;					/* Armour Class */

	s16b sleep;					/* Inactive counter (base) */
	byte aaf;					/* Area affect radius (1-100) */
	byte speed;					/* Speed (normally 110) */

	s32b mexp;					/* Exp value for kill */

	s16b extra;					/* Unused (for now) */

	byte freq_inate;			/* Inate spell frequency */
	byte freq_spell;			/* Other spell frequency */

	u32b flags1;				/* Flags 1 (general) */
	u32b flags2;				/* Flags 2 (abilities) */
	u32b flags3;				/* Flags 3 (race/resist) */
	u32b flags4;				/* Flags 4 (inate/breath) */
	u32b flags5;				/* Flags 5 (normal spells) */
	u32b flags6;				/* Flags 6 (special spells) */

	monster_blow blow[4];		/* Up to four blows per round */


	byte level;					/* Level of creature */
	byte rarity;				/* Rarity of creature */


	byte d_attr;				/* Default monster attribute */
	char d_char;				/* Default monster character */


	byte x_attr;				/* Desired monster attribute */
	char x_char;				/* Desired monster character */


	byte max_num;				/* Maximum population allowed per level */

	byte cur_num;				/* Monster population on current level */


	s16b r_sights;				/* Count sightings of this monster */
	s16b r_deaths;				/* Count deaths from this monster */

	s16b r_pkills;				/* Count monsters killed in this life */
	s16b r_tkills;				/* Count monsters killed in all lives */

	byte r_wake;				/* Number of times woken up (?) */
	byte r_ignore;				/* Number of times ignored (?) */

	byte r_xtra1;				/* Something (unused) */
	byte r_xtra2;				/* Something (unused) */

	byte r_drop_gold;			/* Max number of gold dropped at once */
	byte r_drop_item;			/* Max number of item dropped at once */

	byte r_cast_inate;			/* Max number of inate spells seen */
	byte r_cast_spell;			/* Max number of other spells seen */
	byte r_blows[4];			/* Number of times each blow type was seen */

	u32b r_flags1;				/* Observed racial flags */
	u32b r_flags2;				/* Observed racial flags */
	u32b r_flags3;				/* Observed racial flags */
	u32b r_flags4;				/* Observed racial flags */
	u32b r_flags5;				/* Observed racial flags */
	u32b r_flags6;				/* Observed racial flags */
};



/*
 * Information about "vault generation"
 */
struct vault_type
{
	u16b name;					/* Name (offset) */
	u16b text;					/* Text (offset) */

	byte typ;					/* Vault type */

	byte rat;					/* Vault rating */

	byte hgt;					/* Vault height */
	byte wid;					/* Vault width */
};



/*
 * Object information, for a specific object.
 *
 * Note that a "discount" on an item is permanent and never goes away.
 *
 * Note that inscriptions are now handled via the "quark_str()" function
 * applied to the "note" field, which will return NULL if "note" is zero.
 *
 * Note that "object" records are "copied" on a fairly regular basis,
 * and care must be taken when handling such objects.
 *
 * Each cave grid points to one (or zero) objects via the "o_idx"
 * field (above).  Each object then points to one (or zero) objects
 * via the "next_o_idx" field, forming a singly linked list, which
 * in game terms, represents a "stack" of objects in the same grid.
 *
 * Each monster points to one (or zero) objects via the "hold_o_idx"
 * field (below).  Each object then points to one (or zero) objects
 * via the "next_o_idx" field, forming a singly linked list, which
 * in game terms, represents a pile of objects held by the monster.
 *
 * The "held_m_idx" field is used to indicate which monster, if any,
 * is holding the object.  Objects being held have "ix=0" and "iy=0".
 */
struct object_type
{
	s16b k_idx;					/* Kind index (zero if "dead") */

	byte iy;					/* Y-position on map, or zero */
	byte ix;					/* X-position on map, or zero */

	byte tval;					/* Item type (from kind) */
	byte sval;					/* Item sub-type (from kind) */

	s16b pval;					/* Item extra-parameter */

	byte discount;				/* Discount (if any) */

	byte number;				/* Number of items */
	s16b weight;				/* Item weight */

	byte name1;					/* Artifact type, if any */
	byte name2;					/* Ego-Item type, if any */

	u32b flags1;				/* Flags, set 1 */
	u32b flags2;				/* Flags, set 2 */
	u32b flags3;				/* Flags, set 3 */

	s32b b_cost;				/* Base cost */

	s16b to_h;					/* Plusses to hit */
	s16b to_d;					/* Plusses to damage */
	s16b to_a;					/* Plusses to AC */

	s16b ac;					/* Normal AC */

	byte dd, ds;				/* Damage dice/sides */

	s16b timeout;				/* Timeout Counter */

	byte ident;					/* Special flags  */

	byte marked;				/* Object is marked */

	u16b note;					/* Inscription index */

	s16b next_o_idx;			/* Next object in stack (if any) */

	s16b held_m_idx;			/* Monster holding us (if any) */
};



/*
 * Monster information, for a specific monster.
 *
 * Note: fy, fx constrain dungeon size to 256x256
 *
 * The "hold_o_idx" field points to the first object of a stack
 * of objects (if any) being carried by the monster (see above).
 */
struct monster_type
{
	s16b r_idx;					/* Monster race index */

	byte fy;					/* Y location on map */
	byte fx;					/* X location on map */

	s16b hp;					/* Current Hit points */
	s16b maxhp;					/* Max Hit points */

	s16b csleep;				/* Inactive counter */

	byte mspeed;				/* Monster "speed" */
	byte energy;				/* Monster "energy" */

	byte stunned;				/* Monster is stunned */
	byte confused;				/* Monster is confused */
	byte monfear;				/* Monster is afraid */

	byte cdis;					/* Current dis from player */

	byte mflag;					/* Extra monster flags */

	bool ml;					/* Monster is "visible" */

	s16b hold_o_idx;			/* Object being held (if any) */

#ifdef DRS_SMART_OPTIONS

	u32b smart;					/* Field for "smart_learn" */

#endif
};


/*
 * An entry for the object/monster allocation functions
 *
 * Pass 1 is determined from allocation information
 * Pass 2 is determined from allocation restriction
 * Pass 3 is determined from allocation calculation
 */
struct alloc_entry
{
	s16b index;					/* The actual index */

	byte level;					/* Base dungeon level */
	byte prob1;					/* Probability, pass 1 */
	byte prob2;					/* Probability, pass 2 */
	byte prob3;					/* Probability, pass 3 */

	u16b total;					/* Unused for now */
};



/*
 * Structure for the "quests"
 *
 * Hack -- currently, only the "level" parameter is set, with the
 * semantics that "one (QUEST) monster of that level" must be killed,
 * and then the "level" is reset to zero, meaning "all done".  Later,
 * we should allow quests like "kill 100 fire hounds", and note that
 * the "quest level" is then the level past which progress is forbidden
 * until the quest is complete.  Note that the "QUESTOR" flag then could
 * become a more general "never out of depth" flag for monsters.
 *
 * Actually, in Angband 2.8.0 it will probably prove easier to restrict
 * the concept of quest monsters to specific unique monsters, and to
 * actually scan the dead unique list to see what quests are left.
 */
struct quest
{
	int level;					/* Dungeon level */
	int r_idx;					/* Monster race */
	int cur_num;				/* Number killed (unused) */
	int max_num;				/* Number required (unused) */
};




/*
 * A store owner
 */
struct owner_type
{
	cptr owner_name;			/* Name */

	s16b max_cost;				/* Purse limit */

	byte max_inflate;			/* Inflation (max) */
	byte min_inflate;			/* Inflation (min) */

	byte haggle_per;			/* Haggle unit */

	byte insult_max;			/* Insult limit */

	byte owner_race;			/* Owner race */
	byte unused;				/* Unused */
};




/*
 * A store, with an owner, various state flags, a current stock
 * of items, and a table of items that are often purchased.
 */
struct store_type
{
	byte owner;					/* Owner index */
	byte extra;					/* Unused for now */

	s16b insult_cur;			/* Insult counter */

	s16b good_buy;				/* Number of "good" buys */
	s16b bad_buy;				/* Number of "bad" buys */

	s32b store_open;			/* Closed until this turn */

	s32b store_wrap;			/* Unused for now */
	s16b table_num;				/* Table -- Number of entries */
	s16b table_size;			/* Table -- Total Size of Array */
	s16b *table;				/* Table -- Legal item kinds */

	s16b stock_num;				/* Stock -- Number of entries */
	s16b stock_size;			/* Stock -- Total Size of Array */
	object_type *stock;			/* Stock -- Actual stock items */
};





/*
 * The "name" of spell 'N' is stored as spell_names[X][N],
 * where X is 0 for mage-spells and 1 for priest-spells.
 */
struct magic_type
{
	byte slevel;				/* Required level (to learn) */
	byte smana;					/* Required mana (to cast) */
	byte sfail;					/* Minimum chance of failure */
	s16b sexp;					/* Encoded experience bonus */
};

/*
 * Information about the player's "magic"
 *
 * Note that a player with a "spell_book" of "zero" is illiterate.
 */
struct player_magic
{
	cptr title;					/* Name of realm */
	s16b spell_book;			/* Tval of spell books */
	s16b spell_stat;			/* Stat for spells */
	s16b spell_weight;			/* Weight that hurts spells */
	byte spell_skill;			/* Skill that improves these spells */
	magic_type info[64];		/* The available spells */
};

/*
 * Information about skills
 */

/*
 * The general skill information.
 */
struct skill_type
{
	cptr name;
	cptr desc;
	s16b diff;					/* Difficulty of improvement. */
};

/*
 * The information about the player's current skills
 */
struct skill_info
{
	u16b cur;					/* Current skill level */
	u16b max;					/* Max skill level */
	u16b min;					/* Level at which skill started */
	u16b adv;					/* Number of times skill has been advanced */
};

/*
 * Information about talents
 */
struct talent_type
{
	cptr name;
	s16b skill;					/* Which skill is this based on */
	s16b level;					/* raw value of skill needed to use */
	s16b timeout;				/* How long until you can do something else */
};



/*
 * Player sex info
 */
struct player_sex
{
	cptr title;					/* Type of sex */

	cptr winner;				/* Name of winner */
};


/*
 * Player racial info
 */
struct player_race
{
	cptr title;					/* Type of race */

	s16b r_adj[7];				/* Racial stat bonuses */

	s16b r_thn;					/* combat (normal) */
	s16b r_thb;					/* combat (shooting) */

	byte r_mhp;					/* Race hit-dice modifier */
	byte lifexp;				/* How much general XP the race starts
								 * with. */

	byte b_age;					/* base age */
	byte m_age;					/* mod age */

	byte m_b_ht;				/* base height (males) */
	byte m_m_ht;				/* mod height (males) */
	byte m_b_wt;				/* base weight (males) */
	byte m_m_wt;				/* mod weight (males) */

	byte f_b_ht;				/* base height (females) */
	byte f_m_ht;				/* mod height (females)    */
	byte f_b_wt;				/* base weight (females) */
	byte f_m_wt;				/* mod weight (females) */

	byte infra;					/* Infra-vision     range */

	byte skills[NUM_SKILLS];	/* Tells us how quickly we advance */
	byte start[NUM_SKILLS];		/* Used in determining starting skill values */
};


/*
 * Some more player information
 *
 * This information is retained across player lives
 */
struct player_other
{
	char full_name[32];			/* Full name */
	char base_name[32];			/* Base name */

	bool opt[OPT_MAX];			/* Options */

	u32b window_flag[8];		/* Window flags */

	s16b hitpoint_warn;			/* Hitpoint warning (0 to 9) */

	s16b delay_factor;			/* Delay factor (0 to 9) */
};


/*
 * Most of the "player" information goes here.
 *
 * This stucture gives us a large collection of player variables.
 *
 * This entire structure is wiped when a new character is born.
 *
 * This structure is more or less laid out so that the information
 * which must be saved in the savefile precedes all the information
 * which can be recomputed as needed.
 */
struct player_type
{
	s16b py;					/* Player location */
	s16b px;					/* Player location */

	byte psex;					/* Sex index */
	byte prace;					/* Race index */
	byte realm;					/* Magical realm */
	byte luck_known;			/* Display luck if true */

	byte hitdie;				/* Hit dice (sides) */

	byte maximize;				/* Maximize stats */
	byte preserve;				/* Preserve artifacts */

	s16b age;					/* Characters age */
	s16b ht;					/* Height */
	s16b wt;					/* Weight */
	s16b sc;					/* Social Class */


	s32b au;					/* Current Gold */

	s16b max_depth;				/* Max depth */
	s16b depth;					/* Cur depth */

	s32b max_exp;				/* Max experience */
	s32b exp;					/* Cur experience */
	u16b exp_frac;				/* Cur exp frac (times 2^16) */
	s32b tot_exp;				/* Total exp (used for score) */

	s16b mhp;					/* Max hit pts */
	s16b chp;					/* Cur hit pts */
	u16b chp_frac;				/* Cur hit frac (times 2^16) */

	s16b msp;					/* Max mana pts */
	s16b csp;					/* Cur mana pts */
	u16b csp_frac;				/* Cur mana frac (times 2^16) */

	s16b stat_max[7];			/* Current "maximal" stat values */
	s16b stat_cur[7];			/* Current "natural" stat values */
	s16b stat_mod[7];			/* Player modifications to stats */

	s16b fast;					/* Timed -- Fast */
	s16b slow;					/* Timed -- Slow */
	s16b blind;					/* Timed -- Blindness */
	s16b paralyzed;				/* Timed -- Paralysis */
	s16b confused;				/* Timed -- Confusion */
	s16b afraid;				/* Timed -- Fear */
	s16b image;					/* Timed -- Hallucination */
	s16b poisoned;				/* Timed -- Poisoned */
	s16b cut;					/* Timed -- Cut */
	s16b stun;					/* Timed -- Stun */

	s16b protevil;				/* Timed -- Protection */
	s16b res_dam;				/* Timed -- Damage Resistance */
	s16b hero;					/* Timed -- Heroism */
	s16b shero;					/* Timed -- Super Heroism */
	s16b shield;				/* Timed -- Shield Spell */
	s16b blessed;				/* Timed -- Blessed */
	s16b tim_stealth;			/* Timed -- Stealth */
	s16b tim_invis;				/* Timed -- Invisibility */
	s16b tim_inv_pow;			/* Power of timed invisibility */
	s16b tim_infra;				/* Timed -- Infra Vision */
	s16b detect_inv;			/* Timed -- See Invisible */
	s16b regen_hp;				/* Timed -- Regenerate HP */
	s16b regen_mana;			/* Timed -- Regenerate Mana */
	s16b cheat_death;			/* Timed -- Cheat Death */

	s16b oppose_acid;			/* Timed -- oppose acid */
	s16b oppose_elec;			/* Timed -- oppose lightning */
	s16b oppose_fire;			/* Timed -- oppose heat */
	s16b oppose_cold;			/* Timed -- oppose cold */
	s16b oppose_pois;			/* Timed -- oppose poison */
	s16b word_recall;			/* Word of recall counter */
#if 0
	s16b tim_special;			/* Timed -- special arbitrary effects */
	s16b special_type;			/* type of special effect */
#endif

	s16b energy;				/* Current energy */

	s16b food;					/* Current nutrition */

	byte schange;				/* Current form we've changed shape to. */

	s16b soul_reserve;			/* How much xp you weapon has stored */

	s16b tim_weath;				/* Time until weather changes */
	s16b hold_weath;			/* Timed -- Hold Weather */
	s16b cur_weath;				/* Current weather */
	s16b new_weath;				/* What the new weather will be */

	s16b tt;					/* Talent time-out */

	byte barehand;				/* Skill we use when have no weapon */
	byte lastadv;				/* Says which skill we last advanced */
	skill_info pskills[NUM_SKILLS];		/* The player's skills */

	s16b quest_type;			/* What kind of monster we are hunting */
	byte quest_num;				/* How many of them need to be killed */

	byte confusing;				/* Glowing hands */
	byte searching;				/* Currently searching */

	u32b spell_learned1;		/* Spell flags */
	u32b spell_learned2;		/* Spell flags */
	u32b spell_worked1;			/* Spell flags */
	u32b spell_worked2;			/* Spell flags */
	u32b spell_forgotten1;		/* Spell flags */
	u32b spell_forgotten2;		/* Spell flags */

	byte spell_order[64];		/* Spell order */

	s16b player_hp[PY_MAX_LEVEL];	/* HP Array */

	char died_from[80];			/* Cause of death */
	char history[4][60];		/* Initial history */

	u16b total_winner;			/* Total winner */
	u16b panic_save;			/* Panic save */

	u16b noscore;				/* Cheating flags */

	bool is_dead;				/* Player is dead */

	bool wizard;				/* Player is in wizard mode */

	bool cheat[CHEAT_MAX];		/* Cheating options */

/*** Temporary fields ***/

	bool playing;				/* True if player is playing */

	bool leaving;				/* True if player is leaving */

	bool create_up_stair;		/* Create up stair on next level */
	bool create_down_stair;		/* Create down stair on next level */

	s16b wy;					/* Dungeon panel */
	s16b wx;					/* Dungeon panel */

	s16b total_weight;			/* Total weight being carried */

	s16b inven_cnt;				/* Number of items in inventory */
	s16b equip_cnt;				/* Number of items in equipment */

	s16b target_set;			/* Target flag */
	s16b target_who;			/* Target identity */
	s16b target_row;			/* Target location */
	s16b target_col;			/* Target location */

	s16b health_who;			/* Health bar trackee */

	s16b monster_race_idx;		/* Monster race trackee */

	s16b object_kind_idx;		/* Object kind trackee */

	s16b energy_use;			/* Energy use this turn */

	s16b resting;				/* Resting counter */
	s16b running;				/* Running counter */

	s16b run_cur_dir;			/* Direction we are running */
	s16b run_old_dir;			/* Direction we came from */
	bool run_unused;			/* Unused (padding field) */
	bool run_open_area;			/* Looking for an open area */
	bool run_break_right;		/* Looking for a break (right) */
	bool run_break_left;		/* Looking for a break (left) */

	s16b command_cmd;			/* Gives identity of current command */
	s16b command_arg;			/* Gives argument of current command */
	s16b command_rep;			/* Gives repetition of current command */
	s16b command_dir;			/* Gives direction of current command */

	s16b command_see;			/* See "cmd1.c" */
	s16b command_wrk;			/* See "cmd1.c" */

	s16b command_new;			/* Hack -- command chaining XXX XXX */

	s16b new_spells;			/* Number of spells available */

	s16b old_spells;

	bool old_cumber_armor;
	bool old_cumber_glove;
	bool old_heavy_wield;
	bool old_heavy_shoot;
	bool old_icky_wield;

	s16b old_lite;				/* Old radius of lite (if any) */
	s16b old_view;				/* Old radius of view (if any) */

	s16b old_food_aux;			/* Old value of food */


	bool cumber_armor;			/* Mana draining armor */
	bool cumber_glove;			/* Mana draining gloves */
	bool heavy_wield;			/* Heavy weapon */
	bool heavy_shoot;			/* Heavy shooter */
	bool icky_wield;			/* Icky weapon */

	s16b cur_lite;				/* Radius of lite (if any) */

	s16b extrahp;				/* Hit points to be added on for heroism */

	u32b notice;				/* Special Updates (bit flags) */
	u32b update;				/* Pending Updates (bit flags) */
	u32b redraw;				/* Normal Redraws (bit flags) */
	u32b window;				/* Window Redraws (bit flags) */

/*** Extracted fields ***/

	s16b stat_use[7];			/* Current modified stats */
	s16b stat_top[7];			/* Maximal modified stats */
	s16b stat_add[7];			/* Modifiers to stat values */
	s16b stat_ind[7];			/* Indexes into stat tables */
	bool immune_acid;			/* Immunity to acid */
	bool immune_elec;			/* Immunity to lightning */
	bool immune_fire;			/* Immunity to fire */
	bool immune_cold;			/* Immunity to cold */

	bool resist_acid;			/* Resist acid */
	bool resist_elec;			/* Resist lightning */
	bool resist_fire;			/* Resist fire */
	bool resist_cold;			/* Resist cold */
	bool resist_pois;			/* Resist poison */

	bool resist_fear;			/* Resist fear */
	bool resist_lite;			/* Resist light */
	bool resist_dark;			/* Resist darkness */
	bool resist_blind;			/* Resist blindness */
	bool resist_confu;			/* Resist confusion */
	bool resist_sound;			/* Resist sound */
	bool resist_shard;			/* Resist shards */
	bool resist_nexus;			/* Resist nexus */
	bool resist_nethr;			/* Resist nether */
	bool resist_chaos;			/* Resist chaos */
	bool resist_disen;			/* Resist disenchant */

	bool sustain_str;			/* Keep strength */
	bool sustain_int;			/* Keep intelligence */
	bool sustain_wis;			/* Keep wisdom */
	bool sustain_dex;			/* Keep dexterity */
	bool sustain_con;			/* Keep constitution */
	bool sustain_chr;			/* Keep charisma */
	bool sustain_luc;			/* Keep luck */

	bool slow_digest;			/* Slower digestion */
	bool ffall;					/* No damage falling */
	bool lite;					/* Permanent light */
	bool regenerate;			/* Regenerate hit pts */
	bool telepathy;				/* Telepathy */
	bool see_inv;				/* Can see invisible */
	bool free_act;				/* Never paralyzed */
	bool hold_life;				/* Resist life draining */

	bool impact;				/* Earthquake blows */
	bool aggravate;				/* Aggravate monsters */
	bool teleport;				/* Random teleporting */
	bool exp_drain;				/* Experience draining */

	bool bless_blade;			/* Blessed blade */

	s16b dis_to_h;				/* Known bonus to hit */
	s16b dis_to_d;				/* Known bonus to dam */
	s16b dis_to_a;				/* Known bonus to ac */

	s16b dis_ac;				/* Known base ac */

	s16b to_h;					/* Bonus to hit */
	s16b to_d;					/* Bonus to dam */
	s16b to_a;					/* Bonus to ac */

	s16b ac;					/* Base ac */

	s16b see_infra;				/* Infravision range */

	s16b skill_dis;				/* Skill: Disarming */
	s16b skill_dev;				/* Skill: Magic Devices */
	s16b skill_sav;				/* Skill: Saving throw */
	s16b skill_stl;				/* Skill: Stealth factor */
	s16b skill_srh;				/* Skill: Searching ability */
	s16b skill_fos;				/* Skill: Searching frequency */
	s16b skill_thn;				/* Skill: To hit (normal) */
	s16b skill_thb;				/* Skill: To hit (shooting) */
	s16b skill_tht;				/* Skill: To hit (throwing) */
	s16b skill_dig;				/* Skill: Digging */

	u32b noise;					/* Derived from stealth */

	s16b num_blow;				/* Number of blows */
	s16b num_blow2;				/* Number of blows from the secondary weapon */
	s16b num_fire;				/* Number of shots */

	byte ammo_mult;				/* Ammo multiplier */

	byte ammo_tval;				/* Ammo variety */

	s16b pspeed;				/* Current speed */

	s16b invisible;				/* Total level of invisibility */
	bool soulsteal;				/* Your weapon needs feeding */
	bool nomagic;				/* Dispelled magic -- No spell-casting */
	bool twoweap;				/* Currently wielding two weapons */
	byte wskill;				/* Current weapon skill */
};
