OSDN Git Service

自動拾い関係の関数の名前を統一的に改名。全て「autopick」のキーワードを含むようにした。
[hengband/hengband.git] / src / defines.h
index 20b7497..94a4643 100644 (file)
@@ -1,5 +1,13 @@
 /* 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.
+ */
+
 /* Purpose: global constants and macro definitions */
 
 
  */
 #define VERSION_NAME "Hengband"
 
-/* Savefile version for Hengband 1.1.1 and later */
-#define H_VER_MAJOR 1
-#define H_VER_MINOR 3
-#define H_VER_PATCH 0
-#define H_VER_EXTRA 1
 
-/* Added for ZAngband */
+/*
+ * "Program Version Number" of the game
+ *
+ * FAKE_VER_MAJOR=1,2 were reserved for ZAngband version 1.x.x/2.x.x .
+ *
+ * Program Version of Hengband version is
+ *   "(FAKE_VER_MAJOR-10).(FAKE_VER_MINOR).(FAKE_VER_PATCH)".
+ */
 #define FAKE_VERSION   0
 #define FAKE_VER_MAJOR 11
-#define FAKE_VER_MINOR 3
+#define FAKE_VER_MINOR 7
 #define FAKE_VER_PATCH 0
 
-#define ANGBAND_2_8_1
-#define ZANGBAND
 
 /*
- * This value is not currently used
+ * "Savefile Version Number" for Hengband 1.1.1 and later
+ *
+ * First three digits may be same as the Program Version.  But not
+ * always same.  It means that newer version may preserves lower
+ * compatibility with the older version.
+ *
+ * For example, newer Hengband 1.4.4 creates savefiles marked with
+ * Savefile Version 1.4.0.0 .  It means that Hengband 1.4.0 can load a
+ * savefile of Hengband 1.4.4 (lower compatibility!).
+ *
+ * Upper compatibility is always guaranteed.
  */
-#define VERSION_EXTRA   0
+#define H_VER_MAJOR 1
+#define H_VER_MINOR 7
+#define H_VER_PATCH 0
+#define H_VER_EXTRA 1
 
 
+#define ANGBAND_2_8_1
+#define ZANGBAND
+
 /*
  * Number of grids in each block (vertically)
  * Probably hard-coded to 11, see "generate.c"
 /*
  * Quest constants
  */
-#define MAX_MON_QUEST       10
-#define MAX_ITEM_QUEST       5
-
 #define MIN_RANDOM_QUEST    40
 #define MAX_RANDOM_QUEST    49
 
+/* Check is the quest index is "fixed" */
+#define is_fixed_quest_idx(Q_IDX) (((Q_IDX) < MIN_RANDOM_QUEST) || ((Q_IDX) > MAX_RANDOM_QUEST))
+
 #define QUEST_OBERON         8
 #define QUEST_SERPENT        9
 
  * Arena constants
  */
 #define MAX_ARENA_MONS         38      /* -KMW- */
+#define ARENA_DEFEATED_OLD_VER (-(MAX_SHORT))
 
 
 /*
 #define MAX_BLDG               32
 
 /*
- * Total number of stores (see "store.c", etc)
+ * Store types
  */
-#define MAX_STORES_PER_TOWN 12
-#define MAX_STORE_TYPES     10
-
 #define STORE_GENERAL   0
 #define STORE_ARMOURY   1
 #define STORE_WEAPON    2
 
 
 /*
+ * Maximum number of saved floors.
+ */
+#define MAX_SAVED_FLOORS       20
+
+
+/*
  * Maximum size of the "lite" array (see "cave.c")
  * Note that the "lite radius" will NEVER exceed 14, and we would
  * never require more than 581 entries in the array for circular "lite".
 #define LITE_MAX 600
 
 /*
+ * Maximum size of the "mon_lite" array (see "cave.c")
+ * Note that the "view radius" will NEVER exceed 20, monster illumination
+ * flags are dependent on CAVE_VIEW, and even if the "view" was octagonal,
+ * we would never require more than 1520 entries in the array.
+ */
+#define MON_LITE_MAX 1536
+
+/*
  * 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.
  * 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
+#define TEMP_MAX 2298
+
+/*
+ * Maximum size of the "redraw" array (see "cave.c")
+ * We must be large for proper functioning of delayed redrawing.
+ * We must also be as large as two times of the largest view area.
+ * Note that maximum view grids are 1149 entries.
+ */
+#define REDRAW_MAX 2298
 
 
 /*
  * OPTION: Maximum number of "quarks" (see "io.c")
  * Default: assume at most 512 different inscriptions are used
  */
-#define QUARK_MAX       2048
+#define QUARK_MAX       768
 /* Was 512... 256 quarks added for random artifacts */
-/* Was 768... increased greatly for auto inscription (by Mogami) */
 
 /*
  * OPTION: Maximum number of messages to remember (see "io.c")
 #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   21              /* 1/Chance (per day) of an owner changing */
-#define STORE_TURNS     1000    /* Number of turns between turnovers */
+#define STORE_TICKS     1000            /* Number of ticks between turnovers */
 
 
 /*
  */
 #define ENERGY_NEED() (randnor(100, 31))
 
+
+/*
+ * Extract energy from speed (Assumes that SPEED is unsigned)
+ */
+#define SPEED_TO_ENERGY(SPEED) \
+       (((SPEED) > 199) ? 49 : extract_energy[(SPEED)])
+
+
 /*
  * Misc constants
  */
 /*
  * Commands
  */
-#define PET_DISMISS                                    1
-#define PET_TARGET                                     2
-#define PET_STAY_CLOSE                         3
-#define PET_FOLLOW_ME                          4
-#define PET_SEEK_AND_DESTROY           5
-#define PET_ALLOW_SPACE                                6
-#define PET_STAY_AWAY                          7
-#define PET_OPEN_DOORS           8
-#define PET_TAKE_ITEMS                         9
-#define PET_TELEPORT                          10
-#define PET_ATTACK_SPELL                      11
-#define PET_SUMMON_SPELL                      12
-#define PET_BALL_SPELL                        13
-#define PET_RIDING                            14
-#define PET_NAME                              15
-#define PET_RYOUTE                            16
+#define PET_DISMISS            1
+#define PET_TARGET             2
+#define PET_STAY_CLOSE         3
+#define PET_FOLLOW_ME          4
+#define PET_SEEK_AND_DESTROY   5
+#define PET_ALLOW_SPACE                6
+#define PET_STAY_AWAY          7
+#define PET_OPEN_DOORS          8
+#define PET_TAKE_ITEMS         9
+#define PET_TELEPORT           10
+#define PET_ATTACK_SPELL       11
+#define PET_SUMMON_SPELL       12
+#define PET_BALL_SPELL         13
+#define PET_RIDING             14
+#define PET_NAME               15
+#define PET_RYOUTE             16
 
 /*
  * Follow distances
 #define PF_RYOUTE       0x0040
 
 
+/* Maximum number of preservable pets */
+#define MAX_PARTY_MON 21
+
+
 /*
  * 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").
  */
 #define MAX_SIGHT       20      /* Maximum view distance */
 #define MAX_RANGE       (p_ptr->inside_battle ? 36 : 18)      /* Maximum range (spells, etc) */
+#define AAF_LIMIT       100     /* Limit of sensing radius */
 
 
 
 /*
  * Player "food" crucial values
  */
-#define PY_FOOD_MAX             15000   /* Food value (Bloated) */
+#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) */
+#define PY_FOOD_FAINT   500     /* Food value (Fainting) */
+#define PY_FOOD_STARVE  100     /* Food value (Starving) */
 
 /*
  * 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_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 */
+#define PY_REGEN_MNBASE         524     /* Min amount mana regen*2^16 */
 
 /*
  * Possible realms that can be chosen;
 #define VALID_REALM        (MAX_REALM + MAX_MAGIC - MIN_TECHNIC + 1)
 #define NUM_TECHNIC        (MAX_REALM - MIN_TECHNIC + 1)
 
-#define is_magic(A) ((A) < MAX_MAGIC + 1 ? TRUE : FALSE)
+#define is_magic(A) ((((A) > REALM_NONE) && ((A) < MAX_MAGIC + 1)) ? TRUE : FALSE)
 #define tval2realm(A) ((A) - TV_LIFE_BOOK + 1)
 #define technic2magic(A)      (is_magic(A) ? (A) : (A) - MIN_TECHNIC + 1 + MAX_MAGIC)
 #define is_good_realm(REALM)   ((REALM) == REALM_LIFE || (REALM) == REALM_CRUSADE)
  */
 #define INVEN_TOTAL     36
 
-
 /*
- * A "stack" of items is limited to less than 100 items (hard-coded).
+ * Fake inventory slot for selecting force (hard-coded).
  */
-#define MAX_STACK_SIZE                  100
-
+#define INVEN_FORCE     1111
 
 
 /*
 #define CLASS_MIRROR_MASTER     25
 #define CLASS_NINJA             26
 
-#define SEIKAKU_FUTUU  0
-#define SEIKAKU_CHIKARA        1
-#define SEIKAKU_KIREMONO       2
-#define SEIKAKU_SHIAWASE       3
-#define SEIKAKU_SUBASI 4
-#define SEIKAKU_INOCHI 5
-#define SEIKAKU_COMBAT 6
-#define SEIKAKU_NAMAKE 7
-#define SEIKAKU_SEXY   8
-#define SEIKAKU_LUCKY  9
-#define SEIKAKU_GAMAN  10
-#define SEIKAKU_MUNCHKIN   11
+#define SEIKAKU_FUTUU   0
+#define SEIKAKU_CHIKARA         1
+#define SEIKAKU_KIREMONO 2
+#define SEIKAKU_SHIAWASE 3
+#define SEIKAKU_SUBASI  4
+#define SEIKAKU_INOCHI  5
+#define SEIKAKU_COMBAT  6
+#define SEIKAKU_NAMAKE  7
+#define SEIKAKU_SEXY    8
+#define SEIKAKU_LUCKY   9
+#define SEIKAKU_GAMAN   10
+#define SEIKAKU_MUNCHKIN 11
 
 /*** Screen Locations ***/
 
 #define FEAT_MIRROR             0xc3
 
 /* unknown grid (not detected)  */
