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)
52 /* Memorize objects */
53 for (i = 1; i < caster_ptr->current_floor_ptr->o_max; i++)
55 object_type *o_ptr = &caster_ptr->current_floor_ptr->o_list[i];
57 if (!OBJECT_IS_VALID(o_ptr)) continue;
58 if (OBJECT_IS_HELD_MONSTER(o_ptr)) continue;
61 o_ptr->marked |= OM_FOUND;
64 /* Scan all normal grids */
65 for (y = 1; y < caster_ptr->current_floor_ptr->height - 1; y++)
67 /* Scan all normal grids */
68 for (x = 1; x < caster_ptr->current_floor_ptr->width - 1; x++)
70 grid_type *g_ptr = &caster_ptr->current_floor_ptr->grid_array[y][x];
72 /* Memorize terrain of the grid */
73 g_ptr->info |= (CAVE_KNOWN);
75 /* Feature code (applying "mimic" field) */
76 feat = get_feat_mimic(g_ptr);
77 f_ptr = &f_info[feat];
79 /* Process all non-walls */
80 if (!have_flag(f_ptr->flags, FF_WALL))
82 /* Scan all neighbors */
83 for (i = 0; i < 9; i++)
85 POSITION yy = y + ddy_ddd[i];
86 POSITION xx = x + ddx_ddd[i];
87 g_ptr = &caster_ptr->current_floor_ptr->grid_array[yy][xx];
89 /* Feature code (applying "mimic" field) */
90 f_ptr = &f_info[get_feat_mimic(g_ptr)];
92 /* Perma-lite the grid */
93 if (!(d_info[caster_ptr->dungeon_idx].flags1 & DF1_DARKNESS) && !ninja)
95 g_ptr->info |= (CAVE_GLOW);
98 /* Memorize normal features */
99 if (have_flag(f_ptr->flags, FF_REMEMBER))
101 /* Memorize the grid */
102 g_ptr->info |= (CAVE_MARK);
105 /* Perma-lit grids (newly and previously) */
106 else if (g_ptr->info & CAVE_GLOW)
108 /* Normally, memorize floors (see above) */
109 if (view_perma_grids && !view_torch_grids)
111 /* Memorize the grid */
112 g_ptr->info |= (CAVE_MARK);
120 caster_ptr->update |= (PU_MONSTERS);
121 caster_ptr->redraw |= (PR_MAP);
122 caster_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
124 if (caster_ptr->special_defense & NINJA_S_STEALTH)
126 if (caster_ptr->current_floor_ptr->grid_array[caster_ptr->y][caster_ptr->x].info & CAVE_GLOW) set_superstealth(caster_ptr, FALSE);
132 * Forget the dungeon map (ala "Thinking of Maud...").
134 void wiz_dark(player_type *caster_ptr)
139 /* Forget every grid */
140 for (y = 1; y < caster_ptr->current_floor_ptr->height - 1; y++)
142 for (x = 1; x < caster_ptr->current_floor_ptr->width - 1; x++)
144 grid_type *g_ptr = &caster_ptr->current_floor_ptr->grid_array[y][x];
146 /* Process the grid */
147 g_ptr->info &= ~(CAVE_MARK | CAVE_IN_DETECT | CAVE_KNOWN);
148 g_ptr->info |= (CAVE_UNSAFE);
152 /* Forget every grid on horizontal edge */
153 for (x = 0; x < caster_ptr->current_floor_ptr->width; x++)
155 caster_ptr->current_floor_ptr->grid_array[0][x].info &= ~(CAVE_MARK);
156 caster_ptr->current_floor_ptr->grid_array[caster_ptr->current_floor_ptr->height - 1][x].info &= ~(CAVE_MARK);
159 /* Forget every grid on vertical edge */
160 for (y = 1; y < (caster_ptr->current_floor_ptr->height - 1); y++)
162 caster_ptr->current_floor_ptr->grid_array[y][0].info &= ~(CAVE_MARK);
163 caster_ptr->current_floor_ptr->grid_array[y][caster_ptr->current_floor_ptr->width - 1].info &= ~(CAVE_MARK);
166 /* Forget all objects */
167 for (i = 1; i < caster_ptr->current_floor_ptr->o_max; i++)
169 object_type *o_ptr = &caster_ptr->current_floor_ptr->o_list[i];
171 if (!OBJECT_IS_VALID(o_ptr)) continue;
172 if (OBJECT_IS_HELD_MONSTER(o_ptr)) continue;
174 /* Forget the object */
175 o_ptr->marked &= OM_TOUCHED;
178 /* Forget travel route when we have forgotten map */
179 forget_travel_flow(caster_ptr->current_floor_ptr);
181 caster_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
182 caster_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
183 caster_ptr->update |= (PU_MONSTERS);
184 caster_ptr->redraw |= (PR_MAP);
185 caster_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
189 * @brief 守りのルーン設置処理 /
190 * Leave a "glyph of warding" which prevents monster movement
191 * @return 実際に設置が行われた場合TRUEを返す
193 bool warding_glyph(player_type *caster_ptr)
195 if (!cave_clean_bold(caster_ptr->current_floor_ptr, caster_ptr->y, caster_ptr->x))
197 msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
202 caster_ptr->current_floor_ptr->grid_array[caster_ptr->y][caster_ptr->x].info |= CAVE_OBJECT;
203 caster_ptr->current_floor_ptr->grid_array[caster_ptr->y][caster_ptr->x].mimic = feat_glyph;
205 note_spot(caster_ptr->y, caster_ptr->x);
206 lite_spot(caster_ptr->y, caster_ptr->x);
213 * @brief 爆発のルーン設置処理 /
214 * Leave an "explosive rune" which prevents monster movement
215 * @return 実際に設置が行われた場合TRUEを返す
217 bool explosive_rune(floor_type *floor_ptr, POSITION y, POSITION x)
219 if (!cave_clean_bold(floor_ptr, y, x))
221 msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
226 floor_ptr->grid_array[y][x].info |= CAVE_OBJECT;
227 floor_ptr->grid_array[y][x].mimic = feat_explosive_rune;
237 * @return 実際に設置が行われた場合TRUEを返す
239 bool place_mirror(player_type *caster_ptr)
241 if (!cave_clean_bold(caster_ptr->current_floor_ptr, caster_ptr->y, caster_ptr->x))
243 msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
247 /* Create a mirror */
248 caster_ptr->current_floor_ptr->grid_array[caster_ptr->y][caster_ptr->x].info |= CAVE_OBJECT;
249 caster_ptr->current_floor_ptr->grid_array[caster_ptr->y][caster_ptr->x].mimic = feat_mirror;
251 /* Turn on the light */
252 caster_ptr->current_floor_ptr->grid_array[caster_ptr->y][caster_ptr->x].info |= CAVE_GLOW;
254 note_spot(caster_ptr->y, caster_ptr->x);
255 lite_spot(caster_ptr->y, caster_ptr->x);
256 update_local_illumination(caster_ptr, caster_ptr->y, caster_ptr->x);
262 * @brief プレイヤーの手による能動的な階段生成処理 /
263 * Create stairs at or move previously created stairs into the player location.
266 void stair_creation(player_type *caster_ptr)
268 floor_type *floor_ptr = caster_ptr->current_floor_ptr;
269 saved_floor_type *sf_ptr;
270 saved_floor_type *dest_sf_ptr;
274 FLOOR_IDX dest_floor_id = 0;
277 /* Forbid up staircases on Ironman mode */
278 if (ironman_downward) up = FALSE;
280 /* Forbid down staircases on quest level */
281 if (quest_number(floor_ptr->dun_level) || (floor_ptr->dun_level >= d_info[caster_ptr->dungeon_idx].maxdepth)) down = FALSE;
283 /* No effect out of standard dungeon floor */
284 if (!floor_ptr->dun_level || (!up && !down) ||
285 (caster_ptr->current_floor_ptr->inside_quest && is_fixed_quest_idx(caster_ptr->current_floor_ptr->inside_quest)) ||
286 caster_ptr->current_floor_ptr->inside_arena || caster_ptr->phase_out)
289 msg_print(_("効果がありません!", "There is no effect!"));
293 /* Artifacts resists */
294 if (!cave_valid_bold(caster_ptr->current_floor_ptr, caster_ptr->y, caster_ptr->x))
296 msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
300 /* Destroy all objects in the grid */
301 delete_object(caster_ptr->y, caster_ptr->x);
303 /* Extract current floor data */
304 sf_ptr = get_sf_ptr(caster_ptr->floor_id);
307 /* No floor id? -- Create now! */
308 caster_ptr->floor_id = get_new_floor_id();
309 sf_ptr = get_sf_ptr(caster_ptr->floor_id);
312 /* Choose randomly */
315 if (randint0(100) < 50) up = FALSE;
319 /* Destination is already fixed */
322 if (sf_ptr->upper_floor_id) dest_floor_id = sf_ptr->upper_floor_id;
326 if (sf_ptr->lower_floor_id) dest_floor_id = sf_ptr->lower_floor_id;
330 /* Search old stairs leading to the destination */
335 for (y = 0; y < floor_ptr->height; y++)
337 for (x = 0; x < floor_ptr->width; x++)
339 grid_type *g_ptr = &floor_ptr->grid_array[y][x];
341 if (!g_ptr->special) continue;
342 if (feat_uses_special(g_ptr->feat)) continue;
343 if (g_ptr->special != dest_floor_id) continue;
345 /* Remove old stairs */
347 cave_set_feat(floor_ptr, y, x, feat_ground_type[randint0(100)]);
352 /* No old destination -- Get new one now */
355 dest_floor_id = get_new_floor_id();
359 sf_ptr->upper_floor_id = dest_floor_id;
361 sf_ptr->lower_floor_id = dest_floor_id;
364 /* Extract destination floor data */
365 dest_sf_ptr = get_sf_ptr(dest_floor_id);
368 /* Create a staircase */
371 cave_set_feat(caster_ptr->current_floor_ptr, caster_ptr->y, caster_ptr->x,
372 (dest_sf_ptr->last_visit && (dest_sf_ptr->dun_level <= floor_ptr->dun_level - 2)) ?
373 feat_state(feat_up_stair, FF_SHAFT) : feat_up_stair);
377 cave_set_feat(caster_ptr->current_floor_ptr, caster_ptr->y, caster_ptr->x,
378 (dest_sf_ptr->last_visit && (dest_sf_ptr->dun_level >= floor_ptr->dun_level + 2)) ?
379 feat_state(feat_down_stair, FF_SHAFT) : feat_down_stair);
383 /* Connect this stairs to the destination */
384 floor_ptr->grid_array[caster_ptr->y][caster_ptr->x].special = dest_floor_id;
388 * Hack -- map the current panel (plus some) ala "magic mapping"
390 void map_area(player_type *caster_ptr, POSITION range)
398 if (d_info[caster_ptr->dungeon_idx].flags1 & DF1_DARKNESS) range /= 3;
401 for (y = 1; y < caster_ptr->current_floor_ptr->height - 1; y++)
403 for (x = 1; x < caster_ptr->current_floor_ptr->width - 1; x++)
405 if (distance(caster_ptr->y, caster_ptr->x, y, x) > range) continue;
407 g_ptr = &caster_ptr->current_floor_ptr->grid_array[y][x];
409 /* Memorize terrain of the grid */
410 g_ptr->info |= (CAVE_KNOWN);
412 /* Feature code (applying "mimic" field) */
413 feat = get_feat_mimic(g_ptr);
414 f_ptr = &f_info[feat];
416 /* All non-walls are "checked" */
417 if (!have_flag(f_ptr->flags, FF_WALL))
419 /* Memorize normal features */
420 if (have_flag(f_ptr->flags, FF_REMEMBER))
422 /* Memorize the object */
423 g_ptr->info |= (CAVE_MARK);
426 /* Memorize known walls */
427 for (i = 0; i < 8; i++)
429 g_ptr = &caster_ptr->current_floor_ptr->grid_array[y + ddy_ddd[i]][x + ddx_ddd[i]];
431 /* Feature code (applying "mimic" field) */
432 feat = get_feat_mimic(g_ptr);
433 f_ptr = &f_info[feat];
435 /* Memorize walls (etc) */
436 if (have_flag(f_ptr->flags, FF_REMEMBER))
438 /* Memorize the walls */
439 g_ptr->info |= (CAVE_MARK);
446 caster_ptr->redraw |= (PR_MAP);
447 caster_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
453 * @brief *破壊*処理を行う / The spell of destruction
457 * @param in_generate ダンジョンフロア生成中の処理ならばTRUE
458 * @return 効力があった場合TRUEを返す
461 * This spell "deletes" monsters (instead of "killing" them).
463 * Later we may use one function for both "destruction" and
464 * "earthquake" by using the "full" to select "destruction".
467 bool destroy_area(floor_type *floor_ptr, POSITION y1, POSITION x1, POSITION r, bool in_generate)
474 /* Prevent destruction of quest levels and town */
475 if ((floor_ptr->inside_quest && is_fixed_quest_idx(floor_ptr->inside_quest)) || !floor_ptr->dun_level)
480 /* Lose monster light */
481 if (!in_generate) clear_mon_lite(floor_ptr);
483 /* Big area of affect */
484 for (y = (y1 - r); y <= (y1 + r); y++)
486 for (x = (x1 - r); x <= (x1 + r); x++)
488 if (!in_bounds(floor_ptr, y, x)) continue;
490 /* Extract the distance */
491 k = distance(y1, x1, y, x);
493 /* Stay in the circle of death */
495 g_ptr = &floor_ptr->grid_array[y][x];
497 /* Lose room and vault */
498 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
500 /* Lose light and knowledge */
501 g_ptr->info &= ~(CAVE_MARK | CAVE_GLOW | CAVE_KNOWN);
503 if (!in_generate) /* Normal */
506 g_ptr->info &= ~(CAVE_UNSAFE);
508 /* Hack -- Notice player affect */
509 if (player_bold(p_ptr, y, x))
511 /* Hurt the player later */
514 /* Do not hurt this grid */
519 /* Hack -- Skip the epicenter */
520 if ((y == y1) && (x == x1)) continue;
524 monster_type *m_ptr = &floor_ptr->m_list[g_ptr->m_idx];
525 monster_race *r_ptr = &r_info[m_ptr->r_idx];
527 if (in_generate) /* In generation */
529 /* Delete the monster (if any) */
530 delete_monster(floor_ptr, y, x);
532 else if (r_ptr->flags1 & RF1_QUESTOR)
534 /* Heal the monster */
535 m_ptr->hp = m_ptr->maxhp;
537 /* Try to teleport away quest monsters */
538 if (!teleport_away(p_ptr, g_ptr->m_idx, (r * 2) + 1, TELEPORT_DEC_VALOUR)) continue;
542 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
544 GAME_TEXT m_name[MAX_NLEN];
546 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
547 exe_write_diary(p_ptr, NIKKI_NAMED_PET, RECORD_NAMED_PET_DESTROY, m_name);
550 /* Delete the monster (if any) */
551 delete_monster(floor_ptr, y, x);
555 /* During generation, destroyed artifacts are "preserved" */
556 if (preserve_mode || in_generate)
558 OBJECT_IDX this_o_idx, next_o_idx = 0;
560 /* Scan all objects in the grid */
561 for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
564 o_ptr = &floor_ptr->o_list[this_o_idx];
565 next_o_idx = o_ptr->next_o_idx;
567 /* Hack -- Preserve unknown artifacts */
568 if (object_is_fixed_artifact(o_ptr) && (!object_is_known(o_ptr) || in_generate))
570 /* Mega-Hack -- Preserve the artifact */
571 a_info[o_ptr->name1].cur_num = 0;
573 if (in_generate && cheat_peek)
575 GAME_TEXT o_name[MAX_NLEN];
576 object_desc(o_name, o_ptr, (OD_NAME_ONLY | OD_STORE));
577 msg_format(_("伝説のアイテム (%s) は生成中に*破壊*された。", "Artifact (%s) was *destroyed* during generation."), o_name);
580 else if (in_generate && cheat_peek && o_ptr->art_name)
582 msg_print(_("ランダム・アーティファクトの1つは生成中に*破壊*された。",
583 "One of the random artifacts was *destroyed* during generation."));
590 /* Destroy "non-permanent" grids */
591 if (!cave_perma_grid(g_ptr))
593 /* Wall (or floor) type */
596 if (!in_generate) /* Normal */
600 /* Create granite wall */
601 cave_set_feat(floor_ptr, y, x, feat_granite);
605 /* Create quartz vein */
606 cave_set_feat(floor_ptr, y, x, feat_quartz_vein);
610 /* Create magma vein */
611 cave_set_feat(floor_ptr, y, x, feat_magma_vein);
616 cave_set_feat(floor_ptr, y, x, feat_ground_type[randint0(100)]);
619 else /* In generation */
623 /* Create granite wall */
624 place_extra_grid(g_ptr);
628 /* Create quartz vein */
629 g_ptr->feat = feat_quartz_vein;
633 /* Create magma vein */
634 g_ptr->feat = feat_magma_vein;
639 place_floor_grid(g_ptr);
642 /* Clear garbage of hidden trap or door */
651 /* Process "re-glowing" */
652 for (y = (y1 - r); y <= (y1 + r); y++)
654 for (x = (x1 - r); x <= (x1 + r); x++)
656 if (!in_bounds(floor_ptr, y, x)) continue;
658 /* Extract the distance */
659 k = distance(y1, x1, y, x);
661 /* Stay in the circle of death */
663 g_ptr = &floor_ptr->grid_array[y][x];
665 if (is_mirror_grid(g_ptr)) g_ptr->info |= CAVE_GLOW;
666 else if (!(d_info[floor_ptr->dungeon_idx].flags1 & DF1_DARKNESS))
672 for (i = 0; i < 9; i++)
676 if (!in_bounds2(floor_ptr, yy, xx)) continue;
677 cc_ptr = &floor_ptr->grid_array[yy][xx];
678 if (have_flag(f_info[get_feat_mimic(cc_ptr)].flags, FF_GLOW))
680 g_ptr->info |= CAVE_GLOW;
688 /* Hack -- Affect player */
691 msg_print(_("燃えるような閃光が発生した!", "There is a searing blast of light!"));
693 /* Blind the player */
694 if (!p_ptr->resist_blind && !p_ptr->resist_lite)
697 (void)set_blind(p_ptr, p_ptr->blind + 10 + randint1(10));
701 forget_flow(floor_ptr);
703 /* Mega-Hack -- Forget the view and lite */
704 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE | PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE | PU_MONSTERS);
705 p_ptr->redraw |= (PR_MAP);
706 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
708 if (p_ptr->special_defense & NINJA_S_STEALTH)
710 if (floor_ptr->grid_array[p_ptr->y][p_ptr->x].info & CAVE_GLOW) set_superstealth(p_ptr, FALSE);
720 * @brief 地震処理(サブルーチン) /
721 * Induce an "earthquake" of the given radius at the given location.
722 * @return 効力があった場合TRUEを返す
726 * @param m_idx 地震を起こしたモンスターID(0ならばプレイヤー)
730 * This will turn some walls into floors and some floors into walls.
732 * The player will take damage and "jump" into a safe grid if possible,
733 * otherwise, he will "tunnel" through the rubble instantaneously.
735 * Monsters will take damage, and "jump" into a safe grid if possible,
736 * otherwise they will be "buried" in the rubble, disappearing from
737 * the level in the same way that they do when genocided.
739 * Note that thus the player and monsters (except eaters of walls and
740 * passers through walls) will never occupy the same grid as a wall.
741 * Note that as of now (2.7.8) no monster may occupy a "wall" grid, even
742 * for a single turn, unless that monster can pass_walls or kill_walls.
743 * This has allowed massive simplification of the "monster" code.
746 bool earthquake(player_type *caster_ptr, POSITION cy, POSITION cx, POSITION r, MONSTER_IDX m_idx)
750 POSITION y, x, yy, xx, dy, dx;
753 POSITION sy = 0, sx = 0;
758 /* Prevent destruction of quest levels and town */
759 if ((caster_ptr->current_floor_ptr->inside_quest && is_fixed_quest_idx(caster_ptr->current_floor_ptr->inside_quest)) || !caster_ptr->current_floor_ptr->dun_level)
764 /* Paranoia -- Enforce maximum range */
767 /* Clear the "maximal blast" area */
768 for (y = 0; y < 32; y++)
770 for (x = 0; x < 32; x++)
776 /* Check around the epicenter */
777 for (dy = -r; dy <= r; dy++)
779 for (dx = -r; dx <= r; dx++)
784 if (!in_bounds(caster_ptr->current_floor_ptr, yy, xx)) continue;
786 /* Skip distant grids */
787 if (distance(cy, cx, yy, xx) > r) continue;
788 g_ptr = &caster_ptr->current_floor_ptr->grid_array[yy][xx];
790 /* Lose room and vault / Lose light and knowledge */
791 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY | CAVE_UNSAFE);
792 g_ptr->info &= ~(CAVE_GLOW | CAVE_MARK | CAVE_KNOWN);
794 /* Skip the epicenter */
795 if (!dx && !dy) continue;
797 /* Skip most grids */
798 if (randint0(100) < 85) continue;
800 /* Damage this grid */
801 map[16 + yy - cy][16 + xx - cx] = TRUE;
803 /* Hack -- Take note of player damage */
804 if (player_bold(caster_ptr, yy, xx)) hurt = TRUE;
808 /* First, affect the player (if necessary) */
809 if (hurt && !caster_ptr->pass_wall && !caster_ptr->kill_wall)
811 /* Check around the player */
812 for (i = 0; i < 8; i++)
814 y = caster_ptr->y + ddy_ddd[i];
815 x = caster_ptr->x + ddx_ddd[i];
817 /* Skip non-empty grids */
818 if (!cave_empty_bold(caster_ptr->current_floor_ptr, y, x)) continue;
820 /* Important -- Skip "quake" grids */
821 if (map[16 + y - cy][16 + x - cx]) continue;
823 if (caster_ptr->current_floor_ptr->grid_array[y][x].m_idx) continue;
825 /* Count "safe" grids */
828 /* Randomize choice */
829 if (randint0(sn) > 0) continue;
831 /* Save the safe location */
840 msg_print(_("ダンジョンの壁が崩れた!", "The caster_ptr->current_floor_ptr->grid_array ceiling collapses!"));
845 msg_print(_("ダンジョンの床が不自然にねじ曲がった!", "The caster_ptr->current_floor_ptr->grid_array floor twists in an unnatural way!"));
850 msg_print(_("ダンジョンが揺れた!崩れた岩が頭に降ってきた!", "The caster_ptr->current_floor_ptr->grid_array quakes! You are pummeled with debris!"));
855 /* Hurt the player a lot */
858 /* Message and damage */
859 msg_print(_("あなたはひどい怪我を負った!", "You are severely crushed!"));
863 /* Destroy the grid, and push the player to safety */
866 /* Calculate results */
871 msg_print(_("降り注ぐ岩をうまく避けた!", "You nimbly dodge the blast!"));
877 msg_print(_("岩石があなたに直撃した!", "You are bashed by rubble!"));
878 damage = damroll(10, 4);
879 (void)set_stun(caster_ptr, caster_ptr->stun + randint1(50));
884 msg_print(_("あなたは床と壁との間に挟まれてしまった!", "You are crushed between the floor and ceiling!"));
885 damage = damroll(10, 4);
886 (void)set_stun(caster_ptr, caster_ptr->stun + randint1(50));
891 /* Move the player to the safe location */
892 (void)move_player_effect(caster_ptr, sy, sx, MPE_DONT_PICKUP);
895 /* Important -- no wall on player */
896 map[16 + caster_ptr->y - cy][16 + caster_ptr->x - cx] = FALSE;
904 GAME_TEXT m_name[MAX_NLEN];
905 monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[m_idx];
906 monster_desc(m_name, m_ptr, MD_WRONGDOER_NAME);
907 killer = format(_("%sの起こした地震", "an earthquake caused by %s"), m_name);
911 killer = _("地震", "an earthquake");
914 take_hit(caster_ptr, DAMAGE_ATTACK, damage, killer, -1);
918 /* Examine the quaked region */
919 for (dy = -r; dy <= r; dy++)
921 for (dx = -r; dx <= r; dx++)
926 /* Skip unaffected grids */
927 if (!map[16 + yy - cy][16 + xx - cx]) continue;
928 g_ptr = &caster_ptr->current_floor_ptr->grid_array[yy][xx];
930 if (g_ptr->m_idx == caster_ptr->riding) continue;
932 /* Process monsters */
935 monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[g_ptr->m_idx];
936 monster_race *r_ptr = &r_info[m_ptr->r_idx];
939 if (r_ptr->flags1 & RF1_QUESTOR)
941 /* No wall on quest monsters */
942 map[16 + yy - cy][16 + xx - cx] = FALSE;
947 /* Most monsters cannot co-exist with rock */
948 if (!(r_ptr->flags2 & (RF2_KILL_WALL)) &&
949 !(r_ptr->flags2 & (RF2_PASS_WALL)))
951 GAME_TEXT m_name[MAX_NLEN];
953 /* Assume not safe */
956 /* Monster can move to escape the wall */
957 if (!(r_ptr->flags1 & (RF1_NEVER_MOVE)))
959 /* Look for safety */
960 for (i = 0; i < 8; i++)
965 /* Skip non-empty grids */
966 if (!cave_empty_bold(caster_ptr->current_floor_ptr, y, x)) continue;
968 /* Hack -- no safety on glyph of warding */
969 if (is_glyph_grid(&caster_ptr->current_floor_ptr->grid_array[y][x])) continue;
970 if (is_explosive_rune_grid(&caster_ptr->current_floor_ptr->grid_array[y][x])) continue;
972 /* ... nor on the Pattern */
973 if (pattern_tile(y, x)) continue;
975 /* Important -- Skip "quake" grids */
976 if (map[16 + y - cy][16 + x - cx]) continue;
978 if (caster_ptr->current_floor_ptr->grid_array[y][x].m_idx) continue;
979 if (player_bold(caster_ptr, y, x)) continue;
981 /* Count "safe" grids */
984 /* Randomize choice */
985 if (randint0(sn) > 0) continue;
987 /* Save the safe grid */
992 monster_desc(m_name, m_ptr, 0);
995 if (!ignore_unview || is_seen(m_ptr)) msg_format(_("%^sは苦痛で泣きわめいた!", "%^s wails out in pain!"), m_name);
997 /* Take damage from the quake */
998 damage = (sn ? damroll(4, 8) : (m_ptr->hp + 1));
1000 /* Monster is certainly awake */
1001 (void)set_monster_csleep(g_ptr->m_idx, 0);
1003 /* Apply damage directly */
1004 m_ptr->hp -= damage;
1006 /* Delete (not kill) "dead" monsters */
1009 if (!ignore_unview || is_seen(m_ptr))
1010 msg_format(_("%^sは岩石に埋もれてしまった!", "%^s is embedded in the rock!"), m_name);
1014 if (record_named_pet && is_pet(&caster_ptr->current_floor_ptr->m_list[g_ptr->m_idx]) && caster_ptr->current_floor_ptr->m_list[g_ptr->m_idx].nickname)
1016 char m2_name[MAX_NLEN];
1018 monster_desc(m2_name, m_ptr, MD_INDEF_VISIBLE);
1019 exe_write_diary(caster_ptr, NIKKI_NAMED_PET, RECORD_NAMED_PET_EARTHQUAKE, m2_name);
1023 delete_monster(caster_ptr->current_floor_ptr, yy, xx);
1025 /* No longer safe */
1029 /* Hack -- Escape from the rock */
1032 IDX m_idx_aux = caster_ptr->current_floor_ptr->grid_array[yy][xx].m_idx;
1034 /* Update the old location */
1035 caster_ptr->current_floor_ptr->grid_array[yy][xx].m_idx = 0;
1037 /* Update the new location */
1038 caster_ptr->current_floor_ptr->grid_array[sy][sx].m_idx = m_idx_aux;
1040 /* Move the monster */
1044 update_monster(caster_ptr, m_idx, TRUE);
1053 /* Lose monster light */
1054 clear_mon_lite(caster_ptr->current_floor_ptr);
1056 /* Examine the quaked region */
1057 for (dy = -r; dy <= r; dy++)
1059 for (dx = -r; dx <= r; dx++)
1064 /* Skip unaffected grids */
1065 if (!map[16 + yy - cy][16 + xx - cx]) continue;
1067 g_ptr = &caster_ptr->current_floor_ptr->grid_array[yy][xx];
1069 /* Destroy location (if valid) */
1070 if (cave_valid_bold(caster_ptr->current_floor_ptr, yy, xx))
1072 delete_object(yy, xx);
1074 /* Wall (or floor) type */
1075 t = cave_have_flag_bold(caster_ptr->current_floor_ptr, yy, xx, FF_PROJECT) ? randint0(100) : 200;
1080 /* Create granite wall */
1081 cave_set_feat(caster_ptr->current_floor_ptr, yy, xx, feat_granite);
1087 /* Create quartz vein */
1088 cave_set_feat(caster_ptr->current_floor_ptr, yy, xx, feat_quartz_vein);
1094 /* Create magma vein */
1095 cave_set_feat(caster_ptr->current_floor_ptr, yy, xx, feat_magma_vein);
1102 cave_set_feat(caster_ptr->current_floor_ptr, yy, xx, feat_ground_type[randint0(100)]);
1108 /* Process "re-glowing" */
1109 for (dy = -r; dy <= r; dy++)
1111 for (dx = -r; dx <= r; dx++)
1116 if (!in_bounds(caster_ptr->current_floor_ptr, yy, xx)) continue;
1118 /* Skip distant grids */
1119 if (distance(cy, cx, yy, xx) > r) continue;
1120 g_ptr = &caster_ptr->current_floor_ptr->grid_array[yy][xx];
1122 if (is_mirror_grid(g_ptr)) g_ptr->info |= CAVE_GLOW;
1123 else if (!(d_info[caster_ptr->dungeon_idx].flags1 & DF1_DARKNESS))
1129 for (ii = 0; ii < 9; ii++)
1131 yyy = yy + ddy_ddd[ii];
1132 xxx = xx + ddx_ddd[ii];
1133 if (!in_bounds2(caster_ptr->current_floor_ptr, yyy, xxx)) continue;
1134 cc_ptr = &caster_ptr->current_floor_ptr->grid_array[yyy][xxx];
1135 if (have_flag(f_info[get_feat_mimic(cc_ptr)].flags, FF_GLOW))
1137 g_ptr->info |= CAVE_GLOW;
1145 /* Mega-Hack -- Forget the view and lite */
1146 caster_ptr->update |= (PU_UN_VIEW | PU_UN_LITE | PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE | PU_MONSTERS);
1147 caster_ptr->redraw |= (PR_HEALTH | PR_UHEALTH | PR_MAP);
1148 caster_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1150 if (caster_ptr->special_defense & NINJA_S_STEALTH)
1152 if (caster_ptr->current_floor_ptr->grid_array[caster_ptr->y][caster_ptr->x].info & CAVE_GLOW) set_superstealth(caster_ptr, FALSE);