6 #include "spells-floor.h"
10 #include "floor-save.h"
11 #include "player-effects.h"
15 * Light up the dungeon using "clairvoyance"
17 * This function "illuminates" every grid in the dungeon, memorizes all
18 * "objects", memorizes all grids as with magic mapping, and, under the
19 * standard option settings (view_perma_grids but not view_torch_grids)
20 * memorizes all floor grids too.
22 * Note that if "view_perma_grids" is not set, we do not memorize floor
23 * grids, since this would defeat the purpose of "view_perma_grids", not
24 * that anyone seems to play without this option.
26 * Note that if "view_torch_grids" is set, we do not memorize floor grids,
27 * since this would prevent the use of "view_torch_grids" as a method to
28 * keep track of what grids have been observed directly.
30 void wiz_lite(bool ninja)
37 /* Memorize objects */
38 for (i = 1; i < current_floor_ptr->o_max; i++)
40 object_type *o_ptr = ¤t_floor_ptr->o_list[i];
42 /* Skip dead objects */
43 if (!o_ptr->k_idx) continue;
45 /* Skip held objects */
46 if (o_ptr->held_m_idx) continue;
49 o_ptr->marked |= OM_FOUND;
52 /* Scan all normal grids */
53 for (y = 1; y < current_floor_ptr->height - 1; y++)
55 /* Scan all normal grids */
56 for (x = 1; x < current_floor_ptr->width - 1; x++)
58 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
60 /* Memorize terrain of the grid */
61 g_ptr->info |= (CAVE_KNOWN);
63 /* Feature code (applying "mimic" field) */
64 feat = get_feat_mimic(g_ptr);
65 f_ptr = &f_info[feat];
67 /* Process all non-walls */
68 if (!have_flag(f_ptr->flags, FF_WALL))
70 /* Scan all neighbors */
71 for (i = 0; i < 9; i++)
73 POSITION yy = y + ddy_ddd[i];
74 POSITION xx = x + ddx_ddd[i];
75 g_ptr = ¤t_floor_ptr->grid_array[yy][xx];
77 /* Feature code (applying "mimic" field) */
78 f_ptr = &f_info[get_feat_mimic(g_ptr)];
80 /* Perma-lite the grid */
81 if (!(d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS) && !ninja)
83 g_ptr->info |= (CAVE_GLOW);
86 /* Memorize normal features */
87 if (have_flag(f_ptr->flags, FF_REMEMBER))
89 /* Memorize the grid */
90 g_ptr->info |= (CAVE_MARK);
93 /* Perma-lit grids (newly and previously) */
94 else if (g_ptr->info & CAVE_GLOW)
96 /* Normally, memorize floors (see above) */
97 if (view_perma_grids && !view_torch_grids)
99 /* Memorize the grid */
100 g_ptr->info |= (CAVE_MARK);
108 p_ptr->update |= (PU_MONSTERS);
109 p_ptr->redraw |= (PR_MAP);
110 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
112 if (p_ptr->special_defense & NINJA_S_STEALTH)
114 if (current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info & CAVE_GLOW) set_superstealth(FALSE);
120 * Forget the dungeon map (ala "Thinking of Maud...").
127 /* Forget every grid */
128 for (y = 1; y < current_floor_ptr->height - 1; y++)
130 for (x = 1; x < current_floor_ptr->width - 1; x++)
132 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
134 /* Process the grid */
135 g_ptr->info &= ~(CAVE_MARK | CAVE_IN_DETECT | CAVE_KNOWN);
136 g_ptr->info |= (CAVE_UNSAFE);
140 /* Forget every grid on horizontal edge */
141 for (x = 0; x < current_floor_ptr->width; x++)
143 current_floor_ptr->grid_array[0][x].info &= ~(CAVE_MARK);
144 current_floor_ptr->grid_array[current_floor_ptr->height - 1][x].info &= ~(CAVE_MARK);
147 /* Forget every grid on vertical edge */
148 for (y = 1; y < (current_floor_ptr->height - 1); y++)
150 current_floor_ptr->grid_array[y][0].info &= ~(CAVE_MARK);
151 current_floor_ptr->grid_array[y][current_floor_ptr->width - 1].info &= ~(CAVE_MARK);
154 /* Forget all objects */
155 for (i = 1; i < current_floor_ptr->o_max; i++)
157 object_type *o_ptr = ¤t_floor_ptr->o_list[i];
159 /* Skip dead objects */
160 if (!o_ptr->k_idx) continue;
162 /* Skip held objects */
163 if (o_ptr->held_m_idx) continue;
165 /* Forget the object */
166 o_ptr->marked &= OM_TOUCHED;
169 /* Forget travel route when we have forgotten map */
170 forget_travel_flow();
172 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
173 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
174 p_ptr->update |= (PU_MONSTERS);
175 p_ptr->redraw |= (PR_MAP);
176 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
180 * @brief 守りのルーン設置処理 /
181 * Leave a "glyph of warding" which prevents monster movement
182 * @return 実際に設置が行われた場合TRUEを返す
184 bool warding_glyph(void)
186 if (!cave_clean_bold(p_ptr->y, p_ptr->x))
188 msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
193 current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info |= CAVE_OBJECT;
194 current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].mimic = feat_glyph;
196 note_spot(p_ptr->y, p_ptr->x);
197 lite_spot(p_ptr->y, p_ptr->x);
204 * @brief 爆発のルーン設置処理 /
205 * Leave an "explosive rune" which prevents monster movement
206 * @return 実際に設置が行われた場合TRUEを返す
208 bool explosive_rune(void)
210 if (!cave_clean_bold(p_ptr->y, p_ptr->x))
212 msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
217 current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info |= CAVE_OBJECT;
218 current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].mimic = feat_explosive_rune;
220 note_spot(p_ptr->y, p_ptr->x);
221 lite_spot(p_ptr->y, p_ptr->x);
229 * @return 実際に設置が行われた場合TRUEを返す
231 bool place_mirror(void)
233 if (!cave_clean_bold(p_ptr->y, p_ptr->x))
235 msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
239 /* Create a mirror */
240 current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info |= CAVE_OBJECT;
241 current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].mimic = feat_mirror;
243 /* Turn on the light */
244 current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info |= CAVE_GLOW;
246 note_spot(p_ptr->y, p_ptr->x);
247 lite_spot(p_ptr->y, p_ptr->x);
248 update_local_illumination(p_ptr->y, p_ptr->x);
254 * @brief プレイヤーの手による能動的な階段生成処理 /
255 * Create stairs at or move previously created stairs into the player location.
258 void stair_creation(void)
260 saved_floor_type *sf_ptr;
261 saved_floor_type *dest_sf_ptr;
265 FLOOR_IDX dest_floor_id = 0;
268 /* Forbid up staircases on Ironman mode */
269 if (ironman_downward) up = FALSE;
271 /* Forbid down staircases on quest level */
272 if (quest_number(current_floor_ptr->dun_level) || (current_floor_ptr->dun_level >= d_info[p_ptr->dungeon_idx].maxdepth)) down = FALSE;
274 /* No effect out of standard dungeon floor */
275 if (!current_floor_ptr->dun_level || (!up && !down) ||
276 (p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) ||
277 p_ptr->inside_arena || p_ptr->inside_battle)
280 msg_print(_("効果がありません!", "There is no effect!"));
284 /* Artifacts resists */
285 if (!cave_valid_bold(p_ptr->y, p_ptr->x))
287 msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
291 /* Destroy all objects in the grid */
292 delete_object(p_ptr->y, p_ptr->x);
294 /* Extract current floor data */
295 sf_ptr = get_sf_ptr(p_ptr->floor_id);
298 /* No floor id? -- Create now! */
299 p_ptr->floor_id = get_new_floor_id();
300 sf_ptr = get_sf_ptr(p_ptr->floor_id);
303 /* Choose randomly */
306 if (randint0(100) < 50) up = FALSE;
310 /* Destination is already fixed */
313 if (sf_ptr->upper_floor_id) dest_floor_id = sf_ptr->upper_floor_id;
317 if (sf_ptr->lower_floor_id) dest_floor_id = sf_ptr->lower_floor_id;
321 /* Search old stairs leading to the destination */
326 for (y = 0; y < current_floor_ptr->height; y++)
328 for (x = 0; x < current_floor_ptr->width; x++)
330 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
332 if (!g_ptr->special) continue;
333 if (feat_uses_special(g_ptr->feat)) continue;
334 if (g_ptr->special != dest_floor_id) continue;
336 /* Remove old stairs */
338 cave_set_feat(y, x, feat_ground_type[randint0(100)]);
343 /* No old destination -- Get new one now */
346 dest_floor_id = get_new_floor_id();
350 sf_ptr->upper_floor_id = dest_floor_id;
352 sf_ptr->lower_floor_id = dest_floor_id;
355 /* Extract destination floor data */
356 dest_sf_ptr = get_sf_ptr(dest_floor_id);
359 /* Create a staircase */
362 cave_set_feat(p_ptr->y, p_ptr->x,
363 (dest_sf_ptr->last_visit && (dest_sf_ptr->dun_level <= current_floor_ptr->dun_level - 2)) ?
364 feat_state(feat_up_stair, FF_SHAFT) : feat_up_stair);
368 cave_set_feat(p_ptr->y, p_ptr->x,
369 (dest_sf_ptr->last_visit && (dest_sf_ptr->dun_level >= current_floor_ptr->dun_level + 2)) ?
370 feat_state(feat_down_stair, FF_SHAFT) : feat_down_stair);
374 /* Connect this stairs to the destination */
375 current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].special = dest_floor_id;
379 * Hack -- map the current panel (plus some) ala "magic mapping"
381 void map_area(POSITION range)
389 if (d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS) range /= 3;
392 for (y = 1; y < current_floor_ptr->height - 1; y++)
394 for (x = 1; x < current_floor_ptr->width - 1; x++)
396 if (distance(p_ptr->y, p_ptr->x, y, x) > range) continue;
398 g_ptr = ¤t_floor_ptr->grid_array[y][x];
400 /* Memorize terrain of the grid */
401 g_ptr->info |= (CAVE_KNOWN);
403 /* Feature code (applying "mimic" field) */
404 feat = get_feat_mimic(g_ptr);
405 f_ptr = &f_info[feat];
407 /* All non-walls are "checked" */
408 if (!have_flag(f_ptr->flags, FF_WALL))
410 /* Memorize normal features */
411 if (have_flag(f_ptr->flags, FF_REMEMBER))
413 /* Memorize the object */
414 g_ptr->info |= (CAVE_MARK);
417 /* Memorize known walls */
418 for (i = 0; i < 8; i++)
420 g_ptr = ¤t_floor_ptr->grid_array[y + ddy_ddd[i]][x + ddx_ddd[i]];
422 /* Feature code (applying "mimic" field) */
423 feat = get_feat_mimic(g_ptr);
424 f_ptr = &f_info[feat];
426 /* Memorize walls (etc) */
427 if (have_flag(f_ptr->flags, FF_REMEMBER))
429 /* Memorize the walls */
430 g_ptr->info |= (CAVE_MARK);
437 p_ptr->redraw |= (PR_MAP);
438 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);