3 * @brief プレイヤーのコマンド処理1 / Movement commands (part 1)
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.
13 * The running algorithm: -CJS-
15 * In the diagrams below, the player has just arrived in the
16 * grid marked as '@', and he has just come from a grid marked
17 * as 'o', and he is about to enter the grid marked as 'x'.
19 * Of course, if the "requested" move was impossible, then you
20 * will of course be blocked, and will stop.
22 * Overview: You keep moving until something interesting happens.
23 * If you are in an enclosed space, you follow corners. This is
24 * the usual corridor scheme. If you are in an open space, you go
25 * straight, but stop before entering enclosed space. This is
26 * analogous to reaching doorways. If you have enclosed space on
27 * one side only (that is, running along side a wall) stop if
28 * your wall opens out, or your open space closes in. Either case
29 * corresponds to a doorway.
31 * What happens depends on what you can really SEE. (i.e. if you
32 * have no light, then running along a dark corridor is JUST like
33 * running in a dark room.) The algorithm works equally well in
34 * corridors, rooms, mine tailings, earthquake rubble, etc, etc.
36 * These conditions are kept in static memory:
37 * find_openarea You are in the open on at least one
39 * find_breakleft You have a wall on the left, and will
41 * find_breakright You have a wall on the right, and will
44 * To initialize these conditions, we examine the grids adjacent
45 * to the grid marked 'x', two on each side (marked 'L' and 'R').
46 * If either one of the two grids on a given side is seen to be
47 * closed, then that side is considered to be closed. If both
48 * sides are closed, then it is an enclosed (corridor) run.
54 * Looking at more than just the immediate squares is
55 * significant. Consider the following case. A run along the
56 * corridor will stop just before entering the center point,
57 * because a choice is clearly established. Running in any of
58 * three available directions will be defined as a corridor run.
59 * Note that a minor hack is inserted to make the angled corridor
60 * entry (with one side blocked near and the other side blocked
61 * further away from the runner) work correctly. The runner moves
62 * diagonally, but then saves the previous direction as being
63 * straight into the gap. Otherwise, the tail end of the other
64 * entry would be perceived as an alternative on the next move.
72 * Likewise, a run along a wall, and then into a doorway (two
73 * runs) will work correctly. A single run rightwards from \@ will
74 * stop at 1. Another run right and down will enter the corridor
75 * and make the corner, stopping at the 2.
77 * \#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#
79 * \#\#\#\#\#\#\#\#\#\#\# \#\#\#\#\#\#
81 * \#\#\#\#\#\#\#\#\#\#\#\#\#
83 * After any move, the function area_affect is called to
84 * determine the new surroundings, and the direction of
85 * subsequent moves. It examines the current player location
86 * (at which the runner has just arrived) and the previous
87 * direction (from which the runner is considered to have come).
89 * Moving one square in some direction places you adjacent to
90 * three or five new squares (for straight and diagonal moves
91 * respectively) to which you were not previously adjacent,
92 * marked as '!' in the diagrams below.
95 * .o@@! (normal) .o.! (diagonal)
96 * ...! (east) ..@@! (south east)
99 * You STOP if any of the new squares are interesting in any way:
100 * for example, if they contain visible monsters or treasure.
102 * You STOP if any of the newly adjacent squares seem to be open,
103 * and you are also looking for a break on that side. (that is,
104 * find_openarea AND find_break).
106 * You STOP if any of the newly adjacent squares do NOT seem to be
107 * open and you are in an open area, and that side was previously
110 * Corners: If you are not in the open (i.e. you are in a corridor)
111 * and there is only one way to go in the new squares, then turn in
112 * that direction. If there are more than two new ways to go, STOP.
113 * If there are two ways to go, and those ways are separated by a
114 * square which does not seem to be open, then STOP.
116 * Otherwise, we have a potential corner. There are two new open
117 * squares, which are also adjacent. One of the new squares is
118 * diagonally located, the other is straight on (as in the diagram).
119 * We consider two more squares further out (marked below as ?).
121 * We assign "option" to the straight-on grid, and "option2" to the
122 * diagonal grid, and "check_dir" to the grid marked 's'.
128 * If they are both seen to be closed, then it is seen that no benefit
129 * is gained from moving straight. It is a known corner. To cut the
130 * corner, go diagonally, otherwise go straight, but pretend you
131 * stepped diagonally into that next location for a full view next
132 * time. Conversely, if one of the ? squares is not seen to be closed,
133 * then there is a potential choice. We check to see whether it is a
134 * potential corner or an intersection/room entrance. If the square
135 * two spaces straight ahead, and the space marked with 's' are both
136 * unknown space, then it is a potential corner and enter if
137 * find_examine is set, otherwise must stop because it is not a
138 * corner. (find_examine option is removed and always is TRUE.)
148 * @brief プレイヤー攻撃の種族スレイング倍率計算
149 * @param mult 算出前の基本倍率(/10倍)
150 * @param flgs スレイフラグ配列
151 * @param m_ptr 目標モンスターの構造体参照ポインタ
152 * @return スレイング加味後の倍率(/10倍)
154 static MULTIPLY mult_slaying(MULTIPLY mult, const BIT_FLAGS* flgs, const monster_type* m_ptr)
156 static const struct slay_table_t {
158 BIT_FLAGS affect_race_flag;
161 size_t r_flag_offset;
163 #define OFFSET(X) offsetof(monster_race, X)
164 {TR_SLAY_ANIMAL, RF3_ANIMAL, 25, OFFSET(flags3), OFFSET(r_flags3)},
165 {TR_KILL_ANIMAL, RF3_ANIMAL, 40, OFFSET(flags3), OFFSET(r_flags3)},
166 {TR_SLAY_EVIL, RF3_EVIL, 20, OFFSET(flags3), OFFSET(r_flags3)},
167 {TR_KILL_EVIL, RF3_EVIL, 35, OFFSET(flags3), OFFSET(r_flags3)},
168 {TR_SLAY_GOOD, RF3_GOOD, 20, OFFSET(flags3), OFFSET(r_flags3)},
169 {TR_KILL_GOOD, RF3_GOOD, 35, OFFSET(flags3), OFFSET(r_flags3)},
170 {TR_SLAY_HUMAN, RF2_HUMAN, 25, OFFSET(flags2), OFFSET(r_flags2)},
171 {TR_KILL_HUMAN, RF2_HUMAN, 40, OFFSET(flags2), OFFSET(r_flags2)},
172 {TR_SLAY_UNDEAD, RF3_UNDEAD, 30, OFFSET(flags3), OFFSET(r_flags3)},
173 {TR_KILL_UNDEAD, RF3_UNDEAD, 50, OFFSET(flags3), OFFSET(r_flags3)},
174 {TR_SLAY_DEMON, RF3_DEMON, 30, OFFSET(flags3), OFFSET(r_flags3)},
175 {TR_KILL_DEMON, RF3_DEMON, 50, OFFSET(flags3), OFFSET(r_flags3)},
176 {TR_SLAY_ORC, RF3_ORC, 30, OFFSET(flags3), OFFSET(r_flags3)},
177 {TR_KILL_ORC, RF3_ORC, 50, OFFSET(flags3), OFFSET(r_flags3)},
178 {TR_SLAY_TROLL, RF3_TROLL, 30, OFFSET(flags3), OFFSET(r_flags3)},
179 {TR_KILL_TROLL, RF3_TROLL, 50, OFFSET(flags3), OFFSET(r_flags3)},
180 {TR_SLAY_GIANT, RF3_GIANT, 30, OFFSET(flags3), OFFSET(r_flags3)},
181 {TR_KILL_GIANT, RF3_GIANT, 50, OFFSET(flags3), OFFSET(r_flags3)},
182 {TR_SLAY_DRAGON, RF3_DRAGON, 30, OFFSET(flags3), OFFSET(r_flags3)},
183 {TR_KILL_DRAGON, RF3_DRAGON, 50, OFFSET(flags3), OFFSET(r_flags3)},
187 monster_race* r_ptr = &r_info[m_ptr->r_idx];
189 for (i = 0; i < sizeof(slay_table) / sizeof(slay_table[0]); ++ i)
191 const struct slay_table_t* p = &slay_table[i];
193 if ((have_flag(flgs, p->slay_flag)) &&
194 (atoffset(u32b, r_ptr, p->flag_offset) & p->affect_race_flag))
196 if (is_original_ap_and_seen(m_ptr))
198 atoffset(u32b, r_ptr, p->r_flag_offset) |= p->affect_race_flag;
201 mult = MAX(mult, p->slay_mult);
209 * @brief プレイヤー攻撃の属性スレイング倍率計算
210 * @param mult 算出前の基本倍率(/10倍)
211 * @param flgs スレイフラグ配列
212 * @param m_ptr 目標モンスターの構造体参照ポインタ
213 * @return スレイング加味後の倍率(/10倍)
215 static MULTIPLY mult_brand(MULTIPLY mult, const BIT_FLAGS* flgs, const monster_type* m_ptr)
217 static const struct brand_table_t {
219 BIT_FLAGS resist_mask;
222 {TR_BRAND_ACID, RFR_EFF_IM_ACID_MASK, 0U },
223 {TR_BRAND_ELEC, RFR_EFF_IM_ELEC_MASK, 0U },
224 {TR_BRAND_FIRE, RFR_EFF_IM_FIRE_MASK, RF3_HURT_FIRE},
225 {TR_BRAND_COLD, RFR_EFF_IM_COLD_MASK, RF3_HURT_COLD},
226 {TR_BRAND_POIS, RFR_EFF_IM_POIS_MASK, 0U },
229 monster_race* r_ptr = &r_info[m_ptr->r_idx];
231 for (i = 0; i < sizeof(brand_table) / sizeof(brand_table[0]); ++ i)
233 const struct brand_table_t* p = &brand_table[i];
235 if (have_flag(flgs, p->brand_flag))
237 /* Notice immunity */
238 if (r_ptr->flagsr & p->resist_mask)
240 if (is_original_ap_and_seen(m_ptr))
242 r_ptr->r_flagsr |= (r_ptr->flagsr & p->resist_mask);
246 /* Otherwise, take the damage */
247 else if (r_ptr->flags3 & p->hurt_flag)
249 if (is_original_ap_and_seen(m_ptr))
251 r_ptr->r_flags3 |= p->hurt_flag;
254 mult = MAX(mult, 50);
258 mult = MAX(mult, 25);
267 * @brief ダメージにスレイ要素を加える総合処理ルーチン /
268 * Extract the "total damage" from a given object hitting a given monster.
269 * @param o_ptr 使用武器オブジェクトの構造体参照ポインタ
270 * @param tdam 現在算出途中のダメージ値
271 * @param m_ptr 目標モンスターの構造体参照ポインタ
273 * @param thrown 射撃処理ならばTRUEを指定する
274 * @return 総合的なスレイを加味したダメージ値
276 * Note that "flasks of oil" do NOT do fire damage, although they\n
277 * certainly could be made to do so. XXX XXX\n
279 * Note that most brands and slays are x3, except Slay Animal (x2),\n
280 * Slay Evil (x2), and Kill dragon (x5).\n
282 s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr, BIT_FLAGS mode, bool thrown)
286 BIT_FLAGS flgs[TR_FLAG_SIZE];
288 /* Extract the flags */
289 object_flags(o_ptr, flgs);
290 torch_flags(o_ptr, flgs); /* torches has secret flags */
295 if (p_ptr->special_attack & (ATTACK_ACID)) add_flag(flgs, TR_BRAND_ACID);
296 if (p_ptr->special_attack & (ATTACK_COLD)) add_flag(flgs, TR_BRAND_COLD);
297 if (p_ptr->special_attack & (ATTACK_ELEC)) add_flag(flgs, TR_BRAND_ELEC);
298 if (p_ptr->special_attack & (ATTACK_FIRE)) add_flag(flgs, TR_BRAND_FIRE);
299 if (p_ptr->special_attack & (ATTACK_POIS)) add_flag(flgs, TR_BRAND_POIS);
302 /* Hex - Slay Good (Runesword) */
303 if (hex_spelling(HEX_RUNESWORD)) add_flag(flgs, TR_SLAY_GOOD);
305 /* Some "weapons" and "ammo" do extra damage */
318 mult = mult_slaying(mult, flgs, m_ptr);
320 /* Elemental Brand */
321 mult = mult_brand(mult, flgs, m_ptr);
324 if (p_ptr->pclass == CLASS_SAMURAI)
326 mult = mult_hissatsu(mult, flgs, m_ptr, mode);
330 if ((p_ptr->pclass != CLASS_SAMURAI) && (have_flag(flgs, TR_FORCE_WEAPON)) && (p_ptr->csp > (o_ptr->dd * o_ptr->ds / 5)))
332 p_ptr->csp -= (1+(o_ptr->dd * o_ptr->ds / 5));
333 p_ptr->redraw |= (PR_MANA);
334 mult = mult * 3 / 2 + 20;
337 /* Hack -- The Nothung cause special damage to Fafner */
338 if ((o_ptr->name1 == ART_NOTHUNG) && (m_ptr->r_idx == MON_FAFNER))
343 if (mult > 150) mult = 150;
345 /* Return the total damage */
346 return (tdam * mult / 10);
351 * @brief 地形やその上のアイテムの隠された要素を明かす /
352 * Search for hidden things
353 * @param y 対象となるマスのY座標
354 * @param x 対象となるマスのX座標
357 static void discover_hidden_things(POSITION y, POSITION x)
359 OBJECT_IDX this_o_idx, next_o_idx = 0;
362 /* Access the grid */
366 if (c_ptr->mimic && is_trap(c_ptr->feat))
371 msg_print(_("トラップを発見した。", "You have found a trap."));
378 if (is_hidden_door(c_ptr))
380 msg_print(_("隠しドアを発見した。", "You have found a secret door."));
389 /* Scan all objects in the grid */
390 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
395 o_ptr = &o_list[this_o_idx];
397 /* Acquire next object */
398 next_o_idx = o_ptr->next_o_idx;
400 /* Skip non-chests */
401 if (o_ptr->tval != TV_CHEST) continue;
403 /* Skip non-trapped chests */
404 if (!chest_traps[o_ptr->pval]) continue;
407 if (!object_is_known(o_ptr))
409 msg_print(_("箱に仕掛けられたトラップを発見した!", "You have discovered a trap on the chest!"));
421 * @brief プレイヤーの探索処理判定
429 /* Start with base search ability */
430 chance = p_ptr->skill_srh;
432 /* Penalize various conditions */
433 if (p_ptr->blind || no_lite()) chance = chance / 10;
434 if (p_ptr->confused || p_ptr->image) chance = chance / 10;
436 /* Search the nearby grids, which are always in bounds */
437 for (i = 0; i < 9; ++ i)
439 /* Sometimes, notice things */
440 if (randint0(100) < chance)
442 discover_hidden_things(p_ptr->y + ddy_ddd[i], p_ptr->x + ddx_ddd[i]);
449 * @brief プレイヤーがオブジェクトを拾った際のメッセージ表示処理 /
450 * Helper routine for py_pickup() and py_pickup_floor().
451 * @param o_idx 取得したオブジェクトの参照ID
454 * アイテムを拾った際に「2つのケーキを持っている」\n
455 * "You have two cakes." とアイテムを拾った後の合計のみの表示がオリジナル\n
457 * あるという指摘をうけたので、「~を拾った、~を持っている」という表示\n
459 * Add the given dungeon object to the character's inventory.\n
460 * Delete the object afterwards.\n
462 void py_pickup_aux(OBJECT_IDX o_idx)
467 char o_name[MAX_NLEN];
468 char old_name[MAX_NLEN];
472 char o_name[MAX_NLEN];
477 o_ptr = &o_list[o_idx];
480 /* Describe the object */
481 object_desc(old_name, o_ptr, OD_NAME_ONLY);
482 object_desc_kosuu(kazu_str, o_ptr);
483 hirottakazu = o_ptr->number;
485 /* Carry the object */
486 slot = inven_carry(o_ptr);
488 /* Get the object again */
489 o_ptr = &inventory[slot];
491 /* Delete the object */
492 delete_object_idx(o_idx);
494 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)
496 bool old_known = identify_item(o_ptr);
498 /* Auto-inscription/destroy */
499 autopick_alter_item(slot, (bool)(destroy_identify && !old_known));
501 /* If it is destroyed, don't pick it up */
502 if (o_ptr->marked & OM_AUTODESTROY) return;
505 /* Describe the object */
506 object_desc(o_name, o_ptr, 0);
509 if ((o_ptr->name1 == ART_CRIMSON) && (p_ptr->pseikaku == SEIKAKU_COMBAT))
511 msg_format("こうして、%sは『クリムゾン』を手に入れた。", p_ptr->name);
512 msg_print("しかし今、『混沌のサーペント』の放ったモンスターが、");
513 msg_format("%sに襲いかかる...", p_ptr->name);
519 msg_format("%s(%c)を持っている。",o_name, index_to_label(slot));
523 if (o_ptr->number > hirottakazu) {
524 msg_format("%s拾って、%s(%c)を持っている。",
525 kazu_str, o_name, index_to_label(slot));
527 msg_format("%s(%c)を拾った。", o_name, index_to_label(slot));
531 strcpy(record_o_name, old_name);
533 msg_format("You have %s (%c).", o_name, index_to_label(slot));
534 strcpy(record_o_name, o_name);
539 check_find_art_quest_completion(o_ptr);
544 * @brief プレイヤーがオブジェクト上に乗った際の表示処理
545 * @param pickup 自動拾い処理を行うならばTRUEとする
548 * Player "wants" to pick up an object or gold.
549 * Note that we ONLY handle things that can be picked up.
550 * See "move_player()" for handling of other things.
552 void carry(bool pickup)
554 cave_type *c_ptr = &cave[p_ptr->y][p_ptr->x];
556 OBJECT_IDX this_o_idx, next_o_idx = 0;
558 char o_name[MAX_NLEN];
560 /* Recenter the map around the player */
564 p_ptr->update |= (PU_MONSTERS);
567 p_ptr->redraw |= (PR_MAP);
570 p_ptr->window |= (PW_OVERHEAD);
575 /* Automatically pickup/destroy/inscribe items */
576 autopick_pickup_items(c_ptr);
579 #ifdef ALLOW_EASY_FLOOR
583 py_pickup_floor(pickup);
587 #endif /* ALLOW_EASY_FLOOR */
589 /* Scan the pile of objects */
590 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
595 o_ptr = &o_list[this_o_idx];
597 #ifdef ALLOW_EASY_SENSE /* TNB */
599 /* Option: Make item sensing easy */
602 /* Sense the object */
603 (void)sense_object(o_ptr);
606 #endif /* ALLOW_EASY_SENSE -- TNB */
608 /* Describe the object */
609 object_desc(o_name, o_ptr, 0);
611 /* Acquire next object */
612 next_o_idx = o_ptr->next_o_idx;
614 /* Hack -- disturb */
618 if (o_ptr->tval == TV_GOLD)
620 int value = (long)o_ptr->pval;
622 /* Delete the gold */
623 delete_object_idx(this_o_idx);
625 msg_format(_(" $%ld の価値がある%sを見つけた。", "You collect %ld gold pieces worth of %s."),
626 (long)value, o_name);
630 /* Collect the gold */
634 p_ptr->redraw |= (PR_GOLD);
637 p_ptr->window |= (PW_PLAYER);
640 /* Pick up objects */
643 /* Hack - some objects were handled in autopick_pickup_items(). */
644 if (o_ptr->marked & OM_NOMSG)
646 /* Clear the flag. */
647 o_ptr->marked &= ~OM_NOMSG;
649 /* Describe the object */
652 msg_format(_("%sがある。", "You see %s."), o_name);
655 /* Note that the pack is too full */
656 else if (!inven_carry_okay(o_ptr))
658 msg_format(_("ザックには%sを入れる隙間がない。", "You have no room for %s."), o_name);
661 /* Pick up the item (if requested and allowed) */
666 /* Hack -- query every item */
667 if (carry_query_flag)
669 char out_val[MAX_NLEN+20];
670 sprintf(out_val, _("%sを拾いますか? ", "Pick up %s? "), o_name);
671 okay = get_check(out_val);
674 /* Attempt to pick up an object. */
677 /* Pick up the object */
678 py_pickup_aux(this_o_idx);
687 * @brief パターンによる移動制限処理
688 * @param c_y プレイヤーの移動元Y座標
689 * @param c_x プレイヤーの移動元X座標
690 * @param n_y プレイヤーの移動先Y座標
691 * @param n_x プレイヤーの移動先X座標
692 * @return 移動処理が可能である場合(可能な場合に選択した場合)TRUEを返す。
694 bool pattern_seq(POSITION c_y, POSITION c_x, POSITION n_y, POSITION n_x)
696 feature_type *cur_f_ptr = &f_info[cave[c_y][c_x].feat];
697 feature_type *new_f_ptr = &f_info[cave[n_y][n_x].feat];
698 bool is_pattern_tile_cur = have_flag(cur_f_ptr->flags, FF_PATTERN);
699 bool is_pattern_tile_new = have_flag(new_f_ptr->flags, FF_PATTERN);
700 int pattern_type_cur, pattern_type_new;
702 if (!is_pattern_tile_cur && !is_pattern_tile_new) return TRUE;
704 pattern_type_cur = is_pattern_tile_cur ? cur_f_ptr->subtype : NOT_PATTERN_TILE;
705 pattern_type_new = is_pattern_tile_new ? new_f_ptr->subtype : NOT_PATTERN_TILE;
707 if (pattern_type_new == PATTERN_TILE_START)
709 if (!is_pattern_tile_cur && !p_ptr->confused && !p_ptr->stun && !p_ptr->image)
711 if (get_check(_("パターンの上を歩き始めると、全てを歩かなければなりません。いいですか?",
712 "If you start walking the Pattern, you must walk the whole way. Ok? ")))
720 else if ((pattern_type_new == PATTERN_TILE_OLD) ||
721 (pattern_type_new == PATTERN_TILE_END) ||
722 (pattern_type_new == PATTERN_TILE_WRECKED))
724 if (is_pattern_tile_cur)
730 msg_print(_("パターンの上を歩くにはスタート地点から歩き始めなくてはなりません。",
731 "You must start walking the Pattern from the startpoint."));
736 else if ((pattern_type_new == PATTERN_TILE_TELEPORT) ||
737 (pattern_type_cur == PATTERN_TILE_TELEPORT))
741 else if (pattern_type_cur == PATTERN_TILE_START)
743 if (is_pattern_tile_new)
747 msg_print(_("パターンの上は正しい順序で歩かねばなりません。", "You must walk the Pattern in correct order."));
751 else if ((pattern_type_cur == PATTERN_TILE_OLD) ||
752 (pattern_type_cur == PATTERN_TILE_END) ||
753 (pattern_type_cur == PATTERN_TILE_WRECKED))
755 if (!is_pattern_tile_new)
757 msg_print(_("パターンを踏み外してはいけません。", "You may not step off from the Pattern."));
767 if (!is_pattern_tile_cur)
769 msg_print(_("パターンの上を歩くにはスタート地点から歩き始めなくてはなりません。",
770 "You must start walking the Pattern from the startpoint."));
776 byte ok_move = PATTERN_TILE_START;
777 switch (pattern_type_cur)
780 ok_move = PATTERN_TILE_2;
783 ok_move = PATTERN_TILE_3;
786 ok_move = PATTERN_TILE_4;
789 ok_move = PATTERN_TILE_1;
793 msg_format(_("おかしなパターン歩行、%d。", "Funny Pattern walking, %d."), pattern_type_cur);
795 return TRUE; /* Goof-up */
798 if ((pattern_type_new == ok_move) ||
799 (pattern_type_new == pattern_type_cur))
803 if (!is_pattern_tile_new)
804 msg_print(_("パターンを踏み外してはいけません。", "You may not step off from the Pattern."));
806 msg_print(_("パターンの上は正しい順序で歩かねばなりません。", "You must walk the Pattern in correct order."));
816 * @brief プレイヤーが地形踏破可能かを返す
817 * @param feature 判定したい地形ID
818 * @param mode 移動に関するオプションフラグ
819 * @return 移動可能ならばTRUEを返す
821 bool player_can_enter(s16b feature, u16b mode)
823 feature_type *f_ptr = &f_info[feature];
825 if (p_ptr->riding) return monster_can_cross_terrain(feature, &r_info[m_list[p_ptr->riding].r_idx], mode | CEM_RIDING);
828 if (have_flag(f_ptr->flags, FF_PATTERN))
830 if (!(mode & CEM_P_CAN_ENTER_PATTERN)) return FALSE;
834 if (have_flag(f_ptr->flags, FF_CAN_FLY) && p_ptr->levitation) return TRUE;
835 if (have_flag(f_ptr->flags, FF_CAN_SWIM) && p_ptr->can_swim) return TRUE;
836 if (have_flag(f_ptr->flags, FF_CAN_PASS) && p_ptr->pass_wall) return TRUE;
838 if (!have_flag(f_ptr->flags, FF_MOVE)) return FALSE;
845 * @brief 移動に伴うプレイヤーのステータス変化処理
848 * @param mpe_mode 移動オプションフラグ
849 * @return プレイヤーが死亡やフロア離脱を行わず、実際に移動が可能ならばTRUEを返す。
851 bool move_player_effect(POSITION ny, POSITION nx, BIT_FLAGS mpe_mode)
853 cave_type *c_ptr = &cave[ny][nx];
854 feature_type *f_ptr = &f_info[c_ptr->feat];
856 if (!(mpe_mode & MPE_STAYING))
858 POSITION oy = p_ptr->y;
859 POSITION ox = p_ptr->x;
860 cave_type *oc_ptr = &cave[oy][ox];
861 IDX om_idx = oc_ptr->m_idx;
862 IDX nm_idx = c_ptr->m_idx;
864 /* Move the player */
868 /* Hack -- For moving monster or riding player's moving */
869 if (!(mpe_mode & MPE_DONT_SWAP_MON))
871 /* Swap two monsters */
872 c_ptr->m_idx = om_idx;
873 oc_ptr->m_idx = nm_idx;
875 if (om_idx > 0) /* Monster on old spot (or p_ptr->riding) */
877 monster_type *om_ptr = &m_list[om_idx];
880 update_mon(om_idx, TRUE);
883 if (nm_idx > 0) /* Monster on new spot */
885 monster_type *nm_ptr = &m_list[nm_idx];
888 update_mon(nm_idx, TRUE);
892 /* Redraw old spot */
895 /* Redraw new spot */
898 /* Check for new panel (redraw map) */
901 if (mpe_mode & MPE_FORGET_FLOW)
905 /* Mega-Hack -- Forget the view */
906 p_ptr->update |= (PU_UN_VIEW);
909 p_ptr->redraw |= (PR_MAP);
913 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE | PU_DISTANCE);
916 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
918 /* Remove "unsafe" flag */
919 if ((!p_ptr->blind && !no_lite()) || !is_trap(c_ptr->feat)) c_ptr->info &= ~(CAVE_UNSAFE);
921 /* For get everything when requested hehe I'm *NASTY* */
922 if (dun_level && (d_info[dungeon_type].flags1 & DF1_FORGET)) wiz_dark();
925 if (mpe_mode & MPE_HANDLE_STUFF) handle_stuff();
927 if (p_ptr->pclass == CLASS_NINJA)
929 if (c_ptr->info & (CAVE_GLOW)) set_superstealth(FALSE);
930 else if (p_ptr->cur_lite <= 0) set_superstealth(TRUE);
933 if ((p_ptr->action == ACTION_HAYAGAKE) &&
934 (!have_flag(f_ptr->flags, FF_PROJECT) ||
935 (!p_ptr->levitation && have_flag(f_ptr->flags, FF_DEEP))))
937 msg_print(_("ここでは素早く動けない。", "You cannot run in here."));
938 set_action(ACTION_NONE);
942 if (mpe_mode & MPE_ENERGY_USE)
944 if (music_singing(MUSIC_WALL))
946 (void)project(0, 0, p_ptr->y, p_ptr->x, (60 + p_ptr->lev), GF_DISINTEGRATE,
947 PROJECT_KILL | PROJECT_ITEM, -1);
949 if (!player_bold(ny, nx) || p_ptr->is_dead || p_ptr->leaving) return FALSE;
952 /* Spontaneous Searching */
953 if ((p_ptr->skill_fos >= 50) || (0 == randint0(50 - p_ptr->skill_fos)))
958 /* Continuous Searching */
959 if (p_ptr->action == ACTION_SEARCH)
965 /* Handle "objects" */
966 if (!(mpe_mode & MPE_DONT_PICKUP))
968 carry((mpe_mode & MPE_DO_PICKUP) ? TRUE : FALSE);
971 /* Handle "store doors" */
972 if (have_flag(f_ptr->flags, FF_STORE))
977 p_ptr->energy_use = 0;
978 /* Hack -- Enter store */
979 command_new = SPECIAL_KEY_STORE;
982 /* Handle "building doors" -KMW- */
983 else if (have_flag(f_ptr->flags, FF_BLDG))
988 p_ptr->energy_use = 0;
989 /* Hack -- Enter building */
990 command_new = SPECIAL_KEY_BUILDING;
993 /* Handle quest areas -KMW- */
994 else if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
999 p_ptr->energy_use = 0;
1000 /* Hack -- Enter quest level */
1001 command_new = SPECIAL_KEY_QUEST;
1004 else if (have_flag(f_ptr->flags, FF_QUEST_EXIT))
1006 if (quest[p_ptr->inside_quest].type == QUEST_TYPE_FIND_EXIT)
1008 complete_quest(p_ptr->inside_quest);
1011 leave_quest_check();
1013 p_ptr->inside_quest = c_ptr->special;
1018 p_ptr->leaving = TRUE;
1021 /* Set off a trap */
1022 else if (have_flag(f_ptr->flags, FF_HIT_TRAP) && !(mpe_mode & MPE_STAYING))
1028 if (c_ptr->mimic || have_flag(f_ptr->flags, FF_SECRET))
1030 msg_print(_("トラップだ!", "You found a trap!"));
1033 disclose_grid(p_ptr->y, p_ptr->x);
1037 hit_trap((mpe_mode & MPE_BREAK_TRAP) ? TRUE : FALSE);
1039 if (!player_bold(ny, nx) || p_ptr->is_dead || p_ptr->leaving) return FALSE;
1042 /* Warn when leaving trap detected region */
1043 if (!(mpe_mode & MPE_STAYING) && (disturb_trap_detect || alert_trap_detect)
1044 && p_ptr->dtrap && !(c_ptr->info & CAVE_IN_DETECT))
1046 /* No duplicate warning */
1047 p_ptr->dtrap = FALSE;
1049 /* You are just on the edge */
1050 if (!(c_ptr->info & CAVE_UNSAFE))
1052 if (alert_trap_detect)
1054 msg_print(_("* 注意:この先はトラップの感知範囲外です! *", "*Leaving trap detect region!*"));
1057 if (disturb_trap_detect) disturb(0, 1);
1061 return player_bold(ny, nx) && !p_ptr->is_dead && !p_ptr->leaving;
1065 * @brief 該当地形のトラップがプレイヤーにとって無効かどうかを判定して返す
1067 * @return トラップが自動的に無効ならばTRUEを返す
1069 bool trap_can_be_ignored(int feat)
1071 feature_type *f_ptr = &f_info[feat];
1073 if (!have_flag(f_ptr->flags, FF_TRAP)) return TRUE;
1075 switch (f_ptr->subtype)
1079 case TRAP_SPIKED_PIT:
1080 case TRAP_POISON_PIT:
1081 if (p_ptr->levitation) return TRUE;
1084 if (p_ptr->anti_tele) return TRUE;
1087 if (p_ptr->immune_fire) return TRUE;
1090 if (p_ptr->immune_acid) return TRUE;
1093 if (p_ptr->resist_blind) return TRUE;
1096 if (p_ptr->resist_conf) return TRUE;
1099 if (p_ptr->resist_pois) return TRUE;
1102 if (p_ptr->free_act) return TRUE;
1111 * Determine if a "boundary" grid is "floor mimic"
1113 #define boundary_floor(C, F, MF) \
1114 ((C)->mimic && permanent_wall(F) && \
1115 (have_flag((MF)->flags, FF_MOVE) || have_flag((MF)->flags, FF_CAN_FLY)) && \
1116 have_flag((MF)->flags, FF_PROJECT) && \
1117 !have_flag((MF)->flags, FF_OPEN))
1121 * @brief 該当地形のトラップがプレイヤーにとって無効かどうかを判定して返す /
1122 * Move player in the given direction, with the given "pickup" flag.
1124 * @param do_pickup 罠解除を試みながらの移動ならばTRUE
1125 * @param break_trap トラップ粉砕処理を行うならばTRUE
1126 * @return 実際に移動が行われたならばTRUEを返す。
1128 * This routine should (probably) always induce energy expenditure.\n
1130 * Note that moving will *always* take a turn, and will *always* hit\n
1131 * any monster which might be in the destination grid. Previously,\n
1132 * moving into walls was "free" and did NOT hit invisible monsters.\n
1134 void move_player(DIRECTION dir, bool do_pickup, bool break_trap)
1136 /* Find the result of moving */
1137 POSITION y = p_ptr->y + ddy[dir];
1138 POSITION x = p_ptr->x + ddx[dir];
1140 /* Examine the destination */
1141 cave_type *c_ptr = &cave[y][x];
1143 feature_type *f_ptr = &f_info[c_ptr->feat];
1145 monster_type *m_ptr;
1147 monster_type *riding_m_ptr = &m_list[p_ptr->riding];
1148 monster_race *riding_r_ptr = &r_info[p_ptr->riding ? riding_m_ptr->r_idx : 0]; /* Paranoia */
1152 bool p_can_enter = player_can_enter(c_ptr->feat, CEM_P_CAN_ENTER_PATTERN);
1153 bool p_can_kill_walls = FALSE;
1154 bool stormbringer = FALSE;
1156 bool oktomove = TRUE;
1157 bool do_past = FALSE;
1160 if (!dun_level && !p_ptr->wild_mode &&
1161 ((x == 0) || (x == MAX_WID - 1) ||
1162 (y == 0) || (y == MAX_HGT - 1)))
1164 /* Can the player enter the grid? */
1165 if (c_ptr->mimic && player_can_enter(c_ptr->mimic, 0))
1167 /* Hack: move to new area */
1168 if ((y == 0) && (x == 0))
1170 p_ptr->wilderness_y--;
1171 p_ptr->wilderness_x--;
1172 p_ptr->oldpy = cur_hgt - 2;
1173 p_ptr->oldpx = cur_wid - 2;
1174 ambush_flag = FALSE;
1177 else if ((y == 0) && (x == MAX_WID - 1))
1179 p_ptr->wilderness_y--;
1180 p_ptr->wilderness_x++;
1181 p_ptr->oldpy = cur_hgt - 2;
1183 ambush_flag = FALSE;
1186 else if ((y == MAX_HGT - 1) && (x == 0))
1188 p_ptr->wilderness_y++;
1189 p_ptr->wilderness_x--;
1191 p_ptr->oldpx = cur_wid - 2;
1192 ambush_flag = FALSE;
1195 else if ((y == MAX_HGT - 1) && (x == MAX_WID - 1))
1197 p_ptr->wilderness_y++;
1198 p_ptr->wilderness_x++;
1201 ambush_flag = FALSE;
1206 p_ptr->wilderness_y--;
1207 p_ptr->oldpy = cur_hgt - 2;
1209 ambush_flag = FALSE;
1212 else if (y == MAX_HGT - 1)
1214 p_ptr->wilderness_y++;
1217 ambush_flag = FALSE;
1222 p_ptr->wilderness_x--;
1223 p_ptr->oldpx = cur_wid - 2;
1225 ambush_flag = FALSE;
1228 else if (x == MAX_WID - 1)
1230 p_ptr->wilderness_x++;
1233 ambush_flag = FALSE;
1236 p_ptr->leaving = TRUE;
1237 p_ptr->energy_use = 100;
1242 /* "Blocked" message appears later */
1243 /* oktomove = FALSE; */
1244 p_can_enter = FALSE;
1247 /* Get the monster */
1248 m_ptr = &m_list[c_ptr->m_idx];
1251 if (inventory[INVEN_RARM].name1 == ART_STORMBRINGER) stormbringer = TRUE;
1252 if (inventory[INVEN_LARM].name1 == ART_STORMBRINGER) stormbringer = TRUE;
1254 /* Player can not walk through "walls"... */
1255 /* unless in Shadow Form */
1256 p_can_kill_walls = p_ptr->kill_wall && have_flag(f_ptr->flags, FF_HURT_DISI) &&
1257 (!p_can_enter || !have_flag(f_ptr->flags, FF_LOS)) &&
1258 !have_flag(f_ptr->flags, FF_PERMANENT);
1260 /* Hack -- attack monsters */
1261 if (c_ptr->m_idx && (m_ptr->ml || p_can_enter || p_can_kill_walls))
1263 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1265 /* Attack -- only if we can see it OR it is not in a wall */
1266 if (!is_hostile(m_ptr) &&
1267 !(p_ptr->confused || p_ptr->image || !m_ptr->ml || p_ptr->stun ||
1268 ((p_ptr->muta2 & MUT2_BERS_RAGE) && p_ptr->shero)) &&
1269 pattern_seq(p_ptr->y, p_ptr->x, y, x) && (p_can_enter || p_can_kill_walls))
1271 /* Disturb the monster */
1272 (void)set_monster_csleep(c_ptr->m_idx, 0);
1274 /* Extract monster name (or "it") */
1275 monster_desc(m_name, m_ptr, 0);
1279 /* Auto-Recall if possible and visible */
1280 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
1282 /* Track a new monster */
1283 health_track(c_ptr->m_idx);
1287 if ((stormbringer && (randint1(1000) > 666)) || (p_ptr->pclass == CLASS_BERSERKER))
1292 else if (monster_can_cross_terrain(cave[p_ptr->y][p_ptr->x].feat, r_ptr, 0))
1298 msg_format(_("%^sが邪魔だ!", "%^s is in your way!"), m_name);
1299 p_ptr->energy_use = 0;
1303 /* now continue on to 'movement' */
1312 if (oktomove && p_ptr->riding)
1314 if (riding_r_ptr->flags1 & RF1_NEVER_MOVE)
1316 msg_print(_("動けない!", "Can't move!"));
1317 p_ptr->energy_use = 0;
1321 else if (MON_MONFEAR(riding_m_ptr))
1323 char steed_name[80];
1325 /* Acquire the monster name */
1326 monster_desc(steed_name, riding_m_ptr, 0);
1328 /* Dump a message */
1329 msg_format(_("%sが恐怖していて制御できない。", "%^s is too scared to control."), steed_name);
1333 else if (p_ptr->riding_ryoute)
1338 else if (have_flag(f_ptr->flags, FF_CAN_FLY) && (riding_r_ptr->flags7 & RF7_CAN_FLY))
1342 else if (have_flag(f_ptr->flags, FF_CAN_SWIM) && (riding_r_ptr->flags7 & RF7_CAN_SWIM))
1346 else if (have_flag(f_ptr->flags, FF_WATER) &&
1347 !(riding_r_ptr->flags7 & RF7_AQUATIC) &&
1348 (have_flag(f_ptr->flags, FF_DEEP) || (riding_r_ptr->flags2 & RF2_AURA_FIRE)))
1350 msg_format(_("%sの上に行けない。", "Can't swim."), f_name + f_info[get_feat_mimic(c_ptr)].name);
1351 p_ptr->energy_use = 0;
1355 else if (!have_flag(f_ptr->flags, FF_WATER) && (riding_r_ptr->flags7 & RF7_AQUATIC))
1357 msg_format(_("%sから上がれない。", "Can't land."), f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name);
1358 p_ptr->energy_use = 0;
1362 else if (have_flag(f_ptr->flags, FF_LAVA) && !(riding_r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK))
1364 msg_format(_("%sの上に行けない。", "Too hot to go through."), f_name + f_info[get_feat_mimic(c_ptr)].name);
1365 p_ptr->energy_use = 0;
1370 if (oktomove && MON_STUNNED(riding_m_ptr) && one_in_(2))
1372 char steed_name[80];
1373 monster_desc(steed_name, riding_m_ptr, 0);
1374 msg_format(_("%sが朦朧としていてうまく動けない!", "You cannot control stunned %s!"), steed_name);
1384 else if (!have_flag(f_ptr->flags, FF_MOVE) && have_flag(f_ptr->flags, FF_CAN_FLY) && !p_ptr->levitation)
1386 msg_format(_("空を飛ばないと%sの上には行けない。", "You need to fly to go through the %s."), f_name + f_info[get_feat_mimic(c_ptr)].name);
1387 p_ptr->energy_use = 0;
1393 * Player can move through trees and
1394 * has effective -10 speed
1395 * Rangers can move without penality
1397 else if (have_flag(f_ptr->flags, FF_TREE) && !p_can_kill_walls)
1399 if ((p_ptr->pclass != CLASS_RANGER) && !p_ptr->levitation && (!p_ptr->riding || !(riding_r_ptr->flags8 & RF8_WILD_WOOD))) p_ptr->energy_use *= 2;
1402 #ifdef ALLOW_EASY_DISARM /* TNB */
1404 /* Disarm a visible trap */
1405 else if ((do_pickup != easy_disarm) && have_flag(f_ptr->flags, FF_DISARM) && !c_ptr->mimic)
1407 if (!trap_can_be_ignored(c_ptr->feat))
1409 (void)do_cmd_disarm_aux(y, x, dir);
1414 #endif /* ALLOW_EASY_DISARM -- TNB */
1416 /* Player can not walk through "walls" unless in wraith form...*/
1417 else if (!p_can_enter && !p_can_kill_walls)
1419 /* Feature code (applying "mimic" field) */
1420 FEAT_IDX feat = get_feat_mimic(c_ptr);
1421 feature_type *mimic_f_ptr = &f_info[feat];
1422 cptr name = f_name + mimic_f_ptr->name;
1426 /* Notice things in the dark */
1427 if (!(c_ptr->info & CAVE_MARK) && !player_can_see_bold(y, x))
1429 /* Boundary floor mimic */
1430 if (boundary_floor(c_ptr, f_ptr, mimic_f_ptr))
1432 msg_print(_("それ以上先には進めないようだ。", "You feel you cannot go any more."));
1435 /* Wall (or secret door) */
1439 msg_format("%sが行く手をはばんでいるようだ。", name);
1441 msg_format("You feel %s %s blocking your way.",
1442 is_a_vowel(name[0]) ? "an" : "a", name);
1445 c_ptr->info |= (CAVE_MARK);
1453 /* Boundary floor mimic */
1454 if (boundary_floor(c_ptr, f_ptr, mimic_f_ptr))
1456 msg_print(_("それ以上先には進めない。", "You cannot go any more."));
1457 if (!(p_ptr->confused || p_ptr->stun || p_ptr->image))
1458 p_ptr->energy_use = 0;
1461 /* Wall (or secret door) */
1464 #ifdef ALLOW_EASY_OPEN
1466 if (easy_open && is_closed_door(feat) && easy_open_door(y, x)) return;
1467 #endif /* ALLOW_EASY_OPEN */
1470 msg_format("%sが行く手をはばんでいる。", name);
1472 msg_format("There is %s %s blocking your way.",
1473 is_a_vowel(name[0]) ? "an" : "a", name);
1477 * Well, it makes sense that you lose time bumping into
1478 * a wall _if_ you are confused, stunned or blind; but
1479 * typing mistakes should not cost you a turn...
1481 if (!(p_ptr->confused || p_ptr->stun || p_ptr->image))
1482 p_ptr->energy_use = 0;
1486 /* Disturb the player */
1489 if (!boundary_floor(c_ptr, f_ptr, mimic_f_ptr)) sound(SOUND_HITWALL);
1492 /* Normal movement */
1493 if (oktomove && !pattern_seq(p_ptr->y, p_ptr->x, y, x))
1495 if (!(p_ptr->confused || p_ptr->stun || p_ptr->image))
1497 p_ptr->energy_use = 0;
1500 /* To avoid a loop with running */
1506 /* Normal movement */
1509 u32b mpe_mode = MPE_ENERGY_USE;
1513 if (!process_warning(x, y))
1515 p_ptr->energy_use = 25;
1522 msg_format(_("%sを押し退けた。", "You push past %s."), m_name);
1525 /* Change oldpx and oldpy to place the player well when going back to big mode */
1526 if (p_ptr->wild_mode)
1528 if (ddy[dir] > 0) p_ptr->oldpy = 1;
1529 if (ddy[dir] < 0) p_ptr->oldpy = MAX_HGT - 2;
1530 if (ddy[dir] == 0) p_ptr->oldpy = MAX_HGT / 2;
1531 if (ddx[dir] > 0) p_ptr->oldpx = 1;
1532 if (ddx[dir] < 0) p_ptr->oldpx = MAX_WID - 2;
1533 if (ddx[dir] == 0) p_ptr->oldpx = MAX_WID / 2;
1536 if (p_can_kill_walls)
1538 cave_alter_feat(y, x, FF_HURT_DISI);
1540 /* Update some things -- similar to GF_KILL_WALL */
1541 p_ptr->update |= (PU_FLOW);
1544 /* sound(SOUND_WALK); */
1546 #ifdef ALLOW_EASY_DISARM /* TNB */
1548 if (do_pickup != always_pickup) mpe_mode |= MPE_DO_PICKUP;
1550 #else /* ALLOW_EASY_DISARM -- TNB */
1552 if (do_pickup) mpe_mode |= MPE_DO_PICKUP;
1554 #endif /* ALLOW_EASY_DISARM -- TNB */
1556 if (break_trap) mpe_mode |= MPE_BREAK_TRAP;
1558 /* Move the player */
1559 (void)move_player_effect(y, x, mpe_mode);
1564 static bool ignore_avoid_run;
1567 * @brief ダッシュ移動処理中、移動先のマスが既知の壁かどうかを判定する /
1568 * Hack -- Check for a "known wall" (see below)
1569 * @param dir 想定する移動方向ID
1572 * @return 移動先が既知の壁ならばTRUE
1574 static bool see_wall(DIRECTION dir, POSITION y, POSITION x)
1578 /* Get the new location */
1582 /* Illegal grids are not known walls */
1583 if (!in_bounds2(y, x)) return (FALSE);
1586 c_ptr = &cave[y][x];
1588 /* Must be known to the player */
1589 if (c_ptr->info & (CAVE_MARK))
1591 /* Feature code (applying "mimic" field) */
1592 s16b feat = get_feat_mimic(c_ptr);
1593 feature_type *f_ptr = &f_info[feat];
1595 /* Wall grids are known walls */
1596 if (!player_can_enter(feat, 0)) return !have_flag(f_ptr->flags, FF_DOOR);
1598 /* Don't run on a tree unless explicitly requested */
1599 if (have_flag(f_ptr->flags, FF_AVOID_RUN) && !ignore_avoid_run)
1602 /* Don't run in a wall */
1603 if (!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY))
1604 return !have_flag(f_ptr->flags, FF_DOOR);
1612 * @brief ダッシュ移動処理中、移動先のマスか未知の地形かどうかを判定する /
1613 * Hack -- Check for an "unknown corner" (see below)
1614 * @param dir 想定する移動方向ID
1617 * @return 移動先が未知の地形ならばTRUE
1619 static bool see_nothing(DIRECTION dir, POSITION y, POSITION x)
1621 /* Get the new location */
1625 /* Illegal grids are unknown */
1626 if (!in_bounds2(y, x)) return (TRUE);
1628 /* Memorized grids are always known */
1629 if (cave[y][x].info & (CAVE_MARK)) return (FALSE);
1631 /* Viewable door/wall grids are known */
1632 if (player_can_see_bold(y, x)) return (FALSE);
1644 * Hack -- allow quick "cycling" through the legal directions
1646 static byte cycle[] =
1647 { 1, 2, 3, 6, 9, 8, 7, 4, 1, 2, 3, 6, 9, 8, 7, 4, 1 };
1650 * Hack -- map each direction into the "middle" of the "cycle[]" array
1652 static byte chome[] =
1653 { 0, 8, 9, 10, 7, 0, 11, 6, 5, 4 };
1656 * The direction we are running
1658 static DIRECTION find_current;
1661 * The direction we came from
1663 static DIRECTION find_prevdir;
1666 * We are looking for open area
1668 static bool find_openarea;
1671 * We are looking for a break
1673 static bool find_breakright;
1674 static bool find_breakleft;
1679 * @brief ダッシュ処理の導入 /
1680 * Initialize the running algorithm for a new direction.
1683 * Diagonal Corridor -- allow diaginal entry into corridors.\n
1685 * Blunt Corridor -- If there is a wall two spaces ahead and\n
1686 * we seem to be in a corridor, then force a turn into the side\n
1687 * corridor, must be moving straight into a corridor here. ???\n
1689 * Diagonal Corridor Blunt Corridor (?)\n
1694 static void run_init(DIRECTION dir)
1696 int row, col, deepleft, deepright;
1697 int i, shortleft, shortright;
1700 /* Save the direction */
1703 /* Assume running straight */
1706 /* Assume looking for open area */
1707 find_openarea = TRUE;
1709 /* Assume not looking for breaks */
1710 find_breakright = find_breakleft = FALSE;
1712 /* Assume no nearby walls */
1713 deepleft = deepright = FALSE;
1714 shortright = shortleft = FALSE;
1716 p_ptr->run_py = p_ptr->y;
1717 p_ptr->run_px = p_ptr->x;
1719 /* Find the destination grid */
1720 row = p_ptr->y + ddy[dir];
1721 col = p_ptr->x + ddx[dir];
1723 ignore_avoid_run = cave_have_flag_bold(row, col, FF_AVOID_RUN);
1725 /* Extract cycle index */
1728 /* Check for walls */
1729 if (see_wall(cycle[i+1], p_ptr->y, p_ptr->x))
1731 find_breakleft = TRUE;
1734 else if (see_wall(cycle[i+1], row, col))
1736 find_breakleft = TRUE;
1740 /* Check for walls */
1741 if (see_wall(cycle[i-1], p_ptr->y, p_ptr->x))
1743 find_breakright = TRUE;
1746 else if (see_wall(cycle[i-1], row, col))
1748 find_breakright = TRUE;
1752 /* Looking for a break */
1753 if (find_breakleft && find_breakright)
1755 /* Not looking for open area */
1756 find_openarea = FALSE;
1758 /* Hack -- allow angled corridor entry */
1761 if (deepleft && !deepright)
1763 find_prevdir = cycle[i - 1];
1765 else if (deepright && !deepleft)
1767 find_prevdir = cycle[i + 1];
1771 /* Hack -- allow blunt corridor entry */
1772 else if (see_wall(cycle[i], row, col))
1774 if (shortleft && !shortright)
1776 find_prevdir = cycle[i - 2];
1778 else if (shortright && !shortleft)
1780 find_prevdir = cycle[i + 2];
1788 * @brief ダッシュ移動が継続できるかどうかの判定 /
1789 * Update the current "run" path
1791 * ダッシュ移動が継続できるならばTRUEを返す。
1792 * Return TRUE if the running should be stopped
1794 static bool run_test(void)
1796 int prev_dir, new_dir, check_dir = 0;
1799 int option = 0, option2 = 0;
1802 feature_type *f_ptr;
1804 /* Where we came from */
1805 prev_dir = find_prevdir;
1808 /* Range of newly adjacent grids */
1809 max = (prev_dir & 0x01) + 1;
1811 /* break run when leaving trap detected region */
1812 if ((disturb_trap_detect || alert_trap_detect)
1813 && p_ptr->dtrap && !(cave[p_ptr->y][p_ptr->x].info & CAVE_IN_DETECT))
1815 /* No duplicate warning */
1816 p_ptr->dtrap = FALSE;
1818 /* You are just on the edge */
1819 if (!(cave[p_ptr->y][p_ptr->x].info & CAVE_UNSAFE))
1821 if (alert_trap_detect)
1823 msg_print(_("* 注意:この先はトラップの感知範囲外です! *", "*Leaving trap detect region!*"));
1826 if (disturb_trap_detect)
1834 /* Look at every newly adjacent square. */
1835 for (i = -max; i <= max; i++)
1837 OBJECT_IDX this_o_idx, next_o_idx = 0;
1840 new_dir = cycle[chome[prev_dir] + i];
1843 row = p_ptr->y + ddy[new_dir];
1844 col = p_ptr->x + ddx[new_dir];
1847 c_ptr = &cave[row][col];
1849 /* Feature code (applying "mimic" field) */
1850 feat = get_feat_mimic(c_ptr);
1851 f_ptr = &f_info[feat];
1853 /* Visible monsters abort running */
1856 monster_type *m_ptr = &m_list[c_ptr->m_idx];
1858 /* Visible monster */
1859 if (m_ptr->ml) return (TRUE);
1862 /* Visible objects abort running */
1863 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
1867 /* Acquire object */
1868 o_ptr = &o_list[this_o_idx];
1870 /* Acquire next object */
1871 next_o_idx = o_ptr->next_o_idx;
1873 /* Visible object */
1874 if (o_ptr->marked & OM_FOUND) return (TRUE);
1877 /* Assume unknown */
1880 /* Check memorized grids */
1881 if (c_ptr->info & (CAVE_MARK))
1883 bool notice = have_flag(f_ptr->flags, FF_NOTICE);
1885 if (notice && have_flag(f_ptr->flags, FF_MOVE))
1888 if (find_ignore_doors && have_flag(f_ptr->flags, FF_DOOR) && have_flag(f_ptr->flags, FF_CLOSE))
1890 /* Option -- ignore */
1895 else if (find_ignore_stairs && have_flag(f_ptr->flags, FF_STAIRS))
1897 /* Option -- ignore */
1902 else if (have_flag(f_ptr->flags, FF_LAVA) && (p_ptr->immune_fire || IS_INVULN()))
1909 else if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP) &&
1910 (p_ptr->levitation || p_ptr->can_swim || (p_ptr->total_weight <= weight_limit())))
1917 /* Interesting feature */
1918 if (notice) return (TRUE);
1920 /* The grid is "visible" */
1924 /* Analyze unknown grids and floors considering mimic */
1925 if (inv || !see_wall(0, row, col))
1927 /* Looking for open area */
1933 /* The first new direction. */
1939 /* Three new directions. Stop running. */
1945 /* Two non-adjacent new directions. Stop running. */
1946 else if (option != cycle[chome[prev_dir] + i - 1])
1951 /* Two new (adjacent) directions (case 1) */
1952 else if (new_dir & 0x01)
1954 check_dir = cycle[chome[prev_dir] + i - 2];
1958 /* Two new (adjacent) directions (case 2) */
1961 check_dir = cycle[chome[prev_dir] + i + 1];
1967 /* Obstacle, while looking for open area */
1974 /* Break to the right */
1975 find_breakright = TRUE;
1980 /* Break to the left */
1981 find_breakleft = TRUE;
1987 /* Looking for open area */
1990 /* Hack -- look again */
1991 for (i = -max; i < 0; i++)
1993 /* Unknown grid or non-wall */
1994 if (!see_wall(cycle[chome[prev_dir] + i], p_ptr->y, p_ptr->x))
1996 /* Looking to break right */
1997 if (find_breakright)
2006 /* Looking to break left */
2014 /* Hack -- look again */
2015 for (i = max; i > 0; i--)
2017 /* Unknown grid or non-wall */
2018 if (!see_wall(cycle[chome[prev_dir] + i], p_ptr->y, p_ptr->x))
2020 /* Looking to break left */
2030 /* Looking to break right */
2031 if (find_breakright)
2039 /* Not looking for open area */
2051 /* Primary option */
2052 find_current = option;
2054 /* No other options */
2055 find_prevdir = option;
2058 /* Two options, examining corners */
2061 /* Primary option */
2062 find_current = option;
2064 /* Hack -- allow curving */
2065 find_prevdir = option2;
2068 /* Two options, pick one */
2071 /* Get next location */
2072 row = p_ptr->y + ddy[option];
2073 col = p_ptr->x + ddx[option];
2075 /* Don't see that it is closed off. */
2076 /* This could be a potential corner or an intersection. */
2077 if (!see_wall(option, row, col) ||
2078 !see_wall(check_dir, row, col))
2080 /* Can not see anything ahead and in the direction we */
2081 /* are turning, assume that it is a potential corner. */
2082 if (see_nothing(option, row, col) &&
2083 see_nothing(option2, row, col))
2085 find_current = option;
2086 find_prevdir = option2;
2089 /* STOP: we are next to an intersection or a room */
2096 /* This corner is seen to be enclosed; we cut the corner. */
2099 find_current = option2;
2100 find_prevdir = option2;
2103 /* This corner is seen to be enclosed, and we */
2104 /* deliberately go the long way. */
2107 find_current = option;
2108 find_prevdir = option2;
2113 /* About to hit a known wall, stop */
2114 if (see_wall(find_current, p_ptr->y, p_ptr->x))
2126 * @brief 継続的なダッシュ処理 /
2127 * Take one step along the current "run" path
2128 * @param dir 移動を試みる方向ID
2131 void run_step(DIRECTION dir)
2136 /* Ignore AVOID_RUN on a first step */
2137 ignore_avoid_run = TRUE;
2139 /* Hack -- do not start silly run */
2140 if (see_wall(dir, p_ptr->y, p_ptr->x))
2142 sound(SOUND_HITWALL);
2144 msg_print(_("その方向には走れません。", "You cannot run in that direction."));
2169 /* Decrease the run counter */
2170 if (--running <= 0) return;
2173 p_ptr->energy_use = 100;
2175 /* Move the player, using the "pickup" flag */
2176 #ifdef ALLOW_EASY_DISARM /* TNB */
2178 move_player(find_current, FALSE, FALSE);
2180 #else /* ALLOW_EASY_DISARM -- TNB */
2182 move_player(find_current, always_pickup, FALSE);
2184 #endif /* ALLOW_EASY_DISARM -- TNB */
2186 if (player_bold(p_ptr->run_py, p_ptr->run_px))
2198 * @brief トラベル機能の判定処理 /
2199 * Test for traveling
2200 * @param prev_dir 前回移動を行った元の方角ID
2203 static DIRECTION travel_test(DIRECTION prev_dir)
2207 const cave_type *c_ptr;
2210 /* Cannot travel when blind */
2211 if (p_ptr->blind || no_lite())
2213 msg_print(_("目が見えない!", "You cannot see!"));
2217 /* break run when leaving trap detected region */
2218 if ((disturb_trap_detect || alert_trap_detect)
2219 && p_ptr->dtrap && !(cave[p_ptr->y][p_ptr->x].info & CAVE_IN_DETECT))
2221 /* No duplicate warning */
2222 p_ptr->dtrap = FALSE;
2224 /* You are just on the edge */
2225 if (!(cave[p_ptr->y][p_ptr->x].info & CAVE_UNSAFE))
2227 if (alert_trap_detect)
2229 msg_print(_("* 注意:この先はトラップの感知範囲外です! *", "*Leaving trap detect region!*"));
2232 if (disturb_trap_detect)
2240 /* Range of newly adjacent grids */
2241 max = (prev_dir & 0x01) + 1;
2243 /* Look at every newly adjacent square. */
2244 for (i = -max; i <= max; i++)
2247 DIRECTION dir = cycle[chome[prev_dir] + i];
2250 int row = p_ptr->y + ddy[dir];
2251 int col = p_ptr->x + ddx[dir];
2254 c_ptr = &cave[row][col];
2256 /* Visible monsters abort running */
2259 monster_type *m_ptr = &m_list[c_ptr->m_idx];
2261 /* Visible monster */
2262 if (m_ptr->ml) return (0);
2267 /* Travel cost of current grid */
2268 cost = travel.cost[p_ptr->y][p_ptr->x];
2270 /* Determine travel direction */
2271 for (i = 0; i < 8; ++ i) {
2272 int dir_cost = travel.cost[p_ptr->y+ddy_ddd[i]][p_ptr->x+ddx_ddd[i]];
2274 if (dir_cost < cost)
2281 if (!new_dir) return (0);
2283 /* Access newly move grid */
2284 c_ptr = &cave[p_ptr->y+ddy[new_dir]][p_ptr->x+ddx[new_dir]];
2286 /* Close door abort traveling */
2287 if (!easy_open && is_closed_door(c_ptr->feat)) return (0);
2289 /* Visible and unignorable trap abort tarveling */
2290 if (!c_ptr->mimic && !trap_can_be_ignored(c_ptr->feat)) return (0);
2298 * @brief トラベル機能の実装 /
2302 void travel_step(void)
2304 /* Get travel direction */
2305 travel.dir = travel_test(travel.dir);
2310 if (travel.run == 255)
2312 msg_print(_("道筋が見つかりません!", "No route is found!"));
2313 travel.y = travel.x = 0;
2319 p_ptr->energy_use = 100;
2321 move_player(travel.dir, always_pickup, FALSE);
2323 if ((p_ptr->y == travel.y) && (p_ptr->x == travel.x))
2326 travel.y = travel.x = 0;
2328 else if (travel.run > 0)
2332 Term_xtra(TERM_XTRA_DELAY, delay_factor);