3 * Flags for change floor mode
5 #define CFM_UP 0x0001 /* Move up */
6 #define CFM_DOWN 0x0002 /* Move down */
7 #define CFM_LONG_STAIRS 0x0004 /* Randomly occurred long stairs/shaft */
8 #define CFM_XXX 0x0008 /* XXX */
9 #define CFM_SHAFT 0x0010 /* Shaft */
10 #define CFM_RAND_PLACE 0x0020 /* Arrive at random grid */
11 #define CFM_RAND_CONNECT 0x0040 /* Connect with random stairs */
12 #define CFM_SAVE_FLOORS 0x0080 /* Save floors */
13 #define CFM_NO_RETURN 0x0100 /* Flee from random quest etc... */
14 #define CFM_FIRST_FLOOR 0x0200 /* Create exit from the dungeon */
17 * Determines if a map location is fully inside the outer walls
19 #define in_bounds(Y,X) \
20 (((Y) > 0) && ((X) > 0) && ((Y) < current_floor_ptr->height-1) && ((X) < current_floor_ptr->width-1))
23 * Determines if a map location is on or inside the outer walls
25 #define in_bounds2(Y,X) \
26 (((Y) >= 0) && ((X) >= 0) && ((Y) < current_floor_ptr->height) && ((X) < current_floor_ptr->width))
29 * Determines if a map location is on or inside the outer walls
32 #define in_bounds2u(Y,X) \
33 (((Y) < current_floor_ptr->height) && ((X) < current_floor_ptr->width))
37 * Determine if player is on this grid
39 #define player_bold(Y,X) \
40 (((Y) == p_ptr->y) && ((X) == p_ptr->x))
43 * Grid based version of "player_bold()"
45 #define player_grid(C) \
46 ((C) == ¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x])
49 #define cave_have_flag_bold(Y,X,INDEX) \
50 (have_flag(f_info[current_floor_ptr->grid_array[(Y)][(X)].feat].flags, (INDEX)))
53 #define cave_have_flag_grid(C,INDEX) \
54 (have_flag(f_info[(C)->feat].flags, (INDEX)))
58 * Determine if a "feature" supports "los"
60 #define feat_supports_los(F) \
61 (have_flag(f_info[(F)].flags, FF_LOS))
65 * Determine if a "legal" grid supports "los"
67 #define cave_los_bold(Y,X) \
68 (feat_supports_los(current_floor_ptr->grid_array[(Y)][(X)].feat))
70 #define cave_los_grid(C) \
71 (feat_supports_los((C)->feat))
75 * Determine if a "legal" grid is a "clean" floor grid
76 * Determine if terrain-change spells are allowed in a grid.
78 * Line 1 -- forbid non-floors
79 * Line 2 -- forbid object terrains
80 * Line 3 -- forbid normal objects
82 #define cave_clean_bold(Y,X) \
83 (cave_have_flag_bold((Y), (X), FF_FLOOR) && \
84 !(current_floor_ptr->grid_array[Y][X].info & CAVE_OBJECT) && \
85 (current_floor_ptr->grid_array[Y][X].o_idx == 0))
89 * Determine if an object can be dropped on a "legal" grid
91 * Line 1 -- forbid non-drops
92 * Line 2 -- forbid object terrains
94 #define cave_drop_bold(Y,X) \
95 (cave_have_flag_bold((Y), (X), FF_DROP) && \
96 !(current_floor_ptr->grid_array[Y][X].info & CAVE_OBJECT))
100 * Determine if a "legal" grid is an "empty" floor grid
101 * Determine if monsters are allowed to move into a grid
103 * Line 1 -- forbid non-placement grids
104 * Line 2 -- forbid normal monsters
105 * Line 3 -- forbid the player
107 #define cave_empty_bold(Y,X) \
108 (cave_have_flag_bold((Y), (X), FF_PLACE) && \
109 !(current_floor_ptr->grid_array[Y][X].m_idx) && \
114 * Determine if a "legal" grid is an "empty" floor grid
115 * Determine if monster generation is allowed in a grid
117 * Line 1 -- forbid non-empty grids
118 * Line 2 -- forbid trees while dungeon generation
120 #define cave_empty_bold2(Y,X) \
121 (cave_empty_bold(Y,X) && \
122 (character_dungeon || !cave_have_flag_bold((Y), (X), FF_TREE)))
126 * Determine if a "legal" grid is an "naked" floor grid
128 * Line 1 -- forbid non-clean gird
129 * Line 2 -- forbid monsters
130 * Line 3 -- forbid the player
132 #define cave_naked_bold(Y,X) \
133 (cave_clean_bold(Y,X) && \
134 !(current_floor_ptr->grid_array[Y][X].m_idx) && \
139 * Determine if a "legal" grid is "permanent"
141 * Line 1 -- permanent flag
143 #define cave_perma_bold(Y,X) \
144 (cave_have_flag_bold((Y), (X), FF_PERMANENT))
148 * Grid based version of "cave_empty_bold()"
150 #define cave_empty_grid(C) \
151 (cave_have_flag_grid((C), FF_PLACE) && \
157 * Grid based version of "cave_perma_bold()"
159 #define cave_perma_grid(C) \
160 (cave_have_flag_grid((C), FF_PERMANENT))
163 #define pattern_tile(Y,X) \
164 (cave_have_flag_bold((Y), (X), FF_PATTERN))
167 * Does the grid stop disintegration?
169 #define cave_stop_disintegration(Y,X) \
170 (!cave_have_flag_bold((Y), (X), FF_PROJECT) && \
171 (!cave_have_flag_bold((Y), (X), FF_HURT_DISI) || \
172 cave_have_flag_bold((Y), (X), FF_PERMANENT)))
176 * Determine if a "legal" grid is within "los" of the player
178 * Note the use of comparison to zero to force a "boolean" result
180 #define player_has_los_grid(C) \
181 (((C)->info & (CAVE_VIEW)) != 0)
184 * Determine if a "legal" grid is within "los" of the player
186 * Note the use of comparison to zero to force a "boolean" result
188 #define player_has_los_bold(Y,X) \
189 (((current_floor_ptr->grid_array[Y][X].info & (CAVE_VIEW)) != 0) || p_ptr->inside_battle)
193 * Determine if a "feature" is "permanent wall"
195 #define permanent_wall(F) \
196 (have_flag((F)->flags, FF_WALL) && \
197 have_flag((F)->flags, FF_PERMANENT))
200 * Get feature mimic from f_info[] (applying "mimic" field)
202 #define get_feat_mimic(C) \
203 (f_info[(C)->mimic ? (C)->mimic : (C)->feat].mimic)