-#define FEAT_UNDETECTD          0xc4
+#define FEAT_UNDETECTED         0xc4
+
+/* special traps */
+#define FEAT_TRAP_ARMAGEDDON    0xc5
+#define FEAT_TRAP_PIRANHA       0xc6
 
 /*
  * Wilderness terrains
 #define ART_MAGATAMA             149
 #define ART_INROU                166
 #define ART_NIGHT                215
+#define ART_SACRED_KNIGHTS       217
+#define ART_HELL                 218
+#define ART_CHARMED              219
+#define ART_GOGO                 220
 
 /* Rings */
 #define ART_FRAKIR               8
 #define TV_CHEST         7      /* Chests ('&') */
 #define TV_FIGURINE      8      /* Magical figurines */
 #define TV_STATUE        9      /* Statue, what a silly object... */
-#define TV_CORPSE      10      /* Corpses and Skeletons, specific */
-#define TV_CAPTURE     11      /* Monster ball */
+#define TV_CORPSE       10      /* Corpses and Skeletons, specific */
+#define TV_CAPTURE      11      /* Monster ball */
 #define TV_NO_AMMO      15      /* Ammo for crimson */
 #define TV_SHOT         16      /* Ammo for slings */
 #define TV_ARROW        17      /* Ammo for bows */
 #define TV_STAFF        55
 #define TV_WAND         65
 #define TV_ROD          66
-#define TV_PARCHEMENT   69
+#define TV_PARCHMENT    69
 #define TV_SCROLL       70
 #define TV_POTION       75
 #define TV_FLASK        77
 #define TV_HISSATSU_BOOK 106
 #define TV_GOLD         127     /* Gold can only be picked up by players */
 
+#define TV_EQUIP_BEGIN    TV_SHOT
+#define TV_EQUIP_END      TV_CARD
+#define TV_MISSILE_BEGIN  TV_SHOT
+#define TV_MISSILE_END    TV_BOLT
+#define TV_WEARABLE_BEGIN TV_BOW
+#define TV_WEARABLE_END   TV_CARD
+#define TV_WEAPON_BEGIN   TV_BOW
+#define TV_WEAPON_END     TV_SWORD
+#define TV_ARMOR_BEGIN    TV_BOOTS
+#define TV_ARMOR_END      TV_DRAG_ARMOR
+
 /* Any subvalue */
 #define SV_ANY                                         255
 
 #define SV_PHOTO                       50
 
 /* The "sval" codes for TV_CORPSE */
-#define SV_SKELETON                            0
-#define SV_CORPSE                                      1
+#define SV_SKELETON                    0
+#define SV_CORPSE                      1
 
 /* The "sval" codes for TV_SHOT/TV_ARROW/TV_BOLT */
 #define SV_AMMO_LIGHT                    0     /* pebbles */
 #define SV_LONG_BOW                     13     /* (x3) */
 #define SV_LIGHT_XBOW                   23     /* (x3) */
 #define SV_HEAVY_XBOW                   24     /* (x4) */
-#define SV_CRIMSON                      50
-#define SV_NAMAKE_BOW                   63
+#define SV_CRIMSON                      50     /* (x0) */
+#define SV_NAMAKE_BOW                   63     /* (x3) */
 
 /* The "sval" codes for TV_DIGGING */
 #define SV_SHOVEL                        1
 #define SV_TWO_HANDED_FLAIL             18     /* 3d6  */
 #define SV_GREAT_HAMMER                 19     /* 4d6  */
 #define SV_MACE_OF_DISRUPTION           20     /* 5d8  */
-#define SV_WIZSTAFF                     21      /* 1d4  */
-#define SV_GROND                        50     /* 3d4  */
-#define SV_NAMAKE_HAMMER                63
+#define SV_WIZSTAFF                     21     /* 1d2  */
+#define SV_GROND                        50     /* 3d9  */
+#define SV_NAMAKE_HAMMER                63     /* 1d77 */
 
 /* The "sval" values for TV_POLEARM */
 #define SV_HATCHET                       1     /* 1d5 */
 #define SV_BLADE_OF_CHAOS               30  /* 6d5 */
 #define SV_DIAMOND_EDGE                 31  /* 7d5 */
 #define SV_DOKUBARI                     32  /* 1d1 */
-#define SV_HAYABUSA                     33  /* 1d4 */
+#define SV_HAYABUSA                     33  /* 1d6 */
 
 /* The "sval" codes for TV_SHIELD */
 #define SV_SMALL_LEATHER_SHIELD          2
 #define SV_LARGE_METAL_SHIELD            5
 #define SV_DRAGON_SHIELD                 6
 #define SV_KNIGHT_SHIELD                 7
-#define SV_SHIELD_OF_DEFLECTION         10
+#define SV_MIRROR_SHIELD                10
 #define SV_YATA_MIRROR                  50
 
 /* The "sval" codes for TV_HELM */
 #define SV_STEEL_HELM                    6
 #define SV_DRAGON_HELM                   7
 #define SV_KABUTO                        8  /* 7 */
+
+/* The "sval" codes for TV_CROWN */
 #define SV_IRON_CROWN                   10
 #define SV_GOLDEN_CROWN                 11
 #define SV_JEWELED_CROWN                12
-#define SV_MORGOTH                      50
+#define SV_CHAOS                        50
 
 /* The "sval" codes for TV_BOOTS */
 #define SV_PAIR_OF_SOFT_LEATHER_BOOTS    2
 #define SV_CLOAK                         1
 #define SV_ELVEN_CLOAK                   2
 #define SV_FUR_CLOAK                     3
-#define SV_ETHEREAL_CLOAK               5
+#define SV_ETHEREAL_CLOAK                5
 #define SV_SHADOW_CLOAK                  6
 
 /* The "sval" codes for TV_GLOVES */
 #define SV_LITE_EDISON                   3
 #define SV_LITE_GALADRIEL                4
 #define SV_LITE_ELENDIL                  5
-#define SV_LITE_THRAIN                   6
+#define SV_LITE_JUDGE                    6
 #define SV_LITE_LORE                     7
 #define SV_LITE_PALANTIR                 8
 #define SV_LITE_FLY_STONE                9
 #define SV_RING_DAMAGE                  29
 #define SV_RING_SLAYING                 30
 #define SV_RING_SPEED                   31
-#define SV_RING_BARAHIR                 32
+#define SV_RING_FRAKIR                  32
 #define SV_RING_TULKAS                  33
 #define SV_RING_NARYA                   34
 #define SV_RING_NENYA                   35
 #define SV_STAFF_DESTRUCTION            29
 #define SV_STAFF_ANIMATE_DEAD           30
 #define SV_STAFF_MSTORM                 31
+#define SV_STAFF_NOTHING                32
 
 
 /* The "sval" codes for TV_WAND */
 #define SV_POTION_TSUYOSHI              65
 #define SV_POTION_POLYMORPH             66
 
+/* The "sval" codes for TV_FLASK */
+#define SV_FLASK_OIL                   0
+
 /* The "sval" codes for TV_FOOD */
 #define SV_FOOD_POISON                   0
 #define SV_FOOD_BLINDNESS                1
 #define CAVE_VIEW       0x0020    /* view flag */
 #define CAVE_TEMP       0x0040    /* temp flag */
 #define CAVE_XTRA       0x0080    /* misc flag */
-#define CAVE_MNLT      0x0100  /* Illuminated by monster */
-
-#define CAVE_TRAP       0x8000
+#define CAVE_MNLT       0x0100    /* Illuminated by monster */
+#define CAVE_MNDK       0x8000    /* Darken by monster */
 
 /* Used only while cave generation */
 #define CAVE_FLOOR      0x0200
 
 /* Used only after cave generation */
 #define CAVE_XXXX1      0x0200
-#define CAVE_XXXX2      0x0400
-#define CAVE_XXXX3      0x0800
-#define CAVE_IN_MIRROR  0x1000    /* mirror */
+#define CAVE_NOTE       0x0400    /* Flag for delayed visual update (needs note_spot()) */
+#define CAVE_REDRAW     0x0800    /* Flag for delayed visual update (needs lite_spot()) */
+#define CAVE_OBJECT     0x1000    /* Mirror, glyph, etc. */
 #define CAVE_UNSAFE     0x2000    /* Might have trap */
 #define CAVE_IN_DETECT  0x4000    /* trap detected area (inner circle only) */
 
  *   ITEM: Affect each object in the "blast area" in some way
  *   KILL: Affect each monster in the "blast area" in some way
  *   HIDE: Hack -- disable "visual" feedback from projection
- */
-#define PROJECT_JUMP       0x01
-#define PROJECT_BEAM       0x02
-#define PROJECT_THRU       0x04
-#define PROJECT_STOP       0x08
-#define PROJECT_GRID       0x10
-#define PROJECT_ITEM       0x20
-#define PROJECT_KILL       0x40
-#define PROJECT_HIDE       0x80
-#define PROJECT_DISI       0x100
-#define PROJECT_PLAYER     0x200
-#define PROJECT_MONSTER    0x400
-#define PROJECT_NO_REF     0x800
-#define PROJECT_NO_HANGEKI 0x1000
-#define PROJECT_PATH       0x2000
-#define PROJECT_FAST       0x4000
+ *   DISI: Disintegrate non-permanent features
+ *   PLAYER: Main target is player (used for riding player)
+ *   AIMED: Target is only player or monster, so don't affect another.
+ *          Depend on PROJECT_PLAYER.
+ *          (used for minimum (rad == 0) balls on riding player)
+ *   REFLECTABLE: Refrectable spell attacks (used for "bolts")
+ *   NO_HANGEKI: Avoid counter attacks of monsters
+ *   PATH: Only used for printing project path
+ *   FAST: Hide "visual" of flying bolts until blast
+ */
+#define PROJECT_JUMP        0x01
+#define PROJECT_BEAM        0x02
+#define PROJECT_THRU        0x04
+#define PROJECT_STOP        0x08
+#define PROJECT_GRID        0x10
+#define PROJECT_ITEM        0x20
+#define PROJECT_KILL        0x40
+#define PROJECT_HIDE        0x80
+#define PROJECT_DISI        0x100
+#define PROJECT_PLAYER      0x200
+#define PROJECT_AIMED       0x400
+#define PROJECT_REFLECTABLE 0x800
+#define PROJECT_NO_HANGEKI  0x1000
+#define PROJECT_PATH        0x2000
+#define PROJECT_FAST        0x4000
 
 /*
  * Bit flags for the "enchant()" function
 #define CHECK_OKAY_CANCEL 0x01
 #define CHECK_NO_ESCAPE   0x02
 #define CHECK_NO_HISTORY  0x04
+#define CHECK_DEFAULT_Y   0x08
 
 
 /*
  */
 #define PN_COMBINE      0x00000001L     /* Combine the pack */
 #define PN_REORDER      0x00000002L     /* Reorder the pack */
