3 * @brief プレイヤーのコマンド処理2 / Movement commands (part 2)
6 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
8 * This software may be copied and distributed for educational, research,
9 * and not for profit purposes provided that this copyright and statement
10 * are included in all such copies. Other copyrights may also apply.
15 #include "object-hook.h"
18 * @brief フロア脱出時に出戻りが不可能だった場合に警告を加える処理
19 * @param down_stair TRUEならば階段を降りる処理、FALSEなら階段を昇る処理による内容
20 * @return フロア移動を実際に行うならTRUE、キャンセルする場合はFALSE
22 bool confirm_leave_level(bool down_stair)
24 quest_type *q_ptr = &quest[p_ptr->inside_quest];
26 /* Confirm leaving from once only quest */
27 if (confirm_quest && p_ptr->inside_quest &&
28 (q_ptr->type == QUEST_TYPE_RANDOM ||
29 (q_ptr->flags & QUEST_FLAG_ONCE &&
30 q_ptr->status != QUEST_STATUS_COMPLETED) ||
31 (q_ptr->flags & QUEST_FLAG_TOWER &&
32 ((q_ptr->status != QUEST_STATUS_STAGE_COMPLETED) ||
33 (down_stair && (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))))))
35 msg_print(_("この階を一度去ると二度と戻って来られません。", "You can't come back here once you leave this floor."));
36 if (get_check(_("本当にこの階を去りますか?", "Really leave this floor? "))) return TRUE;
46 * @brief 階段を使って階層を昇る処理 / Go up one level
49 void do_cmd_go_up(void)
54 cave_type *c_ptr = &cave[p_ptr->y][p_ptr->x];
55 feature_type *f_ptr = &f_info[c_ptr->feat];
59 if (p_ptr->special_defense & KATA_MUSOU)
61 set_action(ACTION_NONE);
65 if (!have_flag(f_ptr->flags, FF_LESS))
67 msg_print(_("ここには上り階段が見当たらない。", "I see no up staircase here."));
72 if (have_flag(f_ptr->flags, FF_QUEST))
74 /* Cancel the command */
75 if (!confirm_leave_level(FALSE)) return;
79 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
80 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
82 msg_print(_("上の階に登った。", "You enter the up staircase."));
86 p_ptr->inside_quest = c_ptr->special;
88 /* Activate the quest */
89 if (!quest[p_ptr->inside_quest].status)
91 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
93 init_flags = INIT_ASSIGN;
94 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
96 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
100 if (!p_ptr->inside_quest)
106 p_ptr->leaving = TRUE;
111 /* Hack -- take a turn */
112 p_ptr->energy_use = 100;
114 /* End the command */
124 go_up = confirm_leave_level(FALSE);
127 /* Cancel the command */
130 /* Hack -- take a turn */
131 p_ptr->energy_use = 100;
133 if (autosave_l) do_cmd_save_game(TRUE);
135 /* For a random quest */
136 if (p_ptr->inside_quest &&
137 quest[p_ptr->inside_quest].type == QUEST_TYPE_RANDOM)
141 p_ptr->inside_quest = 0;
144 /* For a fixed quest */
145 if (p_ptr->inside_quest &&
146 quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
150 p_ptr->inside_quest = c_ptr->special;
155 /* For normal dungeon and random quest */
159 if (have_flag(f_ptr->flags, FF_SHAFT))
161 /* Create a way back */
162 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_SHAFT);
168 /* Create a way back */
169 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP);
174 /* Get out from current dungeon */
175 if (dun_level - up_num < d_info[dungeon_type].mindepth)
178 if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, _("階段を上った", "climbed up the stairs to"));
181 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
182 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
183 else if (up_num == dun_level)
184 msg_print(_("地上に戻った。", "You go back to the surface."));
186 msg_print(_("階段を上って新たなる迷宮へと足を踏み入れた。", "You enter a maze of up staircases."));
189 p_ptr->leaving = TRUE;
194 * @brief 階段を使って階層を降りる処理 / Go down one level
197 void do_cmd_go_down(void)
200 cave_type *c_ptr = &cave[p_ptr->y][p_ptr->x];
201 feature_type *f_ptr = &f_info[c_ptr->feat];
203 bool fall_trap = FALSE;
206 if (p_ptr->special_defense & KATA_MUSOU)
208 set_action(ACTION_NONE);
212 if (!have_flag(f_ptr->flags, FF_MORE))
214 msg_print(_("ここには下り階段が見当たらない。", "I see no down staircase here."));
218 if (have_flag(f_ptr->flags, FF_TRAP)) fall_trap = TRUE;
221 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
226 /* Quest down stairs */
227 else if (have_flag(f_ptr->flags, FF_QUEST))
229 /* Confirm Leaving */
230 if(!confirm_leave_level(TRUE)) return;
232 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
233 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
235 msg_print(_("下の階に降りた。", "You enter the down staircase."));
240 p_ptr->inside_quest = c_ptr->special;
242 /* Activate the quest */
243 if (!quest[p_ptr->inside_quest].status)
245 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
247 init_flags = INIT_ASSIGN;
248 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
250 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
253 /* Leaving a quest */
254 if (!p_ptr->inside_quest)
260 p_ptr->leaving = TRUE;
266 /* Hack -- take a turn */
267 p_ptr->energy_use = 100;
272 int target_dungeon = 0;
276 target_dungeon = have_flag(f_ptr->flags, FF_ENTRANCE) ? c_ptr->special : DUNGEON_ANGBAND;
278 if (ironman_downward && (target_dungeon != DUNGEON_ANGBAND))
280 msg_print(_("ダンジョンの入口は塞がれている!", "The entrance of this dungeon is closed!"));
283 if (!max_dlv[target_dungeon])
285 msg_format(_("ここには%sの入り口(%d階相当)があります", "There is the entrance of %s (Danger level: %d)"),
286 d_name+d_info[target_dungeon].name, d_info[target_dungeon].mindepth);
287 if (!get_check(_("本当にこのダンジョンに入りますか?", "Do you really get in this dungeon? "))) return;
290 /* Save old player position */
291 p_ptr->oldpx = p_ptr->x;
292 p_ptr->oldpy = p_ptr->y;
293 dungeon_type = (byte)target_dungeon;
296 * Clear all saved floors
297 * and create a first saved floor
299 prepare_change_floor_mode(CFM_FIRST_FLOOR);
302 /* Hack -- take a turn */
303 p_ptr->energy_use = 100;
305 if (autosave_l) do_cmd_save_game(TRUE);
308 if (have_flag(f_ptr->flags, FF_SHAFT)) down_num += 2;
313 /* Enter the dungeon just now */
314 p_ptr->enter_dungeon = TRUE;
315 down_num = d_info[dungeon_type].mindepth;
320 if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, _("落とし戸に落ちた", "fell through a trap door"));
321 else do_cmd_write_nikki(NIKKI_STAIR, down_num, _("階段を下りた", "climbed down the stairs to"));
326 msg_print(_("わざと落とし戸に落ちた。", "You deliberately jump through the trap door."));
333 msg_format(_("%sへ入った。", "You entered %s."), d_text + d_info[dungeon_type].text);
337 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
338 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
340 msg_print(_("階段を下りて新たなる迷宮へと足を踏み入れた。", "You enter a maze of down staircases."));
346 p_ptr->leaving = TRUE;
350 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
354 if (have_flag(f_ptr->flags, FF_SHAFT))
356 /* Create a way back */
357 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_SHAFT);
361 /* Create a way back */
362 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN);
370 * @brief 探索コマンドのメインルーチン / Simple command to "search" for one turn
373 void do_cmd_search(void)
375 /* Allow repeated command */
378 /* Set repeat count */
379 command_rep = command_arg - 1;
381 /* Redraw the state */
382 p_ptr->redraw |= (PR_STATE);
387 p_ptr->energy_use = 100;
395 * @brief 該当のマスに存在している箱のオブジェクトIDを返す。
396 * @param y 走査対象にしたいマスのY座標
397 * @param x 走査対象にしたいマスのX座標
398 * @param trapped TRUEならばトラップが存在する箱のみ、FALSEならば空でない箱全てを対象にする
399 * @return 箱が存在する場合そのオブジェクトID、存在しない場合0を返す。
401 static OBJECT_IDX chest_check(POSITION y, POSITION x, bool trapped)
403 cave_type *c_ptr = &cave[y][x];
405 OBJECT_IDX this_o_idx, next_o_idx = 0;
408 /* Scan all objects in the grid */
409 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
414 o_ptr = &o_list[this_o_idx];
416 /* Acquire next object */
417 next_o_idx = o_ptr->next_o_idx;
419 /* Skip unknown chests XXX XXX */
420 /* if (!(o_ptr->marked & OM_FOUND)) continue; */
422 /* Check for non empty chest */
423 if ((o_ptr->tval == TV_CHEST) &&
424 (((!trapped) && (o_ptr->pval)) || /* non empty */
425 ((trapped) && (o_ptr->pval > 0)))) /* trapped only */
436 * @brief 箱を開けるコマンドのメインルーチン /
437 * Attempt to open the given chest at the given location
438 * @param y 箱の存在するマスのY座標
439 * @param x 箱の存在するマスのX座標
440 * @param o_idx 箱のオブジェクトID
441 * @return 箱が開かなかった場合TRUE / Returns TRUE if repeated commands may continue
443 * Assume there is no monster blocking the destination
445 static bool do_cmd_open_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
450 object_type *o_ptr = &o_list[o_idx];
452 p_ptr->energy_use = 100;
454 /* Attempt to unlock it */
457 /* Assume locked, and thus not open */
460 /* Get the "disarm" factor */
461 i = p_ptr->skill_dis;
463 /* Penalize some conditions */
464 if (p_ptr->blind || no_lite()) i = i / 10;
465 if (p_ptr->confused || p_ptr->image) i = i / 10;
467 /* Extract the difficulty */
470 /* Always have a small chance of success */
473 /* Success -- May still have traps */
474 if (randint0(100) < j)
476 msg_print(_("鍵をはずした。", "You have picked the lock."));
481 /* Failure -- Keep trying */
484 /* We may continue repeating */
486 if (flush_failure) flush();
487 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
492 /* Allowed to open */
495 /* Apply chest traps, if any */
496 chest_trap(y, x, o_idx);
498 /* Let the Chest drop items */
499 chest_death(FALSE, y, x, o_idx);
507 #if defined(ALLOW_EASY_OPEN) || defined(ALLOW_EASY_DISARM) /* TNB */
510 * @brief 地形は開くものであって、かつ開かれているかを返す /
511 * Attempt to open the given chest at the given location
513 * @return 開いた地形である場合TRUEを返す / Return TRUE if the given feature is an open door
515 static bool is_open(IDX feat)
517 return have_flag(f_info[feat].flags, FF_CLOSE) && (feat != feat_state(feat, FF_CLOSE));
522 * @brief プレイヤーの周辺9マスに該当する地形がいくつあるかを返す /
523 * Attempt to open the given chest at the given location
524 * @param y 該当する地形の中から1つのY座標を返す参照ポインタ
525 * @param x 該当する地形の中から1つのX座標を返す参照ポインタ
526 * @param test 地形条件を判定するための関数ポインタ
527 * @param under TRUEならばプレイヤーの直下の座標も走査対象にする
529 * @details Return the number of features around (or under) the character.
530 * Usually look for doors and floor traps.
532 static int count_dt(POSITION *y, POSITION *x, bool (*test)(IDX feat), bool under)
534 int d, count, xx, yy;
536 /* Count how many matches */
539 /* Check around (and under) the character */
540 for (d = 0; d < 9; d++)
545 /* if not searching under player continue */
546 if ((d == 8) && !under) continue;
548 /* Extract adjacent (legal) location */
549 yy = p_ptr->y + ddy_ddd[d];
550 xx = p_ptr->x + ddx_ddd[d];
553 c_ptr = &cave[yy][xx];
555 /* Must have knowledge */
556 if (!(c_ptr->info & (CAVE_MARK))) continue;
558 /* Feature code (applying "mimic" field) */
559 feat = get_feat_mimic(c_ptr);
561 /* Not looking for this feature */
562 if (!((*test)(feat))) continue;
567 /* Remember the location. Only useful if only one match */
578 * @brief プレイヤーの周辺9マスに箱のあるマスがいくつあるかを返す /
579 * Return the number of chests around (or under) the character.
580 * @param y 該当するマスの中から1つのY座標を返す参照ポインタ
581 * @param x 該当するマスの中から1つのX座標を返す参照ポインタ
582 * @param trapped TRUEならばトラップの存在が判明している箱のみ対象にする
585 * If requested, count only trapped chests.
587 static int count_chests(POSITION *y, POSITION *x, bool trapped)
594 /* Count how many matches */
597 /* Check around (and under) the character */
598 for (d = 0; d < 9; d++)
600 /* Extract adjacent (legal) location */
601 POSITION yy = p_ptr->y + ddy_ddd[d];
602 POSITION xx = p_ptr->x + ddx_ddd[d];
604 /* No (visible) chest is there */
605 if ((o_idx = chest_check(yy, xx, FALSE)) == 0) continue;
607 /* Grab the object */
608 o_ptr = &o_list[o_idx];
611 if (o_ptr->pval == 0) continue;
613 /* No (known) traps here */
614 if (trapped && (!object_is_known(o_ptr) ||
615 !chest_traps[o_ptr->pval])) continue;
620 /* Remember the location. Only useful if only one match */
631 * @brief プレイヤーから指定の座標がどの方角にあるかを返す /
632 * Convert an adjacent location to a direction.
633 * @param y 方角を確認したY座標
634 * @param x 方角を確認したX座標
637 static DIRECTION coords_to_dir(POSITION y, POSITION x)
639 int d[3][3] = { {7, 4, 1}, {8, 5, 2}, {9, 6, 3} };
646 if (ABS(dx) > 1 || ABS(dy) > 1) return (0);
648 return d[dx + 1][dy + 1];
651 #endif /* defined(ALLOW_EASY_OPEN) || defined(ALLOW_EASY_DISARM) -- TNB */
655 * @brief 「開ける」動作コマンドのサブルーチン /
656 * Perform the basic "open" command on doors
657 * @param y 対象を行うマスのY座標
658 * @param x 対象を行うマスのX座標
659 * @return 実際に処理が行われた場合TRUEを返す。
661 * Assume destination is a closed/locked/jammed door
662 * Assume there is no monster blocking the destination
663 * Returns TRUE if repeated commands may continue
665 static bool do_cmd_open_aux(POSITION y, POSITION x)
669 /* Get requested grid */
670 cave_type *c_ptr = &cave[y][x];
671 feature_type *f_ptr = &f_info[c_ptr->feat];
674 p_ptr->energy_use = 100;
676 /* Seeing true feature code (ignore mimic) */
679 if (!have_flag(f_ptr->flags, FF_OPEN))
682 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(c_ptr)].name);
686 else if (f_ptr->power)
689 i = p_ptr->skill_dis;
691 /* Penalize some conditions */
692 if (p_ptr->blind || no_lite()) i = i / 10;
693 if (p_ptr->confused || p_ptr->image) i = i / 10;
695 /* Extract the lock power */
698 /* Extract the difficulty XXX XXX XXX */
701 /* Always have a small chance of success */
705 if (randint0(100) < j)
707 msg_print(_("鍵をはずした。", "You have picked the lock."));
710 cave_alter_feat(y, x, FF_OPEN);
712 sound(SOUND_OPENDOOR);
722 if (flush_failure) flush();
724 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
726 /* We may keep trying */
735 cave_alter_feat(y, x, FF_OPEN);
737 sound(SOUND_OPENDOOR);
745 * @brief 「開ける」コマンドのメインルーチン /
746 * Open a closed/locked/jammed door or a closed/locked chest.
749 * Unlocking a locked door/chest is worth one experience point.
751 void do_cmd_open(void)
759 if (p_ptr->special_defense & KATA_MUSOU)
761 set_action(ACTION_NONE);
764 #ifdef ALLOW_EASY_OPEN /* TNB */
766 /* Option: Pick a direction */
769 int num_doors, num_chests;
771 /* Count closed doors (locked or jammed) */
772 num_doors = count_dt(&y, &x, is_closed_door, FALSE);
774 /* Count chests (locked) */
775 num_chests = count_chests(&y, &x, FALSE);
777 /* See if only one target */
778 if (num_doors || num_chests)
780 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
782 if (!too_many) command_dir = coords_to_dir(y, x);
786 #endif /* ALLOW_EASY_OPEN -- TNB */
788 /* Allow repeated command */
791 /* Set repeat count */
792 command_rep = command_arg - 1;
794 /* Redraw the state */
795 p_ptr->redraw |= (PR_STATE);
801 /* Get a "repeated" direction */
802 if (get_rep_dir(&dir, TRUE))
807 /* Get requested location */
808 y = p_ptr->y + ddy[dir];
809 x = p_ptr->x + ddx[dir];
811 /* Get requested grid */
814 /* Feature code (applying "mimic" field) */
815 feat = get_feat_mimic(c_ptr);
817 /* Check for chest */
818 o_idx = chest_check(y, x, FALSE);
821 if (!have_flag(f_info[feat].flags, FF_OPEN) && !o_idx)
823 msg_print(_("そこには開けるものが見当たらない。", "You see nothing there to open."));
826 /* Monster in the way */
827 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
829 p_ptr->energy_use = 100;
831 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
841 more = do_cmd_open_chest(y, x, o_idx);
848 more = do_cmd_open_aux(y, x);
852 /* Cancel repeat unless we may continue */
853 if (!more) disturb(0, 0);
859 * @brief 「閉じる」動作コマンドのサブルーチン /
860 * Perform the basic "close" command
861 * @param y 対象を行うマスのY座標
862 * @param x 対象を行うマスのX座標
863 * @return 実際に処理が行われた場合TRUEを返す。
865 * Assume destination is an open/broken door
866 * Assume there is no monster blocking the destination
867 * Returns TRUE if repeated commands may continue
869 static bool do_cmd_close_aux(POSITION y, POSITION x)
871 /* Get grid and contents */
872 cave_type *c_ptr = &cave[y][x];
873 FEAT_IDX old_feat = c_ptr->feat;
876 p_ptr->energy_use = 100;
878 /* Seeing true feature code (ignore mimic) */
881 if (have_flag(f_info[old_feat].flags, FF_CLOSE))
883 s16b closed_feat = feat_state(old_feat, FF_CLOSE);
885 /* Hack -- object in the way */
886 if ((c_ptr->o_idx || (c_ptr->info & CAVE_OBJECT)) &&
887 (closed_feat != old_feat) && !have_flag(f_info[closed_feat].flags, FF_DROP))
889 msg_print(_("何かがつっかえて閉まらない。", "There seems stuck."));
894 cave_alter_feat(y, x, FF_CLOSE);
897 if (old_feat == c_ptr->feat)
899 msg_print(_("ドアは壊れてしまっている。", "The door appears to be broken."));
903 sound(SOUND_SHUTDOOR);
914 * @brief 「閉じる」コマンドのメインルーチン /
915 * Close an open door.
918 * Unlocking a locked door/chest is worth one experience point.
920 void do_cmd_close(void)
927 if (p_ptr->special_defense & KATA_MUSOU)
929 set_action(ACTION_NONE);
932 #ifdef ALLOW_EASY_OPEN /* TNB */
934 /* Option: Pick a direction */
937 /* Count open doors */
938 if (count_dt(&y, &x, is_open, FALSE) == 1)
940 command_dir = coords_to_dir(y, x);
944 #endif /* ALLOW_EASY_OPEN -- TNB */
946 /* Allow repeated command */
949 /* Set repeat count */
950 command_rep = command_arg - 1;
952 /* Redraw the state */
953 p_ptr->redraw |= (PR_STATE);
959 /* Get a "repeated" direction */
960 if (get_rep_dir(&dir,FALSE))
965 /* Get requested location */
966 y = p_ptr->y + ddy[dir];
967 x = p_ptr->x + ddx[dir];
969 /* Get grid and contents */
972 /* Feature code (applying "mimic" field) */
973 feat = get_feat_mimic(c_ptr);
975 /* Require open/broken door */
976 if (!have_flag(f_info[feat].flags, FF_CLOSE))
978 msg_print(_("そこには閉じるものが見当たらない。", "You see nothing there to close."));
981 /* Monster in the way */
982 else if (c_ptr->m_idx)
984 p_ptr->energy_use = 100;
986 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
996 more = do_cmd_close_aux(y, x);
1000 /* Cancel repeat unless we may continue */
1001 if (!more) disturb(0, 0);
1006 * @brief 「掘る」コマンドを該当のマスに行えるかの判定と結果メッセージの表示 /
1007 * Determine if a given grid may be "tunneled"
1008 * @param y 対象を行うマスのY座標
1009 * @param x 対象を行うマスのX座標
1012 static bool do_cmd_tunnel_test(POSITION y, POSITION x)
1014 cave_type *c_ptr = &cave[y][x];
1016 /* Must have knowledge */
1017 if (!(c_ptr->info & CAVE_MARK))
1019 msg_print(_("そこには何も見当たらない。", "You see nothing there."));
1025 /* Must be a wall/door/etc */
1026 if (!cave_have_flag_grid(c_ptr, FF_TUNNEL))
1028 msg_print(_("そこには掘るものが見当たらない。", "You see nothing there to tunnel."));
1040 * @brief 「掘る」動作コマンドのサブルーチン /
1041 * Perform the basic "tunnel" command
1042 * @param y 対象を行うマスのY座標
1043 * @param x 対象を行うマスのX座標
1044 * @return 実際に処理が行われた場合TRUEを返す。
1046 * Assumes that no monster is blocking the destination
1047 * Do not use twall anymore
1048 * Returns TRUE if repeated commands may continue
1050 static bool do_cmd_tunnel_aux(POSITION y, POSITION x)
1053 feature_type *f_ptr, *mimic_f_ptr;
1058 /* Verify legality */
1059 if (!do_cmd_tunnel_test(y, x)) return (FALSE);
1061 p_ptr->energy_use = 100;
1064 c_ptr = &cave[y][x];
1065 f_ptr = &f_info[c_ptr->feat];
1066 power = f_ptr->power;
1068 /* Feature code (applying "mimic" field) */
1069 mimic_f_ptr = &f_info[get_feat_mimic(c_ptr)];
1071 name = f_name + mimic_f_ptr->name;
1075 if (have_flag(f_ptr->flags, FF_PERMANENT))
1078 if (have_flag(mimic_f_ptr->flags, FF_PERMANENT))
1080 msg_print(_("この岩は硬すぎて掘れないようだ。", "This seems to be permanent rock."));
1083 /* Map border (mimiccing Permanent wall) */
1086 msg_print(_("そこは掘れない!", "You can't tunnel through that!"));
1091 else if (have_flag(f_ptr->flags, FF_CAN_DIG))
1094 if (p_ptr->skill_dig > randint0(20 * power))
1096 msg_format(_("%sをくずした。", "You have removed the %s."), name);
1098 /* Remove the feature */
1099 cave_alter_feat(y, x, FF_TUNNEL);
1101 /* Update some things */
1102 p_ptr->update |= (PU_FLOW);
1106 /* Message, keep digging */
1107 msg_format(_("%sをくずしている。", "You dig into the %s."), name);
1115 bool tree = have_flag(mimic_f_ptr->flags, FF_TREE);
1118 if (p_ptr->skill_dig > power + randint0(40 * power))
1120 if (tree) msg_format(_("%sを切り払った。", "You have cleared away the %s."), name);
1123 msg_print(_("穴を掘り終えた。", "You have finished the tunnel."));
1124 p_ptr->update |= (PU_FLOW);
1127 if (have_flag(f_ptr->flags, FF_GLASS)) sound(SOUND_GLASS);
1129 /* Remove the feature */
1130 cave_alter_feat(y, x, FF_TUNNEL);
1132 chg_virtue(V_DILIGENCE, 1);
1133 chg_virtue(V_NATURE, -1);
1141 /* We may continue chopping */
1142 msg_format(_("%sを切っている。", "You chop away at the %s."), name);
1143 /* Occasional Search XXX XXX */
1144 if (randint0(100) < 25) search();
1148 /* We may continue tunelling */
1149 msg_format(_("%sに穴を掘っている。", "You tunnel into the %s."), name);
1156 if (is_hidden_door(c_ptr))
1158 /* Occasional Search XXX XXX */
1159 if (randint0(100) < 25) search();
1168 * @brief 「掘る」動作コマンドのメインルーチン /
1169 * Tunnels through "walls" (including rubble and closed doors)
1173 * Note that you must tunnel in order to hit invisible monsters
1174 * in walls, though moving into walls still takes a turn anyway.
1176 * Digging is very difficult without a "digger" weapon, but can be
1177 * accomplished by strong players using heavy weapons.
1180 void do_cmd_tunnel(void)
1190 if (p_ptr->special_defense & KATA_MUSOU)
1192 set_action(ACTION_NONE);
1195 /* Allow repeated command */
1198 /* Set repeat count */
1199 command_rep = command_arg - 1;
1201 /* Redraw the state */
1202 p_ptr->redraw |= (PR_STATE);
1204 /* Cancel the arg */
1208 /* Get a direction to tunnel, or Abort */
1209 if (get_rep_dir(&dir,FALSE))
1212 y = p_ptr->y + ddy[dir];
1213 x = p_ptr->x + ddx[dir];
1216 c_ptr = &cave[y][x];
1218 /* Feature code (applying "mimic" field) */
1219 feat = get_feat_mimic(c_ptr);
1221 /* No tunnelling through doors */
1222 if (have_flag(f_info[feat].flags, FF_DOOR))
1224 msg_print(_("ドアは掘れない。", "You cannot tunnel through doors."));
1227 /* No tunnelling through most features */
1228 else if (!have_flag(f_info[feat].flags, FF_TUNNEL))
1230 msg_print(_("そこは掘れない。", "You can't tunnel through that."));
1233 /* A monster is in the way */
1234 else if (c_ptr->m_idx)
1236 p_ptr->energy_use = 100;
1238 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1247 /* Tunnel through walls */
1248 more = do_cmd_tunnel_aux(y, x);
1252 /* Cancel repetition unless we can continue */
1253 if (!more) disturb(0, 0);
1257 #ifdef ALLOW_EASY_OPEN /* TNB */
1260 * @brief 移動処理による簡易な「開く」処理 /
1262 * @return 開く処理が実際に試みられた場合TRUEを返す
1265 * If there is a jammed/closed/locked door at the given location,
1266 * then attempt to unlock/open it. Return TRUE if an attempt was
1267 * made (successful or not), otherwise return FALSE.
1269 * The code here should be nearly identical to that in
1270 * do_cmd_open_test() and do_cmd_open_aux().
1273 bool easy_open_door(POSITION y, POSITION x)
1277 cave_type *c_ptr = &cave[y][x];
1278 feature_type *f_ptr = &f_info[c_ptr->feat];
1280 /* Must be a closed door */
1281 if (!is_closed_door(c_ptr->feat))
1288 if (!have_flag(f_ptr->flags, FF_OPEN))
1291 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(c_ptr)].name);
1296 else if (f_ptr->power)
1299 i = p_ptr->skill_dis;
1301 /* Penalize some conditions */
1302 if (p_ptr->blind || no_lite()) i = i / 10;
1303 if (p_ptr->confused || p_ptr->image) i = i / 10;
1305 /* Extract the lock power */
1308 /* Extract the difficulty XXX XXX XXX */
1311 /* Always have a small chance of success */
1315 if (randint0(100) < j)
1317 msg_print(_("鍵をはずした。", "You have picked the lock."));
1320 cave_alter_feat(y, x, FF_OPEN);
1322 sound(SOUND_OPENDOOR);
1332 if (flush_failure) flush();
1334 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
1343 cave_alter_feat(y, x, FF_OPEN);
1345 sound(SOUND_OPENDOOR);
1352 #endif /* ALLOW_EASY_OPEN -- TNB */
1356 * @brief 箱のトラップを解除するコマンドのメインルーチン /
1357 * Perform the basic "disarm" command
1358 * @param y 解除を行うマスのY座標
1359 * @param x 解除を行うマスのX座標
1360 * @param o_idx 箱のオブジェクトID
1361 * @return ターンを消費する処理が行われた場合TRUEを返す
1364 * Assume destination is a visible trap
1365 * Assume there is no monster blocking the destination
1366 * Returns TRUE if repeated commands may continue
1369 static bool do_cmd_disarm_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
1373 object_type *o_ptr = &o_list[o_idx];
1375 p_ptr->energy_use = 100;
1377 /* Get the "disarm" factor */
1378 i = p_ptr->skill_dis;
1380 /* Penalize some conditions */
1381 if (p_ptr->blind || no_lite()) i = i / 10;
1382 if (p_ptr->confused || p_ptr->image) i = i / 10;
1384 /* Extract the difficulty */
1385 j = i - o_ptr->pval;
1387 /* Always have a small chance of success */
1390 /* Must find the trap first. */
1391 if (!object_is_known(o_ptr))
1393 msg_print(_("トラップが見あたらない。", "I don't see any traps."));
1397 /* Already disarmed/unlocked */
1398 else if (o_ptr->pval <= 0)
1400 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1403 /* No traps to find. */
1404 else if (!chest_traps[o_ptr->pval])
1406 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1409 /* Success (get a lot of experience) */
1410 else if (randint0(100) < j)
1412 msg_print(_("箱に仕掛けられていたトラップを解除した。", "You have disarmed the chest."));
1413 gain_exp(o_ptr->pval);
1414 o_ptr->pval = (0 - o_ptr->pval);
1417 /* Failure -- Keep trying */
1418 else if ((i > 5) && (randint1(i) > 5))
1420 /* We may keep trying */
1422 if (flush_failure) flush();
1423 msg_print(_("箱のトラップ解除に失敗した。", "You failed to disarm the chest."));
1426 /* Failure -- Set off the trap */
1429 msg_print(_("トラップを作動させてしまった!", "You set off a trap!"));
1431 chest_trap(y, x, o_idx);
1440 * @brief 箱のトラップを解除するコマンドのサブルーチン /
1441 * Perform the basic "disarm" command
1442 * @param y 解除を行うマスのY座標
1443 * @param x 解除を行うマスのX座標
1444 * @param dir プレイヤーからみた方向ID
1445 * @return ターンを消費する処理が行われた場合TRUEを返す
1448 * Assume destination is a visible trap
1449 * Assume there is no monster blocking the destination
1450 * Returns TRUE if repeated commands may continue
1453 #ifdef ALLOW_EASY_DISARM /* TNB */
1455 bool do_cmd_disarm_aux(POSITION y, POSITION x, DIRECTION dir)
1457 #else /* ALLOW_EASY_DISARM -- TNB */
1459 static bool do_cmd_disarm_aux(POSITION y, POSITION x, DIRECTION dir)
1461 #endif /* ALLOW_EASY_DISARM -- TNB */
1463 /* Get grid and contents */
1464 cave_type *c_ptr = &cave[y][x];
1467 feature_type *f_ptr = &f_info[c_ptr->feat];
1469 /* Access trap name */
1470 cptr name = (f_name + f_ptr->name);
1472 /* Extract trap "power" */
1473 int power = f_ptr->power;
1476 /* Get the "disarm" factor */
1477 int i = p_ptr->skill_dis;
1480 p_ptr->energy_use = 100;
1482 /* Penalize some conditions */
1483 if (p_ptr->blind || no_lite()) i = i / 10;
1484 if (p_ptr->confused || p_ptr->image) i = i / 10;
1486 /* Extract the difficulty */
1489 /* Always have a small chance of success */
1493 if (randint0(100) < j)
1495 msg_format(_("%sを解除した。", "You have disarmed the %s."), name);
1500 /* Remove the trap */
1501 cave_alter_feat(y, x, FF_DISARM);
1503 #ifdef ALLOW_EASY_DISARM /* TNB */
1505 /* Move the player onto the trap */
1506 move_player(dir, easy_disarm, FALSE);
1508 #else /* ALLOW_EASY_DISARM -- TNB */
1510 /* move the player onto the trap grid */
1511 move_player(dir, FALSE, FALSE);
1513 #endif /* ALLOW_EASY_DISARM -- TNB */
1516 /* Failure -- Keep trying */
1517 else if ((i > 5) && (randint1(i) > 5))
1520 if (flush_failure) flush();
1522 msg_format(_("%sの解除に失敗した。", "You failed to disarm the %s."), name);
1524 /* We may keep trying */
1528 /* Failure -- Set off the trap */
1531 msg_format(_("%sを作動させてしまった!", "You set off the %s!"), name);
1533 #ifdef ALLOW_EASY_DISARM /* TNB */
1535 /* Move the player onto the trap */
1536 move_player(dir, easy_disarm, FALSE);
1538 #else /* ALLOW_EASY_DISARM -- TNB */
1540 /* Move the player onto the trap */
1541 move_player(dir, FALSE, FALSE);
1543 #endif /* ALLOW_EASY_DISARM -- TNB */
1552 * @brief 箱、床のトラップ解除処理双方の統合メインルーチン /
1553 * Disarms a trap, or chest
1556 void do_cmd_disarm(void)
1564 if (p_ptr->special_defense & KATA_MUSOU)
1566 set_action(ACTION_NONE);
1569 #ifdef ALLOW_EASY_DISARM /* TNB */
1571 /* Option: Pick a direction */
1574 int num_traps, num_chests;
1576 /* Count visible traps */
1577 num_traps = count_dt(&y, &x, is_trap, TRUE);
1579 /* Count chests (trapped) */
1580 num_chests = count_chests(&y, &x, TRUE);
1582 /* See if only one target */
1583 if (num_traps || num_chests)
1585 bool too_many = (num_traps && num_chests) || (num_traps > 1) || (num_chests > 1);
1586 if (!too_many) command_dir = coords_to_dir(y, x);
1590 #endif /* ALLOW_EASY_DISARM -- TNB */
1592 /* Allow repeated command */
1595 /* Set repeat count */
1596 command_rep = command_arg - 1;
1598 /* Redraw the state */
1599 p_ptr->redraw |= (PR_STATE);
1601 /* Cancel the arg */
1605 /* Get a direction (or abort) */
1606 if (get_rep_dir(&dir,TRUE))
1612 y = p_ptr->y + ddy[dir];
1613 x = p_ptr->x + ddx[dir];
1615 /* Get grid and contents */
1616 c_ptr = &cave[y][x];
1618 /* Feature code (applying "mimic" field) */
1619 feat = get_feat_mimic(c_ptr);
1621 /* Check for chests */
1622 o_idx = chest_check(y, x, TRUE);
1625 if (!is_trap(feat) && !o_idx)
1627 msg_print(_("そこには解除するものが見当たらない。", "You see nothing there to disarm."));
1630 /* Monster in the way */
1631 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
1633 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1642 /* Disarm the chest */
1643 more = do_cmd_disarm_chest(y, x, o_idx);
1649 /* Disarm the trap */
1650 more = do_cmd_disarm_aux(y, x, dir);
1654 /* Cancel repeat unless told not to */
1655 if (!more) disturb(0, 0);
1660 * @brief 「打ち破る」動作コマンドのサブルーチン /
1661 * Perform the basic "bash" command
1662 * @param y 対象を行うマスのY座標
1663 * @param x 対象を行うマスのX座標
1664 * @param dir プレイヤーから見たターゲットの方角ID
1665 * @return 実際に処理が行われた場合TRUEを返す。
1668 * Assume destination is a closed/locked/jammed door
1669 * Assume there is no monster blocking the destination
1670 * Returns TRUE if repeated commands may continue
1673 static bool do_cmd_bash_aux(POSITION y, POSITION x, DIRECTION dir)
1676 cave_type *c_ptr = &cave[y][x];
1679 feature_type *f_ptr = &f_info[c_ptr->feat];
1681 /* Hack -- Bash power based on strength */
1682 /* (Ranges from 3 to 20 to 100 to 200) */
1683 int bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
1685 /* Extract door power */
1686 int temp = f_ptr->power;
1690 cptr name = f_name + f_info[get_feat_mimic(c_ptr)].name;
1692 p_ptr->energy_use = 100;
1694 msg_format(_("%sに体当たりをした!", "You smash into the %s!"), name);
1696 /* Compare bash power to door power XXX XXX XXX */
1697 temp = (bash - (temp * 10));
1699 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
1701 /* Hack -- always have a chance */
1702 if (temp < 1) temp = 1;
1704 /* Hack -- attempt to bash down the door */
1705 if (randint0(100) < temp)
1707 msg_format(_("%sを壊した!", "The %s crashes open!"), name);
1709 sound(have_flag(f_ptr->flags, FF_GLASS) ? SOUND_GLASS : SOUND_OPENDOOR);
1711 /* Break down the door */
1712 if ((randint0(100) < 50) || (feat_state(c_ptr->feat, FF_OPEN) == c_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS))
1714 cave_alter_feat(y, x, FF_BASH);
1720 cave_alter_feat(y, x, FF_OPEN);
1723 /* Hack -- Fall through the door */
1724 move_player(dir, FALSE, FALSE);
1727 /* Saving throw against stun */
1728 else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
1731 msg_format(_("この%sは頑丈だ。", "The %s holds firm."), name);
1733 /* Allow repeated bashing */
1737 /* High dexterity yields coolness */
1740 msg_print(_("体のバランスをくずしてしまった。", "You are off-balance."));
1742 /* Hack -- Lose balance ala paralysis */
1743 (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
1752 * @brief 「打ち破る」動作コマンドのメインルーチン /
1753 * Bash open a door, success based on character strength
1757 * For a closed door, pval is positive if locked; negative if stuck.
1759 * For an open door, pval is positive for a broken door.
1761 * A closed door can be opened - harder if locked. Any door might be
1762 * bashed open (and thereby broken). Bashing a door is (potentially)
1763 * faster! You move into the door way. To open a stuck door, it must
1764 * be bashed. A closed door can be jammed (see do_cmd_spike()).
1766 * Creatures can also open or bash doors, see elsewhere.
1769 void do_cmd_bash(void)
1778 if (p_ptr->special_defense & KATA_MUSOU)
1780 set_action(ACTION_NONE);
1783 /* Allow repeated command */
1786 /* Set repeat count */
1787 command_rep = command_arg - 1;
1789 /* Redraw the state */
1790 p_ptr->redraw |= (PR_STATE);
1792 /* Cancel the arg */
1796 /* Get a "repeated" direction */
1797 if (get_rep_dir(&dir,FALSE))
1802 y = p_ptr->y + ddy[dir];
1803 x = p_ptr->x + ddx[dir];
1806 c_ptr = &cave[y][x];
1808 /* Feature code (applying "mimic" field) */
1809 feat = get_feat_mimic(c_ptr);
1811 /* Nothing useful */
1812 if (!have_flag(f_info[feat].flags, FF_BASH))
1814 msg_print(_("そこには体当たりするものが見当たらない。", "You see nothing there to bash."));
1817 /* Monster in the way */
1818 else if (c_ptr->m_idx)
1820 p_ptr->energy_use = 100;
1822 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1828 /* Bash a closed door */
1832 more = do_cmd_bash_aux(y, x, dir);
1836 /* Unless valid action taken, cancel bash */
1837 if (!more) disturb(0, 0);
1842 * @brief 特定のマスに影響を及ぼすための汎用的コマンド
1846 * Manipulate an adjacent grid in some way
1848 * Attack monsters, tunnel through walls, disarm traps, open doors.
1850 * Consider confusion XXX XXX XXX
1852 * This command must always take a turn, to prevent free detection
1853 * of invisible monsters.
1856 void do_cmd_alter(void)
1865 if (p_ptr->special_defense & KATA_MUSOU)
1867 set_action(ACTION_NONE);
1870 /* Allow repeated command */
1873 /* Set repeat count */
1874 command_rep = command_arg - 1;
1876 /* Redraw the state */
1877 p_ptr->redraw |= (PR_STATE);
1879 /* Cancel the arg */
1883 /* Get a direction */
1884 if (get_rep_dir(&dir,TRUE))
1887 feature_type *f_ptr;
1890 y = p_ptr->y + ddy[dir];
1891 x = p_ptr->x + ddx[dir];
1894 c_ptr = &cave[y][x];
1896 /* Feature code (applying "mimic" field) */
1897 feat = get_feat_mimic(c_ptr);
1898 f_ptr = &f_info[feat];
1900 p_ptr->energy_use = 100;
1902 /* Attack monsters */
1910 else if (have_flag(f_ptr->flags, FF_OPEN))
1912 more = do_cmd_open_aux(y, x);
1915 /* Bash jammed doors */
1916 else if (have_flag(f_ptr->flags, FF_BASH))
1918 more = do_cmd_bash_aux(y, x, dir);
1921 /* Tunnel through walls */
1922 else if (have_flag(f_ptr->flags, FF_TUNNEL))
1924 more = do_cmd_tunnel_aux(y, x);
1927 /* Close open doors */
1928 else if (have_flag(f_ptr->flags, FF_CLOSE))
1930 more = do_cmd_close_aux(y, x);
1934 else if (have_flag(f_ptr->flags, FF_DISARM))
1936 more = do_cmd_disarm_aux(y, x, dir);
1943 msg_print(_("何もない空中を攻撃した。", "You attack the empty air."));
1947 /* Cancel repetition unless we can continue */
1948 if (!more) disturb(0, 0);
1954 * @brief 「くさびを打つ」ために必要なオブジェクトがあるかどうかの判定を返す /
1955 * Find the index of some "spikes", if possible.
1956 * @param ip くさびとして打てるオブジェクトのID
1957 * @return オブジェクトがある場合TRUEを返す
1960 * XXX XXX XXX Let user choose a pile of spikes, perhaps?
1963 static bool get_spike(INVENTORY_IDX *ip)
1967 /* Check every item in the pack */
1968 for (i = 0; i < INVEN_PACK; i++)
1970 object_type *o_ptr = &inventory[i];
1972 /* Skip non-objects */
1973 if (!o_ptr->k_idx) continue;
1975 /* Check the "tval" code */
1976 if (o_ptr->tval == TV_SPIKE)
1978 /* Save the spike index */
1992 * @brief 「くさびを打つ」動作コマンドのメインルーチン /
1993 * Jam a closed door with a spike
1997 * This command may NOT be repeated
2000 void do_cmd_spike(void)
2004 if (p_ptr->special_defense & KATA_MUSOU)
2006 set_action(ACTION_NONE);
2009 /* Get a "repeated" direction */
2010 if (get_rep_dir(&dir,FALSE))
2018 y = p_ptr->y + ddy[dir];
2019 x = p_ptr->x + ddx[dir];
2021 /* Get grid and contents */
2022 c_ptr = &cave[y][x];
2024 /* Feature code (applying "mimic" field) */
2025 feat = get_feat_mimic(c_ptr);
2027 /* Require closed door */
2028 if (!have_flag(f_info[feat].flags, FF_SPIKE))
2030 msg_print(_("そこにはくさびを打てるものが見当たらない。", "You see nothing there to spike."));
2034 else if (!get_spike(&item))
2036 msg_print(_("くさびを持っていない!", "You have no spikes!"));
2039 /* Is a monster in the way? */
2040 else if (c_ptr->m_idx)
2042 p_ptr->energy_use = 100;
2044 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
2053 p_ptr->energy_use = 100;
2055 /* Successful jamming */
2056 msg_format(_("%sにくさびを打ち込んだ。", "You jam the %s with a spike."), f_name + f_info[feat].name);
2057 cave_alter_feat(y, x, FF_SPIKE);
2059 /* Use up, and describe, a single spike, from the bottom */
2060 inven_item_increase(item, -1);
2061 inven_item_describe(item);
2062 inven_item_optimize(item);
2070 * @brief 「歩く」動作コマンドのメインルーチン /
2071 * Support code for the "Walk" and "Jump" commands
2072 * @param pickup アイテムの自動拾いを行うならTRUE
2075 void do_cmd_walk(bool pickup)
2082 /* Allow repeated command */
2085 /* Set repeat count */
2086 command_rep = command_arg - 1;
2088 /* Redraw the state */
2089 p_ptr->redraw |= (PR_STATE);
2091 /* Cancel the arg */
2095 /* Get a "repeated" direction */
2096 if (get_rep_dir(&dir, FALSE))
2098 p_ptr->energy_use = 100;
2100 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
2102 set_action(ACTION_NONE);
2105 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2106 if (p_ptr->wild_mode) p_ptr->energy_use *= ((MAX_HGT + MAX_WID) / 2);
2107 if (p_ptr->action == ACTION_HAYAGAKE) p_ptr->energy_use = p_ptr->energy_use * (45-(p_ptr->lev/2)) / 100;
2109 /* Actually move the character */
2110 move_player(dir, pickup, FALSE);
2112 /* Allow more walking */
2116 /* Hack again -- Is there a special encounter ??? */
2117 if (p_ptr->wild_mode && !cave_have_flag_bold(p_ptr->y, p_ptr->x, FF_TOWN))
2119 int tmp = 120 + p_ptr->lev*10 - wilderness[p_ptr->y][p_ptr->x].level + 5;
2122 if (((wilderness[p_ptr->y][p_ptr->x].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2124 /* Inform the player of his horrible fate :=) */
2125 msg_print(_("襲撃だ!", "You are ambushed !"));
2127 /* Go into large wilderness view */
2128 p_ptr->oldpy = randint1(MAX_HGT-2);
2129 p_ptr->oldpx = randint1(MAX_WID-2);
2132 /* Give first move to monsters */
2133 p_ptr->energy_use = 100;
2135 /* HACk -- set the encouter flag for the wilderness generation */
2136 generate_encounter = TRUE;
2140 /* Cancel repeat unless we may continue */
2141 if (!more) disturb(0, 0);
2146 * @brief 「走る」動作コマンドのメインルーチン /
2150 void do_cmd_run(void)
2154 /* Hack -- no running when confused */
2155 if (p_ptr->confused)
2157 msg_print(_("混乱していて走れない!", "You are too confused!"));
2161 if (p_ptr->special_defense & KATA_MUSOU)
2163 set_action(ACTION_NONE);
2166 /* Get a "repeated" direction */
2167 if (get_rep_dir(&dir,FALSE))
2169 /* Hack -- Set the run counter */
2170 running = (command_arg ? command_arg : 1000);
2179 * @brief 「留まる」動作コマンドのメインルーチン /
2180 * Stay still. Search. Enter stores.
2181 * Pick up treasure if "pickup" is true.
2182 * @param pickup アイテムの自動拾いを行うならTRUE
2185 void do_cmd_stay(bool pickup)
2187 u32b mpe_mode = MPE_STAYING | MPE_ENERGY_USE;
2189 /* Allow repeated command */
2192 /* Set repeat count */
2193 command_rep = command_arg - 1;
2195 /* Redraw the state */
2196 p_ptr->redraw |= (PR_STATE);
2198 /* Cancel the arg */
2202 p_ptr->energy_use = 100;
2204 if (pickup) mpe_mode |= MPE_DO_PICKUP;
2205 (void)move_player_effect(p_ptr->y, p_ptr->x, mpe_mode);
2210 * @brief 「休む」動作コマンドのメインルーチン /
2211 * Resting allows a player to safely restore his hp -RAK-
2214 void do_cmd_rest(void)
2217 set_action(ACTION_NONE);
2219 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) || INTERUPTING_SONG_EFFECT(p_ptr)))
2225 if (hex_spelling_any()) stop_hex_spell_all();
2227 /* Prompt for time if needed */
2228 if (command_arg <= 0)
2230 cptr p = _("休憩 (0-9999, '*' で HP/MP全快, '&' で必要なだけ): ",
2231 "Rest (0-9999, '*' for HP/SP, '&' as needed): ");
2237 strcpy(out_val, "&");
2239 /* Ask for duration */
2240 if (!get_string(p, out_val, 4)) return;
2242 /* Rest until done */
2243 if (out_val[0] == '&')
2245 command_arg = COMMAND_ARG_REST_UNTIL_DONE;
2249 else if (out_val[0] == '*')
2251 command_arg = COMMAND_ARG_REST_FULL_HEALING;
2257 command_arg = (COMMAND_ARG)atoi(out_val);
2258 if (command_arg <= 0) return;
2264 if (command_arg > 9999) command_arg = 9999;
2266 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
2268 /* Take a turn XXX XXX XXX (?) */
2269 p_ptr->energy_use = 100;
2271 /* The sin of sloth */
2272 if (command_arg > 100)
2273 chg_virtue(V_DILIGENCE, -1);
2275 /* Why are you sleeping when there's no need? WAKE UP!*/
2276 if ((p_ptr->chp == p_ptr->mhp) &&
2277 (p_ptr->csp == p_ptr->msp) &&
2278 !p_ptr->blind && !p_ptr->confused &&
2279 !p_ptr->poisoned && !p_ptr->afraid &&
2280 !p_ptr->stun && !p_ptr->cut &&
2281 !p_ptr->slow && !p_ptr->paralyzed &&
2282 !p_ptr->image && !p_ptr->word_recall &&
2283 !p_ptr->alter_reality)
2284 chg_virtue(V_DILIGENCE, -1);
2286 /* Save the rest code */
2287 resting = command_arg;
2288 p_ptr->action = ACTION_REST;
2290 /* Recalculate bonuses */
2291 p_ptr->update |= (PU_BONUS);
2293 /* Redraw the state */
2294 p_ptr->redraw |= (PR_STATE);
2305 * @brief 矢弾を射撃した場合の破損確率を返す /
2306 * Determines the odds of an object breaking when thrown at a monster
2307 * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
2310 * Note that artifacts never break, see the "drop_near()" function.
2312 static PERCENTAGE breakage_chance(object_type *o_ptr)
2314 PERCENTAGE archer_bonus = (p_ptr->pclass == CLASS_ARCHER ? (PERCENTAGE)(p_ptr->lev-1)/7 + 4: 0);
2316 /* Examine the snipe type */
2319 if (snipe_type == SP_KILL_WALL) return (100);
2320 if (snipe_type == SP_EXPLODE) return (100);
2321 if (snipe_type == SP_PIERCE) return (100);
2322 if (snipe_type == SP_FINAL) return (100);
2323 if (snipe_type == SP_NEEDLE) return (100);
2324 if (snipe_type == SP_EVILNESS) return (40);
2325 if (snipe_type == SP_HOLYNESS) return (40);
2328 /* Examine the item type */
2329 switch (o_ptr->tval)
2345 /* Sometimes break */
2350 return (20 - archer_bonus * 2);
2355 return (10 - archer_bonus);
2363 * @brief 矢弾を射撃した際のスレイ倍率をかけた結果を返す /
2364 * Determines the odds of an object breaking when thrown at a monster
2365 * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
2366 * @param tdam 計算途中のダメージ量
2367 * @param m_ptr 目標モンスターの構造体参照ポインタ
2368 * @return スレイ倍率をかけたダメージ量
2370 static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
2374 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2376 BIT_FLAGS flgs[TR_FLAG_SIZE];
2378 /* Extract the flags */
2379 object_flags(o_ptr, flgs);
2381 /* Some "weapons" and "ammo" do extra damage */
2382 switch (o_ptr->tval)
2389 if ((have_flag(flgs, TR_SLAY_ANIMAL)) &&
2390 (r_ptr->flags3 & RF3_ANIMAL))
2392 if (is_original_ap_and_seen(m_ptr))
2394 r_ptr->r_flags3 |= RF3_ANIMAL;
2397 if (mult < 17) mult = 17;
2401 if ((have_flag(flgs, TR_KILL_ANIMAL)) &&
2402 (r_ptr->flags3 & RF3_ANIMAL))
2404 if (is_original_ap_and_seen(m_ptr))
2406 r_ptr->r_flags3 |= RF3_ANIMAL;
2409 if (mult < 27) mult = 27;
2413 if ((have_flag(flgs, TR_SLAY_EVIL)) &&
2414 (r_ptr->flags3 & RF3_EVIL))
2416 if (is_original_ap_and_seen(m_ptr))
2418 r_ptr->r_flags3 |= RF3_EVIL;
2421 if (mult < 15) mult = 15;
2425 if ((have_flag(flgs, TR_KILL_EVIL)) &&
2426 (r_ptr->flags3 & RF3_EVIL))
2428 if (is_original_ap_and_seen(m_ptr))
2430 r_ptr->r_flags3 |= RF3_EVIL;
2433 if (mult < 25) mult = 25;
2437 if ((have_flag(flgs, TR_SLAY_HUMAN)) &&
2438 (r_ptr->flags2 & RF2_HUMAN))
2440 if (is_original_ap_and_seen(m_ptr))
2442 r_ptr->r_flags2 |= RF2_HUMAN;
2445 if (mult < 17) mult = 17;
2449 if ((have_flag(flgs, TR_KILL_HUMAN)) &&
2450 (r_ptr->flags2 & RF2_HUMAN))
2452 if (is_original_ap_and_seen(m_ptr))
2454 r_ptr->r_flags2 |= RF2_HUMAN;
2457 if (mult < 27) mult = 27;
2461 if ((have_flag(flgs, TR_SLAY_UNDEAD)) &&
2462 (r_ptr->flags3 & RF3_UNDEAD))
2464 if (is_original_ap_and_seen(m_ptr))
2466 r_ptr->r_flags3 |= RF3_UNDEAD;
2469 if (mult < 20) mult = 20;
2473 if ((have_flag(flgs, TR_KILL_UNDEAD)) &&
2474 (r_ptr->flags3 & RF3_UNDEAD))
2476 if (is_original_ap_and_seen(m_ptr))
2478 r_ptr->r_flags3 |= RF3_UNDEAD;
2481 if (mult < 30) mult = 30;
2485 if ((have_flag(flgs, TR_SLAY_DEMON)) &&
2486 (r_ptr->flags3 & RF3_DEMON))
2488 if (is_original_ap_and_seen(m_ptr))
2490 r_ptr->r_flags3 |= RF3_DEMON;
2493 if (mult < 20) mult = 20;
2497 if ((have_flag(flgs, TR_KILL_DEMON)) &&
2498 (r_ptr->flags3 & RF3_DEMON))
2500 if (is_original_ap_and_seen(m_ptr))
2502 r_ptr->r_flags3 |= RF3_DEMON;
2505 if (mult < 30) mult = 30;
2509 if ((have_flag(flgs, TR_SLAY_ORC)) &&
2510 (r_ptr->flags3 & RF3_ORC))
2512 if (is_original_ap_and_seen(m_ptr))
2514 r_ptr->r_flags3 |= RF3_ORC;
2517 if (mult < 20) mult = 20;
2521 if ((have_flag(flgs, TR_KILL_ORC)) &&
2522 (r_ptr->flags3 & RF3_ORC))
2524 if (is_original_ap_and_seen(m_ptr))
2526 r_ptr->r_flags3 |= RF3_ORC;
2529 if (mult < 30) mult = 30;
2533 if ((have_flag(flgs, TR_SLAY_TROLL)) &&
2534 (r_ptr->flags3 & RF3_TROLL))
2536 if (is_original_ap_and_seen(m_ptr))
2538 r_ptr->r_flags3 |= RF3_TROLL;
2541 if (mult < 20) mult = 20;
2545 if ((have_flag(flgs, TR_KILL_TROLL)) &&
2546 (r_ptr->flags3 & RF3_TROLL))
2548 if (is_original_ap_and_seen(m_ptr))
2550 r_ptr->r_flags3 |= RF3_TROLL;
2553 if (mult < 30) mult = 30;
2557 if ((have_flag(flgs, TR_SLAY_GIANT)) &&
2558 (r_ptr->flags3 & RF3_GIANT))
2560 if (is_original_ap_and_seen(m_ptr))
2562 r_ptr->r_flags3 |= RF3_GIANT;
2565 if (mult < 20) mult = 20;
2569 if ((have_flag(flgs, TR_KILL_GIANT)) &&
2570 (r_ptr->flags3 & RF3_GIANT))
2572 if (is_original_ap_and_seen(m_ptr))
2574 r_ptr->r_flags3 |= RF3_GIANT;
2577 if (mult < 30) mult = 30;
2581 if ((have_flag(flgs, TR_SLAY_DRAGON)) &&
2582 (r_ptr->flags3 & RF3_DRAGON))
2584 if (is_original_ap_and_seen(m_ptr))
2586 r_ptr->r_flags3 |= RF3_DRAGON;
2589 if (mult < 20) mult = 20;
2592 /* Execute Dragon */
2593 if ((have_flag(flgs, TR_KILL_DRAGON)) &&
2594 (r_ptr->flags3 & RF3_DRAGON))
2596 if (is_original_ap_and_seen(m_ptr))
2598 r_ptr->r_flags3 |= RF3_DRAGON;
2601 if (mult < 30) mult = 30;
2603 if ((o_ptr->name1 == ART_BARD_ARROW) &&
2604 (m_ptr->r_idx == MON_SMAUG) &&
2605 (inventory[INVEN_BOW].name1 == ART_BARD))
2610 if (have_flag(flgs, TR_BRAND_ACID))
2612 /* Notice immunity */
2613 if (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK)
2615 if (is_original_ap_and_seen(m_ptr))
2617 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK);
2621 /* Otherwise, take the damage */
2624 if (mult < 17) mult = 17;
2629 if (have_flag(flgs, TR_BRAND_ELEC))
2631 /* Notice immunity */
2632 if (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK)
2634 if (is_original_ap_and_seen(m_ptr))
2636 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK);
2640 /* Otherwise, take the damage */
2643 if (mult < 17) mult = 17;
2648 if (have_flag(flgs, TR_BRAND_FIRE))
2650 /* Notice immunity */
2651 if (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK)
2653 if (is_original_ap_and_seen(m_ptr))
2655 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK);
2659 /* Otherwise, take the damage */
2662 if (r_ptr->flags3 & RF3_HURT_FIRE)
2664 if (mult < 25) mult = 25;
2665 if (is_original_ap_and_seen(m_ptr))
2667 r_ptr->r_flags3 |= RF3_HURT_FIRE;
2670 else if (mult < 17) mult = 17;
2675 if (have_flag(flgs, TR_BRAND_COLD))
2677 /* Notice immunity */
2678 if (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK)
2680 if (is_original_ap_and_seen(m_ptr))
2682 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK);
2685 /* Otherwise, take the damage */
2688 if (r_ptr->flags3 & RF3_HURT_COLD)
2690 if (mult < 25) mult = 25;
2691 if (is_original_ap_and_seen(m_ptr))
2693 r_ptr->r_flags3 |= RF3_HURT_COLD;
2696 else if (mult < 17) mult = 17;
2700 /* Brand (Poison) */
2701 if (have_flag(flgs, TR_BRAND_POIS))
2703 /* Notice immunity */
2704 if (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK)
2706 if (is_original_ap_and_seen(m_ptr))
2708 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK);
2712 /* Otherwise, take the damage */
2715 if (mult < 17) mult = 17;
2719 if ((have_flag(flgs, TR_FORCE_WEAPON)) && (p_ptr->csp > (p_ptr->msp / 30)))
2721 p_ptr->csp -= (1+(p_ptr->msp / 30));
2722 p_ptr->redraw |= (PR_MANA);
2723 mult = mult * 5 / 2;
2730 if (snipe_type) mult = tot_dam_aux_snipe(mult, m_ptr);
2732 /* Return the total damage */
2733 return (tdam * mult / 10);
2738 * @brief 射撃処理のサブルーチン /
2739 * Fire an object from the pack or floor.
2740 * @param item 射撃するオブジェクトの所持ID
2741 * @param j_ptr 射撃武器のオブジェクト参照ポインタ
2745 * You may only fire items that "match" your missile launcher.
2747 * You must use slings + pebbles/shots, bows + arrows, xbows + bolts.
2749 * See "calc_bonuses()" for more calculations and such.
2751 * Note that "firing" a missile is MUCH better than "throwing" it.
2753 * Note: "unseen" monsters are very hard to hit.
2755 * Objects are more likely to break if they "attempt" to hit a monster.
2757 * Rangers (with Bows) and Anyone (with "Extra Shots") get extra shots.
2759 * The "extra shot" code works by decreasing the amount of energy
2760 * required to make each shot, spreading the shots out over time.
2762 * Note that when firing missiles, the launcher multiplier is applied
2763 * after all the bonuses are added in, making multipliers very useful.
2765 * Note that Bows of "Extra Might" get extra range and an extra bonus
2766 * for the damage multiplier.
2768 * Note that Bows of "Extra Shots" give an extra shot.
2771 void do_cmd_fire_aux(INVENTORY_IDX item, object_type *j_ptr)
2775 POSITION y, x, ny, nx, ty, tx, prev_y, prev_x;
2776 int tdam_base, tdis, thits, tmul;
2778 int cur_dis, visible;
2786 bool hit_body = FALSE;
2788 char o_name[MAX_NLEN];
2790 u16b path_g[512]; /* For calcuration of path length */
2792 int msec = delay_factor * delay_factor * delay_factor;
2795 bool stick_to = FALSE;
2797 /* Access the item (if in the pack) */
2800 o_ptr = &inventory[item];
2804 o_ptr = &o_list[0 - item];
2807 /* Sniper - Cannot shot a single arrow twice */
2808 if ((snipe_type == SP_DOUBLE) && (o_ptr->number < 2)) snipe_type = SP_NONE;
2810 /* Describe the object */
2811 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
2813 /* Use the proper number of shots */
2814 thits = p_ptr->num_fire;
2816 /* Use a base distance */
2819 /* Base damage from thrown object plus launcher bonus */
2820 tdam_base = damroll(o_ptr->dd, o_ptr->ds) + o_ptr->to_d + j_ptr->to_d;
2822 /* Actually "fire" the object */
2823 bonus = (p_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
2824 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
2825 chance = (p_ptr->skill_thb + (p_ptr->weapon_exp[0][j_ptr->sval] / 400 + bonus) * BTH_PLUS_ADJ);
2827 chance = (p_ptr->skill_thb + ((p_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + bonus) * BTH_PLUS_ADJ);
2829 p_ptr->energy_use = bow_energy(j_ptr->sval);
2830 tmul = bow_tmul(j_ptr->sval);
2832 /* Get extra "power" from "extra might" */
2833 if (p_ptr->xtra_might) tmul++;
2835 tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
2837 /* Boost the damage */
2842 tdis = 13 + tmul/80;
2843 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
2846 tdis -= (5 - (p_ptr->concent + 1) / 2);
2851 project_length = tdis + 1;
2853 /* Get a direction (or cancel) */
2854 if (!get_aim_dir(&dir))
2856 p_ptr->energy_use = 0;
2858 if (snipe_type == SP_AWAY) snipe_type = SP_NONE;
2860 /* need not to reset project_length (already did)*/
2865 /* Predict the "target" location */
2866 tx = p_ptr->x + 99 * ddx[dir];
2867 ty = p_ptr->y + 99 * ddy[dir];
2869 /* Check for "target request" */
2870 if ((dir == 5) && target_okay())
2876 /* Get projection path length */
2877 tdis = project_path(path_g, project_length, p_ptr->y, p_ptr->x, ty, tx, PROJECT_PATH|PROJECT_THRU) - 1;
2879 project_length = 0; /* reset to default */
2881 /* Don't shoot at my feet */
2882 if (tx == p_ptr->x && ty == p_ptr->y)
2884 p_ptr->energy_use = 0;
2886 /* project_length is already reset to 0 */
2892 /* Take a (partial) turn */
2893 p_ptr->energy_use = (p_ptr->energy_use / thits);
2896 /* Sniper - Difficult to shot twice at 1 turn */
2897 if (snipe_type == SP_DOUBLE) p_ptr->concent = (p_ptr->concent + 1) / 2;
2899 /* Sniper - Repeat shooting when double shots */
2900 for (i = 0; i < ((snipe_type == SP_DOUBLE) ? 2 : 1); i++)
2903 /* Start at the player */
2907 /* Get local object */
2910 /* Obtain a local object */
2911 object_copy(q_ptr, o_ptr);
2916 /* Reduce and describe inventory */
2919 inven_item_increase(item, -1);
2920 inven_item_describe(item);
2921 inven_item_optimize(item);
2924 /* Reduce and describe floor item */
2927 floor_item_increase(0 - item, -1);
2928 floor_item_optimize(0 - item);
2933 /* Hack -- Handle stuff */
2936 /* Save the old location */
2940 /* The shot does not hit yet */
2943 /* Travel until stopped */
2944 for (cur_dis = 0; cur_dis <= tdis; )
2948 /* Hack -- Stop at the target */
2949 if ((y == ty) && (x == tx)) break;
2951 /* Calculate the new location (see "project()") */
2954 mmove2(&ny, &nx, p_ptr->y, p_ptr->x, ty, tx);
2957 if (snipe_type == SP_KILL_WALL)
2959 c_ptr = &cave[ny][nx];
2961 if (cave_have_flag_grid(c_ptr, FF_HURT_ROCK) && !c_ptr->m_idx)
2963 if (c_ptr->info & (CAVE_MARK)) msg_print(_("岩が砕け散った。", "Wall rocks were shattered."));
2964 /* Forget the wall */
2965 c_ptr->info &= ~(CAVE_MARK);
2967 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
2969 /* Destroy the wall */
2970 cave_alter_feat(ny, nx, FF_HURT_ROCK);
2977 /* Stopped by walls/doors */
2978 if (!cave_have_flag_bold(ny, nx, FF_PROJECT) && !cave[ny][nx].m_idx) break;
2980 /* Advance the distance */
2984 if (snipe_type == SP_LITE)
2986 cave[ny][nx].info |= (CAVE_GLOW);
2995 /* The player can see the (on screen) missile */
2996 if (panel_contains(ny, nx) && player_can_see_bold(ny, nx))
2998 char c = object_char(q_ptr);
2999 byte a = object_attr(q_ptr);
3001 /* Draw, Hilite, Fresh, Pause, Erase */
3002 print_rel(c, a, ny, nx);
3003 move_cursor_relative(ny, nx);
3005 Term_xtra(TERM_XTRA_DELAY, msec);
3010 /* The player cannot see the missile */
3013 /* Pause anyway, for consistancy */
3014 Term_xtra(TERM_XTRA_DELAY, msec);
3018 if (snipe_type == SP_KILL_TRAP)
3020 project(0, 0, ny, nx, 0, GF_KILL_TRAP,
3021 (PROJECT_JUMP | PROJECT_HIDE | PROJECT_GRID | PROJECT_ITEM), -1);
3025 if (snipe_type == SP_EVILNESS)
3027 cave[ny][nx].info &= ~(CAVE_GLOW | CAVE_MARK);
3036 /* Save the old location */
3040 /* Save the new location */
3045 /* Monster here, Try to hit it */
3046 if (cave[y][x].m_idx)
3048 cave_type *c_mon_ptr = &cave[y][x];
3050 monster_type *m_ptr = &m_list[c_mon_ptr->m_idx];
3051 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3053 /* Check the visibility */
3054 visible = m_ptr->ml;
3056 /* Note the collision */
3059 if (MON_CSLEEP(m_ptr))
3061 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_COMPASSION, -1);
3062 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_HONOUR, -1);
3065 if ((r_ptr->level + 10) > p_ptr->lev)
3067 int now_exp = p_ptr->weapon_exp[0][j_ptr->sval];
3068 if (now_exp < s_info[p_ptr->pclass].w_max[0][j_ptr->sval])
3071 if (now_exp < WEAPON_EXP_BEGINNER) amount = 80;
3072 else if (now_exp < WEAPON_EXP_SKILLED) amount = 25;
3073 else if ((now_exp < WEAPON_EXP_EXPERT) && (p_ptr->lev > 19)) amount = 10;
3074 else if (p_ptr->lev > 34) amount = 2;
3075 p_ptr->weapon_exp[0][j_ptr->sval] += amount;
3076 p_ptr->update |= (PU_BONUS);
3082 if ((p_ptr->skill_exp[GINOU_RIDING] < s_info[p_ptr->pclass].s_max[GINOU_RIDING])
3083 && ((p_ptr->skill_exp[GINOU_RIDING] - (RIDING_EXP_BEGINNER * 2)) / 200 < r_info[m_list[p_ptr->riding].r_idx].level)
3086 p_ptr->skill_exp[GINOU_RIDING] += 1;
3087 p_ptr->update |= (PU_BONUS);
3091 /* Did we hit it (penalize range) */
3092 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
3095 int tdam = tdam_base;
3097 /* Get extra damage from concentration */
3098 if (p_ptr->concent) tdam = boost_concentration_damage(tdam);
3100 /* Handle unseen monster */
3103 /* Invisible monster */
3104 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
3107 /* Handle visible monster */
3112 /* Get "the monster" or "it" */
3113 monster_desc(m_name, m_ptr, 0);
3115 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
3119 /* Hack -- Track this monster race */
3120 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
3122 /* Hack -- Track this monster */
3123 health_track(c_mon_ptr->m_idx);
3127 if (snipe_type == SP_NEEDLE)
3129 if ((randint1(randint1(r_ptr->level / (3 + p_ptr->concent)) + (8 - p_ptr->concent)) == 1)
3130 && !(r_ptr->flags1 & RF1_UNIQUE) && !(r_ptr->flags7 & RF7_UNIQUE2))
3134 /* Get "the monster" or "it" */
3135 monster_desc(m_name, m_ptr, 0);
3137 tdam = m_ptr->hp + 1;
3138 msg_format(_("%sの急所に突き刺さった!", "Your shot sticked on a fatal spot of %s!"), m_name);
3144 /* Apply special damage XXX XXX XXX */
3145 tdam = tot_dam_aux_shot(q_ptr, tdam, m_ptr);
3146 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, j_ptr->to_h, tdam);
3148 /* No negative damage */
3149 if (tdam < 0) tdam = 0;
3151 /* Modify the damage */
3152 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
3155 msg_format_wizard(CHEAT_MONSTER,
3156 _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
3157 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
3160 if (snipe_type == SP_EXPLODE)
3162 u16b flg = (PROJECT_STOP | PROJECT_JUMP | PROJECT_KILL | PROJECT_GRID);
3164 sound(SOUND_EXPLODE); /* No explode sound - use breath fire instead */
3165 project(0, ((p_ptr->concent + 1) / 2 + 1), ny, nx, tdam, GF_MISSILE, flg, -1);
3170 if (snipe_type == SP_HOLYNESS)
3172 cave[ny][nx].info |= (CAVE_GLOW);
3181 /* Hit the monster, check for death */
3182 if (mon_take_hit(c_mon_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_ptr(m_ptr))))
3191 if (object_is_fixed_artifact(q_ptr) &&
3192 (p_ptr->pclass != CLASS_SNIPER || p_ptr->concent == 0))
3196 monster_desc(m_name, m_ptr, 0);
3199 msg_format(_("%sは%sに突き刺さった!", "%^s have stuck into %s!"),o_name, m_name);
3202 message_pain(c_mon_ptr->m_idx, tdam);
3204 /* Anger the monster */
3205 if (tdam > 0) anger_monster(m_ptr);
3208 if (fear && m_ptr->ml)
3214 /* Get the monster name (or "it") */
3215 monster_desc(m_name, m_ptr, 0);
3217 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
3220 set_target(m_ptr, p_ptr->y, p_ptr->x);
3223 if (snipe_type == SP_RUSH)
3225 int n = randint1(5) + 3;
3226 MONSTER_IDX m_idx = c_mon_ptr->m_idx;
3228 for ( ; cur_dis <= tdis; )
3235 /* Calculate the new location (see "project()") */
3236 mmove2(&ny, &nx, p_ptr->y, p_ptr->x, ty, tx);
3238 /* Stopped by wilderness boundary */
3239 if (!in_bounds2(ny, nx)) break;
3241 /* Stopped by walls/doors */
3242 if (!player_can_enter(cave[ny][nx].feat, 0)) break;
3244 /* Stopped by monsters */
3245 if (!cave_empty_bold(ny, nx)) break;
3247 cave[ny][nx].m_idx = m_idx;
3248 cave[oy][ox].m_idx = 0;
3253 /* Update the monster (new location) */
3254 update_mon(c_mon_ptr->m_idx, TRUE);
3260 Term_xtra(TERM_XTRA_DELAY, msec);
3272 if (snipe_type == SP_PIERCE)
3274 if(p_ptr->concent < 1) break;
3284 /* Chance of breakage (during attacks) */
3285 j = (hit_body ? breakage_chance(q_ptr) : 0);
3289 MONSTER_IDX m_idx = cave[y][x].m_idx;
3290 monster_type *m_ptr = &m_list[m_idx];
3291 OBJECT_IDX o_idx = o_pop();
3295 msg_format(_("%sはどこかへ行った。", "The %s have gone to somewhere."), o_name);
3296 if (object_is_fixed_artifact(q_ptr))
3298 a_info[j_ptr->name1].cur_num = 0;
3303 o_ptr = &o_list[o_idx];
3304 object_copy(o_ptr, q_ptr);
3307 o_ptr->marked &= OM_TOUCHED;
3309 /* Forget location */
3310 o_ptr->iy = o_ptr->ix = 0;
3312 /* Memorize monster */
3313 o_ptr->held_m_idx = m_idx;
3316 o_ptr->next_o_idx = m_ptr->hold_o_idx;
3319 m_ptr->hold_o_idx = o_idx;
3321 else if (cave_have_flag_bold(y, x, FF_PROJECT))
3323 /* Drop (or break) near that location */
3324 (void)drop_near(q_ptr, j, y, x);
3328 /* Drop (or break) near that location */
3329 (void)drop_near(q_ptr, j, prev_y, prev_x);
3332 /* Sniper - Repeat shooting when double shots */
3335 /* Sniper - Loose his/her concentration after any shot */
3336 if (p_ptr->concent) reset_concentration(FALSE);
3340 * @brief 射撃処理のメインルーチン
3343 void do_cmd_fire(void)
3349 is_fired = FALSE; /* not fired yet */
3351 /* Get the "bow" (if any) */
3352 j_ptr = &inventory[INVEN_BOW];
3354 /* Require a launcher */
3357 msg_print(_("射撃用の武器を持っていない。", "You have nothing to fire with."));
3362 if (j_ptr->sval == SV_CRIMSON)
3364 msg_print(_("この武器は発動して使うもののようだ。", "Do activate."));
3369 if (j_ptr->sval == SV_HARP)
3371 msg_print(_("この武器で射撃はできない。", "It's not for firing."));
3377 if (p_ptr->special_defense & KATA_MUSOU)
3379 set_action(ACTION_NONE);
3382 /* Require proper missile */
3383 item_tester_tval = p_ptr->tval_ammo;
3386 q = _("どれを撃ちますか? ", "Fire which item? ");
3387 s = _("発射されるアイテムがありません。", "You have nothing to fire.");
3388 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR)))
3395 do_cmd_fire_aux(item, j_ptr);
3397 if (!is_fired || p_ptr->pclass != CLASS_SNIPER) return;
3399 /* Sniper actions after some shootings */
3400 if (snipe_type == SP_AWAY)
3402 teleport_player(10 + (p_ptr->concent * 2), 0L);
3404 if (snipe_type == SP_FINAL)
3406 msg_print(_("射撃の反動が体を襲った。", "A reactionary of shooting attacked you. "));
3407 (void)set_slow(p_ptr->slow + randint0(7) + 7, FALSE);
3408 (void)set_stun(p_ptr->stun + randint1(25));
3414 * @brief 投射処理メインルーチン /
3415 * Throw an object from the pack or floor.
3417 * @param boomerang ブーメラン処理ならばTRUE
3418 * @param shuriken 忍者の手裏剣処理ならばTRUE
3419 * @return ターンを消費した場合TRUEを返す
3422 * Note: "unseen" monsters are very hard to hit.
3424 * Should throwing a weapon do full damage? Should it allow the magic
3425 * to hit bonus of the weapon to have an effect? Should it ever cause
3426 * the item to be destroyed? Should it do any damage at all?
3429 bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
3434 POSITION y, x, ty, tx, prev_y, prev_x;
3435 POSITION ny[19], nx[19];
3436 int chance, tdam, tdis;
3437 int mul, div, dd, ds;
3438 int cur_dis, visible;
3446 bool hit_body = FALSE;
3447 bool hit_wall = FALSE;
3448 bool equiped_item = FALSE;
3449 bool return_when_thrown = FALSE;
3451 char o_name[MAX_NLEN];
3453 int msec = delay_factor * delay_factor * delay_factor;
3455 BIT_FLAGS flgs[TR_FLAG_SIZE];
3457 bool come_back = FALSE;
3458 bool do_drop = TRUE;
3461 if (p_ptr->special_defense & KATA_MUSOU)
3463 set_action(ACTION_NONE);
3472 if (buki_motteruka(INVEN_RARM) && buki_motteruka(INVEN_LARM))
3474 item_tester_hook = item_tester_hook_boomerang;
3475 q = _("どの武器を投げますか? ", "Throw which item? ");
3476 s = _("投げる武器がない。", "You have nothing to throw.");
3477 if (!get_item(&item, q, s, (USE_EQUIP)))
3483 else if (buki_motteruka(INVEN_LARM)) item = INVEN_LARM;
3484 else item = INVEN_RARM;
3489 q = _("どのアイテムを投げますか? ", "Throw which item? ");
3490 s = _("投げるアイテムがない。", "You have nothing to throw.");
3491 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP)))
3498 /* Access the item (if in the pack) */
3501 o_ptr = &inventory[item];
3505 o_ptr = &o_list[0 - item];
3509 /* Item is cursed */
3510 if (object_is_cursed(o_ptr) && (item >= INVEN_RARM))
3513 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
3519 if (p_ptr->inside_arena && !boomerang)
3521 if (o_ptr->tval != TV_SPIKE)
3523 msg_print(_("アリーナではアイテムを使えない!", "You're in the arena now. This is hand-to-hand!"));
3532 /* Get local object */
3535 /* Obtain a local object */
3536 object_copy(q_ptr, o_ptr);
3538 /* Extract the thrown object's flags. */
3539 object_flags(q_ptr, flgs);
3540 torch_flags(q_ptr, flgs);
3542 /* Distribute the charges of rods/wands between the stacks */
3543 distribute_charges(o_ptr, q_ptr, 1);
3549 object_desc(o_name, q_ptr, OD_OMIT_PREFIX);
3551 if (p_ptr->mighty_throw) mult += 3;
3553 /* Extract a "distance multiplier" */
3554 /* Changed for 'launcher' mutation */
3555 mul = 10 + 2 * (mult - 1);
3557 /* Enforce a minimum "weight" of one pound */
3558 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
3559 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
3561 /* Hack -- Distance -- Reward strength, penalize weight */
3562 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
3564 /* Max distance of 10-18 */
3565 if (tdis > mul) tdis = mul;
3569 ty = randint0(101) - 50 + p_ptr->y;
3570 tx = randint0(101) - 50 + p_ptr->x;
3574 project_length = tdis + 1;
3576 /* Get a direction (or cancel) */
3577 if (!get_aim_dir(&dir)) return FALSE;
3579 /* Predict the "target" location */
3580 tx = p_ptr->x + 99 * ddx[dir];
3581 ty = p_ptr->y + 99 * ddy[dir];
3583 /* Check for "target request" */
3584 if ((dir == 5) && target_okay())
3590 project_length = 0; /* reset to default */
3593 if ((q_ptr->name1 == ART_MJOLLNIR) ||
3594 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
3595 return_when_thrown = TRUE;
3597 /* Reduce and describe inventory */
3600 inven_item_increase(item, -1);
3601 if (!return_when_thrown)
3602 inven_item_describe(item);
3603 inven_item_optimize(item);
3606 /* Reduce and describe floor item */
3609 floor_item_increase(0 - item, -1);
3610 floor_item_optimize(0 - item);
3612 if (item >= INVEN_RARM)
3614 equiped_item = TRUE;
3615 p_ptr->redraw |= (PR_EQUIPPY);
3618 p_ptr->energy_use = 100;
3620 /* Rogue and Ninja gets bonus */
3621 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
3622 p_ptr->energy_use -= p_ptr->lev;
3624 /* Start at the player */
3629 /* Hack -- Handle stuff */
3632 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
3633 else shuriken = FALSE;
3635 /* Chance of hitting */
3636 if (have_flag(flgs, TR_THROW)) chance = ((p_ptr->skill_tht) +
3637 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
3638 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
3640 if (shuriken) chance *= 2;
3642 /* Save the old location */
3646 /* Travel until stopped */
3647 for (cur_dis = 0; cur_dis <= tdis; )
3649 /* Hack -- Stop at the target */
3650 if ((y == ty) && (x == tx)) break;
3652 /* Calculate the new location (see "project()") */
3655 mmove2(&ny[cur_dis], &nx[cur_dis], p_ptr->y, p_ptr->x, ty, tx);
3657 /* Stopped by walls/doors */
3658 if (!cave_have_flag_bold(ny[cur_dis], nx[cur_dis], FF_PROJECT))
3661 if ((q_ptr->tval == TV_FIGURINE) || object_is_potion(q_ptr) || !cave[ny[cur_dis]][nx[cur_dis]].m_idx) break;
3664 /* The player can see the (on screen) missile */
3665 if (panel_contains(ny[cur_dis], nx[cur_dis]) && player_can_see_bold(ny[cur_dis], nx[cur_dis]))
3667 char c = object_char(q_ptr);
3668 byte a = object_attr(q_ptr);
3670 /* Draw, Hilite, Fresh, Pause, Erase */
3671 print_rel(c, a, ny[cur_dis], nx[cur_dis]);
3672 move_cursor_relative(ny[cur_dis], nx[cur_dis]);
3674 Term_xtra(TERM_XTRA_DELAY, msec);
3675 lite_spot(ny[cur_dis], nx[cur_dis]);
3679 /* The player cannot see the missile */
3682 /* Pause anyway, for consistancy */
3683 Term_xtra(TERM_XTRA_DELAY, msec);
3686 /* Save the old location */
3690 /* Save the new location */
3694 /* Advance the distance */
3697 /* Monster here, Try to hit it */
3698 if (cave[y][x].m_idx)
3700 cave_type *c_ptr = &cave[y][x];
3701 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3703 /* Check the visibility */
3704 visible = m_ptr->ml;
3706 /* Note the collision */
3709 /* Did we hit it (penalize range) */
3710 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
3714 /* Handle unseen monster */
3717 /* Invisible monster */
3718 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
3721 /* Handle visible monster */
3726 /* Get "the monster" or "it" */
3727 monster_desc(m_name, m_ptr, 0);
3729 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
3733 /* Hack -- Track this monster race */
3734 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
3736 /* Hack -- Track this monster */
3737 health_track(c_ptr->m_idx);
3741 /* Hack -- Base damage from thrown object */
3744 torch_dice(q_ptr, &dd, &ds); /* throwing a torch */
3745 tdam = damroll(dd, ds);
3746 /* Apply special damage XXX XXX XXX */
3747 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0, TRUE);
3748 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, 0, tdam);
3749 if (q_ptr->to_d > 0)
3750 tdam += q_ptr->to_d;
3752 tdam += -q_ptr->to_d;
3756 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
3757 tdam += p_ptr->to_d_m;
3759 else if (have_flag(flgs, TR_THROW))
3762 tdam += p_ptr->to_d_m;
3770 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
3773 /* No negative damage */
3774 if (tdam < 0) tdam = 0;
3776 /* Modify the damage */
3777 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
3779 msg_format_wizard(CHEAT_MONSTER, _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
3780 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
3782 /* Hit the monster, check for death */
3783 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_ptr(m_ptr))))
3791 message_pain(c_ptr->m_idx, tdam);
3793 /* Anger the monster */
3794 if ((tdam > 0) && !object_is_potion(q_ptr))
3795 anger_monster(m_ptr);
3798 if (fear && m_ptr->ml)
3804 /* Get the monster name (or "it") */
3805 monster_desc(m_name, m_ptr, 0);
3807 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
3817 /* decrease toach's fuel */
3818 if (hit_body) torch_lost_fuel(q_ptr);
3820 /* Chance of breakage (during attacks) */
3821 j = (hit_body ? breakage_chance(q_ptr) : 0);
3823 /* Figurines transform */
3824 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
3828 if (!(summon_named_creature(0, y, x, q_ptr->pval,
3829 !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L)))
3830 msg_print(_("人形は捻じ曲がり砕け散ってしまった!", "The Figurine writhes and then shatters."));
3831 else if (object_is_cursed(q_ptr))
3832 msg_print(_("これはあまり良くない気がする。", "You have a bad feeling about this."));
3837 /* Potions smash open */
3838 if (object_is_potion(q_ptr))
3840 if (hit_body || hit_wall || (randint1(100) < j))
3842 msg_format(_("%sは砕け散った!", "The %s shatters!"), o_name);
3844 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
3846 monster_type *m_ptr = &m_list[cave[y][x].m_idx];
3848 /* ToDo (Robert): fix the invulnerability */
3849 if (cave[y][x].m_idx &&
3850 is_friendly(&m_list[cave[y][x].m_idx]) &&
3851 !MON_INVULNER(m_ptr))
3854 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
3855 msg_format(_("%sは怒った!", "%^s gets angry!"), m_name);
3856 set_hostile(&m_list[cave[y][x].m_idx]);
3867 if (return_when_thrown)
3869 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
3870 char o2_name[MAX_NLEN];
3871 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
3874 if (boomerang) back_chance += 4+randint1(5);
3875 if (super_boomerang) back_chance += 100;
3876 object_desc(o2_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3878 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
3880 for (i = cur_dis - 1; i > 0; i--)
3882 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
3884 char c = object_char(q_ptr);
3885 byte a = object_attr(q_ptr);
3887 /* Draw, Hilite, Fresh, Pause, Erase */
3888 print_rel(c, a, ny[i], nx[i]);
3889 move_cursor_relative(ny[i], nx[i]);
3891 Term_xtra(TERM_XTRA_DELAY, msec);
3892 lite_spot(ny[i], nx[i]);
3897 /* Pause anyway, for consistancy */
3898 Term_xtra(TERM_XTRA_DELAY, msec);
3901 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
3903 msg_format(_("%sが手元に返ってきた。", "%s comes back to you."), o2_name);
3910 msg_format(_("%sを受け損ねた!", "%s backs, but you can't catch!"), o2_name);
3914 msg_format(_("%sが返ってきた。", "%s comes back."), o2_name);
3922 msg_format(_("%sが返ってこなかった!", "%s doesn't back!"), o2_name);
3928 if (item == INVEN_RARM || item == INVEN_LARM)
3930 /* Access the wield slot */
3931 o_ptr = &inventory[item];
3933 /* Wear the new stuff */
3934 object_copy(o_ptr, q_ptr);
3936 /* Increase the weight */
3937 p_ptr->total_weight += q_ptr->weight;
3939 /* Increment the equip counter by hand */
3942 /* Recalculate bonuses */
3943 p_ptr->update |= (PU_BONUS);
3945 /* Recalculate torch */
3946 p_ptr->update |= (PU_TORCH);
3948 /* Recalculate mana XXX */
3949 p_ptr->update |= (PU_MANA);
3951 p_ptr->window |= (PW_EQUIP);
3959 else if (equiped_item)
3965 /* Drop (or break) near that location */
3968 if (cave_have_flag_bold(y, x, FF_PROJECT))
3970 /* Drop (or break) near that location */
3971 (void)drop_near(q_ptr, j, y, x);
3975 /* Drop (or break) near that location */
3976 (void)drop_near(q_ptr, j, prev_y, prev_x);
3986 * Hack: travel command
3988 #define TRAVEL_UNABLE 9999
3990 static int flow_head = 0;
3991 static int flow_tail = 0;
3992 static POSITION temp2_x[MAX_SHORT];
3993 static POSITION temp2_y[MAX_SHORT];
3996 * @brief トラベル処理の記憶配列を初期化する Hack: forget the "flow" information
3999 void forget_travel_flow(void)
4003 /* Check the entire dungeon */
4004 for (y = 0; y < cur_hgt; y++)
4006 for (x = 0; x < cur_wid; x++)
4008 /* Forget the old data */
4009 travel.cost[y][x] = MAX_SHORT;
4013 travel.y = travel.x = 0;
4017 * @brief トラベル処理中に地形に応じた移動コスト基準を返す
4022 static int travel_flow_cost(POSITION y, POSITION x)
4024 feature_type *f_ptr = &f_info[cave[y][x].feat];
4027 /* Avoid obstacles (ex. trees) */
4028 if (have_flag(f_ptr->flags, FF_AVOID_RUN)) cost += 1;
4031 if (have_flag(f_ptr->flags, FF_WATER))
4033 if (have_flag(f_ptr->flags, FF_DEEP) && !p_ptr->levitation) cost += 5;
4037 if (have_flag(f_ptr->flags, FF_LAVA))
4040 if (!p_ptr->resist_fire) lava *= 2;
4041 if (!p_ptr->levitation) lava *= 2;
4042 if (have_flag(f_ptr->flags, FF_DEEP)) lava *= 2;
4047 /* Detected traps and doors */
4048 if (cave[y][x].info & (CAVE_MARK))
4050 if (have_flag(f_ptr->flags, FF_DOOR)) cost += 1;
4051 if (have_flag(f_ptr->flags, FF_TRAP)) cost += 10;
4058 * @brief トラベル処理の到達地点までの行程を得る処理のサブルーチン
4062 * @param wall プレイヤーが壁の中にいるならばTRUE
4065 static void travel_flow_aux(POSITION y, POSITION x, int n, bool wall)
4067 cave_type *c_ptr = &cave[y][x];
4068 feature_type *f_ptr = &f_info[c_ptr->feat];
4069 int old_head = flow_head;
4071 int base_cost = (n % TRAVEL_UNABLE);
4072 int from_wall = (n / TRAVEL_UNABLE);
4075 /* Ignore out of bounds */
4076 if (!in_bounds(y, x)) return;
4078 /* Ignore unknown grid except in wilderness */
4079 if (dun_level > 0 && !(c_ptr->info & CAVE_KNOWN)) return;
4081 /* Ignore "walls" and "rubble" (include "secret doors") */
4082 if (have_flag(f_ptr->flags, FF_WALL) ||
4083 have_flag(f_ptr->flags, FF_CAN_DIG) ||
4084 (have_flag(f_ptr->flags, FF_DOOR) && cave[y][x].mimic) ||
4085 (!have_flag(f_ptr->flags, FF_MOVE) && have_flag(f_ptr->flags, FF_CAN_FLY) && !p_ptr->levitation))
4087 if (!wall || !from_wall) return;
4088 add_cost += TRAVEL_UNABLE;
4092 add_cost = travel_flow_cost(y, x);
4095 cost = base_cost + add_cost;
4097 /* Ignore lower cost entries */
4098 if (travel.cost[y][x] <= cost) return;
4100 /* Save the flow cost */
4101 travel.cost[y][x] = cost;
4103 /* Enqueue that entry */
4104 temp2_y[flow_head] = y;
4105 temp2_x[flow_head] = x;
4107 /* Advance the queue */
4108 if (++flow_head == MAX_SHORT) flow_head = 0;
4110 /* Hack -- notice overflow by forgetting new entry */
4111 if (flow_head == flow_tail) flow_head = old_head;
4117 * @brief トラベル処理の到達地点までの行程を得る処理のメインルーチン
4118 * @param ty 目標地点のY座標
4119 * @param tx 目標地点のX座標
4122 static void travel_flow(POSITION ty, POSITION tx)
4126 feature_type *f_ptr = &f_info[cave[p_ptr->y][p_ptr->x].feat];
4128 /* Reset the "queue" */
4129 flow_head = flow_tail = 0;
4131 /* is player in the wall? */
4132 if (!have_flag(f_ptr->flags, FF_MOVE)) wall = TRUE;
4134 /* Start at the target grid */
4135 travel_flow_aux(ty, tx, 0, wall);
4137 /* Now process the queue */
4138 while (flow_head != flow_tail)
4140 /* Extract the next entry */
4141 y = temp2_y[flow_tail];
4142 x = temp2_x[flow_tail];
4144 /* Forget that entry */
4145 if (++flow_tail == MAX_SHORT) flow_tail = 0;
4147 /* Ignore too far entries */
4148 //if (distance(ty, tx, y, x) > 100) continue;
4150 /* Add the "children" */
4151 for (d = 0; d < 8; d++)
4153 /* Add that child if "legal" */
4154 travel_flow_aux(y + ddy_ddd[d], x + ddx_ddd[d], travel.cost[y][x], wall);
4158 /* Forget the flow info */
4159 flow_head = flow_tail = 0;
4163 * @brief トラベル処理のメインルーチン
4166 void do_cmd_travel(void)
4171 feature_type *f_ptr;
4173 if (travel.x != 0 && travel.y != 0 &&
4174 get_check(_("トラベルを継続しますか?", "Do you continue to travel?")))
4179 else if (!tgt_pt(&x, &y)) return;
4181 if ((x == p_ptr->x) && (y == p_ptr->y))
4183 msg_print(_("すでにそこにいます!", "You are already there!!"));
4187 f_ptr = &f_info[cave[y][x].feat];
4189 if ((cave[y][x].info & CAVE_MARK) &&
4190 (have_flag(f_ptr->flags, FF_WALL) ||
4191 have_flag(f_ptr->flags, FF_CAN_DIG) ||
4192 (have_flag(f_ptr->flags, FF_DOOR) && cave[y][x].mimic)))
4194 msg_print(_("そこには行くことができません!", "You cannot travel there!"));
4198 forget_travel_flow();
4204 /* Travel till 255 steps */
4210 /* Decides first direction */
4211 dx = abs(p_ptr->x - x);
4212 dy = abs(p_ptr->y - y);
4213 sx = ((x == p_ptr->x) || (dx < dy)) ? 0 : ((x > p_ptr->x) ? 1 : -1);
4214 sy = ((y == p_ptr->y) || (dy < dx)) ? 0 : ((y > p_ptr->y) ? 1 : -1);
4216 for (i = 1; i <= 9; i++)
4218 if ((sx == ddx[i]) && (sy == ddy[i])) travel.dir = i;