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);
1941 msg_print(_("何もない空中を攻撃した。", "You attack the empty air."));
1945 /* Cancel repetition unless we can continue */
1946 if (!more) disturb(0, 0);
1952 * @brief 「くさびを打つ」ために必要なオブジェクトがあるかどうかの判定を返す /
1953 * Find the index of some "spikes", if possible.
1954 * @param ip くさびとして打てるオブジェクトのID
1955 * @return オブジェクトがある場合TRUEを返す
1958 * XXX XXX XXX Let user choose a pile of spikes, perhaps?
1961 static bool get_spike(INVENTORY_IDX *ip)
1965 /* Check every item in the pack */
1966 for (i = 0; i < INVEN_PACK; i++)
1968 object_type *o_ptr = &inventory[i];
1970 /* Skip non-objects */
1971 if (!o_ptr->k_idx) continue;
1973 /* Check the "tval" code */
1974 if (o_ptr->tval == TV_SPIKE)
1976 /* Save the spike index */
1989 * @brief 「くさびを打つ」動作コマンドのメインルーチン /
1990 * Jam a closed door with a spike
1994 * This command may NOT be repeated
1997 void do_cmd_spike(void)
2001 if (p_ptr->special_defense & KATA_MUSOU)
2003 set_action(ACTION_NONE);
2006 /* Get a "repeated" direction */
2007 if (get_rep_dir(&dir,FALSE))
2015 y = p_ptr->y + ddy[dir];
2016 x = p_ptr->x + ddx[dir];
2018 /* Get grid and contents */
2019 c_ptr = &cave[y][x];
2021 /* Feature code (applying "mimic" field) */
2022 feat = get_feat_mimic(c_ptr);
2024 /* Require closed door */
2025 if (!have_flag(f_info[feat].flags, FF_SPIKE))
2027 msg_print(_("そこにはくさびを打てるものが見当たらない。", "You see nothing there to spike."));
2031 else if (!get_spike(&item))
2033 msg_print(_("くさびを持っていない!", "You have no spikes!"));
2036 /* Is a monster in the way? */
2037 else if (c_ptr->m_idx)
2039 p_ptr->energy_use = 100;
2041 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
2050 p_ptr->energy_use = 100;
2052 /* Successful jamming */
2053 msg_format(_("%sにくさびを打ち込んだ。", "You jam the %s with a spike."), f_name + f_info[feat].name);
2054 cave_alter_feat(y, x, FF_SPIKE);
2056 /* Use up, and describe, a single spike, from the bottom */
2057 inven_item_increase(item, -1);
2058 inven_item_describe(item);
2059 inven_item_optimize(item);
2067 * @brief 「歩く」動作コマンドのメインルーチン /
2068 * Support code for the "Walk" and "Jump" commands
2069 * @param pickup アイテムの自動拾いを行うならTRUE
2072 void do_cmd_walk(bool pickup)
2079 /* Allow repeated command */
2082 /* Set repeat count */
2083 command_rep = command_arg - 1;
2085 /* Redraw the state */
2086 p_ptr->redraw |= (PR_STATE);
2088 /* Cancel the arg */
2092 /* Get a "repeated" direction */
2093 if (get_rep_dir(&dir, FALSE))
2095 p_ptr->energy_use = 100;
2097 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
2099 set_action(ACTION_NONE);
2102 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2103 if (p_ptr->wild_mode) p_ptr->energy_use *= ((MAX_HGT + MAX_WID) / 2);
2104 if (p_ptr->action == ACTION_HAYAGAKE) p_ptr->energy_use = p_ptr->energy_use * (45-(p_ptr->lev/2)) / 100;
2106 /* Actually move the character */
2107 move_player(dir, pickup, FALSE);
2109 /* Allow more walking */
2113 /* Hack again -- Is there a special encounter ??? */
2114 if (p_ptr->wild_mode && !cave_have_flag_bold(p_ptr->y, p_ptr->x, FF_TOWN))
2116 int tmp = 120 + p_ptr->lev*10 - wilderness[p_ptr->y][p_ptr->x].level + 5;
2119 if (((wilderness[p_ptr->y][p_ptr->x].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2121 /* Inform the player of his horrible fate :=) */
2122 msg_print(_("襲撃だ!", "You are ambushed !"));
2124 /* Go into large wilderness view */
2125 p_ptr->oldpy = randint1(MAX_HGT-2);
2126 p_ptr->oldpx = randint1(MAX_WID-2);
2129 /* Give first move to monsters */
2130 p_ptr->energy_use = 100;
2132 /* HACk -- set the encouter flag for the wilderness generation */
2133 generate_encounter = TRUE;
2137 /* Cancel repeat unless we may continue */
2138 if (!more) disturb(0, 0);
2143 * @brief 「走る」動作コマンドのメインルーチン /
2147 void do_cmd_run(void)
2151 /* Hack -- no running when confused */
2152 if (p_ptr->confused)
2154 msg_print(_("混乱していて走れない!", "You are too confused!"));
2158 if (p_ptr->special_defense & KATA_MUSOU)
2160 set_action(ACTION_NONE);
2163 /* Get a "repeated" direction */
2164 if (get_rep_dir(&dir,FALSE))
2166 /* Hack -- Set the run counter */
2167 running = (command_arg ? command_arg : 1000);
2176 * @brief 「留まる」動作コマンドのメインルーチン /
2177 * Stay still. Search. Enter stores.
2178 * Pick up treasure if "pickup" is true.
2179 * @param pickup アイテムの自動拾いを行うならTRUE
2182 void do_cmd_stay(bool pickup)
2184 u32b mpe_mode = MPE_STAYING | MPE_ENERGY_USE;
2186 /* Allow repeated command */
2189 /* Set repeat count */
2190 command_rep = command_arg - 1;
2192 /* Redraw the state */
2193 p_ptr->redraw |= (PR_STATE);
2195 /* Cancel the arg */
2199 p_ptr->energy_use = 100;
2201 if (pickup) mpe_mode |= MPE_DO_PICKUP;
2202 (void)move_player_effect(p_ptr->y, p_ptr->x, mpe_mode);
2207 * @brief 「休む」動作コマンドのメインルーチン /
2208 * Resting allows a player to safely restore his hp -RAK-
2211 void do_cmd_rest(void)
2214 set_action(ACTION_NONE);
2216 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) || INTERUPTING_SONG_EFFECT(p_ptr)))
2222 if (hex_spelling_any()) stop_hex_spell_all();
2224 /* Prompt for time if needed */
2225 if (command_arg <= 0)
2227 cptr p = _("休憩 (0-9999, '*' で HP/MP全快, '&' で必要なだけ): ",
2228 "Rest (0-9999, '*' for HP/SP, '&' as needed): ");
2234 strcpy(out_val, "&");
2236 /* Ask for duration */
2237 if (!get_string(p, out_val, 4)) return;
2239 /* Rest until done */
2240 if (out_val[0] == '&')
2242 command_arg = COMMAND_ARG_REST_UNTIL_DONE;
2246 else if (out_val[0] == '*')
2248 command_arg = COMMAND_ARG_REST_FULL_HEALING;
2254 command_arg = (COMMAND_ARG)atoi(out_val);
2255 if (command_arg <= 0) return;
2261 if (command_arg > 9999) command_arg = 9999;
2263 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
2265 /* Take a turn XXX XXX XXX (?) */
2266 p_ptr->energy_use = 100;
2268 /* The sin of sloth */
2269 if (command_arg > 100)
2270 chg_virtue(V_DILIGENCE, -1);
2272 /* Why are you sleeping when there's no need? WAKE UP!*/
2273 if ((p_ptr->chp == p_ptr->mhp) &&
2274 (p_ptr->csp == p_ptr->msp) &&
2275 !p_ptr->blind && !p_ptr->confused &&
2276 !p_ptr->poisoned && !p_ptr->afraid &&
2277 !p_ptr->stun && !p_ptr->cut &&
2278 !p_ptr->slow && !p_ptr->paralyzed &&
2279 !p_ptr->image && !p_ptr->word_recall &&
2280 !p_ptr->alter_reality)
2281 chg_virtue(V_DILIGENCE, -1);
2283 /* Save the rest code */
2284 resting = command_arg;
2285 p_ptr->action = ACTION_REST;
2287 /* Recalculate bonuses */
2288 p_ptr->update |= (PU_BONUS);
2290 /* Redraw the state */
2291 p_ptr->redraw |= (PR_STATE);
2302 * @brief 矢弾を射撃した場合の破損確率を返す /
2303 * Determines the odds of an object breaking when thrown at a monster
2304 * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
2307 * Note that artifacts never break, see the "drop_near()" function.
2309 static PERCENTAGE breakage_chance(object_type *o_ptr)
2311 PERCENTAGE archer_bonus = (p_ptr->pclass == CLASS_ARCHER ? (PERCENTAGE)(p_ptr->lev-1)/7 + 4: 0);
2313 /* Examine the snipe type */
2316 if (snipe_type == SP_KILL_WALL) return (100);
2317 if (snipe_type == SP_EXPLODE) return (100);
2318 if (snipe_type == SP_PIERCE) return (100);
2319 if (snipe_type == SP_FINAL) return (100);
2320 if (snipe_type == SP_NEEDLE) return (100);
2321 if (snipe_type == SP_EVILNESS) return (40);
2322 if (snipe_type == SP_HOLYNESS) return (40);
2325 /* Examine the item type */
2326 switch (o_ptr->tval)
2342 /* Sometimes break */
2347 return (20 - archer_bonus * 2);
2352 return (10 - archer_bonus);
2360 * @brief 矢弾を射撃した際のスレイ倍率をかけた結果を返す /
2361 * Determines the odds of an object breaking when thrown at a monster
2362 * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
2363 * @param tdam 計算途中のダメージ量
2364 * @param m_ptr 目標モンスターの構造体参照ポインタ
2365 * @return スレイ倍率をかけたダメージ量
2367 static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
2371 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2373 BIT_FLAGS flgs[TR_FLAG_SIZE];
2375 /* Extract the flags */
2376 object_flags(o_ptr, flgs);
2378 /* Some "weapons" and "ammo" do extra damage */
2379 switch (o_ptr->tval)
2386 if ((have_flag(flgs, TR_SLAY_ANIMAL)) &&
2387 (r_ptr->flags3 & RF3_ANIMAL))
2389 if (is_original_ap_and_seen(m_ptr))
2391 r_ptr->r_flags3 |= RF3_ANIMAL;
2394 if (mult < 17) mult = 17;
2398 if ((have_flag(flgs, TR_KILL_ANIMAL)) &&
2399 (r_ptr->flags3 & RF3_ANIMAL))
2401 if (is_original_ap_and_seen(m_ptr))
2403 r_ptr->r_flags3 |= RF3_ANIMAL;
2406 if (mult < 27) mult = 27;
2410 if ((have_flag(flgs, TR_SLAY_EVIL)) &&
2411 (r_ptr->flags3 & RF3_EVIL))
2413 if (is_original_ap_and_seen(m_ptr))
2415 r_ptr->r_flags3 |= RF3_EVIL;
2418 if (mult < 15) mult = 15;
2422 if ((have_flag(flgs, TR_KILL_EVIL)) &&
2423 (r_ptr->flags3 & RF3_EVIL))
2425 if (is_original_ap_and_seen(m_ptr))
2427 r_ptr->r_flags3 |= RF3_EVIL;
2430 if (mult < 25) mult = 25;
2434 if ((have_flag(flgs, TR_SLAY_HUMAN)) &&
2435 (r_ptr->flags2 & RF2_HUMAN))
2437 if (is_original_ap_and_seen(m_ptr))
2439 r_ptr->r_flags2 |= RF2_HUMAN;
2442 if (mult < 17) mult = 17;
2446 if ((have_flag(flgs, TR_KILL_HUMAN)) &&
2447 (r_ptr->flags2 & RF2_HUMAN))
2449 if (is_original_ap_and_seen(m_ptr))
2451 r_ptr->r_flags2 |= RF2_HUMAN;
2454 if (mult < 27) mult = 27;
2458 if ((have_flag(flgs, TR_SLAY_UNDEAD)) &&
2459 (r_ptr->flags3 & RF3_UNDEAD))
2461 if (is_original_ap_and_seen(m_ptr))
2463 r_ptr->r_flags3 |= RF3_UNDEAD;
2466 if (mult < 20) mult = 20;
2470 if ((have_flag(flgs, TR_KILL_UNDEAD)) &&
2471 (r_ptr->flags3 & RF3_UNDEAD))
2473 if (is_original_ap_and_seen(m_ptr))
2475 r_ptr->r_flags3 |= RF3_UNDEAD;
2478 if (mult < 30) mult = 30;
2482 if ((have_flag(flgs, TR_SLAY_DEMON)) &&
2483 (r_ptr->flags3 & RF3_DEMON))
2485 if (is_original_ap_and_seen(m_ptr))
2487 r_ptr->r_flags3 |= RF3_DEMON;
2490 if (mult < 20) mult = 20;
2494 if ((have_flag(flgs, TR_KILL_DEMON)) &&
2495 (r_ptr->flags3 & RF3_DEMON))
2497 if (is_original_ap_and_seen(m_ptr))
2499 r_ptr->r_flags3 |= RF3_DEMON;
2502 if (mult < 30) mult = 30;
2506 if ((have_flag(flgs, TR_SLAY_ORC)) &&
2507 (r_ptr->flags3 & RF3_ORC))
2509 if (is_original_ap_and_seen(m_ptr))
2511 r_ptr->r_flags3 |= RF3_ORC;
2514 if (mult < 20) mult = 20;
2518 if ((have_flag(flgs, TR_KILL_ORC)) &&
2519 (r_ptr->flags3 & RF3_ORC))
2521 if (is_original_ap_and_seen(m_ptr))
2523 r_ptr->r_flags3 |= RF3_ORC;
2526 if (mult < 30) mult = 30;
2530 if ((have_flag(flgs, TR_SLAY_TROLL)) &&
2531 (r_ptr->flags3 & RF3_TROLL))
2533 if (is_original_ap_and_seen(m_ptr))
2535 r_ptr->r_flags3 |= RF3_TROLL;
2538 if (mult < 20) mult = 20;
2542 if ((have_flag(flgs, TR_KILL_TROLL)) &&
2543 (r_ptr->flags3 & RF3_TROLL))
2545 if (is_original_ap_and_seen(m_ptr))
2547 r_ptr->r_flags3 |= RF3_TROLL;
2550 if (mult < 30) mult = 30;
2554 if ((have_flag(flgs, TR_SLAY_GIANT)) &&
2555 (r_ptr->flags3 & RF3_GIANT))
2557 if (is_original_ap_and_seen(m_ptr))
2559 r_ptr->r_flags3 |= RF3_GIANT;
2562 if (mult < 20) mult = 20;
2566 if ((have_flag(flgs, TR_KILL_GIANT)) &&
2567 (r_ptr->flags3 & RF3_GIANT))
2569 if (is_original_ap_and_seen(m_ptr))
2571 r_ptr->r_flags3 |= RF3_GIANT;
2574 if (mult < 30) mult = 30;
2578 if ((have_flag(flgs, TR_SLAY_DRAGON)) &&
2579 (r_ptr->flags3 & RF3_DRAGON))
2581 if (is_original_ap_and_seen(m_ptr))
2583 r_ptr->r_flags3 |= RF3_DRAGON;
2586 if (mult < 20) mult = 20;
2589 /* Execute Dragon */
2590 if ((have_flag(flgs, TR_KILL_DRAGON)) &&
2591 (r_ptr->flags3 & RF3_DRAGON))
2593 if (is_original_ap_and_seen(m_ptr))
2595 r_ptr->r_flags3 |= RF3_DRAGON;
2598 if (mult < 30) mult = 30;
2600 if ((o_ptr->name1 == ART_BARD_ARROW) &&
2601 (m_ptr->r_idx == MON_SMAUG) &&
2602 (inventory[INVEN_BOW].name1 == ART_BARD))
2607 if (have_flag(flgs, TR_BRAND_ACID))
2609 /* Notice immunity */
2610 if (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK)
2612 if (is_original_ap_and_seen(m_ptr))
2614 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK);
2618 /* Otherwise, take the damage */
2621 if (mult < 17) mult = 17;
2626 if (have_flag(flgs, TR_BRAND_ELEC))
2628 /* Notice immunity */
2629 if (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK)
2631 if (is_original_ap_and_seen(m_ptr))
2633 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK);
2637 /* Otherwise, take the damage */
2640 if (mult < 17) mult = 17;
2645 if (have_flag(flgs, TR_BRAND_FIRE))
2647 /* Notice immunity */
2648 if (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK)
2650 if (is_original_ap_and_seen(m_ptr))
2652 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK);
2656 /* Otherwise, take the damage */
2659 if (r_ptr->flags3 & RF3_HURT_FIRE)
2661 if (mult < 25) mult = 25;
2662 if (is_original_ap_and_seen(m_ptr))
2664 r_ptr->r_flags3 |= RF3_HURT_FIRE;
2667 else if (mult < 17) mult = 17;
2672 if (have_flag(flgs, TR_BRAND_COLD))
2674 /* Notice immunity */
2675 if (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK)
2677 if (is_original_ap_and_seen(m_ptr))
2679 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK);
2682 /* Otherwise, take the damage */
2685 if (r_ptr->flags3 & RF3_HURT_COLD)
2687 if (mult < 25) mult = 25;
2688 if (is_original_ap_and_seen(m_ptr))
2690 r_ptr->r_flags3 |= RF3_HURT_COLD;
2693 else if (mult < 17) mult = 17;
2697 /* Brand (Poison) */
2698 if (have_flag(flgs, TR_BRAND_POIS))
2700 /* Notice immunity */
2701 if (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK)
2703 if (is_original_ap_and_seen(m_ptr))
2705 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK);
2709 /* Otherwise, take the damage */
2712 if (mult < 17) mult = 17;
2716 if ((have_flag(flgs, TR_FORCE_WEAPON)) && (p_ptr->csp > (p_ptr->msp / 30)))
2718 p_ptr->csp -= (1+(p_ptr->msp / 30));
2719 p_ptr->redraw |= (PR_MANA);
2720 mult = mult * 5 / 2;
2727 if (snipe_type) mult = tot_dam_aux_snipe(mult, m_ptr);
2729 /* Return the total damage */
2730 return (tdam * mult / 10);
2735 * @brief 射撃処理のサブルーチン /
2736 * Fire an object from the pack or floor.
2737 * @param item 射撃するオブジェクトの所持ID
2738 * @param j_ptr 射撃武器のオブジェクト参照ポインタ
2742 * You may only fire items that "match" your missile launcher.
2744 * You must use slings + pebbles/shots, bows + arrows, xbows + bolts.
2746 * See "calc_bonuses()" for more calculations and such.
2748 * Note that "firing" a missile is MUCH better than "throwing" it.
2750 * Note: "unseen" monsters are very hard to hit.
2752 * Objects are more likely to break if they "attempt" to hit a monster.
2754 * Rangers (with Bows) and Anyone (with "Extra Shots") get extra shots.
2756 * The "extra shot" code works by decreasing the amount of energy
2757 * required to make each shot, spreading the shots out over time.
2759 * Note that when firing missiles, the launcher multiplier is applied
2760 * after all the bonuses are added in, making multipliers very useful.
2762 * Note that Bows of "Extra Might" get extra range and an extra bonus
2763 * for the damage multiplier.
2765 * Note that Bows of "Extra Shots" give an extra shot.
2768 void do_cmd_fire_aux(INVENTORY_IDX item, object_type *j_ptr)
2772 POSITION y, x, ny, nx, ty, tx, prev_y, prev_x;
2773 int tdam_base, tdis, thits, tmul;
2775 int cur_dis, visible;
2783 bool hit_body = FALSE;
2785 char o_name[MAX_NLEN];
2787 u16b path_g[512]; /* For calcuration of path length */
2789 int msec = delay_factor * delay_factor * delay_factor;
2792 bool stick_to = FALSE;
2794 /* Access the item (if in the pack) */
2797 o_ptr = &inventory[item];
2801 o_ptr = &o_list[0 - item];
2804 /* Sniper - Cannot shot a single arrow twice */
2805 if ((snipe_type == SP_DOUBLE) && (o_ptr->number < 2)) snipe_type = SP_NONE;
2807 /* Describe the object */
2808 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
2810 /* Use the proper number of shots */
2811 thits = p_ptr->num_fire;
2813 /* Use a base distance */
2816 /* Base damage from thrown object plus launcher bonus */
2817 tdam_base = damroll(o_ptr->dd, o_ptr->ds) + o_ptr->to_d + j_ptr->to_d;
2819 /* Actually "fire" the object */
2820 bonus = (p_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
2821 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
2822 chance = (p_ptr->skill_thb + (p_ptr->weapon_exp[0][j_ptr->sval] / 400 + bonus) * BTH_PLUS_ADJ);
2824 chance = (p_ptr->skill_thb + ((p_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + bonus) * BTH_PLUS_ADJ);
2826 p_ptr->energy_use = bow_energy(j_ptr->sval);
2827 tmul = bow_tmul(j_ptr->sval);
2829 /* Get extra "power" from "extra might" */
2830 if (p_ptr->xtra_might) tmul++;
2832 tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
2834 /* Boost the damage */
2839 tdis = 13 + tmul/80;
2840 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
2843 tdis -= (5 - (p_ptr->concent + 1) / 2);
2848 project_length = tdis + 1;
2850 /* Get a direction (or cancel) */
2851 if (!get_aim_dir(&dir))
2853 p_ptr->energy_use = 0;
2855 if (snipe_type == SP_AWAY) snipe_type = SP_NONE;
2857 /* need not to reset project_length (already did)*/
2862 /* Predict the "target" location */
2863 tx = p_ptr->x + 99 * ddx[dir];
2864 ty = p_ptr->y + 99 * ddy[dir];
2866 /* Check for "target request" */
2867 if ((dir == 5) && target_okay())
2873 /* Get projection path length */
2874 tdis = project_path(path_g, project_length, p_ptr->y, p_ptr->x, ty, tx, PROJECT_PATH|PROJECT_THRU) - 1;
2876 project_length = 0; /* reset to default */
2878 /* Don't shoot at my feet */
2879 if (tx == p_ptr->x && ty == p_ptr->y)
2881 p_ptr->energy_use = 0;
2883 /* project_length is already reset to 0 */
2889 /* Take a (partial) turn */
2890 p_ptr->energy_use = (p_ptr->energy_use / thits);
2893 /* Sniper - Difficult to shot twice at 1 turn */
2894 if (snipe_type == SP_DOUBLE) p_ptr->concent = (p_ptr->concent + 1) / 2;
2896 /* Sniper - Repeat shooting when double shots */
2897 for (i = 0; i < ((snipe_type == SP_DOUBLE) ? 2 : 1); i++)
2900 /* Start at the player */
2904 /* Get local object */
2907 /* Obtain a local object */
2908 object_copy(q_ptr, o_ptr);
2913 /* Reduce and describe inventory */
2916 inven_item_increase(item, -1);
2917 inven_item_describe(item);
2918 inven_item_optimize(item);
2921 /* Reduce and describe floor item */
2924 floor_item_increase(0 - item, -1);
2925 floor_item_optimize(0 - item);
2930 /* Hack -- Handle stuff */
2933 /* Save the old location */
2937 /* The shot does not hit yet */
2940 /* Travel until stopped */
2941 for (cur_dis = 0; cur_dis <= tdis; )
2945 /* Hack -- Stop at the target */
2946 if ((y == ty) && (x == tx)) break;
2948 /* Calculate the new location (see "project()") */
2951 mmove2(&ny, &nx, p_ptr->y, p_ptr->x, ty, tx);
2954 if (snipe_type == SP_KILL_WALL)
2956 c_ptr = &cave[ny][nx];
2958 if (cave_have_flag_grid(c_ptr, FF_HURT_ROCK) && !c_ptr->m_idx)
2960 if (c_ptr->info & (CAVE_MARK)) msg_print(_("岩が砕け散った。", "Wall rocks were shattered."));
2961 /* Forget the wall */
2962 c_ptr->info &= ~(CAVE_MARK);
2964 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
2966 /* Destroy the wall */
2967 cave_alter_feat(ny, nx, FF_HURT_ROCK);
2974 /* Stopped by walls/doors */
2975 if (!cave_have_flag_bold(ny, nx, FF_PROJECT) && !cave[ny][nx].m_idx) break;
2977 /* Advance the distance */
2981 if (snipe_type == SP_LITE)
2983 cave[ny][nx].info |= (CAVE_GLOW);
2992 /* The player can see the (on screen) missile */
2993 if (panel_contains(ny, nx) && player_can_see_bold(ny, nx))
2995 char c = object_char(q_ptr);
2996 byte a = object_attr(q_ptr);
2998 /* Draw, Hilite, Fresh, Pause, Erase */
2999 print_rel(c, a, ny, nx);
3000 move_cursor_relative(ny, nx);
3002 Term_xtra(TERM_XTRA_DELAY, msec);
3007 /* The player cannot see the missile */
3010 /* Pause anyway, for consistancy */
3011 Term_xtra(TERM_XTRA_DELAY, msec);
3015 if (snipe_type == SP_KILL_TRAP)
3017 project(0, 0, ny, nx, 0, GF_KILL_TRAP,
3018 (PROJECT_JUMP | PROJECT_HIDE | PROJECT_GRID | PROJECT_ITEM), -1);
3022 if (snipe_type == SP_EVILNESS)
3024 cave[ny][nx].info &= ~(CAVE_GLOW | CAVE_MARK);
3033 /* Save the old location */
3037 /* Save the new location */
3042 /* Monster here, Try to hit it */
3043 if (cave[y][x].m_idx)
3045 cave_type *c_mon_ptr = &cave[y][x];
3047 monster_type *m_ptr = &m_list[c_mon_ptr->m_idx];
3048 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3050 /* Check the visibility */
3051 visible = m_ptr->ml;
3053 /* Note the collision */
3056 if (MON_CSLEEP(m_ptr))
3058 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_COMPASSION, -1);
3059 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_HONOUR, -1);
3062 if ((r_ptr->level + 10) > p_ptr->lev)
3064 int now_exp = p_ptr->weapon_exp[0][j_ptr->sval];
3065 if (now_exp < s_info[p_ptr->pclass].w_max[0][j_ptr->sval])
3068 if (now_exp < WEAPON_EXP_BEGINNER) amount = 80;
3069 else if (now_exp < WEAPON_EXP_SKILLED) amount = 25;
3070 else if ((now_exp < WEAPON_EXP_EXPERT) && (p_ptr->lev > 19)) amount = 10;
3071 else if (p_ptr->lev > 34) amount = 2;
3072 p_ptr->weapon_exp[0][j_ptr->sval] += amount;
3073 p_ptr->update |= (PU_BONUS);
3079 if ((p_ptr->skill_exp[GINOU_RIDING] < s_info[p_ptr->pclass].s_max[GINOU_RIDING])
3080 && ((p_ptr->skill_exp[GINOU_RIDING] - (RIDING_EXP_BEGINNER * 2)) / 200 < r_info[m_list[p_ptr->riding].r_idx].level)
3083 p_ptr->skill_exp[GINOU_RIDING] += 1;
3084 p_ptr->update |= (PU_BONUS);
3088 /* Did we hit it (penalize range) */
3089 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
3092 int tdam = tdam_base;
3094 /* Get extra damage from concentration */
3095 if (p_ptr->concent) tdam = boost_concentration_damage(tdam);
3097 /* Handle unseen monster */
3100 /* Invisible monster */
3101 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
3104 /* Handle visible monster */
3109 /* Get "the monster" or "it" */
3110 monster_desc(m_name, m_ptr, 0);
3112 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
3116 /* Hack -- Track this monster race */
3117 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
3119 /* Hack -- Track this monster */
3120 health_track(c_mon_ptr->m_idx);
3124 if (snipe_type == SP_NEEDLE)
3126 if ((randint1(randint1(r_ptr->level / (3 + p_ptr->concent)) + (8 - p_ptr->concent)) == 1)
3127 && !(r_ptr->flags1 & RF1_UNIQUE) && !(r_ptr->flags7 & RF7_UNIQUE2))
3131 /* Get "the monster" or "it" */
3132 monster_desc(m_name, m_ptr, 0);
3134 tdam = m_ptr->hp + 1;
3135 msg_format(_("%sの急所に突き刺さった!", "Your shot sticked on a fatal spot of %s!"), m_name);
3141 /* Apply special damage XXX XXX XXX */
3142 tdam = tot_dam_aux_shot(q_ptr, tdam, m_ptr);
3143 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, j_ptr->to_h, tdam);
3145 /* No negative damage */
3146 if (tdam < 0) tdam = 0;
3148 /* Modify the damage */
3149 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
3152 msg_format_wizard(CHEAT_MONSTER,
3153 _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
3154 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
3157 if (snipe_type == SP_EXPLODE)
3159 u16b flg = (PROJECT_STOP | PROJECT_JUMP | PROJECT_KILL | PROJECT_GRID);
3161 sound(SOUND_EXPLODE); /* No explode sound - use breath fire instead */
3162 project(0, ((p_ptr->concent + 1) / 2 + 1), ny, nx, tdam, GF_MISSILE, flg, -1);
3167 if (snipe_type == SP_HOLYNESS)
3169 cave[ny][nx].info |= (CAVE_GLOW);
3178 /* Hit the monster, check for death */
3179 if (mon_take_hit(c_mon_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_ptr(m_ptr))))
3188 if (object_is_fixed_artifact(q_ptr) &&
3189 (p_ptr->pclass != CLASS_SNIPER || p_ptr->concent == 0))
3193 monster_desc(m_name, m_ptr, 0);
3196 msg_format(_("%sは%sに突き刺さった!", "%^s have stuck into %s!"),o_name, m_name);
3199 message_pain(c_mon_ptr->m_idx, tdam);
3201 /* Anger the monster */
3202 if (tdam > 0) anger_monster(m_ptr);
3205 if (fear && m_ptr->ml)
3211 /* Get the monster name (or "it") */
3212 monster_desc(m_name, m_ptr, 0);
3214 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
3217 set_target(m_ptr, p_ptr->y, p_ptr->x);
3220 if (snipe_type == SP_RUSH)
3222 int n = randint1(5) + 3;
3223 MONSTER_IDX m_idx = c_mon_ptr->m_idx;
3225 for ( ; cur_dis <= tdis; )
3232 /* Calculate the new location (see "project()") */
3233 mmove2(&ny, &nx, p_ptr->y, p_ptr->x, ty, tx);
3235 /* Stopped by wilderness boundary */
3236 if (!in_bounds2(ny, nx)) break;
3238 /* Stopped by walls/doors */
3239 if (!player_can_enter(cave[ny][nx].feat, 0)) break;
3241 /* Stopped by monsters */
3242 if (!cave_empty_bold(ny, nx)) break;
3244 cave[ny][nx].m_idx = m_idx;
3245 cave[oy][ox].m_idx = 0;
3250 /* Update the monster (new location) */
3251 update_mon(c_mon_ptr->m_idx, TRUE);
3257 Term_xtra(TERM_XTRA_DELAY, msec);
3269 if (snipe_type == SP_PIERCE)
3271 if(p_ptr->concent < 1) break;
3281 /* Chance of breakage (during attacks) */
3282 j = (hit_body ? breakage_chance(q_ptr) : 0);
3286 MONSTER_IDX m_idx = cave[y][x].m_idx;
3287 monster_type *m_ptr = &m_list[m_idx];
3288 OBJECT_IDX o_idx = o_pop();
3292 msg_format(_("%sはどこかへ行った。", "The %s have gone to somewhere."), o_name);
3293 if (object_is_fixed_artifact(q_ptr))
3295 a_info[j_ptr->name1].cur_num = 0;
3300 o_ptr = &o_list[o_idx];
3301 object_copy(o_ptr, q_ptr);
3304 o_ptr->marked &= OM_TOUCHED;
3306 /* Forget location */
3307 o_ptr->iy = o_ptr->ix = 0;
3309 /* Memorize monster */
3310 o_ptr->held_m_idx = m_idx;
3313 o_ptr->next_o_idx = m_ptr->hold_o_idx;
3316 m_ptr->hold_o_idx = o_idx;
3318 else if (cave_have_flag_bold(y, x, FF_PROJECT))
3320 /* Drop (or break) near that location */
3321 (void)drop_near(q_ptr, j, y, x);
3325 /* Drop (or break) near that location */
3326 (void)drop_near(q_ptr, j, prev_y, prev_x);
3329 /* Sniper - Repeat shooting when double shots */
3332 /* Sniper - Loose his/her concentration after any shot */
3333 if (p_ptr->concent) reset_concentration(FALSE);
3337 * @brief 射撃処理のメインルーチン
3340 void do_cmd_fire(void)
3346 is_fired = FALSE; /* not fired yet */
3348 /* Get the "bow" (if any) */
3349 j_ptr = &inventory[INVEN_BOW];
3351 /* Require a launcher */
3354 msg_print(_("射撃用の武器を持っていない。", "You have nothing to fire with."));
3359 if (j_ptr->sval == SV_CRIMSON)
3361 msg_print(_("この武器は発動して使うもののようだ。", "Do activate."));
3366 if (j_ptr->sval == SV_HARP)
3368 msg_print(_("この武器で射撃はできない。", "It's not for firing."));
3374 if (p_ptr->special_defense & KATA_MUSOU)
3376 set_action(ACTION_NONE);
3379 /* Require proper missile */
3380 item_tester_tval = p_ptr->tval_ammo;
3383 q = _("どれを撃ちますか? ", "Fire which item? ");
3384 s = _("発射されるアイテムがありません。", "You have nothing to fire.");
3385 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR)))
3392 do_cmd_fire_aux(item, j_ptr);
3394 if (!is_fired || p_ptr->pclass != CLASS_SNIPER) return;
3396 /* Sniper actions after some shootings */
3397 if (snipe_type == SP_AWAY)
3399 teleport_player(10 + (p_ptr->concent * 2), 0L);
3401 if (snipe_type == SP_FINAL)
3403 msg_print(_("射撃の反動が体を襲った。", "A reactionary of shooting attacked you. "));
3404 (void)set_slow(p_ptr->slow + randint0(7) + 7, FALSE);
3405 (void)set_stun(p_ptr->stun + randint1(25));
3411 * @brief 投射処理メインルーチン /
3412 * Throw an object from the pack or floor.
3414 * @param boomerang ブーメラン処理ならばTRUE
3415 * @param shuriken 忍者の手裏剣処理ならばTRUE
3416 * @return ターンを消費した場合TRUEを返す
3419 * Note: "unseen" monsters are very hard to hit.
3421 * Should throwing a weapon do full damage? Should it allow the magic
3422 * to hit bonus of the weapon to have an effect? Should it ever cause
3423 * the item to be destroyed? Should it do any damage at all?
3426 bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
3431 POSITION y, x, ty, tx, prev_y, prev_x;
3432 POSITION ny[19], nx[19];
3433 int chance, tdam, tdis;
3434 int mul, div, dd, ds;
3435 int cur_dis, visible;
3443 bool hit_body = FALSE;
3444 bool hit_wall = FALSE;
3445 bool equiped_item = FALSE;
3446 bool return_when_thrown = FALSE;
3448 char o_name[MAX_NLEN];
3450 int msec = delay_factor * delay_factor * delay_factor;
3452 BIT_FLAGS flgs[TR_FLAG_SIZE];
3454 bool come_back = FALSE;
3455 bool do_drop = TRUE;
3458 if (p_ptr->special_defense & KATA_MUSOU)
3460 set_action(ACTION_NONE);
3469 if (buki_motteruka(INVEN_RARM) && buki_motteruka(INVEN_LARM))
3471 item_tester_hook = item_tester_hook_boomerang;
3472 q = _("どの武器を投げますか? ", "Throw which item? ");
3473 s = _("投げる武器がない。", "You have nothing to throw.");
3474 if (!get_item(&item, q, s, (USE_EQUIP)))
3480 else if (buki_motteruka(INVEN_LARM)) item = INVEN_LARM;
3481 else item = INVEN_RARM;
3486 q = _("どのアイテムを投げますか? ", "Throw which item? ");
3487 s = _("投げるアイテムがない。", "You have nothing to throw.");
3488 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP)))
3495 /* Access the item (if in the pack) */
3498 o_ptr = &inventory[item];
3502 o_ptr = &o_list[0 - item];
3506 /* Item is cursed */
3507 if (object_is_cursed(o_ptr) && (item >= INVEN_RARM))
3509 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
3515 if (p_ptr->inside_arena && !boomerang)
3517 if (o_ptr->tval != TV_SPIKE)
3519 msg_print(_("アリーナではアイテムを使えない!", "You're in the arena now. This is hand-to-hand!"));
3528 /* Get local object */
3531 /* Obtain a local object */
3532 object_copy(q_ptr, o_ptr);
3534 /* Extract the thrown object's flags. */
3535 object_flags(q_ptr, flgs);
3536 torch_flags(q_ptr, flgs);
3538 /* Distribute the charges of rods/wands between the stacks */
3539 distribute_charges(o_ptr, q_ptr, 1);
3545 object_desc(o_name, q_ptr, OD_OMIT_PREFIX);
3547 if (p_ptr->mighty_throw) mult += 3;
3549 /* Extract a "distance multiplier" */
3550 /* Changed for 'launcher' mutation */
3551 mul = 10 + 2 * (mult - 1);
3553 /* Enforce a minimum "weight" of one pound */
3554 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
3555 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
3557 /* Hack -- Distance -- Reward strength, penalize weight */
3558 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
3560 /* Max distance of 10-18 */
3561 if (tdis > mul) tdis = mul;
3565 ty = randint0(101) - 50 + p_ptr->y;
3566 tx = randint0(101) - 50 + p_ptr->x;
3570 project_length = tdis + 1;
3572 /* Get a direction (or cancel) */
3573 if (!get_aim_dir(&dir)) return FALSE;
3575 /* Predict the "target" location */
3576 tx = p_ptr->x + 99 * ddx[dir];
3577 ty = p_ptr->y + 99 * ddy[dir];
3579 /* Check for "target request" */
3580 if ((dir == 5) && target_okay())
3586 project_length = 0; /* reset to default */
3589 if ((q_ptr->name1 == ART_MJOLLNIR) ||
3590 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
3591 return_when_thrown = TRUE;
3593 /* Reduce and describe inventory */
3596 inven_item_increase(item, -1);
3597 if (!return_when_thrown)
3598 inven_item_describe(item);
3599 inven_item_optimize(item);
3602 /* Reduce and describe floor item */
3605 floor_item_increase(0 - item, -1);
3606 floor_item_optimize(0 - item);
3608 if (item >= INVEN_RARM)
3610 equiped_item = TRUE;
3611 p_ptr->redraw |= (PR_EQUIPPY);
3614 p_ptr->energy_use = 100;
3616 /* Rogue and Ninja gets bonus */
3617 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
3618 p_ptr->energy_use -= p_ptr->lev;
3620 /* Start at the player */
3625 /* Hack -- Handle stuff */
3628 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
3629 else shuriken = FALSE;
3631 /* Chance of hitting */
3632 if (have_flag(flgs, TR_THROW)) chance = ((p_ptr->skill_tht) +
3633 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
3634 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
3636 if (shuriken) chance *= 2;
3638 /* Save the old location */
3642 /* Travel until stopped */
3643 for (cur_dis = 0; cur_dis <= tdis; )
3645 /* Hack -- Stop at the target */
3646 if ((y == ty) && (x == tx)) break;
3648 /* Calculate the new location (see "project()") */
3651 mmove2(&ny[cur_dis], &nx[cur_dis], p_ptr->y, p_ptr->x, ty, tx);
3653 /* Stopped by walls/doors */
3654 if (!cave_have_flag_bold(ny[cur_dis], nx[cur_dis], FF_PROJECT))
3657 if ((q_ptr->tval == TV_FIGURINE) || object_is_potion(q_ptr) || !cave[ny[cur_dis]][nx[cur_dis]].m_idx) break;
3660 /* The player can see the (on screen) missile */
3661 if (panel_contains(ny[cur_dis], nx[cur_dis]) && player_can_see_bold(ny[cur_dis], nx[cur_dis]))
3663 char c = object_char(q_ptr);
3664 byte a = object_attr(q_ptr);
3666 /* Draw, Hilite, Fresh, Pause, Erase */
3667 print_rel(c, a, ny[cur_dis], nx[cur_dis]);
3668 move_cursor_relative(ny[cur_dis], nx[cur_dis]);
3670 Term_xtra(TERM_XTRA_DELAY, msec);
3671 lite_spot(ny[cur_dis], nx[cur_dis]);
3675 /* The player cannot see the missile */
3678 /* Pause anyway, for consistancy */
3679 Term_xtra(TERM_XTRA_DELAY, msec);
3682 /* Save the old location */
3686 /* Save the new location */
3690 /* Advance the distance */
3693 /* Monster here, Try to hit it */
3694 if (cave[y][x].m_idx)
3696 cave_type *c_ptr = &cave[y][x];
3697 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3699 /* Check the visibility */
3700 visible = m_ptr->ml;
3702 /* Note the collision */
3705 /* Did we hit it (penalize range) */
3706 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
3710 /* Handle unseen monster */
3713 /* Invisible monster */
3714 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
3717 /* Handle visible monster */
3722 /* Get "the monster" or "it" */
3723 monster_desc(m_name, m_ptr, 0);
3725 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
3729 /* Hack -- Track this monster race */
3730 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
3732 /* Hack -- Track this monster */
3733 health_track(c_ptr->m_idx);
3737 /* Hack -- Base damage from thrown object */
3740 torch_dice(q_ptr, &dd, &ds); /* throwing a torch */
3741 tdam = damroll(dd, ds);
3742 /* Apply special damage XXX XXX XXX */
3743 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0, TRUE);
3744 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, 0, tdam);
3745 if (q_ptr->to_d > 0)
3746 tdam += q_ptr->to_d;
3748 tdam += -q_ptr->to_d;
3752 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
3753 tdam += p_ptr->to_d_m;
3755 else if (have_flag(flgs, TR_THROW))
3758 tdam += p_ptr->to_d_m;
3766 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
3769 /* No negative damage */
3770 if (tdam < 0) tdam = 0;
3772 /* Modify the damage */
3773 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
3775 msg_format_wizard(CHEAT_MONSTER, _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
3776 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
3778 /* Hit the monster, check for death */
3779 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_ptr(m_ptr))))
3787 message_pain(c_ptr->m_idx, tdam);
3789 /* Anger the monster */
3790 if ((tdam > 0) && !object_is_potion(q_ptr))
3791 anger_monster(m_ptr);
3794 if (fear && m_ptr->ml)
3800 /* Get the monster name (or "it") */
3801 monster_desc(m_name, m_ptr, 0);
3803 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
3813 /* decrease toach's fuel */
3814 if (hit_body) torch_lost_fuel(q_ptr);
3816 /* Chance of breakage (during attacks) */
3817 j = (hit_body ? breakage_chance(q_ptr) : 0);
3819 /* Figurines transform */
3820 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
3824 if (!(summon_named_creature(0, y, x, q_ptr->pval,
3825 !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L)))
3826 msg_print(_("人形は捻じ曲がり砕け散ってしまった!", "The Figurine writhes and then shatters."));
3827 else if (object_is_cursed(q_ptr))
3828 msg_print(_("これはあまり良くない気がする。", "You have a bad feeling about this."));
3833 /* Potions smash open */
3834 if (object_is_potion(q_ptr))
3836 if (hit_body || hit_wall || (randint1(100) < j))
3838 msg_format(_("%sは砕け散った!", "The %s shatters!"), o_name);
3840 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
3842 monster_type *m_ptr = &m_list[cave[y][x].m_idx];
3844 /* ToDo (Robert): fix the invulnerability */
3845 if (cave[y][x].m_idx &&
3846 is_friendly(&m_list[cave[y][x].m_idx]) &&
3847 !MON_INVULNER(m_ptr))
3850 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
3851 msg_format(_("%sは怒った!", "%^s gets angry!"), m_name);
3852 set_hostile(&m_list[cave[y][x].m_idx]);
3863 if (return_when_thrown)
3865 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
3866 char o2_name[MAX_NLEN];
3867 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
3870 if (boomerang) back_chance += 4+randint1(5);
3871 if (super_boomerang) back_chance += 100;
3872 object_desc(o2_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3874 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
3876 for (i = cur_dis - 1; i > 0; i--)
3878 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
3880 char c = object_char(q_ptr);
3881 byte a = object_attr(q_ptr);
3883 /* Draw, Hilite, Fresh, Pause, Erase */
3884 print_rel(c, a, ny[i], nx[i]);
3885 move_cursor_relative(ny[i], nx[i]);
3887 Term_xtra(TERM_XTRA_DELAY, msec);
3888 lite_spot(ny[i], nx[i]);
3893 /* Pause anyway, for consistancy */
3894 Term_xtra(TERM_XTRA_DELAY, msec);
3897 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
3899 msg_format(_("%sが手元に返ってきた。", "%s comes back to you."), o2_name);
3906 msg_format(_("%sを受け損ねた!", "%s backs, but you can't catch!"), o2_name);
3910 msg_format(_("%sが返ってきた。", "%s comes back."), o2_name);
3918 msg_format(_("%sが返ってこなかった!", "%s doesn't back!"), o2_name);
3924 if (item == INVEN_RARM || item == INVEN_LARM)
3926 /* Access the wield slot */
3927 o_ptr = &inventory[item];
3929 /* Wear the new stuff */
3930 object_copy(o_ptr, q_ptr);
3932 /* Increase the weight */
3933 p_ptr->total_weight += q_ptr->weight;
3935 /* Increment the equip counter by hand */
3938 /* Recalculate bonuses */
3939 p_ptr->update |= (PU_BONUS);
3941 /* Recalculate torch */
3942 p_ptr->update |= (PU_TORCH);
3944 /* Recalculate mana XXX */
3945 p_ptr->update |= (PU_MANA);
3947 p_ptr->window |= (PW_EQUIP);
3955 else if (equiped_item)
3961 /* Drop (or break) near that location */
3964 if (cave_have_flag_bold(y, x, FF_PROJECT))
3966 /* Drop (or break) near that location */
3967 (void)drop_near(q_ptr, j, y, x);
3971 /* Drop (or break) near that location */
3972 (void)drop_near(q_ptr, j, prev_y, prev_x);
3982 * Hack: travel command
3984 #define TRAVEL_UNABLE 9999
3986 static int flow_head = 0;
3987 static int flow_tail = 0;
3988 static POSITION temp2_x[MAX_SHORT];
3989 static POSITION temp2_y[MAX_SHORT];
3992 * @brief トラベル処理の記憶配列を初期化する Hack: forget the "flow" information
3995 void forget_travel_flow(void)
3999 /* Check the entire dungeon */
4000 for (y = 0; y < cur_hgt; y++)
4002 for (x = 0; x < cur_wid; x++)
4004 /* Forget the old data */
4005 travel.cost[y][x] = MAX_SHORT;
4009 travel.y = travel.x = 0;
4013 * @brief トラベル処理中に地形に応じた移動コスト基準を返す
4018 static int travel_flow_cost(POSITION y, POSITION x)
4020 feature_type *f_ptr = &f_info[cave[y][x].feat];
4023 /* Avoid obstacles (ex. trees) */
4024 if (have_flag(f_ptr->flags, FF_AVOID_RUN)) cost += 1;
4027 if (have_flag(f_ptr->flags, FF_WATER))
4029 if (have_flag(f_ptr->flags, FF_DEEP) && !p_ptr->levitation) cost += 5;
4033 if (have_flag(f_ptr->flags, FF_LAVA))
4036 if (!p_ptr->resist_fire) lava *= 2;
4037 if (!p_ptr->levitation) lava *= 2;
4038 if (have_flag(f_ptr->flags, FF_DEEP)) lava *= 2;
4043 /* Detected traps and doors */
4044 if (cave[y][x].info & (CAVE_MARK))
4046 if (have_flag(f_ptr->flags, FF_DOOR)) cost += 1;
4047 if (have_flag(f_ptr->flags, FF_TRAP)) cost += 10;
4054 * @brief トラベル処理の到達地点までの行程を得る処理のサブルーチン
4058 * @param wall プレイヤーが壁の中にいるならばTRUE
4061 static void travel_flow_aux(POSITION y, POSITION x, int n, bool wall)
4063 cave_type *c_ptr = &cave[y][x];
4064 feature_type *f_ptr = &f_info[c_ptr->feat];
4065 int old_head = flow_head;
4067 int base_cost = (n % TRAVEL_UNABLE);
4068 int from_wall = (n / TRAVEL_UNABLE);
4071 /* Ignore out of bounds */
4072 if (!in_bounds(y, x)) return;
4074 /* Ignore unknown grid except in wilderness */
4075 if (dun_level > 0 && !(c_ptr->info & CAVE_KNOWN)) return;
4077 /* Ignore "walls" and "rubble" (include "secret doors") */
4078 if (have_flag(f_ptr->flags, FF_WALL) ||
4079 have_flag(f_ptr->flags, FF_CAN_DIG) ||
4080 (have_flag(f_ptr->flags, FF_DOOR) && cave[y][x].mimic) ||
4081 (!have_flag(f_ptr->flags, FF_MOVE) && have_flag(f_ptr->flags, FF_CAN_FLY) && !p_ptr->levitation))
4083 if (!wall || !from_wall) return;
4084 add_cost += TRAVEL_UNABLE;
4088 add_cost = travel_flow_cost(y, x);
4091 cost = base_cost + add_cost;
4093 /* Ignore lower cost entries */
4094 if (travel.cost[y][x] <= cost) return;
4096 /* Save the flow cost */
4097 travel.cost[y][x] = cost;
4099 /* Enqueue that entry */
4100 temp2_y[flow_head] = y;
4101 temp2_x[flow_head] = x;
4103 /* Advance the queue */
4104 if (++flow_head == MAX_SHORT) flow_head = 0;
4106 /* Hack -- notice overflow by forgetting new entry */
4107 if (flow_head == flow_tail) flow_head = old_head;
4113 * @brief トラベル処理の到達地点までの行程を得る処理のメインルーチン
4114 * @param ty 目標地点のY座標
4115 * @param tx 目標地点のX座標
4118 static void travel_flow(POSITION ty, POSITION tx)
4122 feature_type *f_ptr = &f_info[cave[p_ptr->y][p_ptr->x].feat];
4124 /* Reset the "queue" */
4125 flow_head = flow_tail = 0;
4127 /* is player in the wall? */
4128 if (!have_flag(f_ptr->flags, FF_MOVE)) wall = TRUE;
4130 /* Start at the target grid */
4131 travel_flow_aux(ty, tx, 0, wall);
4133 /* Now process the queue */
4134 while (flow_head != flow_tail)
4136 /* Extract the next entry */
4137 y = temp2_y[flow_tail];
4138 x = temp2_x[flow_tail];
4140 /* Forget that entry */
4141 if (++flow_tail == MAX_SHORT) flow_tail = 0;
4143 /* Ignore too far entries */
4144 //if (distance(ty, tx, y, x) > 100) continue;
4146 /* Add the "children" */
4147 for (d = 0; d < 8; d++)
4149 /* Add that child if "legal" */
4150 travel_flow_aux(y + ddy_ddd[d], x + ddx_ddd[d], travel.cost[y][x], wall);
4154 /* Forget the flow info */
4155 flow_head = flow_tail = 0;
4159 * @brief トラベル処理のメインルーチン
4162 void do_cmd_travel(void)
4167 feature_type *f_ptr;
4169 if (travel.x != 0 && travel.y != 0 &&
4170 get_check(_("トラベルを継続しますか?", "Do you continue to travel?")))
4175 else if (!tgt_pt(&x, &y)) return;
4177 if ((x == p_ptr->x) && (y == p_ptr->y))
4179 msg_print(_("すでにそこにいます!", "You are already there!!"));
4183 f_ptr = &f_info[cave[y][x].feat];
4185 if ((cave[y][x].info & CAVE_MARK) &&
4186 (have_flag(f_ptr->flags, FF_WALL) ||
4187 have_flag(f_ptr->flags, FF_CAN_DIG) ||
4188 (have_flag(f_ptr->flags, FF_DOOR) && cave[y][x].mimic)))
4190 msg_print(_("そこには行くことができません!", "You cannot travel there!"));
4194 forget_travel_flow();
4200 /* Travel till 255 steps */
4206 /* Decides first direction */
4207 dx = abs(p_ptr->x - x);
4208 dy = abs(p_ptr->y - y);
4209 sx = ((x == p_ptr->x) || (dx < dy)) ? 0 : ((x > p_ptr->x) ? 1 : -1);
4210 sy = ((y == p_ptr->y) || (dy < dx)) ? 0 : ((y > p_ptr->y) ? 1 : -1);
4212 for (i = 1; i <= 9; i++)
4214 if ((sx == ddx[i]) && (sy == ddy[i])) travel.dir = i;