+#define PN_AUTODESTROY  0x00000004L     /* Auto-destroy marked item */
 /* xxx (many) */
 
 
 #define PU_VIEW         0x00100000L     /* Update view */
 #define PU_LITE         0x00200000L     /* Update lite */
 #define PU_MON_LITE     0x00400000L     /* Monster illumination */
-/* xxx */
+#define PU_DELAY_VIS    0x00800000L     /* Mega-Hack -- Delayed visual update */
 #define PU_MONSTERS     0x01000000L     /* Update monsters */
 #define PU_DISTANCE     0x02000000L     /* Update distances */
 /* xxx */
 #define PR_STUN         0x00002000L     /* Display Extra (Stun) */
 #define PR_HUNGER       0x00004000L     /* Display Extra (Hunger) */
 #define PR_STATUS       0x00008000L     /* Display Status Bar */
-#define PR_DUNGEON      0x00010000L     /* Display Extra (Blind) */
+#define PR_XXX0         0x00010000L     /* (unused) */
 #define PR_UHEALTH      0x00020000L     /* Display Uma Health Bar */
-#define PR_XXX1         0x00040000L     /* Display Extra (Afraid) */
-#define PR_XXX2         0x00080000L     /* Display Extra (Poisoned) */
+#define PR_XXX1         0x00040000L     /* (unused) */
+#define PR_XXX2         0x00080000L     /* (unused) */
 #define PR_STATE        0x00100000L     /* Display Extra (State) */
 #define PR_SPEED        0x00200000L     /* Display Extra (Speed) */
 #define PR_STUDY        0x00400000L     /* Display Extra (Study) */
 #define PM_ALLOW_UNIQUE   0x00000040
 #define PM_IGNORE_TERRAIN 0x00000080
 #define PM_HASTE          0x00000100
+#define PM_KAGE           0x00000200
+
 
+/* Bit flags for monster_desc() */
+#define MD_OBJECTIVE      0x00000001 /* Objective (or Reflexive) */
+#define MD_POSSESSIVE     0x00000002 /* Possessive (or Reflexive) */
+#define MD_INDEF_HIDDEN   0x00000004 /* Use indefinites for hidden monsters ("something") */
+#define MD_INDEF_VISIBLE  0x00000008 /* Use indefinites for visible monsters ("a kobold") */
+#define MD_PRON_HIDDEN    0x00000010 /* Pronominalize hidden monsters */
+#define MD_PRON_VISIBLE   0x00000020 /* Pronominalize visible monsters */
+#define MD_ASSUME_HIDDEN  0x00000040 /* Assume the monster is hidden */
+#define MD_ASSUME_VISIBLE 0x00000080 /* Assume the monster is visible */
+#define MD_TRUE_NAME      0x00000100 /* Chameleon's true name */
+#define MD_IGNORE_HALLU   0x00000200 /* Ignore hallucination, and penetrate shape change */
 
 /*
  * Bit flags for the "p_ptr->special_attack" variable. -LM-
  * prevents the player from getting more than one at a time.
  */
 #define ATTACK_CONFUSE         0x00000001
-#define ATTACK_BLKBRTH         0x00000002
-#define ATTACK_FLEE            0x00000004
-#define ATTACK_SUPERSHOT       0x00000008
+#define ATTACK_XXX1            0x00000002
+#define ATTACK_XXX2            0x00000004
+#define ATTACK_XXX3            0x00000008
 #define ATTACK_ACID            0x00000010
 #define ATTACK_ELEC            0x00000020
 #define ATTACK_FIRE            0x00000040
 #define ACTION_SING     7
 #define ACTION_HAYAGAKE 8
 
+
+/* Empty hand status */
+#define EMPTY_HAND_NONE 0x0000 /* Both hands are used */
+#define EMPTY_HAND_LARM 0x0001 /* Left hand is empty */
+#define EMPTY_HAND_RARM 0x0002 /* Right hand is empty */
+
 /*** General index values ***/
 
 
 #define SUMMON_GUARDIANS            62
 #define SUMMON_KNIGHTS              63
 #define SUMMON_EAGLES               64
+#define SUMMON_PIRANHAS             65
+#define SUMMON_ARMAGE_GOOD          66
+#define SUMMON_ARMAGE_EVIL          67
 
 
 /*
 
 
 /*
- * 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          19
-
-/*
  * Game generated inscription indices. These are stored in the object,
  * and are used to index the string array from tables.c.
  */
 #define IDENT_BROKEN    0x80    /* Item is permanently worthless */
 
 
+/* 
+ * How object is marked (flags in object_type.mark)
+ * OM_FOUND --- original boolean flag
+ * OM_NOMSG --- temporary flag to suppress messages which were
+ *              already printed in autopick_pickup_items().
+ */
+#define OM_FOUND        0x01    /* original boolean flag */
+#define OM_NOMSG        0x02    /* temporary flag to suppress messages */
+#define OM_NO_QUERY     0x04    /* Query for auto-pick was already answered as 'No' */
+#define OM_AUTODESTROY  0x08    /* Destroy later to avoid illegal inventry shift */
+
 
 /*
  * Special Monster Flags (all temporary)
 #define MFLAG_XXX3      0x08    /* (unused) */
 #define MFLAG_BORN      0x10    /* Monster is still being born */
 #define MFLAG_NICE      0x20    /* Monster is still being nice */
-#define MFLAG_SHOW      0x40    /* Monster is recently memorized */
-#define MFLAG_MARK      0x80    /* Monster is currently memorized */
 
-#define MFLAG_KAGE      0x01    /* Monster is kage */
-#define MFLAG_NOPET     0x02    /* Cannot make monster pet */
-#define MFLAG_NOGENO    0x04    /* Cannot genocide */
-#define MFLAG_CHAMELEON 0x08    /* Monster is chameleon */
-#define MFLAG_NOFLOW    0x10    /* Monster is in no_flow_by_smell mode */
+#define MFLAG2_KAGE      0x01    /* Monster is kage */
+#define MFLAG2_NOPET     0x02    /* Cannot make monster pet */
+#define MFLAG2_NOGENO    0x04    /* Cannot genocide */
+#define MFLAG2_CHAMELEON 0x08    /* Monster is chameleon */
+#define MFLAG2_NOFLOW    0x10    /* Monster is in no_flow_by_smell mode */
+#define MFLAG2_SHOW      0x20    /* Monster is recently memorized */
+#define MFLAG2_MARK      0x40    /* Monster is currently memorized */
 
 
 /*
- * 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.
+ * Object flags
  *
- * 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).
+ * Old variables for object flags such as flags1, flags2, and flags3
+ * are obsolated.  Now single array flgs[TR_FLAG_SIZE] contains all
+ * object flags.  And each flag is refered by single index number
+ * instead of a bit mask.
  *
- * Note that "flags2" contains all "resistances" (including "Stat Sustainers",
- * actual immunities, and resistances).  Note that "Hold Life" is really an
- * "immunity" to ExpLoss, and "Free Action" is "immunity to paralysis".
+ * Therefore it's very easy to add a lot of new flags; no one need to
+ * worry about in which variable a new flag should be put, nor to
+ * modify a huge number of files all over the source directory at once
+ * to add new flag variables such as flags4, flags5, etc...
  *
- * Note that "flags3" contains everything else -- including the three "CURSED"
- * flags, and the "BLESSED" flag, several "item display" parameters, some new
- * flags for powerful Bows, and flags which affect the player in a "general"
- * way (LITE, TELEPATHY, SEE_INVIS, SLOW_DIGEST, REGEN, FEATHER), including
- * all the "general" curses (TELEPORT, AGGRAVATE, EXP_DRAIN).  It also has
- * four new flags called "ITEM_IGNORE_XXX" which lets an item specify that
- * it can not be affected by various forms of destruction.  This is NOT as
- * powerful as actually granting resistance/immunity to the wearer.
+ * All management of flags is now treated using a set of macros
+ * instead of bit operations.
+ * Note: These macros are using division, modulo, and bit shift
+ * operations, and it seems that these operations are rather slower
+ * than original bit operation.  But since index numbers are almost
+ * always given as constant, such slow operations are performed in the
+ * compile time.  So there is no problem on the speed.
+ *
+ * Exceptions of new flag management is a set of flags to control
+ * object generation and the curse flags.  These are not yet rewritten
+ * in new index form; maybe these have no merit of rewriting.
  */
 
 #define have_flag(ARRAY, INDEX) !!((ARRAY)[(INDEX)/32] & (1L << ((INDEX)%32)))
 #define TR_SUST_CON            36
 #define TR_SUST_CHR            37
 #define TR_RIDING              38
-#define TR_XXX2                39     /* Later */
+#define TR_EASY_SPELL          39
 #define TR_IM_ACID             40
 #define TR_IM_ELEC             41
 #define TR_IM_FIRE             42
         TRC_CALL_DEMON | TRC_CALL_DRAGON | TRC_TELEPORT)
 
 #define TRC_P_FLAG_MASK  \
