1 #include "dungeon/dungeon-processor.h"
2 #include "cmd-building/cmd-building.h"
3 #include "cmd-io/cmd-dump.h"
4 #include "core/disturbance.h"
5 #include "core/hp-mp-regenerator.h"
6 #include "core/player-processor.h"
7 #include "core/player-redraw-types.h"
8 #include "core/player-update-types.h"
9 #include "core/stuff-handler.h"
10 #include "core/turn-compensator.h"
11 #include "core/window-redrawer.h"
12 #include "dungeon/dungeon.h"
13 #include "dungeon/quest.h"
14 #include "floor/floor-save-util.h"
15 #include "floor/floor-save.h"
16 #include "floor/floor.h"
17 #include "game-option/map-screen-options.h"
18 #include "game-option/play-record-options.h"
19 #include "io/cursor.h"
20 #include "io/input-key-requester.h"
21 #include "io/write-diary.h"
22 #include "market/arena.h"
23 #include "mind/mind-ninja.h"
24 #include "monster-race/monster-race.h"
25 #include "monster-race/race-flags1.h"
26 #include "monster/monster-compaction.h"
27 #include "monster/monster-processor.h"
28 #include "monster/monster-status.h"
29 #include "monster/monster-util.h"
30 #include "player/special-defense-types.h"
31 #include "realm/realm-song-numbers.h"
32 #include "realm/realm-song.h"
33 #include "system/floor-type-definition.h"
34 #include "target/target-checker.h"
35 #include "view/display-messages.h"
36 #include "world/world-turn-processor.h"
37 #include "world/world.h"
40 * process_player()、process_world() をcore.c から移設するのが先.
41 * process_upkeep_with_speed() はこの関数と同じところでOK
42 * @brief 現在プレイヤーがいるダンジョンの全体処理 / Interact with the current dungeon level.
46 * この関数から現在の階層を出る、プレイヤーがキャラが死ぬ、
47 * ゲームを終了するかのいずれかまでループする。
50 * This function will not exit until the level is completed,\n
51 * the user dies, or the game is terminated.\n
54 void process_dungeon(player_type *player_ptr, bool load_game)
56 floor_type *floor_ptr = player_ptr->current_floor_ptr;
57 floor_ptr->base_level = floor_ptr->dun_level;
58 current_world_ptr->is_loading_now = FALSE;
59 player_ptr->leaving = FALSE;
67 player_ptr->pet_t_m_idx = 0;
68 player_ptr->riding_t_m_idx = 0;
69 player_ptr->ambush_flag = FALSE;
70 health_track(player_ptr, 0);
71 repair_monsters = TRUE;
73 disturb(player_ptr, TRUE, TRUE);
74 int quest_num = quest_num = quest_number(player_ptr, floor_ptr->dun_level);
76 r_info[quest[quest_num].r_idx].flags1 |= RF1_QUESTOR;
79 if (player_ptr->max_plv < player_ptr->lev) {
80 player_ptr->max_plv = player_ptr->lev;
83 if ((max_dlv[player_ptr->dungeon_idx] < floor_ptr->dun_level) && !floor_ptr->inside_quest) {
84 max_dlv[player_ptr->dungeon_idx] = floor_ptr->dun_level;
86 exe_write_diary(player_ptr, DIARY_MAXDEAPTH, floor_ptr->dun_level, NULL);
89 (void)calculate_upkeep(player_ptr);
90 panel_bounds_center();
91 verify_panel(player_ptr);
94 current_world_ptr->character_xtra = TRUE;
95 player_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER | PW_MONSTER | PW_OVERHEAD | PW_DUNGEON);
96 player_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_EQUIPPY | PR_MAP);
97 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);
98 handle_stuff(player_ptr);
100 current_world_ptr->character_xtra = FALSE;
101 player_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
102 player_ptr->update |= (PU_COMBINE | PU_REORDER);
103 handle_stuff(player_ptr);
107 && (is_fixed_quest_idx(quest_num) && !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) || !(quest[quest_num].flags & QUEST_FLAG_PRESET))))
108 do_cmd_feeling(player_ptr);
110 if (player_ptr->phase_out) {
112 player_ptr->energy_need = 0;
113 update_gambling_monsters(player_ptr);
115 msg_print(_("試合開始!", "Ready..Fight!"));
120 if ((player_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(player_ptr) > MUSIC_DETECT))
121 SINGING_SONG_EFFECT(player_ptr) = MUSIC_DETECT;
123 if (!player_ptr->playing || player_ptr->is_dead)
126 if (!floor_ptr->inside_quest && (player_ptr->dungeon_idx == DUNGEON_ANGBAND)) {
127 quest_discovery(random_quest_number(player_ptr, floor_ptr->dun_level));
128 floor_ptr->inside_quest = random_quest_number(player_ptr, floor_ptr->dun_level);
130 if ((floor_ptr->dun_level == d_info[player_ptr->dungeon_idx].maxdepth) && d_info[player_ptr->dungeon_idx].final_guardian) {
131 if (r_info[d_info[player_ptr->dungeon_idx].final_guardian].max_num)
133 msg_format("この階には%sの主である%sが棲んでいる。", d_name + d_info[player_ptr->dungeon_idx].name,
134 r_name + r_info[d_info[player_ptr->dungeon_idx].final_guardian].name);
136 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,
137 d_name + d_info[player_ptr->dungeon_idx].name);
141 if (!load_game && (player_ptr->special_defense & NINJA_S_STEALTH))
142 set_superstealth(player_ptr, FALSE);
144 floor_ptr->monster_level = floor_ptr->base_level;
145 floor_ptr->object_level = floor_ptr->base_level;
146 current_world_ptr->is_loading_now = TRUE;
147 if (player_ptr->energy_need > 0 && !player_ptr->phase_out && (floor_ptr->dun_level || player_ptr->leaving_dungeon || floor_ptr->inside_arena))
148 player_ptr->energy_need = 0;
150 player_ptr->leaving_dungeon = FALSE;
151 mproc_init(floor_ptr);
154 if ((floor_ptr->m_cnt + 32 > current_world_ptr->max_m_idx) && !player_ptr->phase_out)
155 compact_monsters(player_ptr, 64);
157 if ((floor_ptr->m_cnt + 32 < floor_ptr->m_max) && !player_ptr->phase_out)
158 compact_monsters(player_ptr, 0);
160 if (floor_ptr->o_cnt + 32 > current_world_ptr->max_o_idx)
161 compact_objects(player_ptr, 64);
163 if (floor_ptr->o_cnt + 32 < floor_ptr->o_max)
164 compact_objects(player_ptr, 0);
166 process_player(player_ptr);
167 process_upkeep_with_speed(player_ptr);
168 handle_stuff(player_ptr);
170 move_cursor_relative(player_ptr->y, player_ptr->x);
174 if (!player_ptr->playing || player_ptr->is_dead)
177 process_monsters(player_ptr);
178 handle_stuff(player_ptr);
180 move_cursor_relative(player_ptr->y, player_ptr->x);
184 if (!player_ptr->playing || player_ptr->is_dead)
187 process_world(player_ptr);
188 handle_stuff(player_ptr);
190 move_cursor_relative(player_ptr->y, player_ptr->x);
194 if (!player_ptr->playing || player_ptr->is_dead)
197 current_world_ptr->game_turn++;
198 if (current_world_ptr->dungeon_turn < current_world_ptr->dungeon_turn_limit) {
199 if (!player_ptr->wild_mode || wild_regen)
200 current_world_ptr->dungeon_turn++;
201 else if (player_ptr->wild_mode && !(current_world_ptr->game_turn % ((MAX_HGT + MAX_WID) / 2)))
202 current_world_ptr->dungeon_turn++;
205 prevent_turn_overflow(player_ptr);
207 if (player_ptr->leaving)
214 if (quest_num && !(r_info[quest[quest_num].r_idx].flags1 & RF1_UNIQUE)) {
215 r_info[quest[quest_num].r_idx].flags1 &= ~RF1_QUESTOR;
218 if (player_ptr->playing && !player_ptr->is_dead) {
220 * Maintain Unique monsters and artifact, save current
221 * floor, then prepare next floor
223 leave_floor(player_ptr);
224 reinit_wilderness = FALSE;