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.)
144 #define MAX_VAMPIRIC_DRAIN 50 /*!< 吸血処理の最大回復HP */
148 * @brief プレイヤーからモンスターへの射撃命中判定 /
149 * Determine if the player "hits" a monster (normal combat).
150 * @param chance 基本命中値
151 * @param m_ptr モンスターの構造体参照ポインタ
152 * @param vis 目標を視界に捕らえているならばTRUEを指定
153 * @param o_name メッセージ表示時のモンスター名
154 * @return 命中と判定された場合TRUEを返す
155 * @note Always miss 5%, always hit 5%, otherwise random.
157 bool test_hit_fire(int chance, monster_type *m_ptr, int vis, char* o_name)
160 monster_race *r_ptr = &r_info[m_ptr->r_idx];
163 if(m_ptr->r_idx == MON_GOEMON && !MON_CSLEEP(m_ptr)) ac *= 3;
165 /* Percentile dice */
168 /* Snipers with high-concentration reduce instant miss percentage.*/
171 /* Hack -- Instant miss or hit */
172 if (k < 10) return (k < 5);
174 if (p_ptr->pseikaku == SEIKAKU_NAMAKE)
175 if (one_in_(20)) return (FALSE);
178 if (chance <= 0) return (FALSE);
180 /* Invisible monsters are harder to hit */
181 if (!vis) chance = (chance + 1) / 2;
183 /* Power competes against armor */
184 if (randint0(chance) < (ac * 3 / 4))
186 if(m_ptr->r_idx == MON_GOEMON && !MON_CSLEEP(m_ptr))
190 /* Extract monster name */
191 monster_desc(m_name, m_ptr, 0);
192 msg_format(_("%sは%sを斬り捨てた!", "%s cuts down %s!"), m_name, o_name);
204 * @brief プレイヤーからモンスターへの打撃命中判定 /
205 * Determine if the player "hits" a monster (normal combat).
206 * @param chance 基本命中値
208 * @param vis 目標を視界に捕らえているならばTRUEを指定
209 * @return 命中と判定された場合TRUEを返す
210 * @note Always miss 5%, always hit 5%, otherwise random.
212 bool test_hit_norm(int chance, int ac, int vis)
216 /* Percentile dice */
219 /* Hack -- Instant miss or hit */
220 if (k < 10) return (k < 5);
222 if (p_ptr->pseikaku == SEIKAKU_NAMAKE)
223 if (one_in_(20)) return (FALSE);
225 /* Wimpy attack never hits */
226 if (chance <= 0) return (FALSE);
228 /* Penalize invisible targets */
229 if (!vis) chance = (chance + 1) / 2;
231 /* Power must defeat armor */
232 if (randint0(chance) < (ac * 3 / 4)) return (FALSE);
241 * @brief プレイヤーからモンスターへの射撃クリティカル判定 /
242 * Critical hits (from objects thrown by player) Factor in item weight, total plusses, and player level.
243 * @param weight 矢弾の重量
244 * @param plus_ammo 矢弾の命中修正
245 * @param plus_bow 弓の命中修正
246 * @param dam 現在算出中のダメージ値
247 * @return クリティカル修正が入ったダメージ値
249 s16b critical_shot(int weight, int plus_ammo, int plus_bow, int dam)
252 object_type *j_ptr = &inventory[INVEN_BOW];
254 /* Extract "shot" power */
255 i = p_ptr->to_h_b + plus_ammo;
257 if (p_ptr->tval_ammo == TV_BOLT)
258 i = (p_ptr->skill_thb + (p_ptr->weapon_exp[0][j_ptr->sval] / 400 + i) * BTH_PLUS_ADJ);
260 i = (p_ptr->skill_thb + ((p_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + i) * BTH_PLUS_ADJ);
263 /* Snipers can shot more critically with crossbows */
264 if (p_ptr->concent) i += ((i * p_ptr->concent) / 5);
265 if ((p_ptr->pclass == CLASS_SNIPER) && (p_ptr->tval_ammo == TV_BOLT)) i *= 2;
267 /* Good bow makes more critical */
268 i += plus_bow * 8 * (p_ptr->concent ? p_ptr->concent + 5 : 5);
271 if (randint1(10000) <= i)
273 k = weight * randint1(500);
277 msg_print(_("手ごたえがあった!", "It was a good hit!"));
282 msg_print(_("かなりの手ごたえがあった!", "It was a great hit!"));
287 msg_print(_("会心の一撃だ!", "It was a superb hit!"));
298 * @brief プレイヤーからモンスターへの打撃クリティカル判定 /
299 * Critical hits (by player) Factor in weapon weight, total plusses, player melee bonus
300 * @param weight 矢弾の重量
301 * @param plus 武器の命中修正
302 * @param dam 現在算出中のダメージ値
303 * @param meichuu 打撃の基本命中力
304 * @param mode オプションフラグ
305 * @return クリティカル修正が入ったダメージ値
307 s16b critical_norm(int weight, int plus, int dam, s16b meichuu, int mode)
311 /* Extract "blow" power */
312 i = (weight + (meichuu * 3 + plus * 5) + p_ptr->skill_thn);
315 if ((randint1((p_ptr->pclass == CLASS_NINJA) ? 4444 : 5000) <= i) || (mode == HISSATSU_MAJIN) || (mode == HISSATSU_3DAN))
317 k = weight + randint1(650);
318 if ((mode == HISSATSU_MAJIN) || (mode == HISSATSU_3DAN)) k+= randint1(650);
322 msg_print(_("手ごたえがあった!", "It was a good hit!"));
328 msg_print(_("かなりの手ごたえがあった!", "It was a great hit!"));
333 msg_print(_("会心の一撃だ!", "It was a superb hit!"));
338 msg_print(_("最高の会心の一撃だ!", "It was a *GREAT* hit!"));
343 msg_print(_("比類なき最高の会心の一撃だ!", "It was a *SUPERB* hit!"));
344 dam = ((7 * dam) / 2) + 25;
354 * @brief プレイヤー攻撃の種族スレイング倍率計算
355 * @param mult 算出前の基本倍率(/10倍)
356 * @param flgs スレイフラグ配列
357 * @param m_ptr 目標モンスターの構造体参照ポインタ
358 * @return スレイング加味後の倍率(/10倍)
360 static int mult_slaying(int mult, const u32b* flgs, const monster_type* m_ptr)
362 static const struct slay_table_t {
364 u32b affect_race_flag;
367 size_t r_flag_offset;
369 #define OFFSET(X) offsetof(monster_race, X)
370 {TR_SLAY_ANIMAL, RF3_ANIMAL, 25, OFFSET(flags3), OFFSET(r_flags3)},
371 {TR_KILL_ANIMAL, RF3_ANIMAL, 40, OFFSET(flags3), OFFSET(r_flags3)},
372 {TR_SLAY_EVIL, RF3_EVIL, 20, OFFSET(flags3), OFFSET(r_flags3)},
373 {TR_KILL_EVIL, RF3_EVIL, 35, OFFSET(flags3), OFFSET(r_flags3)},
374 {TR_SLAY_GOOD, RF3_GOOD, 20, OFFSET(flags3), OFFSET(r_flags3)},
375 {TR_KILL_GOOD, RF3_GOOD, 35, OFFSET(flags3), OFFSET(r_flags3)},
376 {TR_SLAY_HUMAN, RF2_HUMAN, 25, OFFSET(flags2), OFFSET(r_flags2)},
377 {TR_KILL_HUMAN, RF2_HUMAN, 40, OFFSET(flags2), OFFSET(r_flags2)},
378 {TR_SLAY_UNDEAD, RF3_UNDEAD, 30, OFFSET(flags3), OFFSET(r_flags3)},
379 {TR_KILL_UNDEAD, RF3_UNDEAD, 50, OFFSET(flags3), OFFSET(r_flags3)},
380 {TR_SLAY_DEMON, RF3_DEMON, 30, OFFSET(flags3), OFFSET(r_flags3)},
381 {TR_KILL_DEMON, RF3_DEMON, 50, OFFSET(flags3), OFFSET(r_flags3)},
382 {TR_SLAY_ORC, RF3_ORC, 30, OFFSET(flags3), OFFSET(r_flags3)},
383 {TR_KILL_ORC, RF3_ORC, 50, OFFSET(flags3), OFFSET(r_flags3)},
384 {TR_SLAY_TROLL, RF3_TROLL, 30, OFFSET(flags3), OFFSET(r_flags3)},
385 {TR_KILL_TROLL, RF3_TROLL, 50, OFFSET(flags3), OFFSET(r_flags3)},
386 {TR_SLAY_GIANT, RF3_GIANT, 30, OFFSET(flags3), OFFSET(r_flags3)},
387 {TR_KILL_GIANT, RF3_GIANT, 50, OFFSET(flags3), OFFSET(r_flags3)},
388 {TR_SLAY_DRAGON, RF3_DRAGON, 30, OFFSET(flags3), OFFSET(r_flags3)},
389 {TR_KILL_DRAGON, RF3_DRAGON, 50, OFFSET(flags3), OFFSET(r_flags3)},
393 monster_race* r_ptr = &r_info[m_ptr->r_idx];
395 for (i = 0; i < sizeof(slay_table) / sizeof(slay_table[0]); ++ i)
397 const struct slay_table_t* p = &slay_table[i];
399 if ((have_flag(flgs, p->slay_flag)) &&
400 (atoffset(u32b, r_ptr, p->flag_offset) & p->affect_race_flag))
402 if (is_original_ap_and_seen(m_ptr))
404 atoffset(u32b, r_ptr, p->r_flag_offset) |= p->affect_race_flag;
407 mult = MAX(mult, p->slay_mult);
415 * @brief プレイヤー攻撃の属性スレイング倍率計算
416 * @param mult 算出前の基本倍率(/10倍)
417 * @param flgs スレイフラグ配列
418 * @param m_ptr 目標モンスターの構造体参照ポインタ
419 * @return スレイング加味後の倍率(/10倍)
421 static int mult_brand(int mult, const u32b* flgs, const monster_type* m_ptr)
423 static const struct brand_table_t {
428 {TR_BRAND_ACID, RFR_EFF_IM_ACID_MASK, 0U },
429 {TR_BRAND_ELEC, RFR_EFF_IM_ELEC_MASK, 0U },
430 {TR_BRAND_FIRE, RFR_EFF_IM_FIRE_MASK, RF3_HURT_FIRE},
431 {TR_BRAND_COLD, RFR_EFF_IM_COLD_MASK, RF3_HURT_COLD},
432 {TR_BRAND_POIS, RFR_EFF_IM_POIS_MASK, 0U },
435 monster_race* r_ptr = &r_info[m_ptr->r_idx];
437 for (i = 0; i < sizeof(brand_table) / sizeof(brand_table[0]); ++ i)
439 const struct brand_table_t* p = &brand_table[i];
441 if (have_flag(flgs, p->brand_flag))
443 /* Notice immunity */
444 if (r_ptr->flagsr & p->resist_mask)
446 if (is_original_ap_and_seen(m_ptr))
448 r_ptr->r_flagsr |= (r_ptr->flagsr & p->resist_mask);
452 /* Otherwise, take the damage */
453 else if (r_ptr->flags3 & p->hurt_flag)
455 if (is_original_ap_and_seen(m_ptr))
457 r_ptr->r_flags3 |= p->hurt_flag;
460 mult = MAX(mult, 50);
464 mult = MAX(mult, 25);
473 * @brief ダメージにスレイ要素を加える総合処理ルーチン /
474 * Extract the "total damage" from a given object hitting a given monster.
475 * @param o_ptr 使用武器オブジェクトの構造体参照ポインタ
476 * @param tdam 現在算出途中のダメージ値
477 * @param m_ptr 目標モンスターの構造体参照ポインタ
479 * @param thrown 射撃処理ならばTRUEを指定する
480 * @return 総合的なスレイを加味したダメージ値
482 * Note that "flasks of oil" do NOT do fire damage, although they\n
483 * certainly could be made to do so. XXX XXX\n
485 * Note that most brands and slays are x3, except Slay Animal (x2),\n
486 * Slay Evil (x2), and Kill dragon (x5).\n
488 s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr, int mode, bool thrown)
492 u32b flgs[TR_FLAG_SIZE];
494 /* Extract the flags */
495 object_flags(o_ptr, flgs);
496 torch_flags(o_ptr, flgs); /* torches has secret flags */
501 if (p_ptr->special_attack & (ATTACK_ACID)) add_flag(flgs, TR_BRAND_ACID);
502 if (p_ptr->special_attack & (ATTACK_COLD)) add_flag(flgs, TR_BRAND_COLD);
503 if (p_ptr->special_attack & (ATTACK_ELEC)) add_flag(flgs, TR_BRAND_ELEC);
504 if (p_ptr->special_attack & (ATTACK_FIRE)) add_flag(flgs, TR_BRAND_FIRE);
505 if (p_ptr->special_attack & (ATTACK_POIS)) add_flag(flgs, TR_BRAND_POIS);
508 /* Hex - Slay Good (Runesword) */
509 if (hex_spelling(HEX_RUNESWORD)) add_flag(flgs, TR_SLAY_GOOD);
511 /* Some "weapons" and "ammo" do extra damage */
524 mult = mult_slaying(mult, flgs, m_ptr);
526 /* Elemental Brand */
527 mult = mult_brand(mult, flgs, m_ptr);
530 if (p_ptr->pclass == CLASS_SAMURAI)
532 mult = mult_hissatsu(mult, flgs, m_ptr, mode);
536 if ((p_ptr->pclass != CLASS_SAMURAI) && (have_flag(flgs, TR_FORCE_WEAPON)) && (p_ptr->csp > (o_ptr->dd * o_ptr->ds / 5)))
538 p_ptr->csp -= (1+(o_ptr->dd * o_ptr->ds / 5));
539 p_ptr->redraw |= (PR_MANA);
540 mult = mult * 3 / 2 + 20;
543 /* Hack -- The Nothung cause special damage to Fafner */
544 if ((o_ptr->name1 == ART_NOTHUNG) && (m_ptr->r_idx == MON_FAFNER))
549 if (mult > 150) mult = 150;
551 /* Return the total damage */
552 return (tdam * mult / 10);
557 * @brief 地形やその上のアイテムの隠された要素を明かす /
558 * Search for hidden things
559 * @param y 対象となるマスのY座標
560 * @param x 対象となるマスのX座標
563 static void discover_hidden_things(int y, int x)
565 s16b this_o_idx, next_o_idx = 0;
569 /* Access the grid */
573 if (c_ptr->mimic && is_trap(c_ptr->feat))
579 msg_print(_("トラップを発見した。", "You have found a trap."));
586 if (is_hidden_door(c_ptr))
589 msg_print(_("隠しドアを発見した。", "You have found a secret door."));
598 /* Scan all objects in the grid */
599 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
604 o_ptr = &o_list[this_o_idx];
606 /* Acquire next object */
607 next_o_idx = o_ptr->next_o_idx;
609 /* Skip non-chests */
610 if (o_ptr->tval != TV_CHEST) continue;
612 /* Skip non-trapped chests */
613 if (!chest_traps[o_ptr->pval]) continue;
616 if (!object_is_known(o_ptr))
619 msg_print(_("箱に仕掛けられたトラップを発見した!", "You have discovered a trap on the chest!"));
631 * @brief プレイヤーの探索処理判定
638 /* Start with base search ability */
639 chance = p_ptr->skill_srh;
641 /* Penalize various conditions */
642 if (p_ptr->blind || no_lite()) chance = chance / 10;
643 if (p_ptr->confused || p_ptr->image) chance = chance / 10;
645 /* Search the nearby grids, which are always in bounds */
646 for (i = 0; i < 9; ++ i)
648 /* Sometimes, notice things */
649 if (randint0(100) < chance)
651 discover_hidden_things(py + ddy_ddd[i], px + ddx_ddd[i]);
658 * @brief プレイヤーがオブジェクトを拾った際のメッセージ表示処理 /
659 * Helper routine for py_pickup() and py_pickup_floor().
660 * @param o_idx 取得したオブジェクトの参照ID
663 * アイテムを拾った際に「2つのケーキを持っている」\n
664 * "You have two cakes." とアイテムを拾った後の合計のみの表示がオリジナル\n
666 * あるという指摘をうけたので、「~を拾った、~を持っている」という表示\n
668 * Add the given dungeon object to the character's inventory.\n
669 * Delete the object afterwards.\n
671 void py_pickup_aux(int o_idx)
676 char o_name[MAX_NLEN];
677 char old_name[MAX_NLEN];
681 char o_name[MAX_NLEN];
686 o_ptr = &o_list[o_idx];
689 /* Describe the object */
690 object_desc(old_name, o_ptr, OD_NAME_ONLY);
691 object_desc_kosuu(kazu_str, o_ptr);
692 hirottakazu = o_ptr->number;
694 /* Carry the object */
695 slot = inven_carry(o_ptr);
697 /* Get the object again */
698 o_ptr = &inventory[slot];
700 /* Delete the object */
701 delete_object_idx(o_idx);
703 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)
705 bool old_known = identify_item(o_ptr);
707 /* Auto-inscription/destroy */
708 autopick_alter_item(slot, (bool)(destroy_identify && !old_known));
710 /* If it is destroyed, don't pick it up */
711 if (o_ptr->marked & OM_AUTODESTROY) return;
714 /* Describe the object */
715 object_desc(o_name, o_ptr, 0);
719 if ((o_ptr->name1 == ART_CRIMSON) && (p_ptr->pseikaku == SEIKAKU_COMBAT))
721 msg_format("こうして、%sは『クリムゾン』を手に入れた。", player_name);
722 msg_print("しかし今、『混沌のサーペント』の放ったモンスターが、");
723 msg_format("%sに襲いかかる...", player_name);
729 msg_format("%s(%c)を持っている。",o_name, index_to_label(slot));
733 if (o_ptr->number > hirottakazu) {
734 msg_format("%s拾って、%s(%c)を持っている。",
735 kazu_str, o_name, index_to_label(slot));
737 msg_format("%s(%c)を拾った。", o_name, index_to_label(slot));
741 strcpy(record_o_name, old_name);
743 msg_format("You have %s (%c).", o_name, index_to_label(slot));
744 strcpy(record_o_name, o_name);
749 check_find_art_quest_completion(o_ptr);
754 * @brief プレイヤーがオブジェクト上に乗った際の表示処理
755 * @param pickup 自動拾い処理を行うならばTRUEとする
758 * Player "wants" to pick up an object or gold.
759 * Note that we ONLY handle things that can be picked up.
760 * See "move_player()" for handling of other things.
762 void carry(bool pickup)
764 cave_type *c_ptr = &cave[py][px];
766 s16b this_o_idx, next_o_idx = 0;
768 char o_name[MAX_NLEN];
770 /* Recenter the map around the player */
774 p_ptr->update |= (PU_MONSTERS);
777 p_ptr->redraw |= (PR_MAP);
780 p_ptr->window |= (PW_OVERHEAD);
785 /* Automatically pickup/destroy/inscribe items */
786 autopick_pickup_items(c_ptr);
789 #ifdef ALLOW_EASY_FLOOR
793 py_pickup_floor(pickup);
797 #endif /* ALLOW_EASY_FLOOR */
799 /* Scan the pile of objects */
800 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
805 o_ptr = &o_list[this_o_idx];
807 #ifdef ALLOW_EASY_SENSE /* TNB */
809 /* Option: Make item sensing easy */
812 /* Sense the object */
813 (void)sense_object(o_ptr);
816 #endif /* ALLOW_EASY_SENSE -- TNB */
818 /* Describe the object */
819 object_desc(o_name, o_ptr, 0);
821 /* Acquire next object */
822 next_o_idx = o_ptr->next_o_idx;
824 /* Hack -- disturb */
828 if (o_ptr->tval == TV_GOLD)
830 int value = (long)o_ptr->pval;
832 /* Delete the gold */
833 delete_object_idx(this_o_idx);
837 msg_format(" $%ld の価値がある%sを見つけた。",
838 (long)value, o_name);
840 msg_format("You collect %ld gold pieces worth of %s.",
841 (long)value, o_name);
847 /* Collect the gold */
851 p_ptr->redraw |= (PR_GOLD);
854 p_ptr->window |= (PW_PLAYER);
857 /* Pick up objects */
860 /* Hack - some objects were handled in autopick_pickup_items(). */
861 if (o_ptr->marked & OM_NOMSG)
863 /* Clear the flag. */
864 o_ptr->marked &= ~OM_NOMSG;
866 /* Describe the object */
869 msg_format(_("%sがある。", "You see %s."), o_name);
872 /* Note that the pack is too full */
873 else if (!inven_carry_okay(o_ptr))
875 msg_format(_("ザックには%sを入れる隙間がない。", "You have no room for %s."), o_name);
878 /* Pick up the item (if requested and allowed) */
883 /* Hack -- query every item */
884 if (carry_query_flag)
886 char out_val[MAX_NLEN+20];
887 sprintf(out_val, _("%sを拾いますか? ", "Pick up %s? "), o_name);
888 okay = get_check(out_val);
891 /* Attempt to pick up an object. */
894 /* Pick up the object */
895 py_pickup_aux(this_o_idx);
904 * @brief プレイヤーへのトラップ命中判定 /
905 * Determine if a trap affects the player.
906 * @param power 基本回避難度
907 * @return トラップが命中した場合TRUEを返す。
909 * Always miss 5% of the time, Always hit 5% of the time.
910 * Otherwise, match trap power against player armor.
912 static int check_hit(int power)
916 /* Percentile dice */
919 /* Hack -- 5% hit, 5% miss */
920 if (k < 10) return (k < 5);
922 if (p_ptr->pseikaku == SEIKAKU_NAMAKE)
923 if (one_in_(20)) return (TRUE);
925 /* Paranoia -- No power */
926 if (power <= 0) return (FALSE);
929 ac = p_ptr->ac + p_ptr->to_a;
931 /* Power competes against Armor */
932 if (randint1(power) > ((ac * 3) / 4)) return (TRUE);
940 * @brief 落とし穴系トラップの判定とプレイヤーの被害処理
941 * @param trap_feat_type トラップの種別ID
944 static void hit_trap_pit(int trap_feat_type)
948 cptr spike_name = "";
950 switch (trap_feat_type)
953 trap_name = _("落とし穴", "a pit trap");
955 case TRAP_SPIKED_PIT:
956 trap_name = _("スパイクが敷かれた落とし穴", "a spiked pit");
957 spike_name = _("スパイク", "spikes");
959 case TRAP_POISON_PIT:
960 trap_name = _("スパイクが敷かれた落とし穴", "a spiked pit");
961 spike_name = _("毒を塗られたスパイク", "poisonous spikes");
967 if (p_ptr->levitation)
969 msg_format(_("%sを飛び越えた。", "You fly over %s."), trap_name);
973 msg_format(_("%sに落ちてしまった!", "You have fallen into %s!"), trap_name);
978 /* Extra spike damage */
979 if ((trap_feat_type == TRAP_SPIKED_PIT || trap_feat_type == TRAP_POISON_PIT) &&
982 msg_format(_("%sが刺さった!", "You are impaled on %s!"), spike_name);
985 (void)set_cut(p_ptr->cut + randint1(dam));
987 if (trap_feat_type == TRAP_POISON_PIT) {
988 if (p_ptr->resist_pois || IS_OPPOSE_POIS())
990 msg_print(_("しかし毒の影響はなかった!", "The poison does not affect you!"));
995 (void)set_poisoned(p_ptr->poisoned + randint1(dam));
1000 /* Take the damage */
1001 take_hit(DAMAGE_NOESCAPE, dam, trap_name, -1);
1005 * @brief ダーツ系トラップ(通常ダメージ)の判定とプレイヤーの被害処理
1006 * @return ダーツが命中した場合TRUEを返す
1008 static bool hit_trap_dart(void)
1014 msg_print(_("小さなダーツが飛んできて刺さった!", "A small dart hits you!"));
1016 take_hit(DAMAGE_ATTACK, damroll(1, 4), _("ダーツの罠", "a dart trap"), -1);
1018 if (!CHECK_MULTISHADOW()) hit = TRUE;
1022 msg_print(_("小さなダーツが飛んできた!が、運良く当たらなかった。", "A small dart barely misses you."));
1029 * @brief ダーツ系トラップ(通常ダメージ+能力値減少)の判定とプレイヤーの被害処理
1030 * @param stat 低下する能力値ID
1033 static void hit_trap_lose_stat(int stat)
1035 if (hit_trap_dart())
1042 * @brief ダーツ系トラップ(通常ダメージ+減速)の判定とプレイヤーの被害処理
1045 static void hit_trap_slow(void)
1047 if (hit_trap_dart())
1049 set_slow(p_ptr->slow + randint0(20) + 20, FALSE);
1054 * @brief ダーツ系トラップ(通常ダメージ+状態異常)の判定とプレイヤーの被害処理
1055 * @param trap_message メッセージの補完文字列
1056 * @param resist 状態異常に抵抗する判定が出たならTRUE
1057 * @param set_status 状態異常を指定する関数ポインタ
1058 * @param turn 状態異常の追加ターン量
1061 static void hit_trap_set_abnormal_status(cptr trap_message, bool resist, bool (*set_status)(int turn), int turn)
1063 msg_print(trap_message);
1072 * @brief プレイヤーへのトラップ作動処理メインルーチン /
1073 * Handle player hitting a real trap
1074 * @param break_trap 作動後のトラップ破壊が確定しているならばTRUE
1077 static void hit_trap(bool break_trap)
1082 /* Get the cave grid */
1083 cave_type *c_ptr = &cave[y][x];
1084 feature_type *f_ptr = &f_info[c_ptr->feat];
1085 int trap_feat_type = have_flag(f_ptr->flags, FF_TRAP) ? f_ptr->subtype : NOT_TRAP;
1086 cptr name = _("トラップ", "a trap");
1088 /* Disturb the player */
1091 cave_alter_feat(y, x, FF_HIT_TRAP);
1093 /* Analyze XXX XXX XXX */
1094 switch (trap_feat_type)
1098 if (p_ptr->levitation)
1100 msg_print(_("落とし戸を飛び越えた。", "You fly over a trap door."));
1104 msg_print(_("落とし戸に落ちた!", "You have fallen through a trap door!"));
1105 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1106 msg_print(_("くっそ~!", ""));
1109 dam = damroll(2, 8);
1110 name = _("落とし戸", "a trap door");
1112 take_hit(DAMAGE_NOESCAPE, dam, name, -1);
1114 /* Still alive and autosave enabled */
1115 if (autosave_l && (p_ptr->chp >= 0))
1116 do_cmd_save_game(TRUE);
1118 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("落とし戸に落ちた", "You have fallen through a trap door!"));
1119 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
1122 p_ptr->leaving = TRUE;
1128 case TRAP_SPIKED_PIT:
1129 case TRAP_POISON_PIT:
1131 hit_trap_pit(trap_feat_type);
1137 msg_print(_("何かがピカッと光った!", "There is a flash of shimmering light!"));
1138 num = 2 + randint1(3);
1139 for (i = 0; i < num; i++)
1141 (void)summon_specific(0, y, x, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
1144 if (dun_level > randint1(100)) /* No nasty effect for low levels */
1146 bool stop_ty = FALSE;
1151 stop_ty = activate_ty_curse(stop_ty, &count);
1160 msg_print(_("テレポート・トラップにひっかかった!", "You hit a teleport trap!"));
1161 teleport_player(100, TELEPORT_PASSIVE);
1167 msg_print(_("炎に包まれた!", "You are enveloped in flames!"));
1168 dam = damroll(4, 6);
1169 (void)fire_dam(dam, _("炎のトラップ", "a fire trap"), -1, FALSE);
1175 msg_print(_("酸が吹きかけられた!", "You are splashed with acid!"));
1176 dam = damroll(4, 6);
1177 (void)acid_dam(dam, _("酸のトラップ", "an acid trap"), -1, FALSE);
1189 hit_trap_lose_stat(A_STR);
1195 hit_trap_lose_stat(A_DEX);
1201 hit_trap_lose_stat(A_CON);
1207 hit_trap_set_abnormal_status(
1208 _("黒いガスに包み込まれた!", "A black gas surrounds you!"),
1209 p_ptr->resist_blind,
1210 set_blind, p_ptr->blind + randint0(50) + 25);
1216 hit_trap_set_abnormal_status(
1217 _("きらめくガスに包み込まれた!", "A gas of scintillating colors surrounds you!"),
1219 set_confused, p_ptr->confused + randint0(20) + 10);
1225 hit_trap_set_abnormal_status(
1226 _("刺激的な緑色のガスに包み込まれた!", "A pungent green gas surrounds you!"),
1227 p_ptr->resist_pois || IS_OPPOSE_POIS(),
1228 set_poisoned, p_ptr->poisoned + randint0(20) + 10);
1234 msg_print(_("奇妙な白い霧に包まれた!", "A strange white mist surrounds you!"));
1235 if (!p_ptr->free_act)
1237 msg_print(_("あなたは眠りに就いた。", "You fall asleep."));
1239 if (ironman_nightmare)
1241 msg_print(_("身の毛もよだつ光景が頭に浮かんだ。", "A horrible vision enters your mind."));
1243 /* Pick a nightmare */
1244 get_mon_num_prep(get_nightmare, NULL);
1246 /* Have some nightmares */
1247 have_nightmare(get_mon_num(MAX_DEPTH));
1249 /* Remove the monster restriction */
1250 get_mon_num_prep(NULL, NULL);
1252 (void)set_paralyzed(p_ptr->paralyzed + randint0(10) + 5);
1259 msg_print(_("まばゆい閃光が走った!", "There is a bright flash of light!"));
1260 /* Make some new traps */
1261 project(0, 1, y, x, 0, GF_MAKE_TRAP, PROJECT_HIDE | PROJECT_JUMP | PROJECT_GRID, -1);
1268 msg_print(_("けたたましい音が鳴り響いた!", "An alarm sounds!"));
1270 aggravate_monsters(0);
1277 msg_print(_("大音響と共にまわりの壁が崩れた!", "Suddenly, surrounding walls are opened!"));
1278 (void)project(0, 3, y, x, 0, GF_DISINTEGRATE, PROJECT_GRID | PROJECT_HIDE, -1);
1279 (void)project(0, 3, y, x - 4, 0, GF_DISINTEGRATE, PROJECT_GRID | PROJECT_HIDE, -1);
1280 (void)project(0, 3, y, x + 4, 0, GF_DISINTEGRATE, PROJECT_GRID | PROJECT_HIDE, -1);
1281 aggravate_monsters(0);
1286 case TRAP_ARMAGEDDON:
1288 static int levs[10] = {0, 0, 20, 10, 5, 3, 2, 1, 1, 1};
1289 int evil_idx = 0, good_idx = 0;
1292 msg_print(_("突然天界の戦争に巻き込まれた!", "Suddenly, you are surrounded by immotal beings!"));
1294 /* Summon Demons and Angels */
1295 for (lev = dun_level; lev >= 20; lev -= 1 + lev/16)
1297 num = levs[MIN(lev/10, 9)];
1298 for (i = 0; i < num; i++)
1300 int x1 = rand_spread(x, 7);
1301 int y1 = rand_spread(y, 5);
1303 /* Skip illegal grids */
1304 if (!in_bounds(y1, x1)) continue;
1306 /* Require line of projection */
1307 if (!projectable(py, px, y1, x1)) continue;
1309 if (summon_specific(0, y1, x1, lev, SUMMON_ARMAGE_EVIL, (PM_NO_PET)))
1310 evil_idx = hack_m_idx_ii;
1312 if (summon_specific(0, y1, x1, lev, SUMMON_ARMAGE_GOOD, (PM_NO_PET)))
1314 good_idx = hack_m_idx_ii;
1317 /* Let them fight each other */
1318 if (evil_idx && good_idx)
1320 monster_type *evil_ptr = &m_list[evil_idx];
1321 monster_type *good_ptr = &m_list[good_idx];
1322 evil_ptr->target_y = good_ptr->fy;
1323 evil_ptr->target_x = good_ptr->fx;
1324 good_ptr->target_y = evil_ptr->fy;
1325 good_ptr->target_x = evil_ptr->fx;
1334 msg_print(_("突然壁から水が溢れ出した!ピラニアがいる!", "Suddenly, the room is filled with water with piranhas!"));
1336 /* Water fills room */
1337 fire_ball_hide(GF_WATER_FLOW, 0, 1, 10);
1339 /* Summon Piranhas */
1340 num = 1 + dun_level/20;
1341 for (i = 0; i < num; i++)
1343 (void)summon_specific(0, y, x, dun_level, SUMMON_PIRANHAS, (PM_ALLOW_GROUP | PM_NO_PET));
1349 if (break_trap && is_trap(c_ptr->feat))
1351 cave_alter_feat(y, x, FF_DISARM);
1352 msg_print(_("トラップを粉砕した。", "You destroyed the trap."));
1358 * @brief 敵オーラによるプレイヤーのダメージ処理(補助)
1359 * @param m_ptr オーラを持つモンスターの構造体参照ポインタ
1360 * @param immune ダメージを回避できる免疫フラグ
1361 * @param flags_offset オーラフラグ配列の参照オフセット
1362 * @param r_flags_offset モンスターの耐性配列の参照オフセット
1363 * @param aura_flag オーラフラグ配列
1364 * @param dam_func ダメージ処理を行う関数の参照ポインタ
1365 * @param message オーラダメージを受けた際のメッセージ
1368 static void touch_zap_player_aux(monster_type *m_ptr, bool immune, int flags_offset, int r_flags_offset, u32b aura_flag,
1369 int (*dam_func)(int dam, cptr kb_str, int monspell, bool aura), cptr message)
1371 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1373 if ((atoffset(u32b, r_ptr, flags_offset) & aura_flag) && !immune)
1376 int aura_damage = damroll(1 + (r_ptr->level / 26), 1 + (r_ptr->level / 17));
1378 /* Hack -- Get the "died from" name */
1379 monster_desc(mon_name, m_ptr, MD_IGNORE_HALLU | MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
1383 dam_func(aura_damage, mon_name, -1, TRUE);
1385 if (is_original_ap_and_seen(m_ptr))
1387 atoffset(u32b, r_ptr, r_flags_offset) |= aura_flag;
1395 * @brief 敵オーラによるプレイヤーのダメージ処理(メイン)
1396 * @param m_ptr オーラを持つモンスターの構造体参照ポインタ
1399 static void touch_zap_player(monster_type *m_ptr)
1401 touch_zap_player_aux(m_ptr, p_ptr->immune_fire, offsetof(monster_race, flags2), offsetof(monster_race, r_flags2), RF2_AURA_FIRE,
1402 fire_dam, _("突然とても熱くなった!", "You are suddenly very hot!"));
1403 touch_zap_player_aux(m_ptr, p_ptr->immune_cold, offsetof(monster_race, flags3), offsetof(monster_race, r_flags3), RF3_AURA_COLD,
1404 cold_dam, _("突然とても寒くなった!", "You are suddenly very cold!"));
1405 touch_zap_player_aux(m_ptr, p_ptr->immune_elec, offsetof(monster_race, flags2), offsetof(monster_race, r_flags2), RF2_AURA_ELEC,
1406 elec_dam, _("電撃をくらった!", "You get zapped!"));
1411 * @brief プレイヤーの変異要素による打撃処理
1412 * @param m_idx 攻撃目標となったモンスターの参照ID
1413 * @param attack 変異要素による攻撃要素の種類
1414 * @param fear 攻撃を受けたモンスターが恐慌状態に陥ったかを返す参照ポインタ
1415 * @param mdeath 攻撃を受けたモンスターが死亡したかを返す参照ポインタ
1418 static void natural_attack(s16b m_idx, int attack, bool *fear, bool *mdeath)
1420 int k, bonus, chance;
1422 monster_type *m_ptr = &m_list[m_idx];
1423 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1432 case MUT2_SCOR_TAIL:
1436 atk_desc = _("尻尾", "tail");
1443 atk_desc = _("角", "horns");
1450 atk_desc = _("クチバシ", "beak");
1457 atk_desc = _("象の鼻", "trunk");
1460 case MUT2_TENTACLES:
1464 atk_desc = _("触手", "tentacles");
1468 dss = ddd = n_weight = 1;
1469 atk_desc = _("未定義の部位", "undefined body part");
1473 /* Extract monster name (or "it") */
1474 monster_desc(m_name, m_ptr, 0);
1477 /* Calculate the "attack quality" */
1478 bonus = p_ptr->to_h_m;
1479 bonus += (p_ptr->lev * 6 / 5);
1480 chance = (p_ptr->skill_thn + (bonus * BTH_PLUS_ADJ));
1483 if ((!(r_ptr->flags2 & RF2_QUANTUM) || !randint0(2)) && test_hit_norm(chance, r_ptr->ac, m_ptr->ml))
1487 msg_format(_("%sを%sで攻撃した。", "You hit %s with your %s."), m_name, atk_desc);
1489 k = damroll(ddd, dss);
1490 k = critical_norm(n_weight, bonus, k, (s16b)bonus, 0);
1492 /* Apply the player damage bonuses */
1495 /* No negative damage */
1498 /* Modify the damage */
1499 k = mon_damage_mod(m_ptr, k, FALSE);
1501 /* Complex message */
1504 msg_format(_("%d/%d のダメージを与えた。", "You do %d (out of %d) damage."), k, m_ptr->hp);
1507 /* Anger the monster */
1508 if (k > 0) anger_monster(m_ptr);
1510 /* Damage, check for fear and mdeath */
1513 case MUT2_SCOR_TAIL:
1514 project(0, 0, m_ptr->fy, m_ptr->fx, k, GF_POIS, PROJECT_KILL, -1);
1515 *mdeath = (m_ptr->r_idx == 0);
1518 *mdeath = mon_take_hit(m_idx, k, fear, NULL);
1521 *mdeath = mon_take_hit(m_idx, k, fear, NULL);
1524 *mdeath = mon_take_hit(m_idx, k, fear, NULL);
1526 case MUT2_TENTACLES:
1527 *mdeath = mon_take_hit(m_idx, k, fear, NULL);
1530 *mdeath = mon_take_hit(m_idx, k, fear, NULL);
1533 touch_zap_player(m_ptr);
1542 msg_format(_("ミス! %sにかわされた。", "You miss %s."), m_name);
1548 * @brief プレイヤーの打撃処理サブルーチン /
1549 * Player attacks a (poor, defenseless) creature -RAK-
1552 * @param fear 攻撃を受けたモンスターが恐慌状態に陥ったかを返す参照ポインタ
1553 * @param mdeath 攻撃を受けたモンスターが死亡したかを返す参照ポインタ
1554 * @param hand 攻撃を行うための武器を持つ手
1555 * @param mode 発動中の剣術ID
1558 * If no "weapon" is available, then "punch" the monster one time.
1560 static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int mode)
1562 int num = 0, k, bonus, chance, vir;
1564 cave_type *c_ptr = &cave[y][x];
1566 monster_type *m_ptr = &m_list[c_ptr->m_idx];
1567 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1569 /* Access the weapon */
1570 object_type *o_ptr = &inventory[INVEN_RARM + hand];
1574 bool success_hit = FALSE;
1575 bool backstab = FALSE;
1576 bool vorpal_cut = FALSE;
1577 int chaos_effect = 0;
1578 bool stab_fleeing = FALSE;
1579 bool fuiuchi = FALSE;
1580 bool monk_attack = FALSE;
1581 bool do_quake = FALSE;
1583 bool drain_msg = TRUE;
1584 int drain_result = 0, drain_heal = 0;
1585 bool can_drain = FALSE;
1587 int drain_left = MAX_VAMPIRIC_DRAIN;
1588 u32b flgs[TR_FLAG_SIZE]; /* A massive hack -- life-draining weapons */
1589 bool is_human = (r_ptr->d_char == 'p');
1590 bool is_lowlevel = (r_ptr->level < (p_ptr->lev - 15));
1591 bool zantetsu_mukou, e_j_mukou;
1593 switch (p_ptr->pclass)
1597 if (buki_motteruka(INVEN_RARM + hand) && !p_ptr->icky_wield[hand])
1599 int tmp = p_ptr->lev * 6 + (p_ptr->skill_stl + 10) * 4;
1600 if (p_ptr->monlite && (mode != HISSATSU_NYUSIN)) tmp /= 3;
1601 if (p_ptr->cursed & TRC_AGGRAVATE) tmp /= 2;
1602 if (r_ptr->level > (p_ptr->lev * p_ptr->lev / 20 + 10)) tmp /= 3;
1603 if (MON_CSLEEP(m_ptr) && m_ptr->ml)
1605 /* Can't backstab creatures that we can't see, right? */
1608 else if ((p_ptr->special_defense & NINJA_S_STEALTH) && (randint0(tmp) > (r_ptr->level+20)) && m_ptr->ml && !(r_ptr->flagsr & RFR_RES_ALL))
1612 else if (MON_MONFEAR(m_ptr) && m_ptr->ml)
1614 stab_fleeing = TRUE;
1620 case CLASS_FORCETRAINER:
1621 case CLASS_BERSERKER:
1622 if ((empty_hands(TRUE) & EMPTY_HAND_RARM) && !p_ptr->riding) monk_attack = TRUE;
1626 if (!o_ptr->k_idx) /* Empty hand */
1628 if ((r_ptr->level + 10) > p_ptr->lev)
1630 if (p_ptr->skill_exp[GINOU_SUDE] < s_info[p_ptr->pclass].s_max[GINOU_SUDE])
1632 if (p_ptr->skill_exp[GINOU_SUDE] < WEAPON_EXP_BEGINNER)
1633 p_ptr->skill_exp[GINOU_SUDE] += 40;
1634 else if ((p_ptr->skill_exp[GINOU_SUDE] < WEAPON_EXP_SKILLED))
1635 p_ptr->skill_exp[GINOU_SUDE] += 5;
1636 else if ((p_ptr->skill_exp[GINOU_SUDE] < WEAPON_EXP_EXPERT) && (p_ptr->lev > 19))
1637 p_ptr->skill_exp[GINOU_SUDE] += 1;
1638 else if ((p_ptr->lev > 34))
1639 if (one_in_(3)) p_ptr->skill_exp[GINOU_SUDE] += 1;
1640 p_ptr->update |= (PU_BONUS);
1644 else if (object_is_melee_weapon(o_ptr))
1646 if ((r_ptr->level + 10) > p_ptr->lev)
1648 int tval = inventory[INVEN_RARM+hand].tval - TV_WEAPON_BEGIN;
1649 int sval = inventory[INVEN_RARM+hand].sval;
1650 int now_exp = p_ptr->weapon_exp[tval][sval];
1651 if (now_exp < s_info[p_ptr->pclass].w_max[tval][sval])
1654 if (now_exp < WEAPON_EXP_BEGINNER) amount = 80;
1655 else if (now_exp < WEAPON_EXP_SKILLED) amount = 10;
1656 else if ((now_exp < WEAPON_EXP_EXPERT) && (p_ptr->lev > 19)) amount = 1;
1657 else if ((p_ptr->lev > 34) && one_in_(2)) amount = 1;
1658 p_ptr->weapon_exp[tval][sval] += amount;
1659 p_ptr->update |= (PU_BONUS);
1664 /* Disturb the monster */
1665 (void)set_monster_csleep(c_ptr->m_idx, 0);
1667 /* Extract monster name (or "it") */
1668 monster_desc(m_name, m_ptr, 0);
1670 /* Calculate the "attack quality" */
1671 bonus = p_ptr->to_h[hand] + o_ptr->to_h;
1672 chance = (p_ptr->skill_thn + (bonus * BTH_PLUS_ADJ));
1673 if (mode == HISSATSU_IAI) chance += 60;
1674 if (p_ptr->special_defense & KATA_KOUKIJIN) chance += 150;
1676 if (p_ptr->sutemi) chance = MAX(chance * 3 / 2, chance + 60);
1678 vir = virtue_number(V_VALOUR);
1681 chance += (p_ptr->virtues[vir - 1]/10);
1684 zantetsu_mukou = ((o_ptr->name1 == ART_ZANTETSU) && (r_ptr->d_char == 'j'));
1685 e_j_mukou = ((o_ptr->name1 == ART_EXCALIBUR_J) && (r_ptr->d_char == 'S'));
1687 if ((mode == HISSATSU_KYUSHO) || (mode == HISSATSU_MINEUCHI) || (mode == HISSATSU_3DAN) || (mode == HISSATSU_IAI)) num_blow = 1;
1688 else if (mode == HISSATSU_COLD) num_blow = p_ptr->num_blow[hand]+2;
1689 else num_blow = p_ptr->num_blow[hand];
1691 /* Hack -- DOKUBARI always hit once */
1692 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) num_blow = 1;
1694 /* Attack once for each legal blow */
1695 while ((num++ < num_blow) && !p_ptr->is_dead)
1697 if (((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) || (mode == HISSATSU_KYUSHO))
1701 if (p_ptr->migite && p_ptr->hidarite)
1705 if (mode == HISSATSU_3DAN)
1710 success_hit = one_in_(n);
1712 else if ((p_ptr->pclass == CLASS_NINJA) && ((backstab || fuiuchi) && !(r_ptr->flagsr & RFR_RES_ALL))) success_hit = TRUE;
1713 else success_hit = test_hit_norm(chance, r_ptr->ac, m_ptr->ml);
1715 if (mode == HISSATSU_MAJIN)
1718 success_hit = FALSE;
1724 int vorpal_chance = ((o_ptr->name1 == ART_VORPAL_BLADE) || (o_ptr->name1 == ART_CHAINSWORD)) ? 2 : 4;
1731 if (backstab) msg_format("あなたは冷酷にも眠っている無力な%sを突き刺した!", m_name);
1732 else if (fuiuchi) msg_format("不意を突いて%sに強烈な一撃を喰らわせた!", m_name);
1733 else if (stab_fleeing) msg_format("逃げる%sを背中から突き刺した!", m_name);
1734 else if (!monk_attack) msg_format("%sを攻撃した。", m_name);
1736 if (backstab) msg_format("You cruelly stab the helpless, sleeping %s!", m_name);
1737 else if (fuiuchi) msg_format("You make surprise attack, and hit %s with a powerful blow!", m_name);
1738 else if (stab_fleeing) msg_format("You backstab the fleeing %s!", m_name);
1739 else if (!monk_attack) msg_format("You hit %s.", m_name);
1742 /* Hack -- bare hands do one damage */
1745 object_flags(o_ptr, flgs);
1747 /* Select a chaotic effect (50% chance) */
1748 if ((have_flag(flgs, TR_CHAOTIC)) && one_in_(2))
1751 chg_virtue(V_CHANCE, 1);
1753 if (randint1(5) < 3)
1755 /* Vampiric (20%) */
1758 else if (one_in_(250))
1763 else if (!one_in_(10))
1765 /* Confusion (26.892%) */
1768 else if (one_in_(2))
1770 /* Teleport away (1.494%) */
1775 /* Polymorph (1.494%) */
1780 /* Vampiric drain */
1781 if ((have_flag(flgs, TR_VAMPIRIC)) || (chaos_effect == 1) || (mode == HISSATSU_DRAIN) || hex_spelling(HEX_VAMP_BLADE))
1783 /* Only drain "living" monsters */
1784 if (monster_living(r_ptr))
1790 if ((have_flag(flgs, TR_VORPAL) || hex_spelling(HEX_RUNESWORD)) && (randint1(vorpal_chance*3/2) == 1) && !zantetsu_mukou)
1792 else vorpal_cut = FALSE;
1796 int special_effect = 0, stun_effect = 0, times = 0, max_times;
1798 const martial_arts *ma_ptr = &ma_blows[0], *old_ptr = &ma_blows[0];
1799 int resist_stun = 0;
1802 if (r_ptr->flags1 & RF1_UNIQUE) resist_stun += 88;
1803 if (r_ptr->flags3 & RF3_NO_STUN) resist_stun += 66;
1804 if (r_ptr->flags3 & RF3_NO_CONF) resist_stun += 33;
1805 if (r_ptr->flags3 & RF3_NO_SLEEP) resist_stun += 33;
1806 if ((r_ptr->flags3 & RF3_UNDEAD) || (r_ptr->flags3 & RF3_NONLIVING))
1809 if (p_ptr->special_defense & KAMAE_BYAKKO)
1810 max_times = (p_ptr->lev < 3 ? 1 : p_ptr->lev / 3);
1811 else if (p_ptr->special_defense & KAMAE_SUZAKU)
1813 else if (p_ptr->special_defense & KAMAE_GENBU)
1816 max_times = (p_ptr->lev < 7 ? 1 : p_ptr->lev / 7);
1817 /* Attempt 'times' */
1818 for (times = 0; times < max_times; times++)
1822 ma_ptr = &ma_blows[randint0(MAX_MA)];
1823 if ((p_ptr->pclass == CLASS_FORCETRAINER) && (ma_ptr->min_level > 1)) min_level = ma_ptr->min_level + 3;
1824 else min_level = ma_ptr->min_level;
1826 while ((min_level > p_ptr->lev) ||
1827 (randint1(p_ptr->lev) < ma_ptr->chance));
1829 /* keep the highest level attack available we found */
1830 if ((ma_ptr->min_level > old_ptr->min_level) &&
1831 !p_ptr->stun && !p_ptr->confused)
1835 if (p_ptr->wizard && cheat_xtra)
1837 msg_print(_("攻撃を再選択しました。", "Attack re-selected."));
1846 if (p_ptr->pclass == CLASS_FORCETRAINER) min_level = MAX(1, ma_ptr->min_level - 3);
1847 else min_level = ma_ptr->min_level;
1848 k = damroll(ma_ptr->dd + p_ptr->to_dd[hand], ma_ptr->ds + p_ptr->to_ds[hand]);
1849 if (p_ptr->special_attack & ATTACK_SUIKEN) k *= 2;
1851 if (ma_ptr->effect == MA_KNEE)
1853 if (r_ptr->flags1 & RF1_MALE)
1855 msg_format(_("%sに金的膝蹴りをくらわした!", "You hit %s in the groin with your knee!"), m_name);
1857 special_effect = MA_KNEE;
1860 msg_format(ma_ptr->desc, m_name);
1863 else if (ma_ptr->effect == MA_SLOW)
1865 if (!((r_ptr->flags1 & RF1_NEVER_MOVE) ||
1866 my_strchr("~#{}.UjmeEv$,DdsbBFIJQSXclnw!=?", r_ptr->d_char)))
1868 msg_format(_("%sの足首に関節蹴りをくらわした!", "You kick %s in the ankle."), m_name);
1869 special_effect = MA_SLOW;
1871 else msg_format(ma_ptr->desc, m_name);
1877 stun_effect = (ma_ptr->effect / 2) + randint1(ma_ptr->effect / 2);
1880 msg_format(ma_ptr->desc, m_name);
1883 if (p_ptr->special_defense & KAMAE_SUZAKU) weight = 4;
1884 if ((p_ptr->pclass == CLASS_FORCETRAINER) && (p_ptr->magic_num1[0]))
1886 weight += (p_ptr->magic_num1[0]/30);
1887 if (weight > 20) weight = 20;
1890 k = critical_norm(p_ptr->lev * weight, min_level, k, p_ptr->to_h[0], 0);
1892 if ((special_effect == MA_KNEE) && ((k + p_ptr->to_d[hand]) < m_ptr->hp))
1894 msg_format(_("%^sは苦痛にうめいている!", "%^s moans in agony!"), m_name);
1895 stun_effect = 7 + randint1(13);
1899 else if ((special_effect == MA_SLOW) && ((k + p_ptr->to_d[hand]) < m_ptr->hp))
1901 if (!(r_ptr->flags1 & RF1_UNIQUE) &&
1902 (randint1(p_ptr->lev) > r_ptr->level) &&
1905 msg_format(_("%^sは足をひきずり始めた。", "%^s starts limping slower."), m_name);
1906 m_ptr->mspeed -= 10;
1910 if (stun_effect && ((k + p_ptr->to_d[hand]) < m_ptr->hp))
1912 if (p_ptr->lev > randint1(r_ptr->level + resist_stun + 10))
1914 if (set_monster_stunned(c_ptr->m_idx, stun_effect + MON_STUNNED(m_ptr)))
1916 msg_format(_("%^sはフラフラになった。", "%^s is stunned."), m_name);
1920 msg_format(_("%^sはさらにフラフラになった。", "%^s is more stunned."), m_name);
1926 /* Handle normal weapon */
1927 else if (o_ptr->k_idx)
1929 k = damroll(o_ptr->dd + p_ptr->to_dd[hand], o_ptr->ds + p_ptr->to_ds[hand]);
1930 k = tot_dam_aux(o_ptr, k, m_ptr, mode, FALSE);
1934 k *= (3 + (p_ptr->lev / 20));
1938 k = k*(5+(p_ptr->lev*2/25))/2;
1940 else if (stab_fleeing)
1945 if ((p_ptr->impact[hand] && ((k > 50) || one_in_(7))) ||
1946 (chaos_effect == 2) || (mode == HISSATSU_QUAKE))
1951 if ((!(o_ptr->tval == TV_SWORD) || !(o_ptr->sval == SV_DOKUBARI)) && !(mode == HISSATSU_KYUSHO))
1952 k = critical_norm(o_ptr->weight, o_ptr->to_h, k, p_ptr->to_h[hand], mode);
1960 if ((o_ptr->name1 == ART_CHAINSWORD) && !one_in_(2))
1962 char chainsword_noise[1024];
1963 if (!get_rnd_line(_("chainswd_j.txt", "chainswd.txt"), 0, chainsword_noise))
1965 msg_print(chainsword_noise);
1969 if (o_ptr->name1 == ART_VORPAL_BLADE)
1971 msg_print(_("目にも止まらぬヴォーパルブレード、手錬の早業!", "Your Vorpal Blade goes snicker-snack!"));
1975 msg_format(_("%sをグッサリ切り裂いた!", "Your weapon cuts deep into %s!"), m_name);
1978 /* Try to increase the damage */
1979 while (one_in_(vorpal_chance))
1987 if (((r_ptr->flagsr & RFR_RES_ALL) ? k/100 : k) > m_ptr->hp)
1989 msg_format(_("%sを真っ二つにした!", "You cut %s in half!"), m_name);
1995 case 2: msg_format(_("%sを斬った!", "You gouge %s!"), m_name); break;
1996 case 3: msg_format(_("%sをぶった斬った!", "You maim %s!"), m_name); break;
1997 case 4: msg_format(_("%sをメッタ斬りにした!", "You carve %s!"), m_name); break;
1998 case 5: msg_format(_("%sをメッタメタに斬った!", "You cleave %s!"), m_name); break;
1999 case 6: msg_format(_("%sを刺身にした!", "You smite %s!"), m_name); break;
2000 case 7: msg_format(_("%sを斬って斬って斬りまくった!", "You eviscerate %s!"), m_name); break;
2001 default: msg_format(_("%sを細切れにした!", "You shred %s!"), m_name); break;
2004 drain_result = drain_result * 3 / 2;
2008 drain_result += o_ptr->to_d;
2011 /* Apply the player damage bonuses */
2012 k += p_ptr->to_d[hand];
2013 drain_result += p_ptr->to_d[hand];
2015 if ((mode == HISSATSU_SUTEMI) || (mode == HISSATSU_3DAN)) k *= 2;
2016 if ((mode == HISSATSU_SEKIRYUKA) && !monster_living(r_ptr)) k = 0;
2017 if ((mode == HISSATSU_SEKIRYUKA) && !p_ptr->cut) k /= 2;
2019 /* No negative damage */
2022 if ((mode == HISSATSU_ZANMA) && !(!monster_living(r_ptr) && (r_ptr->flags3 & RF3_EVIL)))
2029 msg_print(_("こんな軟らかいものは切れん!", "You cannot cut such a elastic thing!"));
2035 msg_print(_("蜘蛛は苦手だ!", "Spiders are difficult for you to deal with!"));
2039 if (mode == HISSATSU_MINEUCHI)
2041 int tmp = (10 + randint1(15) + p_ptr->lev / 5);
2044 anger_monster(m_ptr);
2046 if (!(r_ptr->flags3 & (RF3_NO_STUN)))
2049 if (MON_STUNNED(m_ptr))
2051 msg_format(_("%sはひどくもうろうとした。", "%s is more dazed."), m_name);
2056 msg_format(_("%s はもうろうとした。", "%s is dazed."), m_name);
2060 (void)set_monster_stunned(c_ptr->m_idx, MON_STUNNED(m_ptr) + tmp);
2064 msg_format(_("%s には効果がなかった。", "%s is not effected."), m_name);
2068 /* Modify the damage */
2069 k = mon_damage_mod(m_ptr, k, (bool)(((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE)) || ((p_ptr->pclass == CLASS_BERSERKER) && one_in_(2))));
2070 if (((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) || (mode == HISSATSU_KYUSHO))
2072 if ((randint1(randint1(r_ptr->level/7)+5) == 1) && !(r_ptr->flags1 & RF1_UNIQUE) && !(r_ptr->flags7 & RF7_UNIQUE2))
2075 msg_format(_("%sの急所を突き刺した!", "You hit %s on a fatal spot!"), m_name);
2079 else if ((p_ptr->pclass == CLASS_NINJA) && buki_motteruka(INVEN_RARM + hand) && !p_ptr->icky_wield[hand] && ((p_ptr->cur_lite <= 0) || one_in_(7)))
2081 int maxhp = maxroll(r_ptr->hdice, r_ptr->hside);
2082 if (one_in_(backstab ? 13 : (stab_fleeing || fuiuchi) ? 15 : 27))
2086 msg_format(_("刃が%sに深々と突き刺さった!", "You critically injured %s!"), m_name);
2088 else if (((m_ptr->hp < maxhp/2) && one_in_((p_ptr->num_blow[0]+p_ptr->num_blow[1]+1)*10)) || ((one_in_(666) || ((backstab || fuiuchi) && one_in_(11))) && !(r_ptr->flags1 & RF1_UNIQUE) && !(r_ptr->flags7 & RF7_UNIQUE2)))
2090 if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_UNIQUE2) || (m_ptr->hp >= maxhp/2))
2092 k = MAX(k*5, m_ptr->hp/2);
2094 msg_format(_("%sに致命傷を負わせた!", "You fatally injured %s!"), m_name);
2099 msg_format(_("刃が%sの急所を貫いた!", "You hit %s on a fatal spot!"), m_name);
2104 /* Complex message */
2105 if (p_ptr->wizard || cheat_xtra)
2107 msg_format(_("%d/%d のダメージを与えた。", "You do %d (out of %d) damage."), k, m_ptr->hp);
2110 if (k <= 0) can_drain = FALSE;
2112 if (drain_result > m_ptr->hp)
2113 drain_result = m_ptr->hp;
2115 /* Damage, check for fear and death */
2116 if (mon_take_hit(c_ptr->m_idx, k, fear, NULL))
2119 if ((p_ptr->pclass == CLASS_BERSERKER) && energy_use)
2121 if (p_ptr->migite && p_ptr->hidarite)
2123 if (hand) energy_use = energy_use*3/5+energy_use*num*2/(p_ptr->num_blow[hand]*5);
2124 else energy_use = energy_use*num*3/(p_ptr->num_blow[hand]*5);
2128 energy_use = energy_use*num/p_ptr->num_blow[hand];
2131 if ((o_ptr->name1 == ART_ZANTETSU) && is_lowlevel)
2132 msg_print(_("またつまらぬものを斬ってしまった...", "Sigh... Another trifling thing I've cut...."));
2136 /* Anger the monster */
2137 if (k > 0) anger_monster(m_ptr);
2139 touch_zap_player(m_ptr);
2141 /* Are we draining it? A little note: If the monster is
2142 dead, the drain does not work... */
2144 if (can_drain && (drain_result > 0))
2146 if (o_ptr->name1 == ART_MURAMASA)
2150 int to_h = o_ptr->to_h;
2151 int to_d = o_ptr->to_d;
2155 for (i = 0; i < to_h + 3; i++) if (one_in_(4)) flag = 0;
2159 for (i = 0; i < to_d + 3; i++) if (one_in_(4)) flag = 0;
2162 if (o_ptr->to_h != to_h || o_ptr->to_d != to_d)
2164 msg_print(_("妖刀は血を吸って強くなった!", "Muramasa sucked blood, and became more powerful!"));
2172 if (drain_result > 5) /* Did we really hurt it? */
2174 drain_heal = damroll(2, drain_result / 6);
2177 if (hex_spelling(HEX_VAMP_BLADE)) drain_heal *= 2;
2181 msg_format(_("Draining left: %d", "Draining left: %d"), drain_left);
2186 if (drain_heal < drain_left)
2188 drain_left -= drain_heal;
2192 drain_heal = drain_left;
2198 msg_format(_("刃が%sから生命力を吸い取った!", "Your weapon drains life from %s!"), m_name);
2202 drain_heal = (drain_heal * mutant_regenerate_mod) / 100;
2204 hp_player(drain_heal);
2205 /* We get to keep some of it! */
2209 m_ptr->maxhp -= (k+7)/8;
2210 if (m_ptr->hp > m_ptr->maxhp) m_ptr->hp = m_ptr->maxhp;
2211 if (m_ptr->maxhp < 1) m_ptr->maxhp = 1;
2217 /* Confusion attack */
2218 if ((p_ptr->special_attack & ATTACK_CONFUSE) || (chaos_effect == 3) || (mode == HISSATSU_CONF) || hex_spelling(HEX_CONFUSION))
2220 /* Cancel glowing hands */
2221 if (p_ptr->special_attack & ATTACK_CONFUSE)
2223 p_ptr->special_attack &= ~(ATTACK_CONFUSE);
2224 msg_print(_("手の輝きがなくなった。", "Your hands stop glowing."));
2225 p_ptr->redraw |= (PR_STATUS);
2229 /* Confuse the monster */
2230 if (r_ptr->flags3 & RF3_NO_CONF)
2232 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= RF3_NO_CONF;
2233 msg_format(_("%^sには効果がなかった。", "%^s is unaffected."), m_name);
2236 else if (randint0(100) < r_ptr->level)
2238 msg_format(_("%^sには効果がなかった。", "%^s is unaffected."), m_name);
2242 msg_format(_("%^sは混乱したようだ。", "%^s appears confused."), m_name);
2243 (void)set_monster_confused(c_ptr->m_idx, MON_CONFUSED(m_ptr) + 10 + randint0(p_ptr->lev) / 5);
2247 else if (chaos_effect == 4)
2249 bool resists_tele = FALSE;
2251 if (r_ptr->flagsr & RFR_RES_TELE)
2253 if (r_ptr->flags1 & RF1_UNIQUE)
2255 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= RFR_RES_TELE;
2256 msg_format(_("%^sには効果がなかった。", "%^s is unaffected!"), m_name);
2257 resists_tele = TRUE;
2259 else if (r_ptr->level > randint1(100))
2261 if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= RFR_RES_TELE;
2262 msg_format(_("%^sは抵抗力を持っている!", "%^s resists!"), m_name);
2263 resists_tele = TRUE;
2269 msg_format(_("%^sは消えた!", "%^s disappears!"), m_name);
2270 teleport_away(c_ptr->m_idx, 50, TELEPORT_PASSIVE);
2271 num = num_blow + 1; /* Can't hit it anymore! */
2276 else if ((chaos_effect == 5) && (randint1(90) > r_ptr->level))
2278 if (!(r_ptr->flags1 & (RF1_UNIQUE | RF1_QUESTOR)) &&
2279 !(r_ptr->flagsr & RFR_EFF_RES_CHAO_MASK))
2281 if (polymorph_monster(y, x))
2283 msg_format(_("%^sは変化した!", "%^s changes!"), m_name);
2289 msg_format(_("%^sには効果がなかった。", "%^s is unaffected."), m_name);
2292 /* Hack -- Get new monster */
2293 m_ptr = &m_list[c_ptr->m_idx];
2295 /* Oops, we need a different name... */
2296 monster_desc(m_name, m_ptr, 0);
2298 /* Hack -- Get new race */
2299 r_ptr = &r_info[m_ptr->r_idx];
2302 else if (o_ptr->name1 == ART_G_HAMMER)
2304 monster_type *m_ptr = &m_list[c_ptr->m_idx];
2306 if (m_ptr->hold_o_idx)
2308 object_type *q_ptr = &o_list[m_ptr->hold_o_idx];
2309 char o_name[MAX_NLEN];
2311 object_desc(o_name, q_ptr, OD_NAME_ONLY);
2312 q_ptr->held_m_idx = 0;
2313 q_ptr->marked = OM_TOUCHED;
2314 m_ptr->hold_o_idx = q_ptr->next_o_idx;
2315 q_ptr->next_o_idx = 0;
2316 msg_format(_("%sを奪った。", "You snatched %s."), o_name);
2325 backstab = FALSE; /* Clumsy! */
2326 fuiuchi = FALSE; /* Clumsy! */
2328 if ((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE) && one_in_(3))
2330 u32b flgs[TR_FLAG_SIZE];
2336 msg_format(_("ミス! %sにかわされた。", "You miss %s."), m_name);
2338 msg_print(_("振り回した大鎌が自分自身に返ってきた!", "Your scythe returns to you!"));
2340 /* Extract the flags */
2341 object_flags(o_ptr, flgs);
2343 k = damroll(o_ptr->dd + p_ptr->to_dd[hand], o_ptr->ds + p_ptr->to_ds[hand]);
2346 switch (p_ptr->mimic_form)
2349 switch (p_ptr->prace)
2356 case RACE_BARBARIAN:
2360 case RACE_HALF_TROLL:
2361 case RACE_HALF_OGRE:
2362 case RACE_HALF_GIANT:
2363 case RACE_HALF_TITAN:
2371 case RACE_DRACONIAN:
2378 case MIMIC_DEMON_LORD:
2385 if (p_ptr->align < 0 && mult < 20)
2387 if (!(p_ptr->resist_acid || IS_OPPOSE_ACID() || p_ptr->immune_acid) && (mult < 25))
2389 if (!(p_ptr->resist_elec || IS_OPPOSE_ELEC() || p_ptr->immune_elec) && (mult < 25))
2391 if (!(p_ptr->resist_fire || IS_OPPOSE_FIRE() || p_ptr->immune_fire) && (mult < 25))
2393 if (!(p_ptr->resist_cold || IS_OPPOSE_COLD() || p_ptr->immune_cold) && (mult < 25))
2395 if (!(p_ptr->resist_pois || IS_OPPOSE_POIS()) && (mult < 25))
2398 if ((p_ptr->pclass != CLASS_SAMURAI) && (have_flag(flgs, TR_FORCE_WEAPON)) && (p_ptr->csp > (p_ptr->msp / 30)))
2400 p_ptr->csp -= (1+(p_ptr->msp / 30));
2401 p_ptr->redraw |= (PR_MANA);
2402 mult = mult * 3 / 2 + 20;
2408 k = critical_norm(o_ptr->weight, o_ptr->to_h, k, p_ptr->to_h[hand], mode);
2412 msg_format(_("グッサリ切り裂かれた!", "Your weapon cuts deep into yourself!"));
2413 /* Try to increase the damage */
2421 k += (p_ptr->to_d[hand] + o_ptr->to_d);
2424 take_hit(DAMAGE_FORCE, k, _("死の大鎌", "Death scythe"), -1);
2433 msg_format(_("ミス! %sにかわされた。", "You miss %s."), m_name);
2441 if (weak && !(*mdeath))
2443 msg_format(_("%sは弱くなったようだ。", "%^s seems weakened."), m_name);
2445 if (drain_left != MAX_VAMPIRIC_DRAIN)
2449 chg_virtue(V_UNLIFE, 1);
2452 /* Mega-Hack -- apply earthquake brand */
2455 earthquake(py, px, 10);
2456 if (!cave[y][x].m_idx) *mdeath = TRUE;
2461 * @brief プレイヤーの打撃処理メインルーチン
2464 * @param mode 発動中の剣術ID
2465 * @return 実際に攻撃処理が行われた場合TRUEを返す。
2467 * If no "weapon" is available, then "punch" the monster one time.
2469 bool py_attack(int y, int x, int mode)
2472 bool mdeath = FALSE;
2473 bool stormbringer = FALSE;
2475 cave_type *c_ptr = &cave[y][x];
2476 monster_type *m_ptr = &m_list[c_ptr->m_idx];
2477 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2480 /* Disturb the player */
2485 if (!p_ptr->migite && !p_ptr->hidarite &&
2486 !(p_ptr->muta2 & (MUT2_HORNS | MUT2_BEAK | MUT2_SCOR_TAIL | MUT2_TRUNK | MUT2_TENTACLES)))
2488 msg_format(_("%s攻撃できない。", "You cannot do attacking."),
2489 (empty_hands(FALSE) == EMPTY_HAND_NONE) ? _("両手がふさがって", "") : "");
2493 /* Extract monster name (or "it") */
2494 monster_desc(m_name, m_ptr, 0);
2498 /* Auto-Recall if possible and visible */
2499 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
2501 /* Track a new monster */
2502 health_track(c_ptr->m_idx);
2505 if ((r_ptr->flags1 & RF1_FEMALE) &&
2506 !(p_ptr->stun || p_ptr->confused || p_ptr->image || !m_ptr->ml))
2508 if ((inventory[INVEN_RARM].name1 == ART_ZANTETSU) || (inventory[INVEN_LARM].name1 == ART_ZANTETSU))
2510 msg_print(_("拙者、おなごは斬れぬ!", "I can not attack women!"));
2515 if (d_info[dungeon_type].flags1 & DF1_NO_MELEE)
2517 msg_print(_("なぜか攻撃することができない。", "Something prevent you from attacking."));
2521 /* Stop if friendly */
2522 if (!is_hostile(m_ptr) &&
2523 !(p_ptr->stun || p_ptr->confused || p_ptr->image ||
2524 p_ptr->shero || !m_ptr->ml))
2526 if (inventory[INVEN_RARM].name1 == ART_STORMBRINGER) stormbringer = TRUE;
2527 if (inventory[INVEN_LARM].name1 == ART_STORMBRINGER) stormbringer = TRUE;
2530 msg_format(_("黒い刃は強欲に%sを攻撃した!", "Your black blade greedily attacks %s!"), m_name);
2531 chg_virtue(V_INDIVIDUALISM, 1);
2532 chg_virtue(V_HONOUR, -1);
2533 chg_virtue(V_JUSTICE, -1);
2534 chg_virtue(V_COMPASSION, -1);
2536 else if (p_ptr->pclass != CLASS_BERSERKER)
2538 if (get_check(_("本当に攻撃しますか?", "Really hit it? ")))
2540 chg_virtue(V_INDIVIDUALISM, 1);
2541 chg_virtue(V_HONOUR, -1);
2542 chg_virtue(V_JUSTICE, -1);
2543 chg_virtue(V_COMPASSION, -1);
2547 msg_format(_("%sを攻撃するのを止めた。", "You stop to avoid hitting %s."), m_name);
2554 /* Handle player fear */
2559 msg_format(_("恐くて%sを攻撃できない!", "You are too afraid to attack %s!"), m_name);
2561 msg_format (_("そっちには何か恐いものがいる!", "There is something scary in your way!"));
2563 /* Disturb the monster */
2564 (void)set_monster_csleep(c_ptr->m_idx, 0);
2570 if (MON_CSLEEP(m_ptr)) /* It is not honorable etc to attack helpless victims */
2572 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_COMPASSION, -1);
2573 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_HONOUR, -1);
2576 if (p_ptr->migite && p_ptr->hidarite)
2578 if ((p_ptr->skill_exp[GINOU_NITOURYU] < s_info[p_ptr->pclass].s_max[GINOU_NITOURYU]) && ((p_ptr->skill_exp[GINOU_NITOURYU] - 1000) / 200 < r_ptr->level))
2580 if (p_ptr->skill_exp[GINOU_NITOURYU] < WEAPON_EXP_BEGINNER)
2581 p_ptr->skill_exp[GINOU_NITOURYU] += 80;
2582 else if(p_ptr->skill_exp[GINOU_NITOURYU] < WEAPON_EXP_SKILLED)
2583 p_ptr->skill_exp[GINOU_NITOURYU] += 4;
2584 else if(p_ptr->skill_exp[GINOU_NITOURYU] < WEAPON_EXP_EXPERT)
2585 p_ptr->skill_exp[GINOU_NITOURYU] += 1;
2586 else if(p_ptr->skill_exp[GINOU_NITOURYU] < WEAPON_EXP_MASTER)
2587 if (one_in_(3)) p_ptr->skill_exp[GINOU_NITOURYU] += 1;
2588 p_ptr->update |= (PU_BONUS);
2592 /* Gain riding experience */
2595 int cur = p_ptr->skill_exp[GINOU_RIDING];
2596 int max = s_info[p_ptr->pclass].s_max[GINOU_RIDING];
2600 int ridinglevel = r_info[m_list[p_ptr->riding].r_idx].level;
2601 int targetlevel = r_ptr->level;
2604 if ((cur / 200 - 5) < targetlevel)
2607 /* Extra experience */
2608 if ((cur / 100) < ridinglevel)
2610 if ((cur / 100 + 15) < ridinglevel)
2611 inc += 1 + (ridinglevel - (cur / 100 + 15));
2616 p_ptr->skill_exp[GINOU_RIDING] = MIN(max, cur + inc);
2618 p_ptr->update |= (PU_BONUS);
2622 riding_t_m_idx = c_ptr->m_idx;
2623 if (p_ptr->migite) py_attack_aux(y, x, &fear, &mdeath, 0, mode);
2624 if (p_ptr->hidarite && !mdeath) py_attack_aux(y, x, &fear, &mdeath, 1, mode);
2626 /* Mutations which yield extra 'natural' attacks */
2629 if ((p_ptr->muta2 & MUT2_HORNS) && !mdeath)
2630 natural_attack(c_ptr->m_idx, MUT2_HORNS, &fear, &mdeath);
2631 if ((p_ptr->muta2 & MUT2_BEAK) && !mdeath)
2632 natural_attack(c_ptr->m_idx, MUT2_BEAK, &fear, &mdeath);
2633 if ((p_ptr->muta2 & MUT2_SCOR_TAIL) && !mdeath)
2634 natural_attack(c_ptr->m_idx, MUT2_SCOR_TAIL, &fear, &mdeath);
2635 if ((p_ptr->muta2 & MUT2_TRUNK) && !mdeath)
2636 natural_attack(c_ptr->m_idx, MUT2_TRUNK, &fear, &mdeath);
2637 if ((p_ptr->muta2 & MUT2_TENTACLES) && !mdeath)
2638 natural_attack(c_ptr->m_idx, MUT2_TENTACLES, &fear, &mdeath);
2641 /* Hack -- delay fear messages */
2642 if (fear && m_ptr->ml && !mdeath)
2648 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
2651 if ((p_ptr->special_defense & KATA_IAI) && ((mode != HISSATSU_IAI) || mdeath))
2653 set_action(ACTION_NONE);
2661 * @brief パターンによる移動制限処理
2662 * @param c_y プレイヤーの移動元Y座標
2663 * @param c_x プレイヤーの移動元X座標
2664 * @param n_y プレイヤーの移動先Y座標
2665 * @param n_x プレイヤーの移動先X座標
2666 * @return 移動処理が可能である場合(可能な場合に選択した場合)TRUEを返す。
2668 bool pattern_seq(int c_y, int c_x, int n_y, int n_x)
2670 feature_type *cur_f_ptr = &f_info[cave[c_y][c_x].feat];
2671 feature_type *new_f_ptr = &f_info[cave[n_y][n_x].feat];
2672 bool is_pattern_tile_cur = have_flag(cur_f_ptr->flags, FF_PATTERN);
2673 bool is_pattern_tile_new = have_flag(new_f_ptr->flags, FF_PATTERN);
2674 int pattern_type_cur, pattern_type_new;
2676 if (!is_pattern_tile_cur && !is_pattern_tile_new) return TRUE;
2678 pattern_type_cur = is_pattern_tile_cur ? cur_f_ptr->subtype : NOT_PATTERN_TILE;
2679 pattern_type_new = is_pattern_tile_new ? new_f_ptr->subtype : NOT_PATTERN_TILE;
2681 if (pattern_type_new == PATTERN_TILE_START)
2683 if (!is_pattern_tile_cur && !p_ptr->confused && !p_ptr->stun && !p_ptr->image)
2685 if (get_check(_("パターンの上を歩き始めると、全てを歩かなければなりません。いいですか?",
2686 "If you start walking the Pattern, you must walk the whole way. Ok? ")))
2694 else if ((pattern_type_new == PATTERN_TILE_OLD) ||
2695 (pattern_type_new == PATTERN_TILE_END) ||
2696 (pattern_type_new == PATTERN_TILE_WRECKED))
2698 if (is_pattern_tile_cur)
2704 msg_print(_("パターンの上を歩くにはスタート地点から歩き始めなくてはなりません。",
2705 "You must start walking the Pattern from the startpoint."));
2710 else if ((pattern_type_new == PATTERN_TILE_TELEPORT) ||
2711 (pattern_type_cur == PATTERN_TILE_TELEPORT))
2715 else if (pattern_type_cur == PATTERN_TILE_START)
2717 if (is_pattern_tile_new)
2721 msg_print(_("パターンの上は正しい順序で歩かねばなりません。", "You must walk the Pattern in correct order."));
2725 else if ((pattern_type_cur == PATTERN_TILE_OLD) ||
2726 (pattern_type_cur == PATTERN_TILE_END) ||
2727 (pattern_type_cur == PATTERN_TILE_WRECKED))
2729 if (!is_pattern_tile_new)
2731 msg_print(_("パターンを踏み外してはいけません。", "You may not step off from the Pattern."));
2741 if (!is_pattern_tile_cur)
2743 msg_print(_("パターンの上を歩くにはスタート地点から歩き始めなくてはなりません。",
2744 "You must start walking the Pattern from the startpoint."));
2750 byte ok_move = PATTERN_TILE_START;
2751 switch (pattern_type_cur)
2753 case PATTERN_TILE_1:
2754 ok_move = PATTERN_TILE_2;
2756 case PATTERN_TILE_2:
2757 ok_move = PATTERN_TILE_3;
2759 case PATTERN_TILE_3:
2760 ok_move = PATTERN_TILE_4;
2762 case PATTERN_TILE_4:
2763 ok_move = PATTERN_TILE_1;
2767 msg_format(_("おかしなパターン歩行、%d。", "Funny Pattern walking, %d."), pattern_type_cur);
2769 return TRUE; /* Goof-up */
2772 if ((pattern_type_new == ok_move) ||
2773 (pattern_type_new == pattern_type_cur))
2777 if (!is_pattern_tile_new)
2778 msg_print(_("パターンを踏み外してはいけません。", "You may not step off from the Pattern."));
2780 msg_print(_("パターンの上は正しい順序で歩かねばなりません。", "You must walk the Pattern in correct order."));
2790 * @brief プレイヤーが地形踏破可能かを返す
2791 * @param feature 判定したい地形ID
2792 * @param mode 移動に関するオプションフラグ
2793 * @return 移動可能ならばTRUEを返す
2795 bool player_can_enter(s16b feature, u16b mode)
2797 feature_type *f_ptr = &f_info[feature];
2799 if (p_ptr->riding) return monster_can_cross_terrain(feature, &r_info[m_list[p_ptr->riding].r_idx], mode | CEM_RIDING);
2802 if (have_flag(f_ptr->flags, FF_PATTERN))
2804 if (!(mode & CEM_P_CAN_ENTER_PATTERN)) return FALSE;
2808 if (have_flag(f_ptr->flags, FF_CAN_FLY) && p_ptr->levitation) return TRUE;
2809 if (have_flag(f_ptr->flags, FF_CAN_SWIM) && p_ptr->can_swim) return TRUE;
2810 if (have_flag(f_ptr->flags, FF_CAN_PASS) && p_ptr->pass_wall) return TRUE;
2812 if (!have_flag(f_ptr->flags, FF_MOVE)) return FALSE;
2819 * @brief 移動に伴うプレイヤーのステータス変化処理
2822 * @param mpe_mode 移動オプションフラグ
2823 * @return プレイヤーが死亡やフロア離脱を行わず、実際に移動が可能ならばTRUEを返す。
2825 bool move_player_effect(int ny, int nx, u32b mpe_mode)
2827 cave_type *c_ptr = &cave[ny][nx];
2828 feature_type *f_ptr = &f_info[c_ptr->feat];
2830 if (!(mpe_mode & MPE_STAYING))
2834 cave_type *oc_ptr = &cave[oy][ox];
2835 int om_idx = oc_ptr->m_idx;
2836 int nm_idx = c_ptr->m_idx;
2838 /* Move the player */
2842 /* Hack -- For moving monster or riding player's moving */
2843 if (!(mpe_mode & MPE_DONT_SWAP_MON))
2845 /* Swap two monsters */
2846 c_ptr->m_idx = om_idx;
2847 oc_ptr->m_idx = nm_idx;
2849 if (om_idx > 0) /* Monster on old spot (or p_ptr->riding) */
2851 monster_type *om_ptr = &m_list[om_idx];
2854 update_mon(om_idx, TRUE);
2857 if (nm_idx > 0) /* Monster on new spot */
2859 monster_type *nm_ptr = &m_list[nm_idx];
2862 update_mon(nm_idx, TRUE);
2866 /* Redraw old spot */
2869 /* Redraw new spot */
2872 /* Check for new panel (redraw map) */
2875 if (mpe_mode & MPE_FORGET_FLOW)
2879 /* Mega-Hack -- Forget the view */
2880 p_ptr->update |= (PU_UN_VIEW);
2883 p_ptr->redraw |= (PR_MAP);
2887 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE | PU_DISTANCE);
2890 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
2892 /* Remove "unsafe" flag */
2893 if ((!p_ptr->blind && !no_lite()) || !is_trap(c_ptr->feat)) c_ptr->info &= ~(CAVE_UNSAFE);
2895 /* For get everything when requested hehe I'm *NASTY* */
2896 if (dun_level && (d_info[dungeon_type].flags1 & DF1_FORGET)) wiz_dark();
2899 if (mpe_mode & MPE_HANDLE_STUFF) handle_stuff();
2901 if (p_ptr->pclass == CLASS_NINJA)
2903 if (c_ptr->info & (CAVE_GLOW)) set_superstealth(FALSE);
2904 else if (p_ptr->cur_lite <= 0) set_superstealth(TRUE);
2907 if ((p_ptr->action == ACTION_HAYAGAKE) &&
2908 (!have_flag(f_ptr->flags, FF_PROJECT) ||
2909 (!p_ptr->levitation && have_flag(f_ptr->flags, FF_DEEP))))
2911 msg_print(_("ここでは素早く動けない。", "You cannot run in here."));
2912 set_action(ACTION_NONE);
2916 if (mpe_mode & MPE_ENERGY_USE)
2918 if (music_singing(MUSIC_WALL))
2920 (void)project(0, 0, py, px, (60 + p_ptr->lev), GF_DISINTEGRATE,
2921 PROJECT_KILL | PROJECT_ITEM, -1);
2923 if (!player_bold(ny, nx) || p_ptr->is_dead || p_ptr->leaving) return FALSE;
2926 /* Spontaneous Searching */
2927 if ((p_ptr->skill_fos >= 50) || (0 == randint0(50 - p_ptr->skill_fos)))
2932 /* Continuous Searching */
2933 if (p_ptr->action == ACTION_SEARCH)
2939 /* Handle "objects" */
2940 if (!(mpe_mode & MPE_DONT_PICKUP))
2942 carry((mpe_mode & MPE_DO_PICKUP) ? TRUE : FALSE);
2945 /* Handle "store doors" */
2946 if (have_flag(f_ptr->flags, FF_STORE))
2952 /* Hack -- Enter store */
2953 command_new = SPECIAL_KEY_STORE;
2956 /* Handle "building doors" -KMW- */
2957 else if (have_flag(f_ptr->flags, FF_BLDG))
2963 /* Hack -- Enter building */
2964 command_new = SPECIAL_KEY_BUILDING;
2967 /* Handle quest areas -KMW- */
2968 else if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
2974 /* Hack -- Enter quest level */
2975 command_new = SPECIAL_KEY_QUEST;
2978 else if (have_flag(f_ptr->flags, FF_QUEST_EXIT))
2980 if (quest[p_ptr->inside_quest].type == QUEST_TYPE_FIND_EXIT)
2982 complete_quest(p_ptr->inside_quest);
2985 leave_quest_check();
2987 p_ptr->inside_quest = c_ptr->special;
2992 p_ptr->leaving = TRUE;
2995 /* Set off a trap */
2996 else if (have_flag(f_ptr->flags, FF_HIT_TRAP) && !(mpe_mode & MPE_STAYING))
3002 if (c_ptr->mimic || have_flag(f_ptr->flags, FF_SECRET))
3005 msg_print(_("トラップだ!", "You found a trap!"));
3008 disclose_grid(py, px);
3012 hit_trap((mpe_mode & MPE_BREAK_TRAP) ? TRUE : FALSE);
3014 if (!player_bold(ny, nx) || p_ptr->is_dead || p_ptr->leaving) return FALSE;
3017 /* Warn when leaving trap detected region */
3018 if (!(mpe_mode & MPE_STAYING) && (disturb_trap_detect || alert_trap_detect)
3019 && p_ptr->dtrap && !(c_ptr->info & CAVE_IN_DETECT))
3021 /* No duplicate warning */
3022 p_ptr->dtrap = FALSE;
3024 /* You are just on the edge */
3025 if (!(c_ptr->info & CAVE_UNSAFE))
3027 if (alert_trap_detect)
3029 msg_print(_("* 注意:この先はトラップの感知範囲外です! *", "*Leaving trap detect region!*"));
3032 if (disturb_trap_detect) disturb(0, 1);
3036 return player_bold(ny, nx) && !p_ptr->is_dead && !p_ptr->leaving;
3040 * @brief 該当地形のトラップがプレイヤーにとって無効かどうかを判定して返す
3042 * @return トラップが自動的に無効ならばTRUEを返す
3044 bool trap_can_be_ignored(int feat)
3046 feature_type *f_ptr = &f_info[feat];
3048 if (!have_flag(f_ptr->flags, FF_TRAP)) return TRUE;
3050 switch (f_ptr->subtype)
3054 case TRAP_SPIKED_PIT:
3055 case TRAP_POISON_PIT:
3056 if (p_ptr->levitation) return TRUE;
3059 if (p_ptr->anti_tele) return TRUE;
3062 if (p_ptr->immune_fire) return TRUE;
3065 if (p_ptr->immune_acid) return TRUE;
3068 if (p_ptr->resist_blind) return TRUE;
3071 if (p_ptr->resist_conf) return TRUE;
3074 if (p_ptr->resist_pois) return TRUE;
3077 if (p_ptr->free_act) return TRUE;
3086 * Determine if a "boundary" grid is "floor mimic"
3088 #define boundary_floor(C, F, MF) \
3089 ((C)->mimic && permanent_wall(F) && \
3090 (have_flag((MF)->flags, FF_MOVE) || have_flag((MF)->flags, FF_CAN_FLY)) && \
3091 have_flag((MF)->flags, FF_PROJECT) && \
3092 !have_flag((MF)->flags, FF_OPEN))
3096 * @brief 該当地形のトラップがプレイヤーにとって無効かどうかを判定して返す /
3097 * Move player in the given direction, with the given "pickup" flag.
3099 * @param do_pickup 罠解除を試みながらの移動ならばTRUE
3100 * @param break_trap トラップ粉砕処理を行うならばTRUE
3101 * @return 実際に移動が行われたならばTRUEを返す。
3103 * This routine should (probably) always induce energy expenditure.\n
3105 * Note that moving will *always* take a turn, and will *always* hit\n
3106 * any monster which might be in the destination grid. Previously,\n
3107 * moving into walls was "free" and did NOT hit invisible monsters.\n
3109 void move_player(int dir, bool do_pickup, bool break_trap)
3111 /* Find the result of moving */
3112 int y = py + ddy[dir];
3113 int x = px + ddx[dir];
3115 /* Examine the destination */
3116 cave_type *c_ptr = &cave[y][x];
3118 feature_type *f_ptr = &f_info[c_ptr->feat];
3120 monster_type *m_ptr;
3122 monster_type *riding_m_ptr = &m_list[p_ptr->riding];
3123 monster_race *riding_r_ptr = &r_info[p_ptr->riding ? riding_m_ptr->r_idx : 0]; /* Paranoia */
3127 bool p_can_enter = player_can_enter(c_ptr->feat, CEM_P_CAN_ENTER_PATTERN);
3128 bool p_can_kill_walls = FALSE;
3129 bool stormbringer = FALSE;
3131 bool oktomove = TRUE;
3132 bool do_past = FALSE;
3135 if (!dun_level && !p_ptr->wild_mode &&
3136 ((x == 0) || (x == MAX_WID - 1) ||
3137 (y == 0) || (y == MAX_HGT - 1)))
3139 /* Can the player enter the grid? */
3140 if (c_ptr->mimic && player_can_enter(c_ptr->mimic, 0))
3142 /* Hack: move to new area */
3143 if ((y == 0) && (x == 0))
3145 p_ptr->wilderness_y--;
3146 p_ptr->wilderness_x--;
3147 p_ptr->oldpy = cur_hgt - 2;
3148 p_ptr->oldpx = cur_wid - 2;
3149 ambush_flag = FALSE;
3152 else if ((y == 0) && (x == MAX_WID - 1))
3154 p_ptr->wilderness_y--;
3155 p_ptr->wilderness_x++;
3156 p_ptr->oldpy = cur_hgt - 2;
3158 ambush_flag = FALSE;
3161 else if ((y == MAX_HGT - 1) && (x == 0))
3163 p_ptr->wilderness_y++;
3164 p_ptr->wilderness_x--;
3166 p_ptr->oldpx = cur_wid - 2;
3167 ambush_flag = FALSE;
3170 else if ((y == MAX_HGT - 1) && (x == MAX_WID - 1))
3172 p_ptr->wilderness_y++;
3173 p_ptr->wilderness_x++;
3176 ambush_flag = FALSE;
3181 p_ptr->wilderness_y--;
3182 p_ptr->oldpy = cur_hgt - 2;
3184 ambush_flag = FALSE;
3187 else if (y == MAX_HGT - 1)
3189 p_ptr->wilderness_y++;
3192 ambush_flag = FALSE;
3197 p_ptr->wilderness_x--;
3198 p_ptr->oldpx = cur_wid - 2;
3200 ambush_flag = FALSE;
3203 else if (x == MAX_WID - 1)
3205 p_ptr->wilderness_x++;
3208 ambush_flag = FALSE;
3211 p_ptr->leaving = TRUE;
3217 /* "Blocked" message appears later */
3218 /* oktomove = FALSE; */
3219 p_can_enter = FALSE;
3222 /* Get the monster */
3223 m_ptr = &m_list[c_ptr->m_idx];
3226 if (inventory[INVEN_RARM].name1 == ART_STORMBRINGER) stormbringer = TRUE;
3227 if (inventory[INVEN_LARM].name1 == ART_STORMBRINGER) stormbringer = TRUE;
3229 /* Player can not walk through "walls"... */
3230 /* unless in Shadow Form */
3231 p_can_kill_walls = p_ptr->kill_wall && have_flag(f_ptr->flags, FF_HURT_DISI) &&
3232 (!p_can_enter || !have_flag(f_ptr->flags, FF_LOS)) &&
3233 !have_flag(f_ptr->flags, FF_PERMANENT);
3235 /* Hack -- attack monsters */
3236 if (c_ptr->m_idx && (m_ptr->ml || p_can_enter || p_can_kill_walls))
3238 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3240 /* Attack -- only if we can see it OR it is not in a wall */
3241 if (!is_hostile(m_ptr) &&
3242 !(p_ptr->confused || p_ptr->image || !m_ptr->ml || p_ptr->stun ||
3243 ((p_ptr->muta2 & MUT2_BERS_RAGE) && p_ptr->shero)) &&
3244 pattern_seq(py, px, y, x) && (p_can_enter || p_can_kill_walls))
3246 /* Disturb the monster */
3247 (void)set_monster_csleep(c_ptr->m_idx, 0);
3249 /* Extract monster name (or "it") */
3250 monster_desc(m_name, m_ptr, 0);
3254 /* Auto-Recall if possible and visible */
3255 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
3257 /* Track a new monster */
3258 health_track(c_ptr->m_idx);
3262 if ((stormbringer && (randint1(1000) > 666)) || (p_ptr->pclass == CLASS_BERSERKER))
3267 else if (monster_can_cross_terrain(cave[py][px].feat, r_ptr, 0))
3273 msg_format(_("%^sが邪魔だ!", "%^s is in your way!"), m_name);
3278 /* now continue on to 'movement' */
3287 if (oktomove && p_ptr->riding)
3289 if (riding_r_ptr->flags1 & RF1_NEVER_MOVE)
3291 msg_print(_("動けない!", "Can't move!"));
3296 else if (MON_MONFEAR(riding_m_ptr))
3300 /* Acquire the monster name */
3301 monster_desc(m_name, riding_m_ptr, 0);
3303 /* Dump a message */
3304 msg_format(_("%sが恐怖していて制御できない。", "%^s is too scared to control."), m_name);
3308 else if (p_ptr->riding_ryoute)
3313 else if (have_flag(f_ptr->flags, FF_CAN_FLY) && (riding_r_ptr->flags7 & RF7_CAN_FLY))
3317 else if (have_flag(f_ptr->flags, FF_CAN_SWIM) && (riding_r_ptr->flags7 & RF7_CAN_SWIM))
3321 else if (have_flag(f_ptr->flags, FF_WATER) &&
3322 !(riding_r_ptr->flags7 & RF7_AQUATIC) &&
3323 (have_flag(f_ptr->flags, FF_DEEP) || (riding_r_ptr->flags2 & RF2_AURA_FIRE)))
3325 msg_format(_("%sの上に行けない。", "Can't swim."), f_name + f_info[get_feat_mimic(c_ptr)].name);
3330 else if (!have_flag(f_ptr->flags, FF_WATER) && (riding_r_ptr->flags7 & RF7_AQUATIC))
3332 msg_format(_("%sから上がれない。", "Can't land."), f_name + f_info[get_feat_mimic(&cave[py][px])].name);
3337 else if (have_flag(f_ptr->flags, FF_LAVA) && !(riding_r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK))
3339 msg_format(_("%sの上に行けない。", "Too hot to go through."), f_name + f_info[get_feat_mimic(c_ptr)].name);
3345 if (oktomove && MON_STUNNED(riding_m_ptr) && one_in_(2))
3348 monster_desc(m_name, riding_m_ptr, 0);
3349 msg_format(_("%sが朦朧としていてうまく動けない!", "You cannot control stunned %s!"),m_name);
3359 else if (!have_flag(f_ptr->flags, FF_MOVE) && have_flag(f_ptr->flags, FF_CAN_FLY) && !p_ptr->levitation)
3361 msg_format(_("空を飛ばないと%sの上には行けない。", "You need to fly to go through the %s."), f_name + f_info[get_feat_mimic(c_ptr)].name);
3368 * Player can move through trees and
3369 * has effective -10 speed
3370 * Rangers can move without penality
3372 else if (have_flag(f_ptr->flags, FF_TREE) && !p_can_kill_walls)
3374 if ((p_ptr->pclass != CLASS_RANGER) && !p_ptr->levitation && (!p_ptr->riding || !(riding_r_ptr->flags8 & RF8_WILD_WOOD))) energy_use *= 2;
3377 #ifdef ALLOW_EASY_DISARM /* TNB */
3379 /* Disarm a visible trap */
3380 else if ((do_pickup != easy_disarm) && have_flag(f_ptr->flags, FF_DISARM) && !c_ptr->mimic)
3382 if (!trap_can_be_ignored(c_ptr->feat))
3384 (void)do_cmd_disarm_aux(y, x, dir);
3389 #endif /* ALLOW_EASY_DISARM -- TNB */
3391 /* Player can not walk through "walls" unless in wraith form...*/
3392 else if (!p_can_enter && !p_can_kill_walls)
3394 /* Feature code (applying "mimic" field) */
3395 s16b feat = get_feat_mimic(c_ptr);
3396 feature_type *mimic_f_ptr = &f_info[feat];
3397 cptr name = f_name + mimic_f_ptr->name;
3401 /* Notice things in the dark */
3402 if (!(c_ptr->info & CAVE_MARK) && !player_can_see_bold(y, x))
3404 /* Boundary floor mimic */
3405 if (boundary_floor(c_ptr, f_ptr, mimic_f_ptr))
3407 msg_print(_("それ以上先には進めないようだ。", "You feel you cannot go any more."));
3410 /* Wall (or secret door) */
3414 msg_format("%sが行く手をはばんでいるようだ。", name);
3416 msg_format("You feel %s %s blocking your way.",
3417 is_a_vowel(name[0]) ? "an" : "a", name);
3420 c_ptr->info |= (CAVE_MARK);
3428 /* Boundary floor mimic */
3429 if (boundary_floor(c_ptr, f_ptr, mimic_f_ptr))
3431 msg_print(_("それ以上先には進めない。", "You cannot go any more."));
3432 if (!(p_ptr->confused || p_ptr->stun || p_ptr->image))
3436 /* Wall (or secret door) */
3439 #ifdef ALLOW_EASY_OPEN
3441 if (easy_open && is_closed_door(feat) && easy_open_door(y, x)) return;
3442 #endif /* ALLOW_EASY_OPEN */
3445 msg_format("%sが行く手をはばんでいる。", name);
3447 msg_format("There is %s %s blocking your way.",
3448 is_a_vowel(name[0]) ? "an" : "a", name);
3452 * Well, it makes sense that you lose time bumping into
3453 * a wall _if_ you are confused, stunned or blind; but
3454 * typing mistakes should not cost you a turn...
3456 if (!(p_ptr->confused || p_ptr->stun || p_ptr->image))
3461 /* Disturb the player */
3465 if (!boundary_floor(c_ptr, f_ptr, mimic_f_ptr)) sound(SOUND_HITWALL);
3468 /* Normal movement */
3469 if (oktomove && !pattern_seq(py, px, y, x))
3471 if (!(p_ptr->confused || p_ptr->stun || p_ptr->image))
3476 /* To avoid a loop with running */
3482 /* Normal movement */
3485 u32b mpe_mode = MPE_ENERGY_USE;
3489 if (!process_warning(x, y))
3498 msg_format(_("%sを押し退けた。", "You push past %s."), m_name);
3501 /* Change oldpx and oldpy to place the player well when going back to big mode */
3502 if (p_ptr->wild_mode)
3504 if (ddy[dir] > 0) p_ptr->oldpy = 1;
3505 if (ddy[dir] < 0) p_ptr->oldpy = MAX_HGT - 2;
3506 if (ddy[dir] == 0) p_ptr->oldpy = MAX_HGT / 2;
3507 if (ddx[dir] > 0) p_ptr->oldpx = 1;
3508 if (ddx[dir] < 0) p_ptr->oldpx = MAX_WID - 2;
3509 if (ddx[dir] == 0) p_ptr->oldpx = MAX_WID / 2;
3512 if (p_can_kill_walls)
3514 cave_alter_feat(y, x, FF_HURT_DISI);
3516 /* Update some things -- similar to GF_KILL_WALL */
3517 p_ptr->update |= (PU_FLOW);
3521 /* sound(SOUND_WALK); */
3523 #ifdef ALLOW_EASY_DISARM /* TNB */
3525 if (do_pickup != always_pickup) mpe_mode |= MPE_DO_PICKUP;
3527 #else /* ALLOW_EASY_DISARM -- TNB */
3529 if (do_pickup) mpe_mode |= MPE_DO_PICKUP;
3531 #endif /* ALLOW_EASY_DISARM -- TNB */
3533 if (break_trap) mpe_mode |= MPE_BREAK_TRAP;
3535 /* Move the player */
3536 (void)move_player_effect(y, x, mpe_mode);
3541 static bool ignore_avoid_run;
3544 * @brief ダッシュ移動処理中、移動先のマスが既知の壁かどうかを判定する /
3545 * Hack -- Check for a "known wall" (see below)
3546 * @param dir 想定する移動方向ID
3549 * @return 移動先が既知の壁ならばTRUE
3551 static int see_wall(int dir, int y, int x)
3555 /* Get the new location */
3559 /* Illegal grids are not known walls */
3560 if (!in_bounds2(y, x)) return (FALSE);
3563 c_ptr = &cave[y][x];
3565 /* Must be known to the player */
3566 if (c_ptr->info & (CAVE_MARK))
3568 /* Feature code (applying "mimic" field) */
3569 s16b feat = get_feat_mimic(c_ptr);
3570 feature_type *f_ptr = &f_info[feat];
3572 /* Wall grids are known walls */
3573 if (!player_can_enter(feat, 0)) return !have_flag(f_ptr->flags, FF_DOOR);
3575 /* Don't run on a tree unless explicitly requested */
3576 if (have_flag(f_ptr->flags, FF_AVOID_RUN) && !ignore_avoid_run)
3579 /* Don't run in a wall */
3580 if (!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY))
3581 return !have_flag(f_ptr->flags, FF_DOOR);
3589 * @brief ダッシュ移動処理中、移動先のマスか未知の地形かどうかを判定する /
3590 * Hack -- Check for an "unknown corner" (see below)
3591 * @param dir 想定する移動方向ID
3594 * @return 移動先が未知の地形ならばTRUE
3596 static int see_nothing(int dir, int y, int x)
3598 /* Get the new location */
3602 /* Illegal grids are unknown */
3603 if (!in_bounds2(y, x)) return (TRUE);
3605 /* Memorized grids are always known */
3606 if (cave[y][x].info & (CAVE_MARK)) return (FALSE);
3608 /* Viewable door/wall grids are known */
3609 if (player_can_see_bold(y, x)) return (FALSE);
3621 * Hack -- allow quick "cycling" through the legal directions
3623 static byte cycle[] =
3624 { 1, 2, 3, 6, 9, 8, 7, 4, 1, 2, 3, 6, 9, 8, 7, 4, 1 };
3627 * Hack -- map each direction into the "middle" of the "cycle[]" array
3629 static byte chome[] =
3630 { 0, 8, 9, 10, 7, 0, 11, 6, 5, 4 };
3633 * The direction we are running
3635 static byte find_current;
3638 * The direction we came from
3640 static byte find_prevdir;
3643 * We are looking for open area
3645 static bool find_openarea;
3648 * We are looking for a break
3650 static bool find_breakright;
3651 static bool find_breakleft;
3656 * @brief ダッシュ処理の導入 /
3657 * Initialize the running algorithm for a new direction.
3660 * Diagonal Corridor -- allow diaginal entry into corridors.\n
3662 * Blunt Corridor -- If there is a wall two spaces ahead and\n
3663 * we seem to be in a corridor, then force a turn into the side\n
3664 * corridor, must be moving straight into a corridor here. ???\n
3666 * Diagonal Corridor Blunt Corridor (?)\n
3671 static void run_init(int dir)
3673 int row, col, deepleft, deepright;
3674 int i, shortleft, shortright;
3677 /* Save the direction */
3680 /* Assume running straight */
3683 /* Assume looking for open area */
3684 find_openarea = TRUE;
3686 /* Assume not looking for breaks */
3687 find_breakright = find_breakleft = FALSE;
3689 /* Assume no nearby walls */
3690 deepleft = deepright = FALSE;
3691 shortright = shortleft = FALSE;
3696 /* Find the destination grid */
3697 row = py + ddy[dir];
3698 col = px + ddx[dir];
3700 ignore_avoid_run = cave_have_flag_bold(row, col, FF_AVOID_RUN);
3702 /* Extract cycle index */
3705 /* Check for walls */
3706 if (see_wall(cycle[i+1], py, px))
3708 find_breakleft = TRUE;
3711 else if (see_wall(cycle[i+1], row, col))
3713 find_breakleft = TRUE;
3717 /* Check for walls */
3718 if (see_wall(cycle[i-1], py, px))
3720 find_breakright = TRUE;
3723 else if (see_wall(cycle[i-1], row, col))
3725 find_breakright = TRUE;
3729 /* Looking for a break */
3730 if (find_breakleft && find_breakright)
3732 /* Not looking for open area */
3733 find_openarea = FALSE;
3735 /* Hack -- allow angled corridor entry */
3738 if (deepleft && !deepright)
3740 find_prevdir = cycle[i - 1];
3742 else if (deepright && !deepleft)
3744 find_prevdir = cycle[i + 1];
3748 /* Hack -- allow blunt corridor entry */
3749 else if (see_wall(cycle[i], row, col))
3751 if (shortleft && !shortright)
3753 find_prevdir = cycle[i - 2];
3755 else if (shortright && !shortleft)
3757 find_prevdir = cycle[i + 2];
3765 * @brief ダッシュ移動が継続できるかどうかの判定 /
3766 * Update the current "run" path
3768 * ダッシュ移動が継続できるならばTRUEを返す。
3769 * Return TRUE if the running should be stopped
3771 static bool run_test(void)
3773 int prev_dir, new_dir, check_dir = 0;
3776 int option = 0, option2 = 0;
3779 feature_type *f_ptr;
3781 /* Where we came from */
3782 prev_dir = find_prevdir;
3785 /* Range of newly adjacent grids */
3786 max = (prev_dir & 0x01) + 1;
3788 /* break run when leaving trap detected region */
3789 if ((disturb_trap_detect || alert_trap_detect)
3790 && p_ptr->dtrap && !(cave[py][px].info & CAVE_IN_DETECT))
3792 /* No duplicate warning */
3793 p_ptr->dtrap = FALSE;
3795 /* You are just on the edge */
3796 if (!(cave[py][px].info & CAVE_UNSAFE))
3798 if (alert_trap_detect)
3800 msg_print(_("* 注意:この先はトラップの感知範囲外です! *", "*Leaving trap detect region!*"));
3803 if (disturb_trap_detect)
3811 /* Look at every newly adjacent square. */
3812 for (i = -max; i <= max; i++)
3814 s16b this_o_idx, next_o_idx = 0;
3817 new_dir = cycle[chome[prev_dir] + i];
3820 row = py + ddy[new_dir];
3821 col = px + ddx[new_dir];
3824 c_ptr = &cave[row][col];
3826 /* Feature code (applying "mimic" field) */
3827 feat = get_feat_mimic(c_ptr);
3828 f_ptr = &f_info[feat];
3830 /* Visible monsters abort running */
3833 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3835 /* Visible monster */
3836 if (m_ptr->ml) return (TRUE);
3839 /* Visible objects abort running */
3840 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
3844 /* Acquire object */
3845 o_ptr = &o_list[this_o_idx];
3847 /* Acquire next object */
3848 next_o_idx = o_ptr->next_o_idx;
3850 /* Visible object */
3851 if (o_ptr->marked & OM_FOUND) return (TRUE);
3854 /* Assume unknown */
3857 /* Check memorized grids */
3858 if (c_ptr->info & (CAVE_MARK))
3860 bool notice = have_flag(f_ptr->flags, FF_NOTICE);
3862 if (notice && have_flag(f_ptr->flags, FF_MOVE))
3865 if (find_ignore_doors && have_flag(f_ptr->flags, FF_DOOR) && have_flag(f_ptr->flags, FF_CLOSE))
3867 /* Option -- ignore */
3872 else if (find_ignore_stairs && have_flag(f_ptr->flags, FF_STAIRS))
3874 /* Option -- ignore */
3879 else if (have_flag(f_ptr->flags, FF_LAVA) && (p_ptr->immune_fire || IS_INVULN()))
3886 else if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP) &&
3887 (p_ptr->levitation || p_ptr->can_swim || (p_ptr->total_weight <= weight_limit())))
3894 /* Interesting feature */
3895 if (notice) return (TRUE);
3897 /* The grid is "visible" */
3901 /* Analyze unknown grids and floors considering mimic */
3902 if (inv || !see_wall(0, row, col))
3904 /* Looking for open area */
3910 /* The first new direction. */
3916 /* Three new directions. Stop running. */
3922 /* Two non-adjacent new directions. Stop running. */
3923 else if (option != cycle[chome[prev_dir] + i - 1])
3928 /* Two new (adjacent) directions (case 1) */
3929 else if (new_dir & 0x01)
3931 check_dir = cycle[chome[prev_dir] + i - 2];
3935 /* Two new (adjacent) directions (case 2) */
3938 check_dir = cycle[chome[prev_dir] + i + 1];
3944 /* Obstacle, while looking for open area */
3951 /* Break to the right */
3952 find_breakright = TRUE;
3957 /* Break to the left */
3958 find_breakleft = TRUE;
3964 /* Looking for open area */
3967 /* Hack -- look again */
3968 for (i = -max; i < 0; i++)
3970 /* Unknown grid or non-wall */
3971 if (!see_wall(cycle[chome[prev_dir] + i], py, px))
3973 /* Looking to break right */
3974 if (find_breakright)
3983 /* Looking to break left */
3991 /* Hack -- look again */
3992 for (i = max; i > 0; i--)
3994 /* Unknown grid or non-wall */
3995 if (!see_wall(cycle[chome[prev_dir] + i], py, px))
3997 /* Looking to break left */
4007 /* Looking to break right */
4008 if (find_breakright)
4016 /* Not looking for open area */
4028 /* Primary option */
4029 find_current = option;
4031 /* No other options */
4032 find_prevdir = option;
4035 /* Two options, examining corners */
4038 /* Primary option */
4039 find_current = option;
4041 /* Hack -- allow curving */
4042 find_prevdir = option2;
4045 /* Two options, pick one */
4048 /* Get next location */
4049 row = py + ddy[option];
4050 col = px + ddx[option];
4052 /* Don't see that it is closed off. */
4053 /* This could be a potential corner or an intersection. */
4054 if (!see_wall(option, row, col) ||
4055 !see_wall(check_dir, row, col))
4057 /* Can not see anything ahead and in the direction we */
4058 /* are turning, assume that it is a potential corner. */
4059 if (see_nothing(option, row, col) &&
4060 see_nothing(option2, row, col))
4062 find_current = option;
4063 find_prevdir = option2;
4066 /* STOP: we are next to an intersection or a room */
4073 /* This corner is seen to be enclosed; we cut the corner. */
4076 find_current = option2;
4077 find_prevdir = option2;
4080 /* This corner is seen to be enclosed, and we */
4081 /* deliberately go the long way. */
4084 find_current = option;
4085 find_prevdir = option2;
4090 /* About to hit a known wall, stop */
4091 if (see_wall(find_current, py, px))
4103 * @brief 継続的なダッシュ処理 /
4104 * Take one step along the current "run" path
4105 * @param dir 移動を試みる方向ID
4108 void run_step(int dir)
4113 /* Ignore AVOID_RUN on a first step */
4114 ignore_avoid_run = TRUE;
4116 /* Hack -- do not start silly run */
4117 if (see_wall(dir, py, px))
4120 msg_print(_("その方向には走れません。", "You cannot run in that direction."));
4147 /* Decrease the run counter */
4148 if (--running <= 0) return;
4153 /* Move the player, using the "pickup" flag */
4154 #ifdef ALLOW_EASY_DISARM /* TNB */
4156 move_player(find_current, FALSE, FALSE);
4158 #else /* ALLOW_EASY_DISARM -- TNB */
4160 move_player(find_current, always_pickup, FALSE);
4162 #endif /* ALLOW_EASY_DISARM -- TNB */
4164 if (player_bold(p_ptr->run_py, p_ptr->run_px))
4176 * @brief トラベル機能の判定処理 /
4177 * Test for traveling
4178 * @param prev_dir 前回移動を行った元の方角ID
4181 static int travel_test(int prev_dir)
4185 const cave_type *c_ptr;
4188 /* Cannot travel when blind */
4189 if (p_ptr->blind || no_lite())
4191 msg_print(_("目が見えない!", "You cannot see!"));
4195 /* break run when leaving trap detected region */
4196 if ((disturb_trap_detect || alert_trap_detect)
4197 && p_ptr->dtrap && !(cave[py][px].info & CAVE_IN_DETECT))
4199 /* No duplicate warning */
4200 p_ptr->dtrap = FALSE;
4202 /* You are just on the edge */
4203 if (!(cave[py][px].info & CAVE_UNSAFE))
4205 if (alert_trap_detect)
4207 msg_print(_("* 注意:この先はトラップの感知範囲外です! *", "*Leaving trap detect region!*"));
4210 if (disturb_trap_detect)
4218 /* Range of newly adjacent grids */
4219 max = (prev_dir & 0x01) + 1;
4221 /* Look at every newly adjacent square. */
4222 for (i = -max; i <= max; i++)
4225 int dir = cycle[chome[prev_dir] + i];
4228 int row = py + ddy[dir];
4229 int col = px + ddx[dir];
4232 c_ptr = &cave[row][col];
4234 /* Visible monsters abort running */
4237 monster_type *m_ptr = &m_list[c_ptr->m_idx];
4239 /* Visible monster */
4240 if (m_ptr->ml) return (0);
4245 /* Travel cost of current grid */
4246 cost = travel.cost[py][px];
4248 /* Determine travel direction */
4249 for (i = 0; i < 8; ++ i) {
4250 int dir_cost = travel.cost[py+ddy_ddd[i]][px+ddx_ddd[i]];
4252 if (dir_cost < cost)
4259 if (!new_dir) return (0);
4261 /* Access newly move grid */
4262 c_ptr = &cave[py+ddy[new_dir]][px+ddx[new_dir]];
4264 /* Close door abort traveling */
4265 if (!easy_open && is_closed_door(c_ptr->feat)) return (0);
4267 /* Visible and unignorable trap abort tarveling */
4268 if (!c_ptr->mimic && !trap_can_be_ignored(c_ptr->feat)) return (0);
4276 * @brief トラベル機能の実装 /
4280 void travel_step(void)
4282 /* Get travel direction */
4283 travel.dir = travel_test(travel.dir);
4288 if (travel.run == 255)
4290 msg_print(_("道筋が見つかりません!", "No route is found!"));
4291 travel.y = travel.x = 0;
4299 move_player(travel.dir, always_pickup, FALSE);
4301 if ((py == travel.y) && (px == travel.x))
4304 travel.y = travel.x = 0;
4306 else if (travel.run > 0)
4310 Term_xtra(TERM_XTRA_DELAY, delay_factor);