-        (TRC_TELEPORT_SELF | TRC_CHAINSWORD | \
+       (TRC_TELEPORT_SELF | TRC_CHAINSWORD | \
         TRC_TY_CURSE | TRC_DRAIN_EXP | TRC_ADD_L_CURSE | TRC_ADD_H_CURSE | \
         TRC_CALL_ANIMAL | TRC_CALL_DEMON | TRC_CALL_DRAGON | TRC_COWARDICE | \
         TRC_TELEPORT | TRC_DRAIN_HP | TRC_DRAIN_MANA)
 
 
+
+/*
+ * Bit flags for apply_magic() (etc)
+ */
+#define AM_NO_FIXED_ART 0x00000001 /* Don't allow roll for fixed artifacts */
+#define AM_GOOD         0x00000002 /* Generate good items */
+#define AM_GREAT        0x00000004 /* Generate great items */
+#define AM_SPECIAL      0x00000008 /* Generate artifacts (for debug mode only) */
+#define AM_CURSED       0x00000010 /* Generate cursed/worthless items */
+
+
 /*** Monster blow constants ***/
 
 
 #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_SHAPECHANGER        0x00000020  /* TY: shapechanger */
 #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_FORCE_EXTRA         0x00000800  /* Start out something */
-#define RF1_XXX1                0x00001000  /* XXX */
+#define RF1_ATTR_SEMIRAND       0x00001000  /* Color is determined semi-randomly */
 #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 RF2_WEIRD_MIND      0x00000080  /* Monster avoids telepathy? */
 #define RF2_MULTIPLY        0x00000100  /* Monster reproduces */
 #define RF2_REGENERATE      0x00000200  /* Monster regenerates */
-#define RF2_SHAPECHANGER    0x00000400  /* TY: shapechanger */
+#define RF2_CHAR_MULTI      0x00000400  /* (Not implemented) */
 #define RF2_ATTR_ANY        0x00000800  /* TY: Attr_any */
 #define RF2_POWERFUL        0x00001000  /* Monster has strong breath */
 #define RF2_ELDRITCH_HORROR 0x00002000  /* Sanity-blasting horror    */
 #define RF2_KILL_BODY       0x00200000  /* Monster can kill monsters */
 #define RF2_TAKE_ITEM       0x00400000  /* Monster can pick up items */
 #define RF2_KILL_ITEM       0x00800000  /* Monster can crush items */
-#define RF2_BRAIN_1         0x01000000
-#define RF2_BRAIN_2         0x02000000
-#define RF2_BRAIN_3         0x04000000
-#define RF2_BRAIN_4         0x08000000
-#define RF2_BRAIN_5         0x10000000
-#define RF2_BRAIN_6         0x20000000
-#define RF2_HUMAN           0x40000000
+#define RF2_XXX1            0x01000000
+#define RF2_XXX2            0x02000000
+#define RF2_XXX3            0x04000000
+#define RF2_XXX4            0x08000000
+#define RF2_XXX5            0x10000000
+#define RF2_XXX6            0x20000000
+#define RF2_HUMAN           0x40000000  /* Human */
 #define RF2_QUANTUM         0x80000000  /* Monster has quantum behavior */
 
 /*
 #define RF3_HURT_ROCK       0x00002000  /* Hurt by rock remover */
 #define RF3_HURT_FIRE       0x00004000  /* Hurt badly by fire */
 #define RF3_HURT_COLD       0x00008000  /* Hurt badly by cold */
-#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_TELE        0x00200000  /* Resist teleportation */
-#define RF3_RES_NETH        0x00400000  /* Resist nether a lot */
-#define RF3_RES_WATE        0x00800000  /* Resist water */
-#define RF3_RES_PLAS        0x01000000  /* Resist plasma */
-#define RF3_RES_NEXU        0x02000000  /* Resist nexus */
-#define RF3_RES_DISE        0x04000000  /* Resist disenchantment */
-#define RF3_RES_ALL         0x08000000  /* Resist all */
+#define RF3_XXX16           0x00010000
+#define RF3_XXX17           0x00020000
+#define RF3_XXX18           0x00040000
+#define RF3_XXX19           0x00080000
+#define RF3_XXX20           0x00100000
+#define RF3_XXX21           0x00200000
+#define RF3_XXX22           0x00400000
+#define RF3_XXX23           0x00800000
+#define RF3_XXX24           0x01000000
+#define RF3_XXX25           0x02000000
+#define RF3_XXX26           0x04000000
+#define RF3_XXX27           0x08000000
 #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_CONF         0x40000000  /* Cannot be confused and resist confusion */
 #define RF3_NO_SLEEP        0x80000000  /* Cannot be slept */
 
 /*
 #define RF7_CAN_SWIM            0x00000002  /* Monster can swim */
 #define RF7_CAN_FLY             0x00000004  /* Monster can fly */
 #define RF7_FRIENDLY            0x00000008  /* Monster is friendly */
-#define RF7_UNIQUE_7            0x00000010  /* Is a "Nazgul" unique */
+#define RF7_NAZGUL              0x00000010  /* Is a "Nazgul" unique */
 #define RF7_UNIQUE2             0x00000020  /* Fake unique */
 #define RF7_RIDING              0x00000040  /* Good for riding */
 #define RF7_KAGE                0x00000080  /* Is kage */
 #define RF7_CHAMELEON           0x00002000  /* Chameleon can change */
 #define RF7_KILL_EXP            0x00004000  /* No exp until you kill it */
 #define RF7_TANUKI              0x00008000  /* Tanuki disguise */
+#define RF7_HAS_DARK_1          0x00010000  /* Monster carries darkness */
+#define RF7_SELF_DARK_1         0x00020000  /* Monster darkens itself */
+#define RF7_HAS_DARK_2          0x00040000  /* Monster carries darkness */
+#define RF7_SELF_DARK_2         0x00080000  /* Monster darkens itself */
 
 /*
  * Monster race flags
 /*
  * Monster drop info
  */
-
 #define RF9_DROP_CORPSE         0x00000001
 #define RF9_DROP_SKELETON       0x00000002
 #define RF9_EAT_BLIND           0x00000004
 #define RF9_EAT_DRAIN_MANA      0x80000000
 
 /*
+ * Monster bit flags of racial resistances
+ * Note: Resist confusion was merged to RFR_NO_CONF
+ */
+#define RFR_IM_ACID         0x00000001  /* Resist acid */
+#define RFR_IM_ELEC         0x00000002  /* Resist elec */
+#define RFR_IM_FIRE         0x00000004  /* Resist fire */
+#define RFR_IM_COLD         0x00000008  /* Resist cold */
+#define RFR_IM_POIS         0x00000010  /* Resist poison */
+#define RFR_RES_LITE        0x00000020  /* Resist lite */
+#define RFR_RES_DARK        0x00000040  /* Resist dark */
+#define RFR_RES_NETH        0x00000080  /* Resist nether */
+#define RFR_RES_WATE        0x00000100  /* Resist water */
+#define RFR_RES_PLAS        0x00000200  /* Resist plasma */
+#define RFR_RES_SHAR        0x00000400  /* Resist shards */
+#define RFR_RES_SOUN        0x00000800  /* Resist sound */
+#define RFR_RES_CHAO        0x00001000  /* Resist chaos */
+#define RFR_RES_NEXU        0x00002000  /* Resist nexus */
+#define RFR_RES_DISE        0x00004000  /* Resist disenchantment */
+#define RFR_RES_WALL        0x00008000  /* Resist force */
+#define RFR_RES_INER        0x00010000  /* Resist inertia */
+#define RFR_RES_TIME        0x00020000  /* Resist time */
+#define RFR_RES_GRAV        0x00040000  /* Resist gravity */
+#define RFR_RES_ALL         0x00080000  /* Resist all */
+#define RFR_RES_TELE        0x00100000  /* Resist teleportation */
+#define RFR_XXX21           0x00200000
+#define RFR_XXX22           0x00400000
+#define RFR_XXX23           0x00800000
+#define RFR_XXX24           0x01000000
+#define RFR_XXX25           0x02000000
+#define RFR_XXX26           0x04000000
+#define RFR_XXX27           0x08000000
+#define RFR_XXX28           0x10000000
+#define RFR_XXX29           0x20000000
+#define RFR_XXX30           0x40000000
+#define RFR_XXX31           0x80000000
+
+
+/*
  * Hack -- choose "intelligent" spells when desperate
+ * Including "summon" spells
  */
-
 #define RF4_INT_MASK \
-   (RF4_DISPEL)
+       (RF4_SUMMON_MASK | RF4_DISPEL)
 
 #define RF5_INT_MASK \
-  (RF5_HOLD | RF5_SLOW | RF5_CONF | RF5_BLIND | RF5_SCARE)
+       (RF5_SUMMON_MASK | \
+        RF5_HOLD | RF5_SLOW | RF5_CONF | RF5_BLIND | RF5_SCARE)
 
 #define RF6_INT_MASK \
-   (RF6_BLINK |  RF6_TPORT | RF6_TELE_LEVEL | RF6_TELE_AWAY | \
-    RF6_HEAL | RF6_INVULNER | RF6_HASTE | RF6_TRAPS | \
-    RF6_S_KIN | RF6_S_CYBER | RF6_S_MONSTER | RF6_S_MONSTERS | \
-    RF6_S_ANT | RF6_S_SPIDER | RF6_S_HOUND | RF6_S_HYDRA | \
-    RF6_S_ANGEL | RF6_S_DRAGON | RF6_S_UNDEAD | RF6_S_DEMON | \
-    RF6_S_HI_DRAGON | RF6_S_HI_UNDEAD | RF6_S_AMBERITES | RF6_S_UNIQUE)
-
+       (RF6_SUMMON_MASK | \
+        RF6_BLINK | RF6_TPORT | RF6_TELE_LEVEL | RF6_TELE_AWAY | \
+        RF6_HEAL | RF6_INVULNER | RF6_HASTE | RF6_TRAPS)
 
+/*
+ * Hack -- spells that cannot be used while player riding on the monster
+ */
 #define RF4_RIDING_MASK \
-  (RF4_SHRIEK)
+       (RF4_SHRIEK)
 
-#define RF5_RIDING_MASK \
-   0L
+#define RF5_RIDING_MASK 0L
 
 #define RF6_RIDING_MASK \
-   (RF6_BLINK | RF6_TPORT | RF6_TRAPS | RF6_DARKNESS | RF6_SPECIAL)
-
+       (RF6_BLINK | RF6_TPORT | RF6_TRAPS | RF6_DARKNESS | RF6_SPECIAL)
 
 /*
  * Hack -- "bolt" spells that may hurt fellow monsters
+ * Currently "bolt" spells are included in "attack"
  */
 #define RF4_BOLT_MASK \
-  (RF4_ROCKET | RF4_SHOOT)
+       (RF4_ROCKET | RF4_SHOOT)
 
 #define RF5_BOLT_MASK \
-   (RF5_BO_ACID | RF5_BO_ELEC | RF5_BO_FIRE | RF5_BO_COLD | \
-    RF5_BO_NETH | RF5_BO_WATE | RF5_BO_MANA | \
-    RF5_BO_PLAS | RF5_BO_ICEE | RF5_MISSILE)
+       (RF5_BO_ACID | RF5_BO_ELEC | RF5_BO_FIRE | RF5_BO_COLD | \
+        RF5_BO_NETH | RF5_BO_WATE | RF5_BO_MANA | RF5_BO_PLAS | \
+        RF5_BO_ICEE | RF5_MISSILE)
 
-#define RF6_BOLT_MASK 0
+#define RF6_BOLT_MASK 0L
 
 /*
  * Hack -- "beam" spells that may hurt fellow monsters
+ * Currently "beam" spells are included in "attack"
  */
-#define RF4_BEAM_MASK 0
+#define RF4_BEAM_MASK 0L
 
-#define RF5_BEAM_MASK 0
+#define RF5_BEAM_MASK 0L
 
 #define RF6_BEAM_MASK (RF6_PSY_SPEAR)
 
 /*
- * Hack -- 'ball' spells that may hurt friends
+ * Hack -- "ball" spells that may hurt friends
+ * Including "radius 4 ball" and "breath" spells
+ * Currently "ball" spells are included in "attack"
  */
 #define RF4_BALL_MASK \
-       (RF4_ROCKET | RF4_BR_ACID | RF4_BR_ELEC | RF4_BR_FIRE | \
-       RF4_BR_COLD | RF4_BR_POIS | RF4_BR_NETH | RF4_BR_LITE | \
-       RF4_BR_DARK | RF4_BR_CONF | RF4_BR_SOUN | RF4_BR_CHAO | \
-       RF4_BR_DISE | RF4_BR_NEXU | RF4_BR_SHAR | \
-       RF4_BR_SOUN | RF4_BR_TIME | RF4_BR_INER | RF4_BR_GRAV | \
-       RF4_BR_PLAS | RF4_BR_WALL | RF4_BR_MANA | RF4_BA_NUKE | \
-       RF4_BR_NUKE | RF4_BA_CHAO | RF4_BR_DISI)
+       (RF4_BIG_BALL_MASK | RF4_BREATH_MASK | \
+        RF4_ROCKET | RF4_BA_NUKE)
 
 #define RF5_BALL_MASK \
-       (RF5_BA_ACID | RF5_BA_ELEC | RF5_BA_FIRE | RF5_BA_COLD | \
-        RF5_BA_POIS | RF5_BA_LITE | \
-       RF5_BA_NETH | RF5_BA_DARK | RF5_BA_WATE | RF5_BA_MANA)
+       (RF5_BIG_BALL_MASK | RF5_BREATH_MASK | \
+        RF5_BA_ACID | RF5_BA_ELEC | RF5_BA_FIRE | RF5_BA_COLD | \
+        RF5_BA_POIS | RF5_BA_NETH)
 
 #define RF6_BALL_MASK \
-       0L
+       (RF6_BIG_BALL_MASK | RF6_BREATH_MASK)
+
+/*
+ * Hack -- "ball" spells with radius 4 that may hurt friends
+ * Currently "radius 4 ball" spells are included in "ball"
+ */
+#define RF4_BIG_BALL_MASK \
+       (RF4_BA_CHAO)
+
+#define RF5_BIG_BALL_MASK \
+       (RF5_BA_LITE | RF5_BA_DARK | RF5_BA_WATE | RF5_BA_MANA)
 
+#define RF6_BIG_BALL_MASK 0L
 
 /*
- * Hack -- 'breath' spells that may hurt friends
+ * Hack -- "breath" spells that may hurt friends
+ * Currently "breath" spells are included in "ball" and "non-magic"
  */
 #define RF4_BREATH_MASK \
-       (RF4_BR_ACID | RF4_BR_ELEC | RF4_BR_FIRE | \
-       RF4_BR_COLD | RF4_BR_POIS | RF4_BR_NETH | RF4_BR_LITE | \
-       RF4_BR_DARK | RF4_BR_CONF | RF4_BR_SOUN | RF4_BR_CHAO | \
-       RF4_BR_DISE | RF4_BR_NEXU | RF4_BR_SHAR | \
-       RF4_BR_SOUN | RF4_BR_TIME | RF4_BR_INER | RF4_BR_GRAV | \
-       RF4_BR_PLAS | RF4_BR_WALL | RF4_BR_MANA | \
-       RF4_BR_NUKE | RF4_BR_DISI)
+       (RF4_BR_ACID | RF4_BR_ELEC | RF4_BR_FIRE | RF4_BR_COLD | \
+        RF4_BR_POIS | RF4_BR_NETH | RF4_BR_LITE | RF4_BR_DARK | \
+        RF4_BR_CONF | RF4_BR_SOUN | RF4_BR_CHAO | RF4_BR_DISE | \
+        RF4_BR_NEXU | RF4_BR_SHAR | RF4_BR_TIME | RF4_BR_INER | \
+        RF4_BR_GRAV | RF4_BR_PLAS | RF4_BR_WALL | RF4_BR_MANA | \
+        RF4_BR_NUKE | RF4_BR_DISI)
 
-#define RF5_BREATH_MASK \
-    0L
+#define RF5_BREATH_MASK 0L
 
-#define RF6_BREATH_MASK \
-    0L
+#define RF6_BREATH_MASK 0L
 
-/* Hack -- summon spells */
-
-#define RF4_SUMMON_MASK \
-    0L
+/*
+ * Hack -- "summon" spells
+ * Currently "summon" spells are included in "intelligent" and "indirect"
+ */
+#define RF4_SUMMON_MASK 0L
 
-#define RF5_SUMMON_MASK \
-    0L
+#define RF5_SUMMON_MASK 0L
 
 #define RF6_SUMMON_MASK \
-    (RF6_S_KIN | RF6_S_CYBER | RF6_S_MONSTER | RF6_S_MONSTERS | RF6_S_ANT | \
-     RF6_S_SPIDER | RF6_S_HOUND | RF6_S_HYDRA | RF6_S_ANGEL | RF6_S_DEMON | \
-     RF6_S_UNDEAD | RF6_S_DRAGON | RF6_S_HI_UNDEAD | RF6_S_HI_DRAGON | \
-     RF6_S_AMBERITES | RF6_S_UNIQUE)
-
+       (RF6_S_KIN | RF6_S_CYBER | RF6_S_MONSTER | RF6_S_MONSTERS | RF6_S_ANT | \
+        RF6_S_SPIDER | RF6_S_HOUND | RF6_S_HYDRA | RF6_S_ANGEL | RF6_S_DEMON | \
+        RF6_S_UNDEAD | RF6_S_DRAGON | RF6_S_HI_UNDEAD | RF6_S_HI_DRAGON | \
+        RF6_S_AMBERITES | RF6_S_UNIQUE)
 
 /*
  * Hack -- "attack" spells
+ * Including "bolt", "beam" and "ball" spells
  */
 #define RF4_ATTACK_MASK \
-  (RF4_SHRIEK | RF4_DISPEL | RF4_ROCKET | RF4_SHOOT | \
-   RF4_BR_ACID | RF4_BR_ELEC | RF4_BR_FIRE | \
-   RF4_BR_COLD | RF4_BR_POIS | RF4_BR_NETH | RF4_BR_LITE | RF4_BR_DARK | \
-   RF4_BR_CONF | RF4_BR_SOUN | RF4_BR_CHAO | RF4_BR_DISE | RF4_BR_NEXU | \
-   RF4_BR_TIME | RF4_BR_INER | RF4_BR_GRAV | RF4_BR_SHAR | RF4_BR_PLAS | \
-   RF4_BR_WALL | RF4_BR_MANA | RF4_BA_NUKE | RF4_BR_NUKE | RF4_BA_CHAO | \
-   RF4_BR_DISI)
+       (RF4_BOLT_MASK | RF4_BEAM_MASK | RF4_BALL_MASK | RF4_DISPEL)
 
 #define RF5_ATTACK_MASK \
-   (RF5_BA_ACID | RF5_BA_ELEC | RF5_BA_FIRE | RF5_BA_COLD | \
-    RF5_BA_POIS | RF5_BA_NETH | RF5_BA_WATE | RF5_BA_MANA | \
-    RF5_BA_DARK | RF5_DRAIN_MANA | RF5_MIND_BLAST | RF5_BRAIN_SMASH | \
-    RF5_CAUSE_1 | RF5_CAUSE_2 | RF5_CAUSE_3 | RF5_CAUSE_4 | \
-    RF5_BO_ACID | RF5_BO_ELEC | RF5_BO_FIRE | RF5_BO_COLD | \
-    RF5_BA_LITE | RF5_BO_NETH | RF5_BO_WATE | RF5_BO_MANA | \
-    RF5_BO_PLAS | RF5_BO_ICEE | RF5_MISSILE | RF5_SCARE | \
-    RF5_BLIND | RF5_CONF | RF5_SLOW | RF5_HOLD)
+       (RF5_BOLT_MASK | RF5_BEAM_MASK | RF5_BALL_MASK | \
+        RF5_DRAIN_MANA | RF5_MIND_BLAST | RF5_BRAIN_SMASH | \
+        RF5_CAUSE_1 | RF5_CAUSE_2 | RF5_CAUSE_3 | RF5_CAUSE_4 | \
+        RF5_SCARE | RF5_BLIND | RF5_CONF | RF5_SLOW | RF5_HOLD)
 
 #define RF6_ATTACK_MASK \
-  (RF6_HAND_DOOM | RF6_TELE_TO | RF6_TELE_AWAY | RF6_PSY_SPEAR | \
-   RF6_DARKNESS | RF6_TRAPS | RF6_FORGET)
-
+       (RF6_BOLT_MASK | RF6_BEAM_MASK | RF6_BALL_MASK | \
+        RF6_HAND_DOOM | RF6_TELE_TO | RF6_TELE_AWAY | RF6_TELE_LEVEL | \
+        RF6_DARKNESS | RF6_TRAPS | RF6_FORGET)
 
 /*
  * Hack -- "indirect" spells
+ * Including "summon" spells
  */
 #define RF4_INDIRECT_MASK \
-  (RF4_SHRIEK | RF4_XXX1 | RF4_XXX2 | RF4_XXX3 | RF4_XXX4)
+       (RF4_SUMMON_MASK | RF4_SHRIEK)
 
 #define RF5_INDIRECT_MASK \
-  0L
+       (RF5_SUMMON_MASK)
 
 #define RF6_INDIRECT_MASK \
-  (RF6_HASTE | RF6_HEAL | RF6_INVULNER | RF6_BLINK | RF6_WORLD | \
-   RF6_TPORT | RF6_RAISE_DEAD | \
-   RF6_S_KIN | RF6_S_CYBER | RF6_S_MONSTER | RF6_S_MONSTERS | \
-   RF6_S_ANT | RF6_S_SPIDER | RF6_S_HOUND | RF6_S_HYDRA | \
-   RF6_S_ANGEL | RF6_S_DEMON | RF6_S_UNDEAD | RF6_S_DRAGON | \
-   RF6_S_HI_UNDEAD | RF6_S_HI_DRAGON | RF6_S_AMBERITES | RF6_S_UNIQUE)
-
+       (RF6_SUMMON_MASK | \
+        RF6_HASTE | RF6_HEAL | RF6_INVULNER | RF6_BLINK | RF6_WORLD | \
+        RF6_TPORT | RF6_RAISE_DEAD)
 
 /*
- * Hack -- "no magic" spells
+ * Hack -- "non-magic" spells
+ * Including "breath" spells
  */
 #define RF4_NOMAGIC_MASK \
-       (RF4_SHRIEK | RF4_ROCKET | RF4_SHOOT | \
-        RF4_BR_ACID | RF4_BR_ELEC | \
-        RF4_BR_FIRE | RF4_BR_COLD | RF4_BR_POIS | RF4_BR_NETH | \
-        RF4_BR_LITE | RF4_BR_DARK | RF4_BR_CONF | RF4_BR_SOUN | \
-        RF4_BR_CHAO | RF4_BR_DISE | RF4_BR_NEXU | RF4_BR_SHAR | \
-       RF4_BR_SOUN | RF4_BR_TIME | RF4_BR_INER | RF4_BR_GRAV | \
-       RF4_BR_PLAS | RF4_BR_WALL | RF4_BR_MANA | \
-       RF4_BR_NUKE | RF4_BR_DISI)
+       (RF4_BREATH_MASK | RF4_SHRIEK | RF4_ROCKET | RF4_SHOOT)
 
 #define RF5_NOMAGIC_MASK \
-     0L
+       (RF5_BREATH_MASK)
 
 #define RF6_NOMAGIC_MASK \
-     (RF6_SPECIAL)
+       (RF6_BREATH_MASK | RF6_SPECIAL)
+
+/*
+ * Hack -- "torch" masks
+ */
+#define RF7_LITE_MASK \
+       (RF7_HAS_LITE_1 | RF7_SELF_LITE_1 | RF7_HAS_LITE_2 | RF7_SELF_LITE_2)
+
+#define RF7_DARK_MASK \
+       (RF7_HAS_DARK_1 | RF7_SELF_DARK_1 | RF7_HAS_DARK_2 | RF7_SELF_DARK_2)
+
+#define RF7_HAS_LD_MASK \
+       (RF7_HAS_LITE_1 | RF7_HAS_LITE_2 | RF7_HAS_DARK_1 | RF7_HAS_DARK_2)
+
+#define RF7_SELF_LD_MASK \
+       (RF7_SELF_LITE_1 | RF7_SELF_LITE_2 | RF7_SELF_DARK_1 | RF7_SELF_DARK_2)
+
+/*
+ * Hack -- effective elemental and poison immunity mask
+ */
+#define RFR_EFF_IM_ACID_MASK  (RFR_IM_ACID | RFR_RES_ALL)
+#define RFR_EFF_IM_ELEC_MASK  (RFR_IM_ELEC | RFR_RES_ALL)
+#define RFR_EFF_IM_FIRE_MASK  (RFR_IM_FIRE | RFR_RES_ALL)
+#define RFR_EFF_IM_COLD_MASK  (RFR_IM_COLD | RFR_RES_ALL)
+#define RFR_EFF_IM_POIS_MASK  (RFR_IM_POIS | RFR_RES_ALL)
+#define RFR_EFF_RES_SHAR_MASK (RFR_RES_SHAR | RFR_RES_ALL)
+#define RFR_EFF_RES_CHAO_MASK (RFR_RES_CHAO | RFR_RES_ALL)
+#define RFR_EFF_RES_NEXU_MASK (RFR_RES_NEXU | RFR_RES_ALL)
 
 
 #define MR1_SINKA 0x01
 #define is_hostile(A) \
         (bool)((is_friendly(A) || is_pet(A)) ? FALSE : TRUE)
 
+/* Hack -- Determine monster race appearance index is same as race index */
+#define is_original_ap(A) \
+        (bool)(((A)->ap_r_idx == (A)->r_idx) ? TRUE : FALSE)
+
+
+/*** Option Definitions ***/
+
+
+#define OPT_PAGE_INPUT          1
+#define OPT_PAGE_OUTPUT         2
+#define OPT_PAGE_GAMEPLAY       3
+#define OPT_PAGE_DISTURBANCE    4
+#define OPT_PAGE_EFFICIENCY     5
+#define OPT_PAGE_BIRTH          6
+#define OPT_PAGE_AUTODESTROY    7
+#define OPT_PAGE_PLAYRECORD    10
+
+#define OPT_PAGE_JAPANESE_ONLY 99
+
 
 /*** Macro Definitions ***/
 
    ((X) >= panel_col_min) && ((X) <= panel_col_max))
 
 
