OSDN Git Service

[Refactor] #38862 Moved angband.h, h-*.h and system-variables.c/h
[hengband/hengband.git] / src / world / world-movement-processor.c
1 #include "system/angband.h"
2 #include "world/world-movement-processor.h"
3 #include "main/sound-definitions-table.h"
4 #include "io/write-diary.h"
5 #include "dungeon/dungeon.h"
6 #include "quest.h"
7 #include "world/world.h"
8 #include "cmd/cmd-save.h"
9 #include "player/player-move.h"
10 #include "view/display-main-window.h"
11
12 /*!
13  * @brief 10ゲームターンが進行するごとに帰還の残り時間カウントダウンと発動を処理する。
14  * / Handle involuntary movement once every 10 game turns
15  * @param creature_ptr プレーヤーへの参照ポインタ
16  * @return なし
17  * @details
18  * Autosave BEFORE resetting the recall counter (rr9)
19  * The player is yanked up/down as soon as he loads the autosaved game.
20  */
21 void execute_recall(player_type* creature_ptr)
22 {
23     if (creature_ptr->word_recall == 0)
24         return;
25
26     if (autosave_l && (creature_ptr->word_recall == 1) && !creature_ptr->phase_out)
27         do_cmd_save_game(creature_ptr, TRUE);
28
29     creature_ptr->word_recall--;
30     creature_ptr->redraw |= (PR_STATUS);
31     if (creature_ptr->word_recall != 0)
32         return;
33
34     disturb(creature_ptr, FALSE, TRUE);
35     floor_type* floor_ptr = creature_ptr->current_floor_ptr;
36     if (floor_ptr->dun_level || creature_ptr->current_floor_ptr->inside_quest || creature_ptr->enter_dungeon) {
37         msg_print(_("上に引っ張りあげられる感じがする!", "You feel yourself yanked upwards!"));
38         if (creature_ptr->dungeon_idx)
39             creature_ptr->recall_dungeon = creature_ptr->dungeon_idx;
40         if (record_stair)
41             exe_write_diary(creature_ptr, DIARY_RECALL, floor_ptr->dun_level, NULL);
42
43         floor_ptr->dun_level = 0;
44         creature_ptr->dungeon_idx = 0;
45         leave_quest_check(creature_ptr);
46         leave_tower_check(creature_ptr);
47         creature_ptr->current_floor_ptr->inside_quest = 0;
48         creature_ptr->leaving = TRUE;
49         sound(SOUND_TPLEVEL);
50         return;
51     }
52
53     msg_print(_("下に引きずり降ろされる感じがする!", "You feel yourself yanked downwards!"));
54     creature_ptr->dungeon_idx = creature_ptr->recall_dungeon;
55     if (record_stair)
56         exe_write_diary(creature_ptr, DIARY_RECALL, floor_ptr->dun_level, NULL);
57
58     floor_ptr->dun_level = max_dlv[creature_ptr->dungeon_idx];
59     if (floor_ptr->dun_level < 1)
60         floor_ptr->dun_level = 1;
61     if (ironman_nightmare && !randint0(666) && (creature_ptr->dungeon_idx == DUNGEON_ANGBAND)) {
62         if (floor_ptr->dun_level < 50) {
63             floor_ptr->dun_level *= 2;
64         } else if (floor_ptr->dun_level < 99) {
65             floor_ptr->dun_level = (floor_ptr->dun_level + 99) / 2;
66         } else if (floor_ptr->dun_level > 100) {
67             floor_ptr->dun_level = d_info[creature_ptr->dungeon_idx].maxdepth - 1;
68         }
69     }
70
71     if (creature_ptr->wild_mode) {
72         creature_ptr->wilderness_y = creature_ptr->y;
73         creature_ptr->wilderness_x = creature_ptr->x;
74     } else {
75         creature_ptr->oldpx = creature_ptr->x;
76         creature_ptr->oldpy = creature_ptr->y;
77     }
78
79     creature_ptr->wild_mode = FALSE;
80
81     /*
82     * Clear all saved floors
83     * and create a first saved floor
84     */
85     prepare_change_floor_mode(creature_ptr, CFM_FIRST_FLOOR);
86     creature_ptr->leaving = TRUE;
87
88     if (creature_ptr->dungeon_idx != DUNGEON_ANGBAND) {
89         sound(SOUND_TPLEVEL);
90         return;
91     }
92
93     for (int i = MIN_RANDOM_QUEST; i < MAX_RANDOM_QUEST + 1; i++) {
94         quest_type* const q_ptr = &quest[i];
95         if ((q_ptr->type == QUEST_TYPE_RANDOM) && (q_ptr->status == QUEST_STATUS_TAKEN) && (q_ptr->level < floor_ptr->dun_level)) {
96             q_ptr->status = QUEST_STATUS_FAILED;
97             q_ptr->complev = (byte)creature_ptr->lev;
98             update_playtime();
99             q_ptr->comptime = current_world_ptr->play_time;
100             r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
101         }
102     }
103
104     sound(SOUND_TPLEVEL);
105 }
106
107 /*!
108  * @brief 10ゲームターンが進行するごとにフロア・リセット/現実変容の残り時間カウントダウンと発動を処理する。
109  * / Handle involuntary movement once every 10 game turns
110  * @param creature_ptr プレーヤーへの参照ポインタ
111  * @return なし
112  */
113 void execute_floor_reset(player_type* creature_ptr)
114 {
115     floor_type* floor_ptr = creature_ptr->current_floor_ptr;
116     if (creature_ptr->alter_reality == 0)
117         return;
118
119     if (autosave_l && (creature_ptr->alter_reality == 1) && !creature_ptr->phase_out)
120     do_cmd_save_game(creature_ptr, TRUE);
121
122     creature_ptr->alter_reality--;
123     creature_ptr->redraw |= (PR_STATUS);
124     if (creature_ptr->alter_reality != 0)
125         return;
126
127     disturb(creature_ptr, FALSE, TRUE);
128     if (!quest_number(creature_ptr, floor_ptr->dun_level) && floor_ptr->dun_level) {
129         msg_print(_("世界が変わった!", "The world changes!"));
130
131         /*
132          * Clear all saved floors
133          * and create a first saved floor
134          */
135         prepare_change_floor_mode(creature_ptr, CFM_FIRST_FLOOR);
136         creature_ptr->leaving = TRUE;
137     } else {
138         msg_print(_("世界が少しの間変化したようだ。", "The world seems to change for a moment!"));
139     }
140
141     sound(SOUND_TPLEVEL);
142 }