OSDN Git Service

[Refactor] #37353 wreck_the_pattern() to player-status.c.
[hengband/hengband.git] / src / dungeon.c
index 76cd096..0ad8256 100644 (file)
@@ -35,6 +35,7 @@
 #include "quest.h"
 #include "artifact.h"
 #include "avatar.h"
+#include "player-move.h"
 #include "player-status.h"
 #include "cmd-spell.h"
 #include "realm-hex.h"
@@ -610,42 +611,6 @@ static void pattern_teleport(void)
 }
 
 /*!
- * @brief 種族アンバライトが出血時パターンの上に乗った際のペナルティ処理
- * @return なし
- */
-static void wreck_the_pattern(void)
-{
-       int to_ruin = 0;
-       POSITION r_y, r_x;
-       int pattern_type = f_info[current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].feat].subtype;
-
-       if (pattern_type == PATTERN_TILE_WRECKED)
-       {
-               /* Ruined already */
-               return;
-       }
-
-       msg_print(_("パターンを血で汚してしまった!", "You bleed on the Pattern!"));
-       msg_print(_("何か恐ろしい事が起こった!", "Something terrible happens!"));
-
-       if (!IS_INVULN()) take_hit(DAMAGE_NOESCAPE, damroll(10, 8), _("パターン損壊", "corrupting the Pattern"), -1);
-       to_ruin = randint1(45) + 35;
-
-       while (to_ruin--)
-       {
-               scatter(&r_y, &r_x, p_ptr->y, p_ptr->x, 4, 0);
-
-               if (pattern_tile(r_y, r_x) &&
-                   (f_info[current_floor_ptr->grid_array[r_y][r_x].feat].subtype != PATTERN_TILE_WRECKED))
-               {
-                       cave_set_feat(r_y, r_x, feat_pattern_corrupted);
-               }
-       }
-
-       cave_set_feat(p_ptr->y, p_ptr->x, feat_pattern_corrupted);
-}
-
-/*!
  * @brief 各種パターン地形上の特別な処理 / Returns TRUE if we are on the Pattern...
  * @return 実際にパターン地形上にプレイヤーが居た場合はTRUEを返す。
  */
@@ -1041,81 +1006,6 @@ static void notice_lite_change(object_type *o_ptr)
        }
 }
 
-/*!
- * @brief クエスト階層から離脱する際の処理
- * @return なし
- */
-void leave_quest_check(void)
-{
-       /* Save quest number for dungeon pref file ($LEAVING_QUEST) */
-       leaving_quest = p_ptr->inside_quest;
-
-       /* Leaving an 'only once' quest marks it as failed */
-       if (leaving_quest)
-       {       
-               quest_type* const q_ptr = &quest[leaving_quest];
-               
-           if(((q_ptr->flags & QUEST_FLAG_ONCE)  || (q_ptr->type == QUEST_TYPE_RANDOM)) &&
-              (q_ptr->status == QUEST_STATUS_TAKEN))
-               {
-                       q_ptr->status = QUEST_STATUS_FAILED;
-                       q_ptr->complev = p_ptr->lev;
-                       update_playtime();
-                       q_ptr->comptime = playtime;
-
-                       /* Additional settings */
-                       switch (q_ptr->type)
-                       {
-                         case QUEST_TYPE_TOWER:
-                               quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
-                               quest[QUEST_TOWER1].complev = p_ptr->lev;
-                               break;
-                         case QUEST_TYPE_FIND_ARTIFACT:
-                               a_info[q_ptr->k_idx].gen_flags &= ~(TRG_QUESTITEM);
-                               break;
-                         case QUEST_TYPE_RANDOM:
-                               r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
-
-                               /* Floor of random quest will be blocked */
-                               prepare_change_floor_mode(CFM_NO_RETURN);
-                               break;
-                       }
-
-                       /* Record finishing a quest */
-                       if (q_ptr->type == QUEST_TYPE_RANDOM)
-                       {
-                               if (record_rand_quest) do_cmd_write_nikki(NIKKI_RAND_QUEST_F, leaving_quest, NULL);
-                       }
-                       else
-                       {
-                               if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_F, leaving_quest, NULL);
-                       }
-               }
-       }
-}
-
-/*!
- * @brief 「塔」クエストの各階層から離脱する際の処理
- * @return なし
- */
-void leave_tower_check(void)
-{
-       leaving_quest = p_ptr->inside_quest;
-       /* Check for Tower Quest */
-       if (leaving_quest &&
-               (quest[leaving_quest].type == QUEST_TYPE_TOWER) &&
-               (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))
-       {
-               if(quest[leaving_quest].type == QUEST_TYPE_TOWER)
-               {
-                       quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
-                       quest[QUEST_TOWER1].complev = p_ptr->lev;
-                       update_playtime();
-                       quest[QUEST_TOWER1].comptime = playtime;
-               }
-       }
-}
-
 
 /*!
  * @brief !!を刻んだ魔道具の時間経過による再充填を知らせる処理 / If player has inscribed the object with "!!", let him know when it's recharged. -LM-
@@ -1824,7 +1714,7 @@ static void process_world_aux_hp_and_sp(void)
        /* Special floor -- Pattern, in a wall -- yields no healing */
        if (cave_no_regen) regen_amount = 0;
 