+/*
+ * Determine if player is on this grid
+ */
+#define player_bold(Y,X) \
+       (((Y) == py) && ((X) == px))
+
+
+/*
+ * Grid based version of "player_bold()"
+ */
+#define player_grid(C) \
+       ((C) == &cave[py][px])
+
+
+/*
+ * Determine if a "feature" is a "floor"
+ */
+#define feat_floor(F) \
+       (!((F) & 0x20))
+
 
 /*
  * Determine if a "legal" grid is a "floor" grid
  * -KMW-
  */
 #define cave_floor_bold(Y,X) \
-       (!(cave[Y][X].feat & 0x20))
+       (feat_floor(cave[(Y)][(X)].feat))
 
 
 /*
          (cave[Y][X].feat == FEAT_FLOWER) || \
          (cave[Y][X].feat == FEAT_GRASS) || \
          (cave[Y][X].feat == FEAT_DIRT)) && \
-         !(cave[Y][X].info & CAVE_TRAP) && \
-         !(cave[Y][X].info & CAVE_IN_MIRROR) && \
+         !(cave[Y][X].info & CAVE_OBJECT) && \
          (cave[Y][X].o_idx == 0))
 
 
 #define cave_empty_bold(Y,X) \
     (cave_floor_bold(Y,X) && \
      !(cave[Y][X].m_idx) && \
-     !(((Y) == py) && ((X) == px)))
+     !player_bold(Y,X))
 
 
 /*
 #define cave_empty_bold2(Y,X) \
     (((cave_floor_bold(Y,X) && (cave[Y][X].feat != FEAT_DARK_PIT)) || (character_dungeon && (cave[Y][X].feat == FEAT_TREES)))&& \
      !(cave[Y][X].m_idx) && \
-     !(((Y) == py) && ((X) == px)))
+     !player_bold(Y,X))
 
 
 /*
          (cave[Y][X].feat == FEAT_DEEP_GRASS) || \
          (cave[Y][X].feat == FEAT_FLOWER) || \
          (cave[Y][X].feat == FEAT_DIRT)) && \
-         !(cave[Y][X].info & CAVE_TRAP) && \
+         !(cave[Y][X].info & CAVE_OBJECT) && \
          (cave[Y][X].o_idx == 0) && \
          (cave[Y][X].m_idx == 0))
 
 #define cave_perma_bold(Y,X) \
        (((cave[Y][X].feat >= FEAT_PERM_EXTRA) && \
          (cave[Y][X].feat <= FEAT_PERM_SOLID)) || \
-        ((cave[Y][X].feat == FEAT_LESS) || \
-         (cave[Y][X].feat == FEAT_MORE) || \
-         (cave[Y][X].feat == FEAT_ENTRANCE)) || \
-        ((cave[Y][X].feat == FEAT_LESS_LESS) || \
-         (cave[Y][X].feat == FEAT_MORE_MORE)) || \
-        ((cave[Y][X].feat >= FEAT_BLDG_HEAD) && \
-         (cave[Y][X].feat <= FEAT_BLDG_TAIL)) || \
+        (cave[Y][X].feat == FEAT_LESS) || \
+        (cave[Y][X].feat == FEAT_MORE) || \
+        (cave[Y][X].feat == FEAT_ENTRANCE) || \
+        (cave[Y][X].feat == FEAT_LESS_LESS) || \
+        (cave[Y][X].feat == FEAT_MORE_MORE) || \
+        (cave[Y][X].feat == FEAT_MOUNTAIN) || \
+        ((cave[Y][X].feat >= FEAT_QUEST_ENTER) && \
+         (cave[Y][X].feat <= FEAT_QUEST_UP)) || \
+        ((cave[Y][X].feat >= FEAT_PATTERN_START) && \
+         (cave[Y][X].feat <= FEAT_PATTERN_XTRA2)) || \
         ((cave[Y][X].feat >= FEAT_SHOP_HEAD) && \
          (cave[Y][X].feat <= FEAT_SHOP_TAIL)) || \
-         (cave[Y][X].feat == FEAT_MUSEUM))
+        (cave[Y][X].feat == FEAT_MUSEUM) || \
+        ((cave[Y][X].feat >= FEAT_BLDG_HEAD) && \
+         (cave[Y][X].feat <= FEAT_BLDG_TAIL)))
 
 
 /*
  * Grid based version of "cave_floor_bold()"
  */
 #define cave_floor_grid(C) \
