1 #include "dungeon/dungeon-processor.h"
2 #include "cmd-building/cmd-building.h"
3 #include "cmd-io/cmd-dump.h"
4 #include "core/hp-mp-regenerator.h"
5 #include "core/player-processor.h"
6 #include "core/stuff-handler.h"
7 #include "core/turn-compensator.h"
8 #include "dungeon/dungeon.h"
9 #include "dungeon/quest.h"
10 #include "floor/floor-save.h"
11 #include "game-option/map-screen-options.h"
12 #include "game-option/play-record-options.h"
13 #include "io/input-key-requester.h"
14 #include "io/targeting.h"
15 #include "io/write-diary.h"
16 #include "market/arena.h"
17 #include "monster-race/monster-race.h"
18 #include "monster-race/race-flags1.h"
19 #include "monster/monster-compaction.h"
20 #include "monster/monster-processor.h"
21 #include "monster/monster-status.h"
22 #include "monster/monster-util.h"
23 #include "player/player-effects.h"
24 #include "player/player-move.h"
25 #include "realm/realm-song-numbers.h"
26 #include "realm/realm-song.h"
27 #include "view/display-main-window.h"
28 #include "view/display-messages.h"
29 #include "world/world-turn-processor.h"
30 #include "world/world.h"
33 * process_player()、process_world() をcore.c から移設するのが先.
34 * process_upkeep_with_speed() はこの関数と同じところでOK
35 * @brief 現在プレイヤーがいるダンジョンの全体処理 / Interact with the current dungeon level.
39 * この関数から現在の階層を出る、プレイヤーがキャラが死ぬ、
40 * ゲームを終了するかのいずれかまでループする。
43 * This function will not exit until the level is completed,\n
44 * the user dies, or the game is terminated.\n
47 void process_dungeon(player_type *player_ptr, bool load_game)
49 floor_type *floor_ptr = player_ptr->current_floor_ptr;
50 floor_ptr->base_level = floor_ptr->dun_level;
51 current_world_ptr->is_loading_now = FALSE;
52 player_ptr->leaving = FALSE;
60 player_ptr->pet_t_m_idx = 0;
61 player_ptr->riding_t_m_idx = 0;
62 player_ptr->ambush_flag = FALSE;
63 health_track(player_ptr, 0);
64 repair_monsters = TRUE;
66 disturb(player_ptr, TRUE, TRUE);
67 int quest_num = quest_num = quest_number(player_ptr, floor_ptr->dun_level);
69 r_info[quest[quest_num].r_idx].flags1 |= RF1_QUESTOR;
72 if (player_ptr->max_plv < player_ptr->lev) {
73 player_ptr->max_plv = player_ptr->lev;
76 if ((max_dlv[player_ptr->dungeon_idx] < floor_ptr->dun_level) && !floor_ptr->inside_quest) {
77 max_dlv[player_ptr->dungeon_idx] = floor_ptr->dun_level;
79 exe_write_diary(player_ptr, DIARY_MAXDEAPTH, floor_ptr->dun_level, NULL);
82 (void)calculate_upkeep(player_ptr);
83 panel_bounds_center();
84 verify_panel(player_ptr);
87 current_world_ptr->character_xtra = TRUE;
88 player_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER | PW_MONSTER | PW_OVERHEAD | PW_DUNGEON);
89 player_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_EQUIPPY | PR_MAP);
90 player_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS | PU_VIEW | PU_LITE | PU_MON_LITE | PU_TORCH | PU_MONSTERS | PU_DISTANCE | PU_FLOW);
91 handle_stuff(player_ptr);
93 current_world_ptr->character_xtra = FALSE;
94 player_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
95 player_ptr->update |= (PU_COMBINE | PU_REORDER);
96 handle_stuff(player_ptr);
100 && (is_fixed_quest_idx(quest_num) && !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) || !(quest[quest_num].flags & QUEST_FLAG_PRESET))))
101 do_cmd_feeling(player_ptr);
103 if (player_ptr->phase_out) {
105 player_ptr->energy_need = 0;
106 update_gambling_monsters(player_ptr);
108 msg_print(_("試合開始!", "Ready..Fight!"));
113 if ((player_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(player_ptr) > MUSIC_DETECT))
114 SINGING_SONG_EFFECT(player_ptr) = MUSIC_DETECT;
116 if (!player_ptr->playing || player_ptr->is_dead)
119 if (!floor_ptr->inside_quest && (player_ptr->dungeon_idx == DUNGEON_ANGBAND)) {
120 quest_discovery(random_quest_number(player_ptr, floor_ptr->dun_level));
121 floor_ptr->inside_quest = random_quest_number(player_ptr, floor_ptr->dun_level);
123 if ((floor_ptr->dun_level == d_info[player_ptr->dungeon_idx].maxdepth) && d_info[player_ptr->dungeon_idx].final_guardian) {
124 if (r_info[d_info[player_ptr->dungeon_idx].final_guardian].max_num)
126 msg_format("この階には%sの主である%sが棲んでいる。", d_name + d_info[player_ptr->dungeon_idx].name,
127 r_name + r_info[d_info[player_ptr->dungeon_idx].final_guardian].name);
129 msg_format("%^s lives in this level as the keeper of %s.", r_name + r_info[d_info[player_ptr->dungeon_idx].final_guardian].name,
130 d_name + d_info[player_ptr->dungeon_idx].name);
134 if (!load_game && (player_ptr->special_defense & NINJA_S_STEALTH))
135 set_superstealth(player_ptr, FALSE);
137 floor_ptr->monster_level = floor_ptr->base_level;
138 floor_ptr->object_level = floor_ptr->base_level;
139 current_world_ptr->is_loading_now = TRUE;
140 if (player_ptr->energy_need > 0 && !player_ptr->phase_out && (floor_ptr->dun_level || player_ptr->leaving_dungeon || floor_ptr->inside_arena))
141 player_ptr->energy_need = 0;
143 player_ptr->leaving_dungeon = FALSE;
144 mproc_init(floor_ptr);
147 if ((floor_ptr->m_cnt + 32 > current_world_ptr->max_m_idx) && !player_ptr->phase_out)
148 compact_monsters(player_ptr, 64);
150 if ((floor_ptr->m_cnt + 32 < floor_ptr->m_max) && !player_ptr->phase_out)
151 compact_monsters(player_ptr, 0);
153 if (floor_ptr->o_cnt + 32 > current_world_ptr->max_o_idx)
154 compact_objects(player_ptr, 64);
156 if (floor_ptr->o_cnt + 32 < floor_ptr->o_max)
157 compact_objects(player_ptr, 0);
159 process_player(player_ptr);
160 process_upkeep_with_speed(player_ptr);
161 handle_stuff(player_ptr);
163 move_cursor_relative(player_ptr->y, player_ptr->x);
167 if (!player_ptr->playing || player_ptr->is_dead)
170 process_monsters(player_ptr);
171 handle_stuff(player_ptr);
173 move_cursor_relative(player_ptr->y, player_ptr->x);
177 if (!player_ptr->playing || player_ptr->is_dead)
180 process_world(player_ptr);
181 handle_stuff(player_ptr);
183 move_cursor_relative(player_ptr->y, player_ptr->x);
187 if (!player_ptr->playing || player_ptr->is_dead)
190 current_world_ptr->game_turn++;
191 if (current_world_ptr->dungeon_turn < current_world_ptr->dungeon_turn_limit) {
192 if (!player_ptr->wild_mode || wild_regen)
193 current_world_ptr->dungeon_turn++;
194 else if (player_ptr->wild_mode && !(current_world_ptr->game_turn % ((MAX_HGT + MAX_WID) / 2)))
195 current_world_ptr->dungeon_turn++;
198 prevent_turn_overflow(player_ptr);
200 if (player_ptr->leaving)
207 if (quest_num && !(r_info[quest[quest_num].r_idx].flags1 & RF1_UNIQUE)) {
208 r_info[quest[quest_num].r_idx].flags1 &= ~RF1_QUESTOR;
211 if (player_ptr->playing && !player_ptr->is_dead) {
213 * Maintain Unique monsters and artifact, save current
214 * floor, then prepare next floor
216 leave_floor(player_ptr);
217 reinit_wilderness = FALSE;