9 #include "objectkind.h"
10 #include "object-flavor.h"
11 #include "object-hook.h"
13 #include "cmd-basic.h"
16 #include "floor-events.h"
17 #include "floor-save.h"
18 #include "player-damage.h"
19 #include "player-effects.h"
20 #include "player-move.h"
22 #include "view-mainwindow.h"
24 #include "monster-status.h"
27 #include "spells-floor.h"
30 * Light up the dungeon using "clairvoyance"
32 * This function "illuminates" every grid in the dungeon, memorizes all
33 * "objects", memorizes all grids as with magic mapping, and, under the
34 * standard option settings (view_perma_grids but not view_torch_grids)
35 * memorizes all floor grids too.
37 * Note that if "view_perma_grids" is not set, we do not memorize floor
38 * grids, since this would defeat the purpose of "view_perma_grids", not
39 * that anyone seems to play without this option.
41 * Note that if "view_torch_grids" is set, we do not memorize floor grids,
42 * since this would prevent the use of "view_torch_grids" as a method to
43 * keep track of what grids have been observed directly.
45 void wiz_lite(player_type *caster_ptr, bool ninja)
47 /* Memorize objects */
48 for (OBJECT_IDX i = 1; i < caster_ptr->current_floor_ptr->o_max; i++)
50 object_type *o_ptr = &caster_ptr->current_floor_ptr->o_list[i];
51 if (!OBJECT_IS_VALID(o_ptr)) continue;
52 if (OBJECT_IS_HELD_MONSTER(o_ptr)) continue;
53 o_ptr->marked |= OM_FOUND;
56 /* Scan all normal grids */
57 for (POSITION y = 1; y < caster_ptr->current_floor_ptr->height - 1; y++)
59 /* Scan all normal grids */
60 for (POSITION x = 1; x < caster_ptr->current_floor_ptr->width - 1; x++)
62 grid_type *g_ptr = &caster_ptr->current_floor_ptr->grid_array[y][x];
64 /* Memorize terrain of the grid */
65 g_ptr->info |= (CAVE_KNOWN);
67 /* Feature code (applying "mimic" field) */
68 FEAT_IDX feat = get_feat_mimic(g_ptr);
70 f_ptr = &f_info[feat];
72 /* Process all non-walls */
73 if (have_flag(f_ptr->flags, FF_WALL)) continue;
75 /* Scan all neighbors */
76 for (OBJECT_IDX i = 0; i < 9; i++)
78 POSITION yy = y + ddy_ddd[i];
79 POSITION xx = x + ddx_ddd[i];
80 g_ptr = &caster_ptr->current_floor_ptr->grid_array[yy][xx];
82 /* Feature code (applying "mimic" field) */
83 f_ptr = &f_info[get_feat_mimic(g_ptr)];
85 /* Perma-lite the grid */
86 if (!(d_info[caster_ptr->dungeon_idx].flags1 & DF1_DARKNESS) && !ninja)
88 g_ptr->info |= (CAVE_GLOW);
91 /* Memorize normal features */
92 if (have_flag(f_ptr->flags, FF_REMEMBER))
94 /* Memorize the grid */
95 g_ptr->info |= (CAVE_MARK);
98 /* Perma-lit grids (newly and previously) */
99 else if (g_ptr->info & CAVE_GLOW)
101 /* Normally, memorize floors (see above) */
102 if (view_perma_grids && !view_torch_grids)
104 /* Memorize the grid */
105 g_ptr->info |= (CAVE_MARK);
112 caster_ptr->update |= (PU_MONSTERS);
113 caster_ptr->redraw |= (PR_MAP);
114 caster_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
116 if (caster_ptr->special_defense & NINJA_S_STEALTH)
118 if (caster_ptr->current_floor_ptr->grid_array[caster_ptr->y][caster_ptr->x].info & CAVE_GLOW) set_superstealth(caster_ptr, FALSE);
124 * Forget the dungeon map (ala "Thinking of Maud...").
126 void wiz_dark(player_type *caster_ptr)
128 /* Forget every grid */
129 for (POSITION y = 1; y < caster_ptr->current_floor_ptr->height - 1; y++)
131 for (POSITION x = 1; x < caster_ptr->current_floor_ptr->width - 1; x++)
133 grid_type *g_ptr = &caster_ptr->current_floor_ptr->grid_array[y][x];
135 /* Process the grid */
136 g_ptr->info &= ~(CAVE_MARK | CAVE_IN_DETECT | CAVE_KNOWN);
137 g_ptr->info |= (CAVE_UNSAFE);
141 /* Forget every grid on horizontal edge */
142 for (POSITION x = 0; x < caster_ptr->current_floor_ptr->width; x++)
144 caster_ptr->current_floor_ptr->grid_array[0][x].info &= ~(CAVE_MARK);
145 caster_ptr->current_floor_ptr->grid_array[caster_ptr->current_floor_ptr->height - 1][x].info &= ~(CAVE_MARK);
148 /* Forget every grid on vertical edge */
149 for (POSITION y = 1; y < (caster_ptr->current_floor_ptr->height - 1); y++)
151 caster_ptr->current_floor_ptr->grid_array[y][0].info &= ~(CAVE_MARK);
152 caster_ptr->current_floor_ptr->grid_array[y][caster_ptr->current_floor_ptr->width - 1].info &= ~(CAVE_MARK);
155 /* Forget all objects */
156 for (OBJECT_IDX i = 1; i < caster_ptr->current_floor_ptr->o_max; i++)
158 object_type *o_ptr = &caster_ptr->current_floor_ptr->o_list[i];
160 if (!OBJECT_IS_VALID(o_ptr)) continue;
161 if (OBJECT_IS_HELD_MONSTER(o_ptr)) continue;
163 /* Forget the object */
164 o_ptr->marked &= OM_TOUCHED;
167 /* Forget travel route when we have forgotten map */
168 forget_travel_flow(caster_ptr->current_floor_ptr);
170 caster_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
171 caster_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
172 caster_ptr->update |= (PU_MONSTERS);
173 caster_ptr->redraw |= (PR_MAP);
174 caster_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(player_type *caster_ptr)
185 if (!cave_clean_bold(caster_ptr->current_floor_ptr, caster_ptr->y, caster_ptr->x))
187 msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
192 caster_ptr->current_floor_ptr->grid_array[caster_ptr->y][caster_ptr->x].info |= CAVE_OBJECT;
193 caster_ptr->current_floor_ptr->grid_array[caster_ptr->y][caster_ptr->x].mimic = feat_glyph;
195 note_spot(caster_ptr, caster_ptr->y, caster_ptr->x);
196 lite_spot(caster_ptr, caster_ptr->y, caster_ptr->x);
203 * @brief 爆発のルーン設置処理 /
204 * Leave an "explosive rune" which prevents monster movement
205 * @param caster_ptr プレーヤーへの参照ポインタ
208 * @return 実際に設置が行われた場合TRUEを返す
210 bool explosive_rune(player_type *caster_ptr, POSITION y, POSITION x)
212 floor_type *floor_ptr = caster_ptr->current_floor_ptr;
213 if (!cave_clean_bold(floor_ptr, y, x))
215 msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
220 floor_ptr->grid_array[y][x].info |= CAVE_OBJECT;
221 floor_ptr->grid_array[y][x].mimic = feat_explosive_rune;
223 note_spot(caster_ptr, y, x);
224 lite_spot(caster_ptr, y, x);
232 * @return 実際に設置が行われた場合TRUEを返す
234 bool place_mirror(player_type *caster_ptr)
236 if (!cave_clean_bold(caster_ptr->current_floor_ptr, caster_ptr->y, caster_ptr->x))
238 msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
242 /* Create a mirror */
243 caster_ptr->current_floor_ptr->grid_array[caster_ptr->y][caster_ptr->x].info |= CAVE_OBJECT;
244 caster_ptr->current_floor_ptr->grid_array[caster_ptr->y][caster_ptr->x].mimic = feat_mirror;
246 /* Turn on the light */
247 caster_ptr->current_floor_ptr->grid_array[caster_ptr->y][caster_ptr->x].info |= CAVE_GLOW;
249 note_spot(caster_ptr, caster_ptr->y, caster_ptr->x);
250 lite_spot(caster_ptr, caster_ptr->y, caster_ptr->x);
251 update_local_illumination(caster_ptr, caster_ptr->y, caster_ptr->x);
258 * @brief プレイヤーの手による能動的な階段生成処理 /
259 * Create stairs at or move previously created stairs into the player location.
262 void stair_creation(player_type *caster_ptr)
264 /* Forbid up staircases on Ironman mode */
266 if (ironman_downward) up = FALSE;
268 /* Forbid down staircases on quest level */
270 floor_type *floor_ptr = caster_ptr->current_floor_ptr;
271 if (quest_number(caster_ptr, floor_ptr->dun_level) || (floor_ptr->dun_level >= d_info[caster_ptr->dungeon_idx].maxdepth)) down = FALSE;
273 /* No effect out of standard dungeon floor */
274 if (!floor_ptr->dun_level || (!up && !down) ||
275 (floor_ptr->inside_quest && is_fixed_quest_idx(floor_ptr->inside_quest)) ||
276 floor_ptr->inside_arena || caster_ptr->phase_out)
279 msg_print(_("効果がありません!", "There is no effect!"));
283 /* Artifacts resists */
284 if (!cave_valid_bold(floor_ptr, caster_ptr->y, caster_ptr->x))
286 msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
290 /* Destroy all objects in the grid */
291 delete_object(caster_ptr, caster_ptr->y, caster_ptr->x);
293 /* Extract current floor data */
294 saved_floor_type *sf_ptr;
295 sf_ptr = get_sf_ptr(caster_ptr->floor_id);
298 /* No floor id? -- Create now! */
299 caster_ptr->floor_id = get_new_floor_id(caster_ptr);
300 sf_ptr = get_sf_ptr(caster_ptr->floor_id);
303 /* Choose randomly */
306 if (randint0(100) < 50) up = FALSE;
310 /* Destination is already fixed */
311 FLOOR_IDX dest_floor_id = 0;
314 if (sf_ptr->upper_floor_id) dest_floor_id = sf_ptr->upper_floor_id;
318 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 < floor_ptr->height; y++)
328 for (x = 0; x < floor_ptr->width; x++)
330 grid_type *g_ptr = &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(caster_ptr, y, x, feat_ground_type[randint0(100)]);
343 /* No old destination -- Get new one now */
346 dest_floor_id = get_new_floor_id(caster_ptr);
350 sf_ptr->upper_floor_id = dest_floor_id;
352 sf_ptr->lower_floor_id = dest_floor_id;
355 /* Extract destination floor data */
356 saved_floor_type *dest_sf_ptr;
357 dest_sf_ptr = get_sf_ptr(dest_floor_id);
359 /* Create a staircase */
362 cave_set_feat(caster_ptr, caster_ptr->y, caster_ptr->x,
363 (dest_sf_ptr->last_visit && (dest_sf_ptr->dun_level <= floor_ptr->dun_level - 2)) ?
364 feat_state(feat_up_stair, FF_SHAFT) : feat_up_stair);
368 cave_set_feat(caster_ptr, caster_ptr->y, caster_ptr->x,
369 (dest_sf_ptr->last_visit && (dest_sf_ptr->dun_level >= floor_ptr->dun_level + 2)) ?
370 feat_state(feat_down_stair, FF_SHAFT) : feat_down_stair);
373 /* Connect this stairs to the destination */
374 floor_ptr->grid_array[caster_ptr->y][caster_ptr->x].special = dest_floor_id;
378 * Hack -- map the current panel (plus some) ala "magic mapping"
380 void map_area(player_type *caster_ptr, POSITION range)
382 if (d_info[caster_ptr->dungeon_idx].flags1 & DF1_DARKNESS) range /= 3;
385 for (POSITION y = 1; y < caster_ptr->current_floor_ptr->height - 1; y++)
387 for (POSITION x = 1; x < caster_ptr->current_floor_ptr->width - 1; x++)
389 if (distance(caster_ptr->y, caster_ptr->x, y, x) > range) continue;
392 g_ptr = &caster_ptr->current_floor_ptr->grid_array[y][x];
394 /* Memorize terrain of the grid */
395 g_ptr->info |= (CAVE_KNOWN);
397 /* Feature code (applying "mimic" field) */
398 FEAT_IDX feat = get_feat_mimic(g_ptr);
400 f_ptr = &f_info[feat];
402 /* All non-walls are "checked" */
403 if (have_flag(f_ptr->flags, FF_WALL)) continue;
405 /* Memorize normal features */
406 if (have_flag(f_ptr->flags, FF_REMEMBER))
408 /* Memorize the object */
409 g_ptr->info |= (CAVE_MARK);
412 /* Memorize known walls */
413 for (int i = 0; i < 8; i++)
415 g_ptr = &caster_ptr->current_floor_ptr->grid_array[y + ddy_ddd[i]][x + ddx_ddd[i]];
417 /* Feature code (applying "mimic" field) */
418 feat = get_feat_mimic(g_ptr);
419 f_ptr = &f_info[feat];
421 /* Memorize walls (etc) */
422 if (have_flag(f_ptr->flags, FF_REMEMBER))
424 /* Memorize the walls */
425 g_ptr->info |= (CAVE_MARK);
431 caster_ptr->redraw |= (PR_MAP);
432 caster_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
438 * @brief *破壊*処理を行う / The spell of destruction
442 * @param in_generate ダンジョンフロア生成中の処理ならばTRUE
443 * @return 効力があった場合TRUEを返す
446 * This spell "deletes" monsters (instead of "killing" them).
448 * Later we may use one function for both "destruction" and
449 * "earthquake" by using the "full" to select "destruction".
452 bool destroy_area(player_type *caster_ptr, POSITION y1, POSITION x1, POSITION r, bool in_generate)
454 /* Prevent destruction of quest levels and town */
455 floor_type *floor_ptr = caster_ptr->current_floor_ptr;
456 if ((floor_ptr->inside_quest && is_fixed_quest_idx(floor_ptr->inside_quest)) || !floor_ptr->dun_level)
461 /* Lose monster light */
462 if (!in_generate) clear_mon_lite(floor_ptr);
464 /* Big area of affect */
466 for (POSITION y = (y1 - r); y <= (y1 + r); y++)
468 for (POSITION x = (x1 - r); x <= (x1 + r); x++)
470 if (!in_bounds(floor_ptr, y, x)) continue;
472 /* Extract the distance */
473 int k = distance(y1, x1, y, x);
475 /* Stay in the circle of death */
478 g_ptr = &floor_ptr->grid_array[y][x];
480 /* Lose room and vault */
481 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
483 /* Lose light and knowledge */
484 g_ptr->info &= ~(CAVE_MARK | CAVE_GLOW | CAVE_KNOWN);
486 if (!in_generate) /* Normal */
489 g_ptr->info &= ~(CAVE_UNSAFE);
491 /* Hack -- Notice player affect */
492 if (player_bold(caster_ptr, y, x))
494 /* Hurt the player later */
497 /* Do not hurt this grid */
502 /* Hack -- Skip the epicenter */
503 if ((y == y1) && (x == x1)) continue;
507 monster_type *m_ptr = &floor_ptr->m_list[g_ptr->m_idx];
508 monster_race *r_ptr = &r_info[m_ptr->r_idx];
510 if (in_generate) /* In generation */
512 /* Delete the monster (if any) */
513 delete_monster(caster_ptr, y, x);
515 else if (r_ptr->flags1 & RF1_QUESTOR)
517 /* Heal the monster */
518 m_ptr->hp = m_ptr->maxhp;
520 /* Try to teleport away quest monsters */
521 if (!teleport_away(caster_ptr, g_ptr->m_idx, (r * 2) + 1, TELEPORT_DEC_VALOUR)) continue;
525 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
527 GAME_TEXT m_name[MAX_NLEN];
529 monster_desc(caster_ptr, m_name, m_ptr, MD_INDEF_VISIBLE);
530 exe_write_diary(caster_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_DESTROY, m_name);
533 /* Delete the monster (if any) */
534 delete_monster(caster_ptr, y, x);
538 /* During generation, destroyed artifacts are "preserved" */
539 if (preserve_mode || in_generate)
541 OBJECT_IDX this_o_idx, next_o_idx = 0;
543 /* Scan all objects in the grid */
544 for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
547 o_ptr = &floor_ptr->o_list[this_o_idx];
548 next_o_idx = o_ptr->next_o_idx;
550 /* Hack -- Preserve unknown artifacts */
551 if (object_is_fixed_artifact(o_ptr) && (!object_is_known(o_ptr) || in_generate))
553 /* Mega-Hack -- Preserve the artifact */
554 a_info[o_ptr->name1].cur_num = 0;
556 if (in_generate && cheat_peek)
558 GAME_TEXT o_name[MAX_NLEN];
559 object_desc(o_name, o_ptr, (OD_NAME_ONLY | OD_STORE));
560 msg_format(_("伝説のアイテム (%s) は生成中に*破壊*された。", "Artifact (%s) was *destroyed* during generation."), o_name);
563 else if (in_generate && cheat_peek && o_ptr->art_name)
565 msg_print(_("ランダム・アーティファクトの1つは生成中に*破壊*された。",
566 "One of the random artifacts was *destroyed* during generation."));
571 delete_object(caster_ptr, y, x);
573 /* Destroy "non-permanent" grids */
574 if (cave_perma_grid(g_ptr)) continue;
576 /* Wall (or floor) type */
577 int t = randint0(200);
579 if (!in_generate) /* Normal */
583 /* Create granite wall */
584 cave_set_feat(caster_ptr, y, x, feat_granite);
588 /* Create quartz vein */
589 cave_set_feat(caster_ptr, y, x, feat_quartz_vein);
593 /* Create magma vein */
594 cave_set_feat(caster_ptr, y, x, feat_magma_vein);
599 cave_set_feat(caster_ptr, y, x, feat_ground_type[randint0(100)]);
607 /* Create granite wall */
608 place_grid(caster_ptr, g_ptr, extra);
612 /* Create quartz vein */
613 g_ptr->feat = feat_quartz_vein;
617 /* Create magma vein */
618 g_ptr->feat = feat_magma_vein;
623 place_grid(caster_ptr, g_ptr, floor);
626 /* Clear garbage of hidden trap or door */
631 if (in_generate) return TRUE;
633 /* Process "re-glowing" */
634 for (POSITION y = (y1 - r); y <= (y1 + r); y++)
636 for (POSITION x = (x1 - r); x <= (x1 + r); x++)
638 if (!in_bounds(floor_ptr, y, x)) continue;
640 /* Extract the distance */
641 int k = distance(y1, x1, y, x);
643 /* Stay in the circle of death */
646 g_ptr = &floor_ptr->grid_array[y][x];
648 if (is_mirror_grid(g_ptr))
650 g_ptr->info |= CAVE_GLOW;
654 if ((d_info[floor_ptr->dungeon_idx].flags1 & DF1_DARKNESS)) continue;
660 for (i = 0; i < 9; i++)
664 if (!in_bounds2(floor_ptr, yy, xx)) continue;
665 cc_ptr = &floor_ptr->grid_array[yy][xx];
666 if (have_flag(f_info[get_feat_mimic(cc_ptr)].flags, FF_GLOW))
668 g_ptr->info |= CAVE_GLOW;
675 /* Hack -- Affect player */
678 msg_print(_("燃えるような閃光が発生した!", "There is a searing blast of light!"));
680 /* Blind the player */
681 if (!caster_ptr->resist_blind && !caster_ptr->resist_lite)
684 (void)set_blind(caster_ptr, caster_ptr->blind + 10 + randint1(10));
688 forget_flow(floor_ptr);
690 /* Mega-Hack -- Forget the view and lite */
691 caster_ptr->update |= (PU_UN_VIEW | PU_UN_LITE | PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE | PU_MONSTERS);
692 caster_ptr->redraw |= (PR_MAP);
693 caster_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
695 if (caster_ptr->special_defense & NINJA_S_STEALTH)
697 if (floor_ptr->grid_array[caster_ptr->y][caster_ptr->x].info & CAVE_GLOW) set_superstealth(caster_ptr, FALSE);
705 * @brief 地震処理(サブルーチン) /
706 * Induce an "earthquake" of the given radius at the given location.
707 * @param caster_ptrプレーヤーへの参照ポインタ
711 * @param m_idx 地震を起こしたモンスターID(0ならばプレイヤー)
712 * @return 効力があった場合TRUEを返す
716 * This will turn some walls into floors and some floors into walls.
718 * The player will take damage and "jump" into a safe grid if possible,
719 * otherwise, he will "tunnel" through the rubble instantaneously.
721 * Monsters will take damage, and "jump" into a safe grid if possible,
722 * otherwise they will be "buried" in the rubble, disappearing from
723 * the level in the same way that they do when genocided.
725 * Note that thus the player and monsters (except eaters of walls and
726 * passers through walls) will never occupy the same grid as a wall.
727 * Note that as of now (2.7.8) no monster may occupy a "wall" grid, even
728 * for a single turn, unless that monster can pass_walls or kill_walls.
729 * This has allowed massive simplification of the "monster" code.
732 bool earthquake(player_type *caster_ptr, POSITION cy, POSITION cx, POSITION r, MONSTER_IDX m_idx)
734 /* Prevent destruction of quest levels and town */
735 floor_type *floor_ptr = caster_ptr->current_floor_ptr;
736 if ((floor_ptr->inside_quest && is_fixed_quest_idx(floor_ptr->inside_quest)) || !floor_ptr->dun_level)
741 /* Paranoia -- Enforce maximum range */
744 /* Clear the "maximal blast" area */
747 for (y = 0; y < 32; y++)
749 for (x = 0; x < 32; x++)
755 /* Check around the epicenter */
756 POSITION yy, xx, dy, dx;
759 for (dy = -r; dy <= r; dy++)
761 for (dx = -r; dx <= r; dx++)
766 if (!in_bounds(floor_ptr, yy, xx)) continue;
768 /* Skip distant grids */
769 if (distance(cy, cx, yy, xx) > r) continue;
771 g_ptr = &floor_ptr->grid_array[yy][xx];
773 /* Lose room and vault / Lose light and knowledge */
774 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY | CAVE_UNSAFE);
775 g_ptr->info &= ~(CAVE_GLOW | CAVE_MARK | CAVE_KNOWN);
777 /* Skip the epicenter */
778 if (!dx && !dy) continue;
780 /* Skip most grids */
781 if (randint0(100) < 85) continue;
783 /* Damage this grid */
784 map[16 + yy - cy][16 + xx - cx] = TRUE;
786 /* Hack -- Take note of player damage */
787 if (player_bold(caster_ptr, yy, xx)) hurt = TRUE;
791 /* First, affect the player (if necessary) */
793 POSITION sy = 0, sx = 0;
794 if (hurt && !caster_ptr->pass_wall && !caster_ptr->kill_wall)
796 /* Check around the player */
797 for (DIRECTION i = 0; i < 8; i++)
799 y = caster_ptr->y + ddy_ddd[i];
800 x = caster_ptr->x + ddx_ddd[i];
802 /* Skip non-empty grids */
803 if (!cave_empty_bold(floor_ptr, y, x)) continue;
805 /* Important -- Skip "quake" grids */
806 if (map[16 + y - cy][16 + x - cx]) continue;
808 if (floor_ptr->grid_array[y][x].m_idx) continue;
810 /* Count "safe" grids */
813 /* Randomize choice */
814 if (randint0(sn) > 0) continue;
816 /* Save the safe location */
825 msg_print(_("ダンジョンの壁が崩れた!", "The dungeon's ceiling collapses!"));
830 msg_print(_("ダンジョンの床が不自然にねじ曲がった!", "The dungeon's floor twists in an unnatural way!"));
835 msg_print(_("ダンジョンが揺れた!崩れた岩が頭に降ってきた!", "The dungeon quakes! You are pummeled with debris!"));
840 /* Hurt the player a lot */
843 /* Message and damage */
844 msg_print(_("あなたはひどい怪我を負った!", "You are severely crushed!"));
848 /* Destroy the grid, and push the player to safety */
851 /* Calculate results */
856 msg_print(_("降り注ぐ岩をうまく避けた!", "You nimbly dodge the blast!"));
862 msg_print(_("岩石があなたに直撃した!", "You are bashed by rubble!"));
863 damage = damroll(10, 4);
864 (void)set_stun(caster_ptr, caster_ptr->stun + randint1(50));
869 msg_print(_("あなたは床と壁との間に挟まれてしまった!", "You are crushed between the floor and ceiling!"));
870 damage = damroll(10, 4);
871 (void)set_stun(caster_ptr, caster_ptr->stun + randint1(50));
876 /* Move the player to the safe location */
877 (void)move_player_effect(caster_ptr, sy, sx, MPE_DONT_PICKUP);
880 /* Important -- no wall on player */
881 map[16 + caster_ptr->y - cy][16 + caster_ptr->x - cx] = FALSE;
889 GAME_TEXT m_name[MAX_NLEN];
890 monster_type *m_ptr = &floor_ptr->m_list[m_idx];
891 monster_desc(caster_ptr, m_name, m_ptr, MD_WRONGDOER_NAME);
892 killer = format(_("%sの起こした地震", "an earthquake caused by %s"), m_name);
896 killer = _("地震", "an earthquake");
899 take_hit(caster_ptr, DAMAGE_ATTACK, damage, killer, -1);
903 /* Examine the quaked region */
904 for (dy = -r; dy <= r; dy++)
906 for (dx = -r; dx <= r; dx++)
911 /* Skip unaffected grids */
912 if (!map[16 + yy - cy][16 + xx - cx]) continue;
915 g_ptr = &floor_ptr->grid_array[yy][xx];
917 if (g_ptr->m_idx == caster_ptr->riding) continue;
919 /* Process monsters */
920 if (!g_ptr->m_idx) continue;
922 monster_type *m_ptr = &floor_ptr->m_list[g_ptr->m_idx];
923 monster_race *r_ptr = &r_info[m_ptr->r_idx];
926 if (r_ptr->flags1 & RF1_QUESTOR)
928 /* No wall on quest monsters */
929 map[16 + yy - cy][16 + xx - cx] = FALSE;
934 /* Most monsters cannot co-exist with rock */
935 if ((r_ptr->flags2 & RF2_KILL_WALL) || (r_ptr->flags2 & RF2_PASS_WALL)) continue;
937 GAME_TEXT m_name[MAX_NLEN];
939 /* Assume not safe */
942 /* Monster can move to escape the wall */
943 if (!(r_ptr->flags1 & RF1_NEVER_MOVE))
945 /* Look for safety */
946 for (DIRECTION i = 0; i < 8; i++)
951 /* Skip non-empty grids */
952 if (!cave_empty_bold(floor_ptr, y, x)) continue;
954 /* Hack -- no safety on glyph of warding */
955 if (is_glyph_grid(&floor_ptr->grid_array[y][x])) continue;
956 if (is_explosive_rune_grid(&floor_ptr->grid_array[y][x])) continue;
958 /* ... nor on the Pattern */
959 if (pattern_tile(y, x)) continue;
961 /* Important -- Skip "quake" grids */
962 if (map[16 + y - cy][16 + x - cx]) continue;
964 if (floor_ptr->grid_array[y][x].m_idx) continue;
965 if (player_bold(caster_ptr, y, x)) continue;
967 /* Count "safe" grids */
970 /* Randomize choice */
971 if (randint0(sn) > 0) continue;
973 /* Save the safe grid */
978 monster_desc(caster_ptr, m_name, m_ptr, 0);
981 if (!ignore_unview || is_seen(m_ptr)) msg_format(_("%^sは苦痛で泣きわめいた!", "%^s wails out in pain!"), m_name);
983 /* Take damage from the quake */
984 damage = (sn ? damroll(4, 8) : (m_ptr->hp + 1));
986 /* Monster is certainly awake */
987 (void)set_monster_csleep(caster_ptr, g_ptr->m_idx, 0);
989 /* Apply damage directly */
992 /* Delete (not kill) "dead" monsters */
995 if (!ignore_unview || is_seen(m_ptr))
996 msg_format(_("%^sは岩石に埋もれてしまった!", "%^s is embedded in the rock!"), m_name);
1000 if (record_named_pet && is_pet(&floor_ptr->m_list[g_ptr->m_idx]) && floor_ptr->m_list[g_ptr->m_idx].nickname)
1002 char m2_name[MAX_NLEN];
1004 monster_desc(caster_ptr, m2_name, m_ptr, MD_INDEF_VISIBLE);
1005 exe_write_diary(caster_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_EARTHQUAKE, m2_name);
1009 delete_monster(caster_ptr, yy, xx);
1014 /* Hack -- Escape from the rock */
1015 if (sn == 0) continue;
1017 IDX m_idx_aux = floor_ptr->grid_array[yy][xx].m_idx;
1019 /* Update the old location */
1020 floor_ptr->grid_array[yy][xx].m_idx = 0;
1022 /* Update the new location */
1023 floor_ptr->grid_array[sy][sx].m_idx = m_idx_aux;
1025 /* Move the monster */
1029 update_monster(caster_ptr, m_idx, TRUE);
1030 lite_spot(caster_ptr, yy, xx);
1031 lite_spot(caster_ptr, sy, sx);
1035 /* Lose monster light */
1036 clear_mon_lite(floor_ptr);
1038 /* Examine the quaked region */
1039 for (dy = -r; dy <= r; dy++)
1041 for (dx = -r; dx <= r; dx++)
1046 /* Skip unaffected grids */
1047 if (!map[16 + yy - cy][16 + xx - cx]) continue;
1050 g_ptr = &floor_ptr->grid_array[yy][xx];
1052 /* Destroy location (if valid) */
1053 if (!cave_valid_bold(floor_ptr, yy, xx)) continue;
1055 delete_object(caster_ptr, yy, xx);
1057 /* Wall (or floor) type */
1058 int t = cave_have_flag_bold(floor_ptr, yy, xx, FF_PROJECT) ? randint0(100) : 200;
1060 /* Create granite wall */
1063 cave_set_feat(caster_ptr, yy, xx, feat_granite);
1067 /* Create quartz vein */
1070 cave_set_feat(caster_ptr, yy, xx, feat_quartz_vein);
1074 /* Create magma vein */
1077 cave_set_feat(caster_ptr, yy, xx, feat_magma_vein);
1082 cave_set_feat(caster_ptr, yy, xx, feat_ground_type[randint0(100)]);
1086 /* Process "re-glowing" */
1087 for (dy = -r; dy <= r; dy++)
1089 for (dx = -r; dx <= r; dx++)
1094 if (!in_bounds(floor_ptr, yy, xx)) continue;
1096 /* Skip distant grids */
1097 if (distance(cy, cx, yy, xx) > r) continue;
1099 g_ptr = &floor_ptr->grid_array[yy][xx];
1101 if (is_mirror_grid(g_ptr))
1103 g_ptr->info |= CAVE_GLOW;
1107 if ((d_info[caster_ptr->dungeon_idx].flags1 & DF1_DARKNESS)) continue;
1113 for (ii = 0; ii < 9; ii++)
1115 yyy = yy + ddy_ddd[ii];
1116 xxx = xx + ddx_ddd[ii];
1117 if (!in_bounds2(floor_ptr, yyy, xxx)) continue;
1118 cc_ptr = &floor_ptr->grid_array[yyy][xxx];
1119 if (have_flag(f_info[get_feat_mimic(cc_ptr)].flags, FF_GLOW))
1121 g_ptr->info |= CAVE_GLOW;
1128 /* Mega-Hack -- Forget the view and lite */
1129 caster_ptr->update |= (PU_UN_VIEW | PU_UN_LITE | PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE | PU_MONSTERS);
1130 caster_ptr->redraw |= (PR_HEALTH | PR_UHEALTH | PR_MAP);
1131 caster_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1133 if (caster_ptr->special_defense & NINJA_S_STEALTH)
1135 if (floor_ptr->grid_array[caster_ptr->y][caster_ptr->x].info & CAVE_GLOW) set_superstealth(caster_ptr, FALSE);