1 #include "cmd-action/cmd-move.h"
2 #include "action/action-limited.h"
3 #include "action/movement-execution.h"
4 #include "action/run-execution.h"
5 #include "cmd-io/cmd-save.h"
6 #include "core/asking-player.h"
7 #include "core/disturbance.h"
8 #include "core/player-redraw-types.h"
9 #include "core/player-update-types.h"
10 #include "core/stuff-handler.h"
11 #include "dungeon/dungeon.h"
12 #include "dungeon/quest.h"
13 #include "floor/cave.h"
14 #include "floor/floor-mode-changer.h"
15 #include "floor/wild.h"
16 #include "game-option/birth-options.h"
17 #include "game-option/input-options.h"
18 #include "game-option/play-record-options.h"
19 #include "game-option/special-options.h"
20 #include "game-option/map-screen-options.h"
21 #include "grid/grid.h"
22 #include "info-reader/fixed-map-parser.h"
23 #include "io/input-key-requester.h"
24 #include "io/write-diary.h"
25 #include "mind/mind-ninja.h"
26 #include "player-info/avatar.h"
27 #include "player/attack-defense-types.h"
28 #include "player/player-move.h"
29 #include "player/special-defense-types.h"
30 #include "spell-realm/spells-hex.h"
31 #include "status/action-setter.h"
32 #include "system/floor-type-definition.h"
33 #include "system/system-variables.h"
34 #include "target/target-getter.h"
35 #include "util/bit-flags-calculator.h"
36 #include "view/display-messages.h"
39 * @brief フロア脱出時に出戻りが不可能だった場合に警告を加える処理
40 * @param down_stair TRUEならば階段を降りる処理、FALSEなら階段を昇る処理による内容
41 * @return フロア移動を実際に行うならTRUE、キャンセルする場合はFALSE
43 static bool confirm_leave_level(player_type *creature_ptr, bool down_stair)
45 quest_type *q_ptr = &quest[creature_ptr->current_floor_ptr->inside_quest];
46 if (confirm_quest && creature_ptr->current_floor_ptr->inside_quest
47 && (q_ptr->type == QUEST_TYPE_RANDOM || (q_ptr->flags & QUEST_FLAG_ONCE && q_ptr->status != QUEST_STATUS_COMPLETED)
48 || (q_ptr->flags & QUEST_FLAG_TOWER
49 && ((q_ptr->status != QUEST_STATUS_STAGE_COMPLETED) || (down_stair && (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED)))))) {
50 msg_print(_("この階を一度去ると二度と戻って来られません。", "You can't come back here once you leave this floor."));
51 return get_check(_("本当にこの階を去りますか?", "Really leave this floor? "));
58 * @brief 階段を使って階層を昇る処理 / Go up one level
61 void do_cmd_go_up(player_type *creature_ptr)
64 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x];
65 feature_type *f_ptr = &f_info[g_ptr->feat];
67 if (creature_ptr->special_defense & KATA_MUSOU)
68 set_action(creature_ptr, ACTION_NONE);
70 if (!has_flag(f_ptr->flags, FF_LESS)) {
71 msg_print(_("ここには上り階段が見当たらない。", "I see no up staircase here."));
75 if (has_flag(f_ptr->flags, FF_QUEST)) {
76 if (!confirm_leave_level(creature_ptr, FALSE))
79 if (is_echizen(creature_ptr))
80 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
82 msg_print(_("上の階に登った。", "You enter the up staircase."));
84 leave_quest_check(creature_ptr);
85 creature_ptr->current_floor_ptr->inside_quest = g_ptr->special;
86 if (!quest[creature_ptr->current_floor_ptr->inside_quest].status) {
87 if (quest[creature_ptr->current_floor_ptr->inside_quest].type != QUEST_TYPE_RANDOM) {
88 init_flags = INIT_ASSIGN;
89 parse_fixed_map(creature_ptr, "q_info.txt", 0, 0, 0, 0);
92 quest[creature_ptr->current_floor_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
95 if (!creature_ptr->current_floor_ptr->inside_quest) {
96 creature_ptr->current_floor_ptr->dun_level = 0;
97 creature_ptr->word_recall = 0;
100 creature_ptr->leaving = TRUE;
101 creature_ptr->oldpx = 0;
102 creature_ptr->oldpy = 0;
103 take_turn(creature_ptr, 100);
107 if (!is_in_dungeon(creature_ptr))
110 go_up = confirm_leave_level(creature_ptr, FALSE);
115 take_turn(creature_ptr, 100);
118 do_cmd_save_game(creature_ptr, TRUE);
120 if (creature_ptr->current_floor_ptr->inside_quest && quest[creature_ptr->current_floor_ptr->inside_quest].type == QUEST_TYPE_RANDOM) {
121 leave_quest_check(creature_ptr);
122 creature_ptr->current_floor_ptr->inside_quest = 0;
125 if (creature_ptr->current_floor_ptr->inside_quest && quest[creature_ptr->current_floor_ptr->inside_quest].type != QUEST_TYPE_RANDOM) {
126 leave_quest_check(creature_ptr);
127 creature_ptr->current_floor_ptr->inside_quest = g_ptr->special;
128 creature_ptr->current_floor_ptr->dun_level = 0;
131 if (has_flag(f_ptr->flags, FF_SHAFT)) {
132 prepare_change_floor_mode(creature_ptr, CFM_SAVE_FLOORS | CFM_UP | CFM_SHAFT);
135 prepare_change_floor_mode(creature_ptr, CFM_SAVE_FLOORS | CFM_UP);
139 if (creature_ptr->current_floor_ptr->dun_level - up_num < d_info[creature_ptr->dungeon_idx].mindepth)
140 up_num = creature_ptr->current_floor_ptr->dun_level;
144 exe_write_diary(creature_ptr, DIARY_STAIR, 0 - up_num, _("階段を上った", "climbed up the stairs to"));
146 if (is_echizen(creature_ptr))
147 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
148 else if (up_num == creature_ptr->current_floor_ptr->dun_level) {
149 msg_print(_("地上に戻った。", "You go back to the surface."));
150 creature_ptr->word_recall = 0;
153 msg_print(_("階段を上って新たなる迷宮へと足を踏み入れた。", "You enter a maze of up staircases."));
155 creature_ptr->leaving = TRUE;
159 * @brief 階段を使って階層を降りる処理 / Go down one level
160 * @param creature_ptr プレーヤーへの参照ポインタ
163 void do_cmd_go_down(player_type *creature_ptr)
165 bool fall_trap = FALSE;
167 if (creature_ptr->special_defense & KATA_MUSOU)
168 set_action(creature_ptr, ACTION_NONE);
170 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x];
171 feature_type *f_ptr = &f_info[g_ptr->feat];
172 if (!has_flag(f_ptr->flags, FF_MORE)) {
173 msg_print(_("ここには下り階段が見当たらない。", "I see no down staircase here."));
177 if (has_flag(f_ptr->flags, FF_TRAP))
180 if (has_flag(f_ptr->flags, FF_QUEST_ENTER)) {
181 do_cmd_quest(creature_ptr);
185 if (has_flag(f_ptr->flags, FF_QUEST)) {
186 if (!confirm_leave_level(creature_ptr, TRUE))
189 if (is_echizen(creature_ptr))
190 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
192 msg_print(_("下の階に降りた。", "You enter the down staircase."));
194 leave_quest_check(creature_ptr);
195 leave_tower_check(creature_ptr);
196 creature_ptr->current_floor_ptr->inside_quest = g_ptr->special;
197 if (!quest[creature_ptr->current_floor_ptr->inside_quest].status) {
198 if (quest[creature_ptr->current_floor_ptr->inside_quest].type != QUEST_TYPE_RANDOM) {
199 init_flags = INIT_ASSIGN;
200 parse_fixed_map(creature_ptr, "q_info.txt", 0, 0, 0, 0);
203 quest[creature_ptr->current_floor_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
206 if (!creature_ptr->current_floor_ptr->inside_quest) {
207 creature_ptr->current_floor_ptr->dun_level = 0;
208 creature_ptr->word_recall = 0;
211 creature_ptr->leaving = TRUE;
212 creature_ptr->oldpx = 0;
213 creature_ptr->oldpy = 0;
214 take_turn(creature_ptr, 100);
218 DUNGEON_IDX target_dungeon = 0;
219 if (!is_in_dungeon(creature_ptr)) {
220 target_dungeon = has_flag(f_ptr->flags, FF_ENTRANCE) ? g_ptr->special : DUNGEON_ANGBAND;
221 if (ironman_downward && (target_dungeon != DUNGEON_ANGBAND)) {
222 msg_print(_("ダンジョンの入口は塞がれている!", "The entrance of this dungeon is closed!"));
226 if (!max_dlv[target_dungeon]) {
227 msg_format(_("ここには%sの入り口(%d階相当)があります", "There is the entrance of %s (Danger level: %d)"), d_info[target_dungeon].name.c_str(),
228 d_info[target_dungeon].mindepth);
229 if (!get_check(_("本当にこのダンジョンに入りますか?", "Do you really get in this dungeon? ")))
233 creature_ptr->oldpx = creature_ptr->x;
234 creature_ptr->oldpy = creature_ptr->y;
235 creature_ptr->dungeon_idx = target_dungeon;
236 prepare_change_floor_mode(creature_ptr, CFM_FIRST_FLOOR);
239 take_turn(creature_ptr, 100);
241 do_cmd_save_game(creature_ptr, TRUE);
243 if (has_flag(f_ptr->flags, FF_SHAFT))
248 if (!is_in_dungeon(creature_ptr)) {
249 creature_ptr->enter_dungeon = TRUE;
250 down_num = d_info[creature_ptr->dungeon_idx].mindepth;
255 exe_write_diary(creature_ptr, DIARY_STAIR, down_num, _("落とし戸に落ちた", "fell through a trap door"));
257 exe_write_diary(creature_ptr, DIARY_STAIR, down_num, _("階段を下りた", "climbed down the stairs to"));
261 msg_print(_("わざと落とし戸に落ちた。", "You deliberately jump through the trap door."));
263 if (target_dungeon) {
264 msg_format(_("%sへ入った。", "You entered %s."), d_info[creature_ptr->dungeon_idx].text.c_str());
266 if (is_echizen(creature_ptr))
267 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
269 msg_print(_("階段を下りて新たなる迷宮へと足を踏み入れた。", "You enter a maze of down staircases."));
273 creature_ptr->leaving = TRUE;
276 prepare_change_floor_mode(creature_ptr, CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
280 if (has_flag(f_ptr->flags, FF_SHAFT))
281 prepare_change_floor_mode(creature_ptr, CFM_SAVE_FLOORS | CFM_DOWN | CFM_SHAFT);
283 prepare_change_floor_mode(creature_ptr, CFM_SAVE_FLOORS | CFM_DOWN);
287 * @brief 「歩く」動作コマンドのメインルーチン /
288 * Support code for the "Walk" and "Jump" commands
289 * @param creature_ptr プレーヤーへの参照ポインタ
290 * @param pickup アイテムの自動拾いを行うならTRUE
293 void do_cmd_walk(player_type *creature_ptr, bool pickup)
296 command_rep = command_arg - 1;
297 creature_ptr->redraw |= PR_STATE;
303 if (get_rep_dir(creature_ptr, &dir, FALSE)) {
304 take_turn(creature_ptr, 100);
305 if ((dir != 5) && (creature_ptr->special_defense & KATA_MUSOU))
306 set_action(creature_ptr, ACTION_NONE);
308 if (creature_ptr->wild_mode)
309 creature_ptr->energy_use *= ((MAX_HGT + MAX_WID) / 2);
311 if (creature_ptr->action == ACTION_HAYAGAKE)
312 creature_ptr->energy_use = creature_ptr->energy_use * (45 - (creature_ptr->lev / 2)) / 100;
314 exe_movement(creature_ptr, dir, pickup, FALSE);
318 if (creature_ptr->wild_mode && !cave_has_flag_bold(creature_ptr->current_floor_ptr, creature_ptr->y, creature_ptr->x, FF_TOWN)) {
319 int tmp = 120 + creature_ptr->lev * 10 - wilderness[creature_ptr->y][creature_ptr->x].level + 5;
323 if (((wilderness[creature_ptr->y][creature_ptr->x].level + 5) > (creature_ptr->lev / 2)) && randint0(tmp) < (21 - creature_ptr->skill_stl)) {
324 msg_print(_("襲撃だ!", "You are ambushed !"));
325 creature_ptr->oldpy = randint1(MAX_HGT - 2);
326 creature_ptr->oldpx = randint1(MAX_WID - 2);
327 change_wild_mode(creature_ptr, TRUE);
328 take_turn(creature_ptr, 100);
333 disturb(creature_ptr, FALSE, FALSE);
337 * @brief 「走る」動作コマンドのメインルーチン /
339 * @param creature_ptr プレーヤーへの参照ポインタ
342 void do_cmd_run(player_type *creature_ptr)
345 if (cmd_limit_confused(creature_ptr))
348 if (creature_ptr->special_defense & KATA_MUSOU)
349 set_action(creature_ptr, ACTION_NONE);
351 if (get_rep_dir(creature_ptr, &dir, FALSE)) {
352 creature_ptr->running = (command_arg ? command_arg : 1000);
353 run_step(creature_ptr, dir);
358 * @brief 「留まる」動作コマンドのメインルーチン /
359 * Stay still. Search. Enter stores.
360 * Pick up treasure if "pickup" is true.
361 * @param creature_ptr プレーヤーへの参照ポインタ
362 * @param pickup アイテムの自動拾いを行うならTRUE
365 void do_cmd_stay(player_type *creature_ptr, bool pickup)
367 u32b mpe_mode = MPE_STAYING | MPE_ENERGY_USE;
369 command_rep = command_arg - 1;
370 creature_ptr->redraw |= (PR_STATE);
374 take_turn(creature_ptr, 100);
376 mpe_mode |= MPE_DO_PICKUP;
378 (void)move_player_effect(creature_ptr, creature_ptr->y, creature_ptr->x, mpe_mode);
382 * @brief 「休む」動作コマンドのメインルーチン /
383 * Resting allows a player to safely restore his hp -RAK-
384 * @param creature_ptr プレーヤーへの参照ポインタ
387 void do_cmd_rest(player_type *creature_ptr)
389 set_action(creature_ptr, ACTION_NONE);
390 if ((creature_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(creature_ptr) || INTERUPTING_SONG_EFFECT(creature_ptr)))
391 stop_singing(creature_ptr);
393 if (hex_spelling_any(creature_ptr))
394 stop_hex_spell_all(creature_ptr);
396 if (command_arg <= 0) {
397 concptr p = _("休憩 (0-9999, '*' で HP/MP全快, '&' で必要なだけ): ", "Rest (0-9999, '*' for HP/SP, '&' as needed): ");
399 strcpy(out_val, "&");
400 if (!get_string(p, out_val, 4))
403 if (out_val[0] == '&') {
404 command_arg = COMMAND_ARG_REST_UNTIL_DONE;
405 } else if (out_val[0] == '*') {
406 command_arg = COMMAND_ARG_REST_FULL_HEALING;
408 command_arg = (COMMAND_ARG)atoi(out_val);
409 if (command_arg <= 0)
414 if (command_arg > 9999)
417 if (creature_ptr->special_defense & NINJA_S_STEALTH)
418 set_superstealth(creature_ptr, FALSE);
420 take_turn(creature_ptr, 100);
421 if (command_arg > 100)
422 chg_virtue(creature_ptr, V_DILIGENCE, -1);
424 if ((creature_ptr->chp == creature_ptr->mhp) && (creature_ptr->csp == creature_ptr->msp) && !creature_ptr->blind && !creature_ptr->confused
425 && !creature_ptr->poisoned && !creature_ptr->afraid && !creature_ptr->stun && !creature_ptr->cut && !creature_ptr->slow && !creature_ptr->paralyzed
426 && !creature_ptr->image && !creature_ptr->word_recall && !creature_ptr->alter_reality)
427 chg_virtue(creature_ptr, V_DILIGENCE, -1);
429 creature_ptr->resting = command_arg;
430 creature_ptr->action = ACTION_REST;
431 creature_ptr->update |= PU_BONUS;
432 creature_ptr->redraw |= (PR_STATE);
433 handle_stuff(creature_ptr);