OSDN Git Service

[Fix] #39525 コメント置換ミス修正. / Fix comment replacing error.
[hengband/hengband.git] / src / trap.c
index 68b0b4c..63358cd 100644 (file)
@@ -1,10 +1,13 @@
 #include "angband.h"
 #include "util.h"
 
+#include "cmd-dump.h"
 #include "trap.h"
 #include "player-damage.h"
 #include "player-move.h"
 #include "player-effects.h"
+#include "player-class.h"
+#include "player-personality.h"
 #include "spells-summon.h"
 #include "quest.h"
 #include "artifact.h"
@@ -18,6 +21,7 @@
 #include "files.h"
 #include "dungeon.h"
 #include "world.h"
+#include "realm-song.h"
 
 static s16b normal_traps[MAX_NORMAL_TRAPS];
 
@@ -154,10 +158,10 @@ FEAT_IDX choose_random_trap(void)
                if (!have_flag(f_info[feat].flags, FF_MORE)) break;
 
                /* Hack -- no trap doors on special levels */
-               if (p_ptr->inside_arena || quest_number(current_floor_ptr->dun_level)) continue;
+               if (p_ptr->inside_arena || quest_number(p_ptr->current_floor_ptr->dun_level)) continue;
 
                /* Hack -- no trap doors on the deepest level */
-               if (current_floor_ptr->dun_level >= d_info[p_ptr->dungeon_idx].maxdepth) continue;
+               if (p_ptr->current_floor_ptr->dun_level >= d_info[p_ptr->dungeon_idx].maxdepth) continue;
 
                break;
        }
@@ -166,7 +170,7 @@ FEAT_IDX choose_random_trap(void)
 }
 
 /*!
-* @brief マスに存在するトラップを秘匿する /
+* @brief マスに存在する隠しトラップを公開する /
 * Disclose an invisible trap
 * @param y 秘匿したいマスのY座標
 * @param x 秘匿したいマスのX座標
@@ -174,7 +178,7 @@ FEAT_IDX choose_random_trap(void)
 */
 void disclose_grid(POSITION y, POSITION x)
 {
-       grid_type *g_ptr = &current_floor_ptr->grid_array[y][x];
+       grid_type *g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
 
        if (cave_have_flag_grid(g_ptr, FF_SECRET))
        {
@@ -203,10 +207,10 @@ void disclose_grid(POSITION y, POSITION x)
 */
 void place_trap(POSITION y, POSITION x)
 {
-       grid_type *g_ptr = &current_floor_ptr->grid_array[y][x];
+       grid_type *g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
 
        /* Paranoia -- verify location */
-       if (!in_bounds(y, x)) return;
+       if (!in_bounds(p_ptr->current_floor_ptr, y, x)) return;
 
        /* Require empty, clean, floor grid */
        if (!cave_clean_bold(y, x)) return;
@@ -301,7 +305,7 @@ static void hit_trap_pit(int trap_feat_type)
                msg_format(_("%sが刺さった!", "You are impaled on %s!"), spike_name);
 
                dam = dam * 2;
-               (void)set_cut(p_ptr->cut + randint1(dam));
+               (void)set_cut(p_ptr,p_ptr->cut + randint1(dam));
 
                if (trap_feat_type == TRAP_POISON_PIT) {
                        if (p_ptr->resist_pois || IS_OPPOSE_POIS())
@@ -311,12 +315,12 @@ static void hit_trap_pit(int trap_feat_type)
                        else
                        {
                                dam = dam * 2;
-                               (void)set_poisoned(p_ptr->poisoned + randint1(dam));
+                               (void)set_poisoned(p_ptr, p_ptr->poisoned + randint1(dam));
                        }
                }
        }
 
-       take_hit(DAMAGE_NOESCAPE, dam, trap_name, -1);
+       take_hit(p_ptr, DAMAGE_NOESCAPE, dam, trap_name, -1);
 }
 
 /*!
@@ -330,8 +334,8 @@ static bool hit_trap_dart(void)
        if (check_hit(125))
        {
                msg_print(_("小さなダーツが飛んできて刺さった!", "A small dart hits you!"));
-               take_hit(DAMAGE_ATTACK, damroll(1, 4), _("ダーツの罠", "a dart trap"), -1);
-               if (!CHECK_MULTISHADOW()) hit = TRUE;
+               take_hit(p_ptr, DAMAGE_ATTACK, damroll(1, 4), _("ダーツの罠", "a dart trap"), -1);
+               if (!CHECK_MULTISHADOW(p_ptr)) hit = TRUE;
        }
        else
        {
@@ -350,7 +354,7 @@ static void hit_trap_lose_stat(int stat)
 {
        if (hit_trap_dart())
        {
-               do_dec_stat(stat);
+               do_dec_stat(p_ptr, stat);
        }
 }
 
@@ -362,7 +366,7 @@ static void hit_trap_slow(void)
 {
        if (hit_trap_dart())
        {
-               set_slow(p_ptr->slow + randint0(20) + 20, FALSE);
+               set_slow(p_ptr, p_ptr->slow + randint0(20) + 20, FALSE);
        }
 }
 
@@ -371,7 +375,7 @@ static void hit_trap_slow(void)
 * @param trap_message メッセージの補完文字列
 * @param resist 状態異常に抵抗する判定が出たならTRUE
 * @param set_status 状態異常を指定する関数ポインタ
-* @param current_world_ptr->game_turn 状態異常の追加ターン量
+* @param turn_aux 状態異常の追加ターン量
 * @return なし
 */
 static void hit_trap_set_abnormal_status(concptr trap_message, bool resist, bool(*set_status)(IDX), IDX turn_aux)
@@ -383,22 +387,31 @@ static void hit_trap_set_abnormal_status(concptr trap_message, bool resist, bool
        }
 }
 
