5 #include "spells-floor.h"
9 #include "floor-save.h"
10 #include "player-effects.h"
14 * Light up the dungeon using "clairvoyance"
16 * This function "illuminates" every grid in the dungeon, memorizes all
17 * "objects", memorizes all grids as with magic mapping, and, under the
18 * standard option settings (view_perma_grids but not view_torch_grids)
19 * memorizes all floor grids too.
21 * Note that if "view_perma_grids" is not set, we do not memorize floor
22 * grids, since this would defeat the purpose of "view_perma_grids", not
23 * that anyone seems to play without this option.
25 * Note that if "view_torch_grids" is set, we do not memorize floor grids,
26 * since this would prevent the use of "view_torch_grids" as a method to
27 * keep track of what grids have been observed directly.
29 void wiz_lite(bool ninja)
36 /* Memorize objects */
37 for (i = 1; i < o_max; i++)
39 object_type *o_ptr = ¤t_floor_ptr->o_list[i];
41 /* Skip dead objects */
42 if (!o_ptr->k_idx) continue;
44 /* Skip held objects */
45 if (o_ptr->held_m_idx) continue;
48 o_ptr->marked |= OM_FOUND;
51 /* Scan all normal grids */
52 for (y = 1; y < current_floor_ptr->height - 1; y++)
54 /* Scan all normal grids */
55 for (x = 1; x < current_floor_ptr->width - 1; x++)
57 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
59 /* Memorize terrain of the grid */
60 g_ptr->info |= (CAVE_KNOWN);
62 /* Feature code (applying "mimic" field) */
63 feat = get_feat_mimic(g_ptr);
64 f_ptr = &f_info[feat];
66 /* Process all non-walls */
67 if (!have_flag(f_ptr->flags, FF_WALL))
69 /* Scan all neighbors */
70 for (i = 0; i < 9; i++)
72 POSITION yy = y + ddy_ddd[i];
73 POSITION xx = x + ddx_ddd[i];
74 g_ptr = ¤t_floor_ptr->grid_array[yy][xx];
76 /* Feature code (applying "mimic" field) */
77 f_ptr = &f_info[get_feat_mimic(g_ptr)];
79 /* Perma-lite the grid */
80 if (!(d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS) && !ninja)
82 g_ptr->info |= (CAVE_GLOW);
85 /* Memorize normal features */
86 if (have_flag(f_ptr->flags, FF_REMEMBER))
88 /* Memorize the grid */
89 g_ptr->info |= (CAVE_MARK);
92 /* Perma-lit grids (newly and previously) */
93 else if (g_ptr->info & CAVE_GLOW)
95 /* Normally, memorize floors (see above) */
96 if (view_perma_grids && !view_torch_grids)
98 /* Memorize the grid */
99 g_ptr->info |= (CAVE_MARK);
107 p_ptr->update |= (PU_MONSTERS);
108 p_ptr->redraw |= (PR_MAP);
109 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
111 if (p_ptr->special_defense & NINJA_S_STEALTH)
113 if (current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info & CAVE_GLOW) set_superstealth(FALSE);
119 * Forget the dungeon map (ala "Thinking of Maud...").
126 /* Forget every grid */
127 for (y = 1; y < current_floor_ptr->height - 1; y++)
129 for (x = 1; x < current_floor_ptr->width - 1; x++)
131 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
133 /* Process the grid */
134 g_ptr->info &= ~(CAVE_MARK | CAVE_IN_DETECT | CAVE_KNOWN);
135 g_ptr->info |= (CAVE_UNSAFE);
139 /* Forget every grid on horizontal edge */
140 for (x = 0; x < current_floor_ptr->width; x++)
142 current_floor_ptr->grid_array[0][x].info &= ~(CAVE_MARK);
143 current_floor_ptr->grid_array[current_floor_ptr->height - 1][x].info &= ~(CAVE_MARK);
146 /* Forget every grid on vertical edge */
147 for (y = 1; y < (current_floor_ptr->height - 1); y++)
149 current_floor_ptr->grid_array[y][0].info &= ~(CAVE_MARK);
150 current_floor_ptr->grid_array[y][current_floor_ptr->width - 1].info &= ~(CAVE_MARK);
153 /* Forget all objects */
154 for (i = 1; i < o_max; i++)
156 object_type *o_ptr = ¤t_floor_ptr->o_list[i];
158 /* Skip dead objects */
159 if (!o_ptr->k_idx) continue;
161 /* Skip held objects */
162 if (o_ptr->held_m_idx) continue;
164 /* Forget the object */
165 o_ptr->marked &= OM_TOUCHED;
168 /* Forget travel route when we have forgotten map */
169 forget_travel_flow();
171 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
172 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
173 p_ptr->update |= (PU_MONSTERS);
174 p_ptr->redraw |= (PR_MAP);
175 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
179 * @brief 守りのルーン設置処理 /
180 * Leave a "glyph of warding" which prevents monster movement
181 * @return 実際に設置が行われた場合TRUEを返す
183 bool warding_glyph(void)
185 if (!cave_clean_bold(p_ptr->y, p_ptr->x))
187 msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
192 current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info |= CAVE_OBJECT;
193 current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].mimic = feat_glyph;
195 note_spot(p_ptr->y, p_ptr->x);
196 lite_spot(p_ptr->y, p_ptr->x);
203 * @brief 爆発のルーン設置処理 /
204 * Leave an "explosive rune" which prevents monster movement
205 * @return 実際に設置が行われた場合TRUEを返す
207 bool explosive_rune(void)
209 if (!cave_clean_bold(p_ptr->y, p_ptr->x))
211 msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
216 current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info |= CAVE_OBJECT;
217 current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].mimic = feat_explosive_rune;
219 note_spot(p_ptr->y, p_ptr->x);
220 lite_spot(p_ptr->y, p_ptr->x);
228 * @return 実際に設置が行われた場合TRUEを返す
230 bool place_mirror(void)
232 if (!cave_clean_bold(p_ptr->y, p_ptr->x))
234 msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
238 /* Create a mirror */
239 current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info |= CAVE_OBJECT;
240 current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].mimic = feat_mirror;
242 /* Turn on the light */
243 current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info |= CAVE_GLOW;
245 note_spot(p_ptr->y, p_ptr->x);
246 lite_spot(p_ptr->y, p_ptr->x);
247 update_local_illumination(p_ptr->y, p_ptr->x);
253 * @brief プレイヤーの手による能動的な階段生成処理 /
254 * Create stairs at or move previously created stairs into the player location.
257 void stair_creation(void)
259 saved_floor_type *sf_ptr;
260 saved_floor_type *dest_sf_ptr;
264 FLOOR_IDX dest_floor_id = 0;
267 /* Forbid up staircases on Ironman mode */
268 if (ironman_downward) up = FALSE;
270 /* Forbid down staircases on quest level */
271 if (quest_number(current_floor_ptr->dun_level) || (current_floor_ptr->dun_level >= d_info[p_ptr->dungeon_idx].maxdepth)) down = FALSE;
273 /* No effect out of standard dungeon floor */
274 if (!current_floor_ptr->dun_level || (!up && !down) ||
275 (p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) ||
276 p_ptr->inside_arena || p_ptr->inside_battle)
279 msg_print(_("効果がありません!", "There is no effect!"));
283 /* Artifacts resists */
284 if (!cave_valid_bold(p_ptr->y, p_ptr->x))
286 msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
290 /* Destroy all objects in the grid */
291 delete_object(p_ptr->y, p_ptr->x);
293 /* Extract current floor data */
294 sf_ptr = get_sf_ptr(p_ptr->floor_id);
297 /* No floor id? -- Create now! */
298 p_ptr->floor_id = get_new_floor_id();
299 sf_ptr = get_sf_ptr(p_ptr->floor_id);
302 /* Choose randomly */
305 if (randint0(100) < 50) up = FALSE;
309 /* Destination is already fixed */
312 if (sf_ptr->upper_floor_id) dest_floor_id = sf_ptr->upper_floor_id;
316 if (sf_ptr->lower_floor_id) dest_floor_id = sf_ptr->lower_floor_id;
320 /* Search old stairs leading to the destination */
325 for (y = 0; y < current_floor_ptr->height; y++)
327 for (x = 0; x < current_floor_ptr->width; x++)
329 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
331 if (!g_ptr->special) continue;
332 if (feat_uses_special(g_ptr->feat)) continue;
333 if (g_ptr->special != dest_floor_id) continue;
335 /* Remove old stairs */
337 cave_set_feat(y, x, feat_ground_type[randint0(100)]);
342 /* No old destination -- Get new one now */
345 dest_floor_id = get_new_floor_id();
349 sf_ptr->upper_floor_id = dest_floor_id;
351 sf_ptr->lower_floor_id = dest_floor_id;
354 /* Extract destination floor data */
355 dest_sf_ptr = get_sf_ptr(dest_floor_id);
358 /* Create a staircase */
361 cave_set_feat(p_ptr->y, p_ptr->x,
362 (dest_sf_ptr->last_visit && (dest_sf_ptr->dun_level <= current_floor_ptr->dun_level - 2)) ?
363 feat_state(feat_up_stair, FF_SHAFT) : feat_up_stair);
367 cave_set_feat(p_ptr->y, p_ptr->x,
368 (dest_sf_ptr->last_visit && (dest_sf_ptr->dun_level >= current_floor_ptr->dun_level + 2)) ?
369 feat_state(feat_down_stair, FF_SHAFT) : feat_down_stair);
373 /* Connect this stairs to the destination */
374 current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].special = dest_floor_id;
378 * Hack -- map the current panel (plus some) ala "magic mapping"
380 void map_area(POSITION range)
388 if (d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS) range /= 3;
391 for (y = 1; y < current_floor_ptr->height - 1; y++)
393 for (x = 1; x < current_floor_ptr->width - 1; x++)
395 if (distance(p_ptr->y, p_ptr->x, y, x) > range) continue;
397 g_ptr = ¤t_floor_ptr->grid_array[y][x];
399 /* Memorize terrain of the grid */
400 g_ptr->info |= (CAVE_KNOWN);
402 /* Feature code (applying "mimic" field) */
403 feat = get_feat_mimic(g_ptr);
404 f_ptr = &f_info[feat];
406 /* All non-walls are "checked" */
407 if (!have_flag(f_ptr->flags, FF_WALL))
409 /* Memorize normal features */
410 if (have_flag(f_ptr->flags, FF_REMEMBER))
412 /* Memorize the object */
413 g_ptr->info |= (CAVE_MARK);
416 /* Memorize known walls */
417 for (i = 0; i < 8; i++)
419 g_ptr = ¤t_floor_ptr->grid_array[y + ddy_ddd[i]][x + ddx_ddd[i]];
421 /* Feature code (applying "mimic" field) */
422 feat = get_feat_mimic(g_ptr);
423 f_ptr = &f_info[feat];
425 /* Memorize walls (etc) */
426 if (have_flag(f_ptr->flags, FF_REMEMBER))
428 /* Memorize the walls */
429 g_ptr->info |= (CAVE_MARK);
436 p_ptr->redraw |= (PR_MAP);
437 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);