-       regen_amount = (regen_amount * mutant_regenerate_mod) / 100;
+       regen_amount = (regen_amount * p_ptr->mutant_regenerate_mod) / 100;
 
        /* Regenerate Hit Points if needed */
        if ((p_ptr->chp < p_ptr->mhp) && !cave_no_regen)
@@ -3087,7 +2977,7 @@ static void process_world_aux_movement(void)
                                                        q_ptr->status = QUEST_STATUS_FAILED;
                                                        q_ptr->complev = (byte)p_ptr->lev;
                                                        update_playtime();
-                                                       q_ptr->comptime = playtime;
+                                                       q_ptr->comptime = current_world_ptr->play_time;
                                                        r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
                                                }
                                        }
@@ -3450,7 +3340,7 @@ static void process_world(void)
                        p_ptr->energy_need = 0;
                        battle_monsters();
                }
-               else if (current_world_ptr->game_turn - old_turn == 150 * TURNS_PER_TICK)
+               else if (current_world_ptr->game_turn - current_floor_ptr->generated_turn == 150 * TURNS_PER_TICK)
                {
                        msg_print(_("申し分けありませんが、この勝負は引き分けとさせていただきます。", "This battle have ended in a draw."));
                        p_ptr->au += kakekin;
@@ -4731,7 +4621,7 @@ static void process_player(void)
        {
                msg_print(_("何か変わった気がする!", "You feel different!"));
 
-               (void)gain_random_mutation(0);
+               (void)gain_mutation(p_ptr, 0);
                hack_mutation = FALSE;
        }
 
@@ -4769,10 +4659,10 @@ static void process_player(void)
        /*** Check for interupts ***/
 
        /* Complete resting */
-       if (resting < 0)
+       if (p_ptr->resting < 0)
        {
                /* Basic resting */
-               if (resting == COMMAND_ARG_REST_FULL_HEALING)
+               if (p_ptr->resting == COMMAND_ARG_REST_FULL_HEALING)
                {
                        /* Stop resting */
                        if ((p_ptr->chp == p_ptr->mhp) &&
@@ -4783,7 +4673,7 @@ static void process_player(void)
                }
 
                /* Complete resting */
-               else if (resting == COMMAND_ARG_REST_UNTIL_DONE)
+               else if (p_ptr->resting == COMMAND_ARG_REST_UNTIL_DONE)
                {
                        /* Stop resting */
                        if ((p_ptr->chp == p_ptr->mhp) &&
@@ -4968,7 +4858,7 @@ static void process_player(void)
                p_ptr->window |= PW_PLAYER;
                p_ptr->sutemi = FALSE;
                p_ptr->counter = FALSE;
-               now_damaged = FALSE;
+               p_ptr->now_damaged = FALSE;
 
                handle_stuff();
 
@@ -5008,12 +4898,12 @@ static void process_player(void)
                else if (p_ptr->action == ACTION_REST)
                {
                        /* Timed rest */
-                       if (resting > 0)
+                       if (p_ptr->resting > 0)
                        {
                                /* Reduce rest count */
-                               resting--;
+                               p_ptr->resting--;
 
-                               if (!resting) set_action(ACTION_NONE);
+                               if (!p_ptr->resting) set_action(ACTION_NONE);
                                p_ptr->redraw |= (PR_STATE);
                        }
 
@@ -5498,7 +5388,7 @@ static void dungeon(bool load_game)
                /* Count game turns */
                current_world_ptr->game_turn++;
 
-               if (current_world_ptr->dungeon_turn < dungeon_turn_limit)
+               if (current_world_ptr->dungeon_turn < current_world_ptr->dungeon_turn_limit)
                {
                        if (!p_ptr->wild_mode || wild_regen) current_world_ptr->dungeon_turn++;
                        else if (p_ptr->wild_mode && !(current_world_ptr->game_turn % ((MAX_HGT + MAX_WID) / 2))) current_world_ptr->dungeon_turn++;
@@ -5651,8 +5541,8 @@ void determine_bounty_uniques(void)
        {
                while (1)
                {
-                       kubi_r_idx[i] = get_mon_num(MAX_DEPTH - 1);
-                       r_ptr = &r_info[kubi_r_idx[i]];
+                       current_world_ptr->bounty_r_idx[i] = get_mon_num(MAX_DEPTH - 1);
+                       r_ptr = &r_info[current_world_ptr->bounty_r_idx[i]];
 
                        if (!(r_ptr->flags1 & RF1_UNIQUE)) continue;
 
@@ -5660,10 +5550,10 @@ void determine_bounty_uniques(void)
 
                        if (r_ptr->rarity > 100) continue;
 
-                       if (no_questor_or_bounty_uniques(kubi_r_idx[i])) continue;
+                       if (no_questor_or_bounty_uniques(current_world_ptr->bounty_r_idx[i])) continue;
 
                        for (j = 0; j < i; j++)
-                               if (kubi_r_idx[i] == kubi_r_idx[j]) break;
+                               if (current_world_ptr->bounty_r_idx[i] == current_world_ptr->bounty_r_idx[j]) break;
 
                        if (j == i) break;
                }
@@ -5674,11 +5564,11 @@ void determine_bounty_uniques(void)
        {
                for (j = i; j < MAX_KUBI; j++)
                {
-                       if (r_info[kubi_r_idx[i]].level > r_info[kubi_r_idx[j]].level)
+                       if (r_info[current_world_ptr->bounty_r_idx[i]].level > r_info[current_world_ptr->bounty_r_idx[j]].level)
                        {
-                               tmp = kubi_r_idx[i];
-                               kubi_r_idx[i] = kubi_r_idx[j];
-                               kubi_r_idx[j] = tmp;
+                               tmp = current_world_ptr->bounty_r_idx[i];
+                               current_world_ptr->bounty_r_idx[i] = current_world_ptr->bounty_r_idx[j];
+                               current_world_ptr->bounty_r_idx[j] = tmp;
                        }
                }
        }
@@ -5955,8 +5845,8 @@ void play_game(bool new_game)
 
        p_ptr->teleport_town = FALSE;
        p_ptr->sutemi = FALSE;
-       world_monster = FALSE;
-       now_damaged = FALSE;
+       current_world_ptr->timewalk_m_idx = 0;
+       p_ptr->now_damaged = FALSE;
        now_message = 0;
        start_time = time(NULL) - 1;
        record_o_name[0] = '\0';
@@ -6235,8 +6125,8 @@ void prevent_turn_overflow(void)
 
        if (current_world_ptr->game_turn > rollback_turns) current_world_ptr->game_turn -= rollback_turns;
        else current_world_ptr->game_turn = 1; /* Paranoia */
-       if (old_turn > rollback_turns) old_turn -= rollback_turns;
-       else old_turn = 1;
+       if (current_floor_ptr->generated_turn > rollback_turns) current_floor_ptr->generated_turn -= rollback_turns;
+       else current_floor_ptr->generated_turn = 1;
        if (old_battle > rollback_turns) old_battle -= rollback_turns;
        else old_battle = 1;
        if (p_ptr->feeling_turn > rollback_turns) p_ptr->feeling_turn -= rollback_turns;