+static void hit_trap_set_abnormal_status_p(concptr trap_message, bool resist, bool(*set_status)(player_type *, IDX), IDX turn_aux)
+{
+       msg_print(trap_message);
+       if (!resist)
+       {
+               set_status(p_ptr, turn_aux);
+       }
+}
+
 /*!
 * @brief プレイヤーへのトラップ作動処理メインルーチン /
 * Handle player hitting a real trap
 * @param break_trap 作動後のトラップ破壊が確定しているならばTRUE
 * @return なし
 */
-void hit_trap(bool break_trap)
+void hit_trap(player_type *trapped_ptr, bool break_trap)
 {
        int i, num, dam;
-       POSITION x = p_ptr->x, y = p_ptr->y;
-       grid_type *g_ptr = &current_floor_ptr->grid_array[y][x];
+       POSITION x = trapped_ptr->x, y = trapped_ptr->y;
+       grid_type *g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
        feature_type *f_ptr = &f_info[g_ptr->feat];
        int trap_feat_type = have_flag(f_ptr->flags, FF_TRAP) ? f_ptr->subtype : NOT_TRAP;
        concptr name = _("トラップ", "a trap");
 
-       disturb(FALSE, TRUE);
+       disturb(trapped_ptr, FALSE, TRUE);
 
        cave_alter_feat(y, x, FF_HIT_TRAP);
 
@@ -407,16 +420,16 @@ void hit_trap(bool break_trap)
        {
        case TRAP_TRAPDOOR:
        {
-               if (p_ptr->levitation)
+               if (trapped_ptr->levitation)
                {
                        msg_print(_("落とし戸を飛び越えた。", "You fly over a trap door."));
                }
                else
                {
                        msg_print(_("落とし戸に落ちた!", "You have fallen through a trap door!"));
-                       if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
+                       if ((trapped_ptr->pseikaku == SEIKAKU_COMBAT) || (trapped_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON))
                                msg_print(_("くっそ~!", ""));
-                       else if((p_ptr->pseikaku == SEIKAKU_CHARGEMAN))
+                       else if((trapped_ptr->pseikaku == SEIKAKU_CHARGEMAN))
                                msg_print(_("ジュラル星人の仕業に違いない!", ""));
 
 
@@ -424,15 +437,15 @@ void hit_trap(bool break_trap)
                        dam = damroll(2, 8);
                        name = _("落とし戸", "a trap door");
 
-                       take_hit(DAMAGE_NOESCAPE, dam, name, -1);
+                       take_hit(trapped_ptr, DAMAGE_NOESCAPE, dam, name, -1);
 
                        /* Still alive and autosave enabled */
-                       if (autosave_l && (p_ptr->chp >= 0))
+                       if (autosave_l && (trapped_ptr->chp >= 0))
                                do_cmd_save_game(TRUE);
 
-                       do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("落とし戸に落ちた", "You have fallen through a trap door!"));
+                       exe_write_diary(trapped_ptr, NIKKI_BUNSHOU, 0, _("落とし戸に落ちた", "You have fallen through a trap door!"));
                        prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
-                       p_ptr->leaving = TRUE;
+                       trapped_ptr->leaving = TRUE;
                }
                break;
        }
@@ -451,10 +464,10 @@ void hit_trap(bool break_trap)
                num = 2 + randint1(3);
                for (i = 0; i < num; i++)
                {
-                       (void)summon_specific(0, y, x, current_floor_ptr->dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0');
+                       (void)summon_specific(0, y, x, p_ptr->current_floor_ptr->dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
                }
 
-               if (current_floor_ptr->dun_level > randint1(100)) /* No nasty effect for low levels */
+               if (p_ptr->current_floor_ptr->dun_level > randint1(100)) /* No nasty effect for low levels */
                {
                        bool stop_ty = FALSE;
                        int count = 0;
@@ -516,35 +529,35 @@ void hit_trap(bool break_trap)
 
        case TRAP_BLIND:
        {
-               hit_trap_set_abnormal_status(
+               hit_trap_set_abnormal_status_p(
                        _("黒いガスに包み込まれた!", "A black gas surrounds you!"),
-                       p_ptr->resist_blind,
-                       set_blind, p_ptr->blind + (TIME_EFFECT)randint0(50) + 25);
+                       trapped_ptr->resist_blind,
+                       set_blind, trapped_ptr->blind + (TIME_EFFECT)randint0(50) + 25);
                break;
        }
 
        case TRAP_CONFUSE:
        {
-               hit_trap_set_abnormal_status(
+               hit_trap_set_abnormal_status_p(
                        _("きらめくガスに包み込まれた!", "A gas of scintillating colors surrounds you!"),
-                       p_ptr->resist_conf,
-                       set_confused, p_ptr->confused + (TIME_EFFECT)randint0(20) + 10);
+                       trapped_ptr->resist_conf,
+                       set_confused, trapped_ptr->confused + (TIME_EFFECT)randint0(20) + 10);
                break;
        }
 
        case TRAP_POISON:
        {
-               hit_trap_set_abnormal_status(
+               hit_trap_set_abnormal_status_p(
                        _("刺激的な緑色のガスに包み込まれた!", "A pungent green gas surrounds you!"),
-                       p_ptr->resist_pois || IS_OPPOSE_POIS(),
-                       set_poisoned, p_ptr->poisoned + (TIME_EFFECT)randint0(20) + 10);
+                       trapped_ptr->resist_pois || IS_OPPOSE_POIS(),
+                       set_poisoned, trapped_ptr->poisoned + (TIME_EFFECT)randint0(20) + 10);
                break;
        }
 
        case TRAP_SLEEP:
        {
                msg_print(_("奇妙な白い霧に包まれた!", "A strange white mist surrounds you!"));
-               if (!p_ptr->free_act)
+               if (!trapped_ptr->free_act)
                {
                        msg_print(_("あなたは眠りに就いた。", "You fall asleep."));
 
@@ -553,10 +566,10 @@ void hit_trap(bool break_trap)
                                msg_print(_("身の毛もよだつ光景が頭に浮かんだ。", "A horrible vision enters your mind."));
 
                                /* Have some nightmares */
-                               sanity_blast(NULL, FALSE);
+                               sanity_blast(trapped_ptr, NULL, FALSE);
 
                        }
-                       (void)set_paralyzed(p_ptr->paralyzed + randint0(10) + 5);
+                       (void)set_paralyzed(trapped_ptr, trapped_ptr->paralyzed + randint0(10) + 5);
                }
                break;
        }
@@ -599,7 +612,7 @@ void hit_trap(bool break_trap)
                msg_print(_("突然天界の戦争に巻き込まれた!", "Suddenly, you are surrounded by immotal beings!"));
 
                /* Summon Demons and Angels */
-               for (lev = current_floor_ptr->dun_level; lev >= 20; lev -= 1 + lev / 16)
+               for (lev = p_ptr->current_floor_ptr->dun_level; lev >= 20; lev -= 1 + lev / 16)
                {
                        num = levs[MIN(lev / 10, 9)];
                        for (i = 0; i < num; i++)
@@ -607,16 +620,15 @@ void hit_trap(bool break_trap)
                                POSITION x1 = rand_spread(x, 7);
                                POSITION y1 = rand_spread(y, 5);
 
-                               /* Skip illegal grids */
-                               if (!in_bounds(y1, x1)) continue;
+                               if (!in_bounds(p_ptr->current_floor_ptr, y1, x1)) continue;
 
                                /* Require line of projection */
-                               if (!projectable(p_ptr->y, p_ptr->x, y1, x1)) continue;
+                               if (!projectable(trapped_ptr->y, trapped_ptr->x, y1, x1)) continue;
 
-                               if (summon_specific(0, y1, x1, lev, SUMMON_ARMAGE_EVIL, (PM_NO_PET), '\0'))
+                               if (summon_specific(0, y1, x1, lev, SUMMON_ARMAGE_EVIL, (PM_NO_PET)))
                                        evil_idx = hack_m_idx_ii;
 
-                               if (summon_specific(0, y1, x1, lev, SUMMON_ARMAGE_GOOD, (PM_NO_PET), '\0'))
+                               if (summon_specific(0, y1, x1, lev, SUMMON_ARMAGE_GOOD, (PM_NO_PET)))
                                {
                                        good_idx = hack_m_idx_ii;
                                }
@@ -624,8 +636,8 @@ void hit_trap(bool break_trap)
                                /* Let them fight each other */
                                if (evil_idx && good_idx)
                                {
-                                       monster_type *evil_ptr = &current_floor_ptr->m_list[evil_idx];
-                                       monster_type *good_ptr = &current_floor_ptr->m_list[good_idx];
+                                       monster_type *evil_ptr = &p_ptr->current_floor_ptr->m_list[evil_idx];
+                                       monster_type *good_ptr = &p_ptr->current_floor_ptr->m_list[good_idx];
                                        evil_ptr->target_y = good_ptr->fy;
                                        evil_ptr->target_x = good_ptr->fx;
                                        good_ptr->target_y = evil_ptr->fy;
@@ -644,10 +656,10 @@ void hit_trap(bool break_trap)
                fire_ball_hide(GF_WATER_FLOW, 0, 1, 10);
 
                /* Summon Piranhas */
-               num = 1 + current_floor_ptr->dun_level / 20;
+               num = 1 + p_ptr->current_floor_ptr->dun_level / 20;
                for (i = 0; i < num; i++)
                {
-                       (void)summon_specific(0, y, x, current_floor_ptr->dun_level, SUMMON_PIRANHAS, (PM_ALLOW_GROUP | PM_NO_PET), '\0');
+                       (void)summon_specific(0, y, x, p_ptr->current_floor_ptr->dun_level, SUMMON_PIRANHAS, (PM_ALLOW_GROUP | PM_NO_PET));
                }
                break;
        }