4 #include "player-damage.h"
5 #include "projection.h"
6 #include "spells-summon.h"
11 static s16b normal_traps[MAX_NORMAL_TRAPS];
15 * @brief タグに従って、基本トラップテーブルを初期化する / Initialize arrays for normal traps
18 void init_normal_traps(void)
22 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TRAPDOOR");
23 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_PIT");
24 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_SPIKED_PIT");
25 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_POISON_PIT");
26 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TY_CURSE");
27 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TELEPORT");
28 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_FIRE");
29 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_ACID");
30 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_SLOW");
31 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_LOSE_STR");
32 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_LOSE_DEX");
33 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_LOSE_CON");
34 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_BLIND");
35 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_CONFUSE");
36 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_POISON");
37 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_SLEEP");
38 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TRAPS");
39 normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_ALARM");
43 * @brief 基本トラップをランダムに選択する /
47 * This routine should be redone to reflect trap "level".\n
48 * That is, it does not make sense to have spiked pits at 50 feet.\n
49 * Actually, it is not this routine, but the "trap instantiation"\n
50 * code, which should also check for "trap doors" on quest levels.\n
52 FEAT_IDX choose_random_trap(void)
59 /* Hack -- pick a trap */
60 feat = normal_traps[randint0(MAX_NORMAL_TRAPS)];
62 /* Accept non-trapdoors */
63 if (!have_flag(f_info[feat].flags, FF_MORE)) break;
65 /* Hack -- no trap doors on special levels */
66 if (p_ptr->inside_arena || quest_number(dun_level)) continue;
68 /* Hack -- no trap doors on the deepest level */
69 if (dun_level >= d_info[p_ptr->dungeon_idx].maxdepth) continue;
78 * @brief マスに存在するトラップを秘匿する /
79 * Disclose an invisible trap
80 * @param y 秘匿したいマスのY座標
81 * @param x 秘匿したいマスのX座標
84 void disclose_grid(POSITION y, POSITION x)
86 grid_type *g_ptr = ¤t_floor->grid_array[y][x];
88 if (cave_have_flag_grid(g_ptr, FF_SECRET))
90 /* No longer hidden */
91 cave_alter_feat(y, x, FF_SECRET);
93 else if (g_ptr->mimic)
95 /* No longer hidden */
104 * @brief マスをトラップを配置する /
105 * The location must be a legal, naked, floor grid.
106 * @param y 配置したいマスのY座標
107 * @param x 配置したいマスのX座標
109 * Note that all traps start out as "invisible" and "untyped", and then\n
110 * when they are "discovered" (by detecting them or setting them off),\n
111 * the trap is "instantiated" as a visible, "typed", trap.\n
113 void place_trap(POSITION y, POSITION x)
115 grid_type *g_ptr = ¤t_floor->grid_array[y][x];
117 /* Paranoia -- verify location */
118 if (!in_bounds(y, x)) return;
120 /* Require empty, clean, floor grid */
121 if (!cave_clean_bold(y, x)) return;
123 /* Place an invisible trap */
124 g_ptr->mimic = g_ptr->feat;
125 g_ptr->feat = choose_random_trap();
131 * @brief プレイヤーへのトラップ命中判定 /
132 * Determine if a trap affects the player.
133 * @param power 基本回避難度
134 * @return トラップが命中した場合TRUEを返す。
136 * Always miss 5% of the time, Always hit 5% of the time.
137 * Otherwise, match trap power against player armor.
139 static int check_hit(int power)
144 /* Percentile dice */
147 /* Hack -- 5% hit, 5% miss */
148 if (k < 10) return (k < 5);
150 if (p_ptr->pseikaku == SEIKAKU_NAMAKE)
151 if (one_in_(20)) return (TRUE);
153 /* Paranoia -- No power */
154 if (power <= 0) return (FALSE);
157 ac = p_ptr->ac + p_ptr->to_a;
159 /* Power competes against Armor */
160 if (randint1(power) > ((ac * 3) / 4)) return (TRUE);
168 * @brief 落とし穴系トラップの判定とプレイヤーの被害処理
169 * @param trap_feat_type トラップの種別ID
172 static void hit_trap_pit(int trap_feat_type)
175 concptr trap_name = "";
176 concptr spike_name = "";
178 switch (trap_feat_type)
181 trap_name = _("落とし穴", "a pit trap");
183 case TRAP_SPIKED_PIT:
184 trap_name = _("スパイクが敷かれた落とし穴", "a spiked pit");
185 spike_name = _("スパイク", "spikes");
187 case TRAP_POISON_PIT:
188 trap_name = _("スパイクが敷かれた落とし穴", "a spiked pit");
189 spike_name = _("毒を塗られたスパイク", "poisonous spikes");
195 if (p_ptr->levitation)
197 msg_format(_("%sを飛び越えた。", "You fly over %s."), trap_name);
201 msg_format(_("%sに落ちてしまった!", "You have fallen into %s!"), trap_name);
206 /* Extra spike damage */
207 if ((trap_feat_type == TRAP_SPIKED_PIT || trap_feat_type == TRAP_POISON_PIT) &&
210 msg_format(_("%sが刺さった!", "You are impaled on %s!"), spike_name);
213 (void)set_cut(p_ptr->cut + randint1(dam));
215 if (trap_feat_type == TRAP_POISON_PIT) {
216 if (p_ptr->resist_pois || IS_OPPOSE_POIS())
218 msg_print(_("しかし毒の影響はなかった!", "The poison does not affect you!"));
223 (void)set_poisoned(p_ptr->poisoned + randint1(dam));
228 take_hit(DAMAGE_NOESCAPE, dam, trap_name, -1);
232 * @brief ダーツ系トラップ(通常ダメージ)の判定とプレイヤーの被害処理
233 * @return ダーツが命中した場合TRUEを返す
235 static bool hit_trap_dart(void)
241 msg_print(_("小さなダーツが飛んできて刺さった!", "A small dart hits you!"));
242 take_hit(DAMAGE_ATTACK, damroll(1, 4), _("ダーツの罠", "a dart trap"), -1);
243 if (!CHECK_MULTISHADOW()) hit = TRUE;
247 msg_print(_("小さなダーツが飛んできた!が、運良く当たらなかった。", "A small dart barely misses you."));
254 * @brief ダーツ系トラップ(通常ダメージ+能力値減少)の判定とプレイヤーの被害処理
255 * @param stat 低下する能力値ID
258 static void hit_trap_lose_stat(int stat)
267 * @brief ダーツ系トラップ(通常ダメージ+減速)の判定とプレイヤーの被害処理
270 static void hit_trap_slow(void)
274 set_slow(p_ptr->slow + randint0(20) + 20, FALSE);
279 * @brief ダーツ系トラップ(通常ダメージ+状態異常)の判定とプレイヤーの被害処理
280 * @param trap_message メッセージの補完文字列
281 * @param resist 状態異常に抵抗する判定が出たならTRUE
282 * @param set_status 状態異常を指定する関数ポインタ
283 * @param turn 状態異常の追加ターン量
286 static void hit_trap_set_abnormal_status(concptr trap_message, bool resist, bool(*set_status)(IDX), IDX turn_aux)
288 msg_print(trap_message);
291 set_status(turn_aux);
296 * @brief プレイヤーへのトラップ作動処理メインルーチン /
297 * Handle player hitting a real trap
298 * @param break_trap 作動後のトラップ破壊が確定しているならばTRUE
301 void hit_trap(bool break_trap)
304 POSITION x = p_ptr->x, y = p_ptr->y;
305 grid_type *g_ptr = ¤t_floor->grid_array[y][x];
306 feature_type *f_ptr = &f_info[g_ptr->feat];
307 int trap_feat_type = have_flag(f_ptr->flags, FF_TRAP) ? f_ptr->subtype : NOT_TRAP;
308 concptr name = _("トラップ", "a trap");
310 disturb(FALSE, TRUE);
312 cave_alter_feat(y, x, FF_HIT_TRAP);
315 switch (trap_feat_type)
319 if (p_ptr->levitation)
321 msg_print(_("落とし戸を飛び越えた。", "You fly over a trap door."));
325 msg_print(_("落とし戸に落ちた!", "You have fallen through a trap door!"));
326 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
327 msg_print(_("くっそ~!", ""));
328 else if((p_ptr->pseikaku == SEIKAKU_CHARGEMAN))
329 msg_print(_("ジュラル星人の仕業に違いない!", ""));
334 name = _("落とし戸", "a trap door");
336 take_hit(DAMAGE_NOESCAPE, dam, name, -1);
338 /* Still alive and autosave enabled */
339 if (autosave_l && (p_ptr->chp >= 0))
340 do_cmd_save_game(TRUE);
342 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("落とし戸に落ちた", "You have fallen through a trap door!"));
343 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
346 p_ptr->leaving = TRUE;
352 case TRAP_SPIKED_PIT:
353 case TRAP_POISON_PIT:
355 hit_trap_pit(trap_feat_type);
361 msg_print(_("何かがピカッと光った!", "There is a flash of shimmering light!"));
362 num = 2 + randint1(3);
363 for (i = 0; i < num; i++)
365 (void)summon_specific(0, y, x, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0');
368 if (dun_level > randint1(100)) /* No nasty effect for low levels */
370 bool stop_ty = FALSE;
375 stop_ty = activate_ty_curse(stop_ty, &count);
376 } while (one_in_(6));
383 msg_print(_("テレポート・トラップにひっかかった!", "You hit a teleport trap!"));
384 teleport_player(100, TELEPORT_PASSIVE);
390 msg_print(_("炎に包まれた!", "You are enveloped in flames!"));
392 (void)fire_dam(dam, _("炎のトラップ", "a fire trap"), -1, FALSE);
398 msg_print(_("酸が吹きかけられた!", "You are splashed with acid!"));
400 (void)acid_dam(dam, _("酸のトラップ", "an acid trap"), -1, FALSE);
412 hit_trap_lose_stat(A_STR);
418 hit_trap_lose_stat(A_DEX);
424 hit_trap_lose_stat(A_CON);
430 hit_trap_set_abnormal_status(
431 _("黒いガスに包み込まれた!", "A black gas surrounds you!"),
433 set_blind, p_ptr->blind + (TIME_EFFECT)randint0(50) + 25);
439 hit_trap_set_abnormal_status(
440 _("きらめくガスに包み込まれた!", "A gas of scintillating colors surrounds you!"),
442 set_confused, p_ptr->confused + (TIME_EFFECT)randint0(20) + 10);
448 hit_trap_set_abnormal_status(
449 _("刺激的な緑色のガスに包み込まれた!", "A pungent green gas surrounds you!"),
450 p_ptr->resist_pois || IS_OPPOSE_POIS(),
451 set_poisoned, p_ptr->poisoned + (TIME_EFFECT)randint0(20) + 10);
457 msg_print(_("奇妙な白い霧に包まれた!", "A strange white mist surrounds you!"));
458 if (!p_ptr->free_act)
460 msg_print(_("あなたは眠りに就いた。", "You fall asleep."));
462 if (ironman_nightmare)
464 msg_print(_("身の毛もよだつ光景が頭に浮かんだ。", "A horrible vision enters your mind."));
466 /* Have some nightmares */
467 sanity_blast(NULL, FALSE);
470 (void)set_paralyzed(p_ptr->paralyzed + randint0(10) + 5);
477 msg_print(_("まばゆい閃光が走った!", "There is a bright flash of light!"));
478 /* Make some new traps */
479 project(0, 1, y, x, 0, GF_MAKE_TRAP, PROJECT_HIDE | PROJECT_JUMP | PROJECT_GRID, -1);
486 msg_print(_("けたたましい音が鳴り響いた!", "An alarm sounds!"));
488 aggravate_monsters(0);
495 msg_print(_("大音響と共にまわりの壁が崩れた!", "Suddenly, surrounding walls are opened!"));
496 (void)project(0, 3, y, x, 0, GF_DISINTEGRATE, PROJECT_GRID | PROJECT_HIDE, -1);
497 (void)project(0, 3, y, x - 4, 0, GF_DISINTEGRATE, PROJECT_GRID | PROJECT_HIDE, -1);
498 (void)project(0, 3, y, x + 4, 0, GF_DISINTEGRATE, PROJECT_GRID | PROJECT_HIDE, -1);
499 aggravate_monsters(0);
504 case TRAP_ARMAGEDDON:
506 static int levs[10] = { 0, 0, 20, 10, 5, 3, 2, 1, 1, 1 };
507 int evil_idx = 0, good_idx = 0;
510 msg_print(_("突然天界の戦争に巻き込まれた!", "Suddenly, you are surrounded by immotal beings!"));
512 /* Summon Demons and Angels */
513 for (lev = dun_level; lev >= 20; lev -= 1 + lev / 16)
515 num = levs[MIN(lev / 10, 9)];
516 for (i = 0; i < num; i++)
518 POSITION x1 = rand_spread(x, 7);
519 POSITION y1 = rand_spread(y, 5);
521 /* Skip illegal grids */
522 if (!in_bounds(y1, x1)) continue;
524 /* Require line of projection */
525 if (!projectable(p_ptr->y, p_ptr->x, y1, x1)) continue;
527 if (summon_specific(0, y1, x1, lev, SUMMON_ARMAGE_EVIL, (PM_NO_PET), '\0'))
528 evil_idx = hack_m_idx_ii;
530 if (summon_specific(0, y1, x1, lev, SUMMON_ARMAGE_GOOD, (PM_NO_PET), '\0'))
532 good_idx = hack_m_idx_ii;
535 /* Let them fight each other */
536 if (evil_idx && good_idx)
538 monster_type *evil_ptr = &m_list[evil_idx];
539 monster_type *good_ptr = &m_list[good_idx];
540 evil_ptr->target_y = good_ptr->fy;
541 evil_ptr->target_x = good_ptr->fx;
542 good_ptr->target_y = evil_ptr->fy;
543 good_ptr->target_x = evil_ptr->fx;
552 msg_print(_("突然壁から水が溢れ出した!ピラニアがいる!", "Suddenly, the room is filled with water with piranhas!"));
554 /* Water fills room */
555 fire_ball_hide(GF_WATER_FLOW, 0, 1, 10);
557 /* Summon Piranhas */
558 num = 1 + dun_level / 20;
559 for (i = 0; i < num; i++)
561 (void)summon_specific(0, y, x, dun_level, SUMMON_PIRANHAS, (PM_ALLOW_GROUP | PM_NO_PET), '\0');
567 if (break_trap && is_trap(g_ptr->feat))
569 cave_alter_feat(y, x, FF_DISARM);
570 msg_print(_("トラップを粉砕した。", "You destroyed the trap."));