2 * @brief キー入力に応じてゲーム内コマンドを実行する
5 * @todo Ctrl+C がShift+Q に認識されている。仕様の可能性も高いが要確認
8 #include "io/input-key-processor.h"
9 #include "autopick/autopick-pref-processor.h"
10 #include "cmd-action/cmd-hissatsu.h"
11 #include "cmd-action/cmd-mane.h"
12 #include "cmd-action/cmd-mind.h"
13 #include "cmd-action/cmd-move.h"
14 #include "cmd-action/cmd-open-close.h"
15 #include "cmd-action/cmd-others.h"
16 #include "cmd-action/cmd-pet.h"
17 #include "cmd-action/cmd-racial.h"
18 #include "cmd-action/cmd-shoot.h"
19 #include "cmd-action/cmd-spell.h"
20 #include "cmd-action/cmd-travel.h"
21 #include "cmd-action/cmd-tunnel.h"
22 #include "cmd-building/cmd-building.h"
23 #include "cmd-io/cmd-autopick.h"
24 #include "cmd-io/cmd-diary.h"
25 #include "cmd-io/cmd-dump.h"
26 #include "cmd-io/cmd-floor.h"
27 #include "cmd-io/cmd-gameoption.h"
28 #include "cmd-io/cmd-help.h"
29 #include "cmd-io/cmd-knowledge.h"
30 #include "cmd-io/cmd-lore.h"
31 #include "cmd-io/cmd-macro.h"
32 #include "cmd-io/cmd-process-screen.h"
33 #include "cmd-io/cmd-save.h"
34 #include "cmd-item/cmd-destroy.h"
35 #include "cmd-item/cmd-eat.h"
36 #include "cmd-item/cmd-equipment.h"
37 #include "cmd-item/cmd-item.h"
38 #include "cmd-item/cmd-magiceat.h"
39 #include "cmd-item/cmd-quaff.h"
40 #include "cmd-item/cmd-read.h"
41 #include "cmd-item/cmd-refill.h"
42 #include "cmd-item/cmd-smith.h"
43 #include "cmd-item/cmd-throw.h"
44 #include "cmd-item/cmd-usestaff.h"
45 #include "cmd-item/cmd-zaprod.h"
46 #include "cmd-item/cmd-zapwand.h"
47 #include "cmd-visual/cmd-draw.h"
48 #include "cmd-visual/cmd-map.h"
49 #include "cmd-visual/cmd-visuals.h"
50 #include "core/asking-player.h"
51 #include "core/player-redraw-types.h"
52 #include "core/player-update-types.h"
53 #include "core/special-internal-keys.h"
54 #include "dungeon/dungeon-flag-types.h"
55 #include "dungeon/dungeon.h"
56 #include "dungeon/quest.h" //!< @do_cmd_quest() がある。後で移設する.
57 #include "floor/wild.h"
58 #include "game-option/birth-options.h"
59 #include "game-option/disturbance-options.h"
60 #include "game-option/game-play-options.h"
61 #include "game-option/input-options.h"
62 #include "game-option/runtime-arguments.h"
63 #include "io-dump/random-art-info-dumper.h"
64 #include "io/record-play-movie.h"
65 #include "io/command-repeater.h"
66 #include "io/files-util.h"
67 #include "io/input-key-requester.h" //!< @todo 相互依存している、後で何とかする.
68 #include "io/write-diary.h"
69 #include "knowledge/knowledge-autopick.h"
70 #include "knowledge/knowledge-quests.h"
71 #include "main/sound-definitions-table.h"
72 #include "main/sound-of-music.h"
73 #include "mind/mind-blue-mage.h"
74 #include "mind/mind-elementalist.h"
75 #include "mind/mind-magic-eater.h"
76 #include "mind/mind-sniper.h"
77 #include "mind/snipe-types.h"
78 #include "player-status/player-energy.h"
79 #include "player/attack-defense-types.h"
80 #include "player/digestion-processor.h"
81 #include "player/player-class.h"
82 #include "player/player-status.h"
83 #include "player/special-defense-types.h"
84 #include "status/action-setter.h"
85 #include "store/home.h"
86 #include "store/cmd-store.h"
87 #include "store/store-util.h"
88 #include "system/floor-type-definition.h"
89 #include "system/player-type-definition.h"
90 #include "term/screen-processor.h"
91 #include "util/int-char-converter.h"
92 #include "view/display-messages.h"
93 #include "window/display-sub-windows.h"
94 #include "wizard/cmd-wizard.h"
95 #include "world/world.h"
98 * @brief ウィザードモードへの導入処理
99 * / Verify use of "wizard" mode
100 * @param player_ptr プレーヤーへの参照ポインタ
101 * @return 実際にウィザードモードへ移行したらTRUEを返す。
103 bool enter_wizard_mode(player_type *player_ptr)
105 if (!current_world_ptr->noscore) {
106 if (!allow_debug_opts || arg_wizard) {
107 msg_print(_("ウィザードモードは許可されていません。 ", "Wizard mode is not permitted."));
111 msg_print(_("ウィザードモードはデバッグと実験のためのモードです。 ", "Wizard mode is for debugging and experimenting."));
112 msg_print(_("一度ウィザードモードに入るとスコアは記録されません。", "The game will not be scored if you enter wizard mode."));
114 if (!get_check(_("本当にウィザードモードに入りたいのですか? ", "Are you sure you want to enter wizard mode? "))) {
119 player_ptr, DIARY_DESCRIPTION, 0, _("ウィザードモードに突入してスコアを残せなくなった。", "gave up recording score to enter wizard mode."));
120 current_world_ptr->noscore |= 0x0002;
127 * @brief デバッグコマンドへの導入処理
128 * / Verify use of "debug" commands
129 * @param player_ptr プレーヤーへの参照ポインタ
130 * @return 実際にデバッグコマンドへ移行したらTRUEを返す。
132 static bool enter_debug_mode(player_type *player_ptr)
134 if (!current_world_ptr->noscore) {
135 if (!allow_debug_opts) {
136 msg_print(_("デバッグコマンドは許可されていません。 ", "Use of debug command is not permitted."));
140 msg_print(_("デバッグ・コマンドはデバッグと実験のためのコマンドです。 ", "The debug commands are for debugging and experimenting."));
141 msg_print(_("デバッグ・コマンドを使うとスコアは記録されません。", "The game will not be scored if you use debug commands."));
143 if (!get_check(_("本当にデバッグ・コマンドを使いますか? ", "Are you sure you want to use debug commands? "))) {
148 player_ptr, DIARY_DESCRIPTION, 0, _("デバッグモードに突入してスコアを残せなくなった。", "gave up sending score to use debug commands."));
149 current_world_ptr->noscore |= 0x0008;
156 * @brief プレイヤーから受けた入力コマンドの分岐処理。
157 * / Parse and execute the current command Give "Warning" on illegal commands.
158 * @todo Make some "blocks"
160 void process_command(player_type *creature_ptr)
162 COMMAND_CODE old_now_message = now_message;
165 if ((creature_ptr->pclass == CLASS_SNIPER) && (creature_ptr->concent))
166 creature_ptr->reset_concent = TRUE;
168 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
169 switch (command_cmd) {
178 if (current_world_ptr->wizard) {
179 current_world_ptr->wizard = FALSE;
180 msg_print(_("ウィザードモード解除。", "Wizard mode off."));
181 } else if (enter_wizard_mode(creature_ptr)) {
182 current_world_ptr->wizard = TRUE;
183 msg_print(_("ウィザードモード突入。", "Wizard mode on."));
186 creature_ptr->update |= (PU_MONSTERS);
187 creature_ptr->redraw |= (PR_TITLE);
191 if (enter_debug_mode(creature_ptr)) {
192 do_cmd_debug(creature_ptr);
198 if (!creature_ptr->wild_mode)
199 do_cmd_wield(creature_ptr);
204 if (!creature_ptr->wild_mode)
205 do_cmd_takeoff(creature_ptr);
210 if (!creature_ptr->wild_mode)
211 do_cmd_drop(creature_ptr);
216 do_cmd_destroy(creature_ptr);
220 do_cmd_equip(creature_ptr);
224 do_cmd_inven(creature_ptr);
228 do_cmd_observe(creature_ptr);
233 toggle_inventory_equipment(creature_ptr);
237 if (!creature_ptr->wild_mode)
238 do_cmd_alter(creature_ptr);
243 if (!creature_ptr->wild_mode)
244 do_cmd_tunnel(creature_ptr);
249 do_cmd_walk(creature_ptr, FALSE);
253 do_cmd_walk(creature_ptr, TRUE);
257 if (!creature_ptr->wild_mode)
258 do_cmd_run(creature_ptr);
263 do_cmd_stay(creature_ptr, always_pickup);
267 do_cmd_stay(creature_ptr, !always_pickup);
271 do_cmd_rest(creature_ptr);
275 do_cmd_search(creature_ptr);
279 if (creature_ptr->action == ACTION_SEARCH)
280 set_action(creature_ptr, ACTION_NONE);
282 set_action(creature_ptr, ACTION_SEARCH);
286 case SPECIAL_KEY_STORE: {
287 do_cmd_store(creature_ptr);
290 case SPECIAL_KEY_BUILDING: {
291 do_cmd_building(creature_ptr);
294 case SPECIAL_KEY_QUEST: {
295 do_cmd_quest(creature_ptr);
299 if (!creature_ptr->wild_mode && !floor_ptr->dun_level && !floor_ptr->inside_arena && !floor_ptr->inside_quest) {
303 if (creature_ptr->ambush_flag) {
304 msg_print(_("襲撃から逃げるにはマップの端まで移動しなければならない。", "To flee the ambush you have to reach the edge of the map."));
308 if (creature_ptr->food < PY_FOOD_WEAK) {
309 msg_print(_("その前に食事をとらないと。", "You must eat something here."));
313 change_wild_mode(creature_ptr, FALSE);
315 do_cmd_go_up(creature_ptr);
320 if (creature_ptr->wild_mode)
321 change_wild_mode(creature_ptr, FALSE);
323 do_cmd_go_down(creature_ptr);
328 do_cmd_open(creature_ptr);
332 do_cmd_close(creature_ptr);
336 do_cmd_spike(creature_ptr);
340 do_cmd_bash(creature_ptr);
344 do_cmd_disarm(creature_ptr);
348 if (creature_ptr->pclass == CLASS_SORCERER || creature_ptr->pclass == CLASS_RED_MAGE || creature_ptr->pclass == CLASS_ELEMENTALIST)
349 msg_print(_("呪文を学習する必要はない!", "You don't have to learn spells!"));
350 else if (creature_ptr->pclass == CLASS_SAMURAI)
351 do_cmd_gain_hissatsu(creature_ptr);
352 else if (creature_ptr->pclass == CLASS_MAGIC_EATER)
353 import_magic_device(creature_ptr);
355 do_cmd_study(creature_ptr);
360 if ((creature_ptr->pclass == CLASS_MINDCRAFTER) || (creature_ptr->pclass == CLASS_BERSERKER) || (creature_ptr->pclass == CLASS_NINJA)
361 || (creature_ptr->pclass == CLASS_MIRROR_MASTER))
362 do_cmd_mind_browse(creature_ptr);
363 else if (creature_ptr->pclass == CLASS_ELEMENTALIST)
364 do_cmd_element_browse(creature_ptr);
365 else if (creature_ptr->pclass == CLASS_SMITH)
366 do_cmd_kaji(creature_ptr, TRUE);
367 else if (creature_ptr->pclass == CLASS_MAGIC_EATER)
368 do_cmd_magic_eater(creature_ptr, TRUE, FALSE);
369 else if (creature_ptr->pclass == CLASS_SNIPER)
370 do_cmd_snipe_browse(creature_ptr);
372 do_cmd_browse(creature_ptr);
377 if (creature_ptr->wild_mode) {
381 if ((creature_ptr->pclass == CLASS_WARRIOR) || (creature_ptr->pclass == CLASS_ARCHER) || (creature_ptr->pclass == CLASS_CAVALRY)) {
382 msg_print(_("呪文を唱えられない!", "You cannot cast spells!"));
386 if (floor_ptr->dun_level && d_info[creature_ptr->dungeon_idx].flags.has(DF::NO_MAGIC) && (creature_ptr->pclass != CLASS_BERSERKER)
387 && (creature_ptr->pclass != CLASS_SMITH)) {
388 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
393 if (creature_ptr->anti_magic && (creature_ptr->pclass != CLASS_BERSERKER) && (creature_ptr->pclass != CLASS_SMITH)) {
394 concptr which_power = _("魔法", "magic");
395 switch (creature_ptr->pclass) {
396 case CLASS_MINDCRAFTER:
397 which_power = _("超能力", "psionic powers");
400 which_power = _("ものまね", "imitation");
403 which_power = _("必殺剣", "hissatsu");
405 case CLASS_MIRROR_MASTER:
406 which_power = _("鏡魔法", "mirror magic");
409 which_power = _("忍術", "ninjutsu");
411 case CLASS_ELEMENTALIST:
412 which_power = _("元素魔法", "magic");
415 if (mp_ptr->spell_book == TV_LIFE_BOOK)
416 which_power = _("祈り", "prayer");
420 msg_format(_("反魔法バリアが%sを邪魔した!", "An anti-magic shell disrupts your %s!"), which_power);
421 PlayerEnergy(creature_ptr).reset_player_turn();
425 if (is_shero(creature_ptr) && (creature_ptr->pclass != CLASS_BERSERKER)) {
426 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
427 PlayerEnergy(creature_ptr).reset_player_turn();
431 if ((creature_ptr->pclass == CLASS_MINDCRAFTER) || (creature_ptr->pclass == CLASS_BERSERKER) || (creature_ptr->pclass == CLASS_NINJA)
432 || (creature_ptr->pclass == CLASS_MIRROR_MASTER))
433 do_cmd_mind(creature_ptr);
434 else if (creature_ptr->pclass == CLASS_ELEMENTALIST)
435 do_cmd_element(creature_ptr);
436 else if (creature_ptr->pclass == CLASS_IMITATOR)
437 do_cmd_mane(creature_ptr, FALSE);
438 else if (creature_ptr->pclass == CLASS_MAGIC_EATER)
439 do_cmd_magic_eater(creature_ptr, FALSE, FALSE);
440 else if (creature_ptr->pclass == CLASS_SAMURAI)
441 do_cmd_hissatsu(creature_ptr);
442 else if (creature_ptr->pclass == CLASS_BLUE_MAGE)
443 do_cmd_cast_learned(creature_ptr);
444 else if (creature_ptr->pclass == CLASS_SMITH)
445 do_cmd_kaji(creature_ptr, FALSE);
446 else if (creature_ptr->pclass == CLASS_SNIPER)
447 do_cmd_snipe(creature_ptr);
449 (void)do_cmd_cast(creature_ptr);
454 do_cmd_pet(creature_ptr);
458 do_cmd_inscribe(creature_ptr);
462 do_cmd_uninscribe(creature_ptr);
466 do_cmd_activate(creature_ptr);
470 do_cmd_eat_food(creature_ptr);
474 do_cmd_refill(creature_ptr);
478 do_cmd_fire(creature_ptr, SP_NONE);
482 do_cmd_throw(creature_ptr, 1, FALSE, -1);
486 do_cmd_aim_wand(creature_ptr);
490 if (use_command && rogue_like_commands) {
491 do_cmd_use(creature_ptr);
493 do_cmd_zap_rod(creature_ptr);
499 do_cmd_quaff_potion(creature_ptr);
503 do_cmd_read_scroll(creature_ptr);
507 if (use_command && !rogue_like_commands)
508 do_cmd_use(creature_ptr);
510 do_cmd_use_staff(creature_ptr);
515 do_cmd_racial_power(creature_ptr);
519 do_cmd_view_map(creature_ptr);
523 do_cmd_locate(creature_ptr);
527 do_cmd_look(creature_ptr);
531 do_cmd_target(creature_ptr);
535 do_cmd_help(creature_ptr);
539 do_cmd_query_symbol(creature_ptr);
543 do_cmd_player_status(creature_ptr);
551 do_cmd_pref(creature_ptr);
555 do_cmd_reload_autopick(creature_ptr);
559 do_cmd_edit_autopick(creature_ptr);
563 do_cmd_macros(creature_ptr);
567 do_cmd_visuals(creature_ptr);
568 do_cmd_redraw(creature_ptr);
572 do_cmd_colors(creature_ptr);
573 do_cmd_redraw(creature_ptr);
577 do_cmd_options(creature_ptr);
578 (void)combine_and_reorder_home(creature_ptr, STORE_HOME);
579 do_cmd_redraw(creature_ptr);
591 do_cmd_feeling(creature_ptr);
595 do_cmd_message_one();
599 do_cmd_messages(old_now_message);
603 do_cmd_checkquest(creature_ptr);
607 now_message = old_now_message;
608 do_cmd_redraw(creature_ptr);
612 do_cmd_save_game(creature_ptr, FALSE);
616 do_cmd_time(creature_ptr);
620 case SPECIAL_KEY_QUIT: {
621 do_cmd_save_and_exit(creature_ptr);
625 do_cmd_suicide(creature_ptr);
629 do_cmd_diary(creature_ptr);
633 do_cmd_knowledge(creature_ptr);
637 do_cmd_load_screen();
641 do_cmd_save_screen(creature_ptr);
645 prepare_movie_hooks(creature_ptr);
649 spoil_random_artifact(creature_ptr, "randifact.txt");
653 if (!creature_ptr->wild_mode)
654 do_cmd_travel(creature_ptr);
655 if (creature_ptr->special_defense & KATA_MUSOU) {
656 set_action(creature_ptr, ACTION_NONE);
666 sound(SOUND_ILLEGAL);
667 if (!get_rnd_line(_("error_j.txt", "error.txt"), 0, error_m))
670 prt(_(" '?' でヘルプが表示されます。", "Type '?' for help."), 0, 0);
677 if (!creature_ptr->energy_use && !now_message)
678 now_message = old_now_message;