1 #include "spell-kind/earthquake.h"
2 #include "core/player-redraw-types.h"
3 #include "core/player-update-types.h"
4 #include "core/window-redrawer.h"
5 #include "dungeon/dungeon-flag-types.h"
6 #include "dungeon/dungeon.h"
7 #include "dungeon/quest.h"
8 #include "floor/cave.h"
9 #include "floor/floor-object.h"
10 #include "game-option/play-record-options.h"
11 #include "game-option/text-display-options.h"
12 #include "grid/grid.h"
13 #include "grid/stair.h"
14 #include "io/write-diary.h"
15 #include "mind/mind-ninja.h"
16 #include "monster-floor/monster-lite.h"
17 #include "monster-race/monster-race.h"
18 #include "monster-race/race-flags1.h"
19 #include "monster-race/race-flags2.h"
20 #include "monster/monster-describer.h"
21 #include "monster/monster-description-types.h"
22 #include "monster/monster-info.h"
23 #include "monster/monster-status-setter.h"
24 #include "monster/monster-update.h"
25 #include "monster/smart-learn-types.h"
26 #include "status/bad-status-setter.h"
27 #include "player/player-damage.h"
28 #include "player/player-move.h"
29 #include "player/special-defense-types.h"
30 #include "player/player-status-flags.h"
31 #include "system/floor-type-definition.h"
32 #include "util/bit-flags-calculator.h"
33 #include "view/display-messages.h"
37 * Induce an "earthquake" of the given radius at the given location.
38 * @param caster_ptrプレーヤーへの参照ポインタ
42 * @param m_idx 地震を起こしたモンスターID(0ならばプレイヤー)
43 * @return 効力があった場合TRUEを返す
45 bool earthquake(player_type *caster_ptr, POSITION cy, POSITION cx, POSITION r, MONSTER_IDX m_idx)
47 floor_type *floor_ptr = caster_ptr->current_floor_ptr;
48 if ((floor_ptr->inside_quest && is_fixed_quest_idx(floor_ptr->inside_quest)) || !floor_ptr->dun_level) {
56 for (POSITION y = 0; y < 32; y++) {
57 for (POSITION x = 0; x < 32; x++) {
64 for (POSITION dy = -r; dy <= r; dy++) {
65 for (POSITION dx = -r; dx <= r; dx++) {
66 POSITION yy = cy + dy;
67 POSITION xx = cx + dx;
69 if (!in_bounds(floor_ptr, yy, xx))
72 if (distance(cy, cx, yy, xx) > r)
76 g_ptr = &floor_ptr->grid_array[yy][xx];
77 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY | CAVE_UNSAFE);
78 g_ptr->info &= ~(CAVE_GLOW | CAVE_MARK | CAVE_KNOWN);
82 if (randint0(100) < 85)
85 map[16 + yy - cy][16 + xx - cx] = TRUE;
86 if (player_bold(caster_ptr, yy, xx))
92 POSITION sy = 0, sx = 0;
93 if (hurt && !has_pass_wall(caster_ptr) && !caster_ptr->kill_wall) {
94 for (DIRECTION i = 0; i < 8; i++) {
95 POSITION y = caster_ptr->y + ddy_ddd[i];
96 POSITION x = caster_ptr->x + ddx_ddd[i];
97 if (!is_cave_empty_bold(caster_ptr, y, x))
100 if (map[16 + y - cy][16 + x - cx])
103 if (floor_ptr->grid_array[y][x].m_idx)
107 if (randint0(sn) > 0)
114 switch (randint1(3)) {
116 msg_print(_("ダンジョンの壁が崩れた!", "The dungeon's ceiling collapses!"));
120 msg_print(_("ダンジョンの床が不自然にねじ曲がった!", "The dungeon's floor twists in an unnatural way!"));
124 msg_print(_("ダンジョンが揺れた!崩れた岩が頭に降ってきた!", "The dungeon quakes! You are pummeled with debris!"));
130 msg_print(_("あなたはひどい怪我を負った!", "You are severely crushed!"));
134 switch (randint1(3)) {
136 msg_print(_("降り注ぐ岩をうまく避けた!", "You nimbly dodge the blast!"));
141 msg_print(_("岩石があなたに直撃した!", "You are bashed by rubble!"));
142 damage = damroll(10, 4);
143 (void)set_stun(caster_ptr, caster_ptr->stun + randint1(50));
147 msg_print(_("あなたは床と壁との間に挟まれてしまった!", "You are crushed between the floor and ceiling!"));
148 damage = damroll(10, 4);
149 (void)set_stun(caster_ptr, caster_ptr->stun + randint1(50));
154 (void)move_player_effect(caster_ptr, sy, sx, MPE_DONT_PICKUP);
157 map[16 + caster_ptr->y - cy][16 + caster_ptr->x - cx] = FALSE;
162 GAME_TEXT m_name[MAX_NLEN];
163 monster_type *m_ptr = &floor_ptr->m_list[m_idx];
164 monster_desc(caster_ptr, m_name, m_ptr, MD_WRONGDOER_NAME);
165 killer = format(_("%sの起こした地震", "an earthquake caused by %s"), m_name);
167 killer = _("地震", "an earthquake");
170 take_hit(caster_ptr, DAMAGE_ATTACK, damage, killer, -1);
174 for (POSITION dy = -r; dy <= r; dy++) {
175 for (POSITION dx = -r; dx <= r; dx++) {
176 POSITION yy = cy + dy;
177 POSITION xx = cx + dx;
178 if (!map[16 + yy - cy][16 + xx - cx])
182 g_ptr = &floor_ptr->grid_array[yy][xx];
183 if (g_ptr->m_idx == caster_ptr->riding)
189 monster_type *m_ptr = &floor_ptr->m_list[g_ptr->m_idx];
190 monster_race *r_ptr = &r_info[m_ptr->r_idx];
191 if (r_ptr->flags1 & RF1_QUESTOR) {
192 map[16 + yy - cy][16 + xx - cx] = FALSE;
196 if ((r_ptr->flags2 & RF2_KILL_WALL) || (r_ptr->flags2 & RF2_PASS_WALL))
199 GAME_TEXT m_name[MAX_NLEN];
201 if (!(r_ptr->flags1 & RF1_NEVER_MOVE)) {
202 for (DIRECTION i = 0; i < 8; i++) {
203 POSITION y = yy + ddy_ddd[i];
204 POSITION x = xx + ddx_ddd[i];
205 if (!is_cave_empty_bold(caster_ptr, y, x))
208 if (is_glyph_grid(&floor_ptr->grid_array[y][x]))
211 if (is_explosive_rune_grid(&floor_ptr->grid_array[y][x]))
214 if (pattern_tile(floor_ptr, y, x))
217 if (map[16 + y - cy][16 + x - cx])
220 if (floor_ptr->grid_array[y][x].m_idx)
223 if (player_bold(caster_ptr, y, x))
228 if (randint0(sn) > 0)
236 monster_desc(caster_ptr, m_name, m_ptr, 0);
237 if (!ignore_unview || is_seen(caster_ptr, m_ptr))
238 msg_format(_("%^sは苦痛で泣きわめいた!", "%^s wails out in pain!"), m_name);
240 damage = (sn ? damroll(4, 8) : (m_ptr->hp + 1));
241 (void)set_monster_csleep(caster_ptr, g_ptr->m_idx, 0);
244 if (!ignore_unview || is_seen(caster_ptr, m_ptr))
245 msg_format(_("%^sは岩石に埋もれてしまった!", "%^s is embedded in the rock!"), m_name);
248 if (record_named_pet && is_pet(&floor_ptr->m_list[g_ptr->m_idx]) && floor_ptr->m_list[g_ptr->m_idx].nickname) {
249 char m2_name[MAX_NLEN];
251 monster_desc(caster_ptr, m2_name, m_ptr, MD_INDEF_VISIBLE);
252 exe_write_diary(caster_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_EARTHQUAKE, m2_name);
256 delete_monster(caster_ptr, yy, xx);
263 IDX m_idx_aux = floor_ptr->grid_array[yy][xx].m_idx;
264 floor_ptr->grid_array[yy][xx].m_idx = 0;
265 floor_ptr->grid_array[sy][sx].m_idx = m_idx_aux;
268 update_monster(caster_ptr, m_idx, TRUE);
269 lite_spot(caster_ptr, yy, xx);
270 lite_spot(caster_ptr, sy, sx);
274 clear_mon_lite(floor_ptr);
275 for (POSITION dy = -r; dy <= r; dy++) {
276 for (POSITION dx = -r; dx <= r; dx++) {
277 POSITION yy = cy + dy;
278 POSITION xx = cx + dx;
279 if (!map[16 + yy - cy][16 + xx - cx])
282 if (!cave_valid_bold(floor_ptr, yy, xx))
285 delete_all_items_from_floor(caster_ptr, yy, xx);
286 int t = cave_has_flag_bold(floor_ptr, yy, xx, FF_PROJECT) ? randint0(100) : 200;
288 cave_set_feat(caster_ptr, yy, xx, feat_granite);
293 cave_set_feat(caster_ptr, yy, xx, feat_quartz_vein);
298 cave_set_feat(caster_ptr, yy, xx, feat_magma_vein);
302 cave_set_feat(caster_ptr, yy, xx, feat_ground_type[randint0(100)]);
306 for (POSITION dy = -r; dy <= r; dy++) {
307 for (POSITION dx = -r; dx <= r; dx++) {
308 POSITION yy = cy + dy;
309 POSITION xx = cx + dx;
310 if (!in_bounds(floor_ptr, yy, xx))
313 if (distance(cy, cx, yy, xx) > r)
317 g_ptr = &floor_ptr->grid_array[yy][xx];
318 if (is_mirror_grid(g_ptr)) {
319 g_ptr->info |= CAVE_GLOW;
323 if ((d_info[caster_ptr->dungeon_idx].flags1 & DF1_DARKNESS))
327 for (DIRECTION ii = 0; ii < 9; ii++) {
328 POSITION yyy = yy + ddy_ddd[ii];
329 POSITION xxx = xx + ddx_ddd[ii];
330 if (!in_bounds2(floor_ptr, yyy, xxx))
332 cc_ptr = &floor_ptr->grid_array[yyy][xxx];
333 if (has_flag(f_info[get_feat_mimic(cc_ptr)].flags, FF_GLOW)) {
334 g_ptr->info |= CAVE_GLOW;
341 caster_ptr->update |= (PU_UN_VIEW | PU_UN_LITE | PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE | PU_MONSTERS);
342 caster_ptr->redraw |= (PR_HEALTH | PR_UHEALTH | PR_MAP);
343 caster_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
344 if (caster_ptr->special_defense & NINJA_S_STEALTH) {
345 if (floor_ptr->grid_array[caster_ptr->y][caster_ptr->x].info & CAVE_GLOW)
346 set_superstealth(caster_ptr, FALSE);