-    (!((C)->feat & 0x20))
+       (feat_floor((C)->feat))
 
 
 /*
 #define cave_empty_grid(C) \
     (cave_floor_grid(C) && \
      !((C)->m_idx) && \
-     !((C) == &cave[py][px]))
+     !player_grid(C))
 
 /*
  * Grid based version of "cave_empty_bold()"
 #define cave_empty_grid2(C) \
     ((cave_floor_grid(C) || ((C)->feat == FEAT_TREES)) && \
      !((C)->m_idx) && \
-     !((C) == &cave[py][px]))
+     !player_grid(C))
 
 /*
  * Grid based version of "cave_empty_bold()"
     (((C)->feat == FEAT_FLOOR) && \
      !((C)->o_idx) && \
      !((C)->m_idx) && \
-     !((C) == &cave[py][px]))
+     !player_grid(C))
 
 
 /*
 #define cave_perma_grid(C) \
        ((((C)->feat >= FEAT_PERM_EXTRA) && \
          ((C)->feat <= FEAT_PERM_SOLID)) || \
-         ((C)->feat == FEAT_LESS) || \
-         ((C)->feat == FEAT_MORE) || \
-         ((C)->feat == FEAT_ENTRANCE) || \
-         ((C)->feat == FEAT_LESS_LESS) || \
-         ((C)->feat == FEAT_MORE_MORE) || \
-         ((C)->feat == FEAT_MOUNTAIN) || \
+        ((C)->feat == FEAT_LESS) || \
+        ((C)->feat == FEAT_MORE) || \
+        ((C)->feat == FEAT_ENTRANCE) || \
+        ((C)->feat == FEAT_LESS_LESS) || \
+        ((C)->feat == FEAT_MORE_MORE) || \
+        ((C)->feat == FEAT_MOUNTAIN) || \
         (((C)->feat >= FEAT_QUEST_ENTER) && \
          ((C)->feat <= FEAT_QUEST_UP)) || \
         (((C)->feat >= FEAT_PATTERN_START) && \
          ((C)->feat <= FEAT_PATTERN_XTRA2)) || \
         (((C)->feat >= FEAT_SHOP_HEAD) && \
          ((C)->feat <= FEAT_SHOP_TAIL)) || \
-         ((C)->feat == FEAT_MUSEUM) || \
+        ((C)->feat == FEAT_MUSEUM) || \
         (((C)->feat >= FEAT_BLDG_HEAD) && \
          ((C)->feat <= FEAT_BLDG_TAIL)))
 
 #define player_has_los_bold(Y,X) \
     (((cave[Y][X].info & (CAVE_VIEW)) != 0) || p_ptr->inside_battle)
 
+/*
+ * Determine if a "boundary" grid is "floor mimic"
+ */
+#define boundary_floor_bold(Y,X) \
+       ((cave[(Y)][(X)].feat == FEAT_PERM_SOLID) && \
+         cave[(Y)][(X)].mimic && feat_floor(cave[(Y)][(X)].mimic))
+
+#define boundary_floor_grid(C) \
+       (((C)->feat == FEAT_PERM_SOLID) && \
+         (C)->mimic && feat_floor((C)->mimic))
+
+/*
+ * Get feature mimic from f_info[] (applying "mimic" field)
+ */
+#define get_feat_mimic(C) \
+       (f_info[(C)->mimic ? (C)->mimic : (C)->feat].mimic)
 
 #define update_playtime() \
 {\
@@ -4253,7 +4497,7 @@ extern int PlayerUID;
 #define BACT_GREET_KING              4
 #define BACT_KING_LEGENDS            5
 #define BACT_QUEST                   6
-#define BACT_GOLD                    7
+#define BACT_XXX_UNUSED              7
 #define BACT_POSTER                  8
 #define BACT_ARENA_RULES             9
 #define BACT_ARENA                  10
@@ -4292,7 +4536,8 @@ extern int PlayerUID;
 #define BACT_POKER                  43
 #define BACT_IDENT_ONE              44
 #define BACT_RECHARGE_ALL           45
-#define MAX_BACT                    46
+#define BACT_EVAL_AC               46
+#define MAX_BACT                    47
 
 /*
  * Quest status
@@ -4378,6 +4623,34 @@ extern int PlayerUID;
 #define GINOU_NITOURYU   1
 #define GINOU_RIDING      2
 
+/* Proficiency level */
+#define EXP_LEVEL_UNSKILLED 0
+#define EXP_LEVEL_BEGINNER  1
+#define EXP_LEVEL_SKILLED   2
+#define EXP_LEVEL_EXPERT    3
+#define EXP_LEVEL_MASTER    4
+
+/* Proficiency of weapons and misc. skills (except riding) */
+#define WEAPON_EXP_UNSKILLED     0
+#define WEAPON_EXP_BEGINNER   4000
+#define WEAPON_EXP_SKILLED    6000
+#define WEAPON_EXP_EXPERT     7000
+#define WEAPON_EXP_MASTER     8000
+
+/* Proficiency of riding */
+#define RIDING_EXP_UNSKILLED     0
+#define RIDING_EXP_BEGINNER    500
+#define RIDING_EXP_SKILLED    2000
+#define RIDING_EXP_EXPERT     5000
+#define RIDING_EXP_MASTER     8000
+
+/* Proficiency of spells */
+#define SPELL_EXP_UNSKILLED      0
+#define SPELL_EXP_BEGINNER     900
+#define SPELL_EXP_SKILLED     1200
+#define SPELL_EXP_EXPERT      1400
+#define SPELL_EXP_MASTER      1600
+
 #define NO_TOWN 6
 #define SECRET_TOWN 5
 
@@ -4407,6 +4680,11 @@ extern int PlayerUID;
 
 #define MAX_MANE 16
 #define MAX_MONSPELLS 96
+#define MONSPELL_TYPE_BOLT 1
+#define MONSPELL_TYPE_BALL 2
+#define MONSPELL_TYPE_BREATH 3
+#define MONSPELL_TYPE_SUMMON 4
+#define MONSPELL_TYPE_OTHER 5
 
 #define EATER_EXT 36
 #define EATER_CHARGE 0x10000L
@@ -4526,69 +4804,103 @@ extern int PlayerUID;
 #define MON_WOLF          54
 #define MON_FANG          55
 #define MON_LOUSE         69
+#define MON_PIRANHA       70
 #define MON_COPPER_COINS  85
 #define MON_NOV_PALADIN   97
 #define MON_GREEN_G       100
 #define MON_NOV_PRIEST_G  109
 #define MON_SILVER_COINS  117
+#define MON_D_ELF         122
 #define MON_MANES         128
 #define MON_LOST_SOUL     133
 #define MON_ROBIN_HOOD    138
 #define MON_NOV_PALADIN_G 147
 #define MON_PHANTOM_W     152
 #define MON_WOUNDED_BEAR  159
+#define MON_D_ELF_MAGE    178
+#define MON_D_ELF_WARRIOR 182
 #define MON_BLUE_HORROR   189
 #define MON_GOLD_COINS    195
 #define MON_VORPAL_BUNNY  205
 #define MON_PRIEST        225
+#define MON_D_ELF_PRIEST  226
+#define MON_TIGER         230
 #define MON_MITHRIL_COINS 239
+#define MON_DRUID         241
 #define MON_PINK_HORROR   242
+#define MON_HILL_GIANT    255
+#define MON_WERERAT       270
 #define MON_UMBER_HULK    283
+#define MON_ORC_CAPTAIN   285
+#define MON_BERSERKER     293
 #define MON_SHAGRAT       314
 #define MON_GORBAG        315
+#define MON_STONE_GIANT   321
+#define MON_D_ELF_LORD    348
 #define MON_FIRE_VOR      354
 #define MON_WATER_VOR     355
 #define MON_ARCH_VILE     357
 #define MON_COLD_VOR      358
 #define MON_ENERGY_VOR    359
+#define MON_IRON_GOLEM    367
 #define MON_JADE_MONK     370
+#define MON_D_ELF_WARLOCK 375
 #define MON_HAGEN         383
 #define MON_MENELDOR      384
 #define MON_PHANTOM_B     385
+#define MON_C_CRAWLER     395
+#define MON_XICLOTLAN     396
+#define MON_D_ELF_DRUID   400
+#define MON_TROLL_PRIEST  403
 #define MON_GWAIHIR       410
 #define MON_ANGEL         417
 #define MON_ADAMANT_COINS 423
-#define MON_BARNEY        441
+#define MON_SPIRIT_NAGA   436
+#define MON_GACHAPIN      441
+#define MON_BASILISK      453
 #define MON_ARCHANGEL     456
+#define MON_MITHRIL_GOLEM 464
 #define MON_THORONDOR     468
+#define MON_SHADOW_DRAKE  471
 #define MON_GHOST         477
+#define MON_OGRE_SHAMAN   479
 #define MON_NINJA         485
+#define MON_BICLOPS       490
 #define MON_IVORY_MONK    492
 #define MON_LOG_MASTER    498
+#define MON_ETHER_DRAKE   504
 #define MON_GOEMON        505
 #define MON_CHERUB        511
 #define MON_WATER_ELEM    512
 #define MON_JURT          517
 #define MON_LICH          518
 #define MON_BLOODLETTER   523
+#define MON_HALFLING_S    539
 #define MON_GRAV_HOUND    540
 #define MON_REVENANT      555
 #define MON_RAAL          557
 #define MON_COLOSSUS      558
+#define MON_NIGHTBLADE    564
+#define MON_ELDER_THING   569
 #define MON_CRYPT_THING   577
 #define MON_NEXUS_VOR     587
 #define MON_PLASMA_VOR    588
 #define MON_TIME_VOR      589
+#define MON_M_MH_DRAGON   593
 #define MON_MANDOR        598
 #define MON_SHIM_VOR      600
 #define MON_SERAPH        605
 #define MON_KAVLAX        616
+#define MON_ETTIN         621
+#define MON_VAMPIRE_LORD  623
 #define MON_JUBJUB        640
 #define MON_CLUB_DEMON    648
+#define MON_D_ELF_SORC    657
 #define MON_MASTER_LICH   658
 #define MON_RINALDO       660
 #define MON_ARCHON        661
 #define MON_UND_BEHOLDER  664
+#define MON_IRON_LICH     666
 #define MON_JACK_SHADOWS  670
 #define MON_LLOIGOR       682
 #define MON_DREADMASTER   690
@@ -4597,7 +4909,9 @@ extern int PlayerUID;
 #define MON_SMAUG         697
 #define MON_STORMBRINGER  698
 #define MON_ULTRA_PALADIN 699
+#define MON_G_TITAN       702
 #define MON_FAFNER        712
+#define MON_G_BALROG      720
 #define MON_TIME_HOUND    725
 #define MON_PLASMA_HOUND  726
 #define MON_BULLGATES     732
@@ -4624,7 +4938,8 @@ extern int PlayerUID;
 #define MON_FIONA         791
 #define MON_SKY_DRAKE     793
 #define MON_JULIAN        794
-#define MON_CAIN          799
+#define MON_BLACK_REAVER  798
+#define MON_CAINE         799
 #define MON_GERARD        807
 #define MON_UNGOLIANT     808
 #define MON_ATLACH_NACHA  809
@@ -4674,8 +4989,10 @@ extern int PlayerUID;
 #define MON_SHARD_VOR     897
 #define MON_MASTER_MYS    916
 #define MON_G_MASTER_MYS  917
+#define MON_IE            921
 #define MON_TSUCHINOKO    926
 #define MON_GCWADL        929
+#define MON_LOCKE_CLONE   930
 #define MON_CALDARM       931
 #define MON_BANORLUPART   932
 #define MON_BANOR         933
@@ -4696,7 +5013,7 @@ extern int PlayerUID;
 #define MON_BELD          973
 #define MON_THAT_BAT      975
 #define MON_SHUTEN        979
-#define MON_HOUOU         988
+#define MON_FENGHUANG     988
 #define MON_KIRIN         989
 #define MON_BAHAMUT       1000
 #define MON_SUKE          1001
@@ -4715,16 +5032,24 @@ extern int PlayerUID;
 #define MON_CHAMELEON     1040
 #define MON_CHAMELEON_K   1041
 #define MON_TOPAZ_MONK    1047
+#define MON_NOBORTA       1059
+#define MON_MORI_TROLL    1060
+#define MON_BARNEY        1061
+#define MON_GROO          1062
 #define MON_LOUSY         1063
 #define MON_JIZOTAKO      1065
 #define MON_TANUKI        1067
 
-#define MAX_AUTOPICK 1009
-#define DO_AUTOPICK    0x01
-#define DO_AUTODESTROY 0x02
-#define DO_DISPLAY     0x04
-#define DONT_AUTOPICK  0x08
-#define ITEM_DISPLAY   0x10
+/* Maximum "Nazguls" number */
+#define MAX_NAZGUL_NUM 5
+
+#define DO_AUTOPICK       0x01
+#define DO_AUTODESTROY    0x02
+#define DO_DISPLAY        0x04
+#define DONT_AUTOPICK     0x08
+#define ITEM_DISPLAY      0x10
+#define DO_QUERY_AUTOPICK 0x20
+
 
 #define MAGIC_GLOVE_REDUCE_MANA 0x0001
 #define MAGIC_FAIL_5PERCENT     0x0002
@@ -4841,14 +5166,14 @@ extern int PlayerUID;
 #define DF1_NO_DOORS            0x00000020L
 #define DF1_WATER_RIVER         0x00000040L
 #define DF1_LAVA_RIVER          0x00000080L
-#define DF1_WATER_RIVERS        0x00000100L
-#define DF1_LAVA_RIVERS         0x00000200L
+#define DF1_XXX08               0x00000100L
+#define DF1_XXX09               0x00000200L
 #define DF1_CAVE                0x00000400L
 #define DF1_CAVERN              0x00000800L
-#define DF1_NO_UP               0x00001000L
-#define DF1_HOT                 0x00002000L
-#define DF1_COLD                0x00004000L
-#define DF1_NO_DOWN             0x00008000L
+#define DF1_XXX12               0x00001000L
+#define DF1_XXX13               0x00002000L
+#define DF1_XXX14               0x00004000L
+#define DF1_XXX15               0x00008000L
 #define DF1_FORGET              0x00010000L
 #define DF1_LAKE_WATER          0x00020000L
 #define DF1_LAKE_LAVA           0x00040000L
@@ -4857,11 +5182,14 @@ extern int PlayerUID;
 #define DF1_NO_VAULT            0x00200000L
 #define DF1_ARENA               0x00400000L
 #define DF1_DESTROY             0x00800000L
+#define DF1_XXX24               0x01000000L
 #define DF1_NO_CAVE             0x02000000L
 #define DF1_NO_MAGIC            0x04000000L
 #define DF1_NO_MELEE            0x08000000L
 #define DF1_CHAMELEON           0x10000000L
 #define DF1_DARKNESS            0x20000000L
+#define DF1_XXX30               0x40000000L
+#define DF1_XXX31               0x80000000L
 
 #define DF1_LAKE_MASK (DF1_LAKE_WATER | DF1_LAKE_LAVA | DF1_LAKE_RUBBLE | DF1_LAKE_TREE)
 
@@ -4886,6 +5214,85 @@ extern int PlayerUID;
 #define DUNGEON_DARKNESS 19
 
 
+/*
+ * Flags for change floor mode
+ */
+#define CFM_UP          0x0001  /* Move up */
+#define CFM_DOWN        0x0002  /* Move down */
+#define CFM_LONG_STAIRS  0x0004  /* Randomly occurred long stairs/shaft */
+#define CFM_XXX         0x0008  /* XXX */
+#define CFM_SHAFT       0x0010  /* Shaft */
+#define CFM_RAND_PLACE   0x0020  /* Arrive at random grid */
+#define CFM_RAND_CONNECT 0x0040  /* Connect with random stairs */
+#define CFM_SAVE_FLOORS  0x0080  /* Save floors */
+#define CFM_NO_RETURN    0x0100  /* Flee from random quest etc... */
+#define CFM_FIRST_FLOOR  0x0200  /* Create exit from the dungeon */
+
+
+/*
+ * Flags for save/load temporal saved floor file
+ */
+#define SLF_SECOND              0x0001  /* Called from another save/load function */
+#define SLF_NO_KILL      0x0002  /* Don't kill temporal files */
+
+
+/*
+ * Flags for wr_item()/rd_item()
+ */
+#define SAVE_ITEM_PVAL         0x00000001
+#define SAVE_ITEM_DISCOUNT     0x00000002
+#define SAVE_ITEM_NUMBER       0x00000004
+#define SAVE_ITEM_NAME1        0x00000008
+#define SAVE_ITEM_NAME2        0x00000010
+#define SAVE_ITEM_TIMEOUT      0x00000020
+#define SAVE_ITEM_TO_H         0x00000040
+#define SAVE_ITEM_TO_D         0x00000080
+#define SAVE_ITEM_TO_A         0x00000100
+#define SAVE_ITEM_AC           0x00000200
+#define SAVE_ITEM_DD           0x00000400
+#define SAVE_ITEM_DS           0x00000800
+#define SAVE_ITEM_IDENT        0x00001000
+#define SAVE_ITEM_MARKED       0x00002000
+#define SAVE_ITEM_ART_FLAGS0   0x00004000
+#define SAVE_ITEM_ART_FLAGS1   0x00008000
+#define SAVE_ITEM_ART_FLAGS2   0x00010000
+#define SAVE_ITEM_ART_FLAGS3   0x00020000
+#define SAVE_ITEM_CURSE_FLAGS  0x00040000
+#define SAVE_ITEM_HELD_M_IDX   0x00080000
+#define SAVE_ITEM_XTRA1        0x00100000
+#define SAVE_ITEM_XTRA2        0x00200000
+#define SAVE_ITEM_XTRA3        0x00400000
+#define SAVE_ITEM_XTRA4        0x00800000
+#define SAVE_ITEM_XTRA5        0x01000000
+#define SAVE_ITEM_FEELING      0x02000000
+#define SAVE_ITEM_INSCRIPTION  0x04000000
+#define SAVE_ITEM_ART_NAME     0x08000000
+
+
+/*
+ * Flags for wr_monster()/rd_monster()
+ */
+#define SAVE_MON_AP_R_IDX     0x00000001
+#define SAVE_MON_SUB_ALIGN    0x00000002
+#define SAVE_MON_CSLEEP       0x00000004
+#define SAVE_MON_FAST         0x00000008
+#define SAVE_MON_SLOW         0x00000010
+#define SAVE_MON_STUNNED      0x00000020
+#define SAVE_MON_CONFUSED     0x00000040
+#define SAVE_MON_MONFEAR      0x00000080
+#define SAVE_MON_TARGET_Y     0x00000100
+#define SAVE_MON_TARGET_X     0x00000200
+#define SAVE_MON_INVULNER     0x00000400
+#define SAVE_MON_SMART        0x00000800
+#define SAVE_MON_EXP          0x00001000
+#define SAVE_MON_MFLAG2       0x00002000
+#define SAVE_MON_NICKNAME     0x00004000
+#define SAVE_MON_PARENT       0x00008000
+
+
+/*
+ * Constant for kinds of mimic
+ */
 #define MIMIC_NONE       0
 #define MIMIC_DEMON      1
 #define MIMIC_DEMON_LORD 2
@@ -4905,16 +5312,51 @@ extern int PlayerUID;
 #define SUB_ALIGN_EVIL    0x0001
 #define SUB_ALIGN_GOOD    0x0002
 
+/* Temporary flags macro */
+#define IS_FAST() (p_ptr->fast || music_singing(MUSIC_SPEED) || music_singing(MUSIC_SHERO))
+#define IS_INVULN() (p_ptr->invuln || music_singing(MUSIC_INVULN))
+#define IS_HERO() (p_ptr->hero || music_singing(MUSIC_HERO) || music_singing(MUSIC_SHERO))
+#define IS_BLESSED() (p_ptr->blessed || music_singing(MUSIC_BLESS))
+#define IS_OPPOSE_ACID() (p_ptr->oppose_acid || music_singing(MUSIC_RESIST) || (p_ptr->special_defense & KATA_MUSOU))
+#define IS_OPPOSE_ELEC() (p_ptr->oppose_elec || music_singing(MUSIC_RESIST) || (p_ptr->special_defense & KATA_MUSOU))
+#define IS_OPPOSE_FIRE() (p_ptr->oppose_fire || music_singing(MUSIC_RESIST) || (p_ptr->special_defense & KATA_MUSOU))
+#define IS_OPPOSE_COLD() (p_ptr->oppose_cold || music_singing(MUSIC_RESIST) || (p_ptr->special_defense & KATA_MUSOU))
+#define IS_OPPOSE_POIS() (p_ptr->oppose_pois || music_singing(MUSIC_RESIST) || (p_ptr->special_defense & KATA_MUSOU))
+#define IS_TIM_ESP() (p_ptr->tim_esp || music_singing(MUSIC_MIND))
+#define IS_TIM_STEALTH() (p_ptr->tim_stealth || music_singing(MUSIC_STEALTH))
+
+/* Is "teleport level" ineffective to this target? */
+#define TELE_LEVEL_IS_INEFF(TARGET) \
+       (p_ptr->inside_arena || p_ptr->inside_battle || \
+        (p_ptr->inside_quest && !random_quest_number(dun_level)) || \
+        (((TARGET) <= 0) && (quest_number(dun_level) || (dun_level >= d_info[dungeon_type].maxdepth)) && \
+         (dun_level >= 1) && ironman_downward))
+
+
 /*
- * World Score -- internet resource value
+ * Max numbers of macro trigger names
  */
-#define HTTP_PROXY ""                   /* Default proxy url */
-#define HTTP_PROXY_PORT 0               /* Default proxy port */
-#define HTTP_TIMEOUT    20              /* Timeout length (second) */
-#define SCORE_SERVER "www.kmc.gr.jp"    /* Default score server url */
-#define SCORE_PORT 80                   /* Default score server port */
-
 #define MAX_MACRO_MOD 12
 #define MAX_MACRO_TRIG 200
 
-#define SCREEN_BUF_SIZE 65536           /* max screen dump buffer size */
+/* Max size of screen dump buffer */
+#define SCREEN_BUF_SIZE 65536
+
+
+/*
+ * Special key code used for inkey_special()
+ */
+#define SKEY_MOD_MASK     0x0f00
+#define SKEY_MOD_SHIFT    0x0100
+#define SKEY_MOD_CONTROL  0x0200
+
+#define SKEY_MASK         0xf000
+#define SKEY_DOWN        0xf001
+#define SKEY_LEFT        0xf002
+#define SKEY_RIGHT       0xf003
+#define SKEY_UP          0xf004
+#define SKEY_PGUP        0xf005
+#define SKEY_PGDOWN      0xf006
+#define SKEY_TOP         0xf007
+#define SKEY_BOTTOM      0xf008
+