1 #include "combat/attack-accuracy.h"
2 #include "inventory/inventory-slot-types.h"
3 #include "main/sound-definitions-table.h"
4 #include "main/sound-of-music.h"
5 #include "monster-race/monster-race.h"
6 #include "monster-race/race-flags-resistance.h"
7 #include "player/attack-defense-types.h"
8 #include "player/player-status-flags.h"
9 #include "specific-object/death-scythe.h"
10 #include "sv-definition/sv-weapon-types.h"
11 #include "view/display-messages.h"
14 * @brief プレイヤーからモンスターへの打撃命中判定 /
15 * Determine if the player "hits" a monster (normal combat).
18 * @param visible 目標を視界に捕らえているならばTRUEを指定
19 * @return 命中と判定された場合TRUEを返す
20 * @note Always miss 5%, always hit 5%, otherwise random.
22 bool test_hit_norm(player_type *attacker_ptr, HIT_RELIABILITY chance, ARMOUR_CLASS ac, bool visible)
25 chance = (chance + 1) / 2;
26 return hit_chance(attacker_ptr, chance, ac) >= randint1(100);
30 * @brief モンスターへの命中率の計算
31 * @param player_ptr プレーヤーへの参照ポインタ
36 PERCENTAGE hit_chance(player_type *attacker_ptr, HIT_RELIABILITY reli, ARMOUR_CLASS ac)
38 PERCENTAGE chance = 5, chance_left = 90;
41 if (attacker_ptr->pseikaku == PERSONALITY_LAZY)
42 chance_left = (chance_left * 19 + 9) / 20;
43 chance += (100 - ((ac * 75) / reli)) * chance_left / 100;
50 * @brief モンスター打撃の命中を判定する /
51 * Determine if a monster attack against the player succeeds.
52 * @param power 打撃属性毎の基本命中値
53 * @param level モンスターのレベル
54 * @param stun モンスターの朦朧値
57 * Always miss 5% of the time, Always hit 5% of the time.
58 * Otherwise, match monster power against player armor.
60 int check_hit_from_monster_to_player(player_type *target_ptr, int power, DEPTH level, int stun)
62 int k = randint0(100);
63 if (stun && one_in_(2))
67 int i = (power + (level * 3));
69 int ac = target_ptr->ac + target_ptr->to_a;
70 if (target_ptr->special_attack & ATTACK_SUIKEN)
71 ac += (target_ptr->lev * 2);
73 if ((i > 0) && (randint1(i) > ((ac * 3) / 4)))
79 * @brief モンスターから敵モンスターへの命中判定
80 * @param power 打撃属性による基本命中値
81 * @param level 攻撃側モンスターのレベル
82 * @param ac 目標モンスターのAC
83 * @param stun 攻撃側モンスターが朦朧状態ならTRUEを返す
84 * @return 命中ならばTRUEを返す
86 int check_hit_from_monster_to_monster(int power, DEPTH level, ARMOUR_CLASS ac, int stun)
88 int k = randint0(100);
89 if (stun && one_in_(2))
93 int i = (power + (level * 3));
95 if ((i > 0) && (randint1(i) > ((ac * 3) / 4)))
101 * @brief 攻撃が当たるかどうかを判定する
102 * @param attacker_ptr プレーヤーへの参照ポインタ
103 * @param pa_ptr 直接攻撃構造体への参照ポインタ
104 * @param chance 基本命中値
107 static bool decide_attack_hit(player_type *attacker_ptr, player_attack_type *pa_ptr, int chance)
109 bool success_hit = FALSE;
110 object_type *o_ptr = &attacker_ptr->inventory_list[INVEN_MAIN_HAND + pa_ptr->hand];
111 monster_race *r_ptr = &r_info[pa_ptr->m_ptr->r_idx];
112 if (((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_POISON_NEEDLE)) || (pa_ptr->mode == HISSATSU_KYUSHO)) {
115 if (has_right_hand_weapon(attacker_ptr) && has_left_hand_weapon(attacker_ptr))
118 if (pa_ptr->mode == HISSATSU_3DAN)
121 success_hit = one_in_(n);
122 } else if ((attacker_ptr->pclass == CLASS_NINJA) && ((pa_ptr->backstab || pa_ptr->surprise_attack) && !(r_ptr->flagsr & RFR_RES_ALL)))
125 success_hit = test_hit_norm(attacker_ptr, chance, r_ptr->ac, pa_ptr->m_ptr->ml);
127 if ((pa_ptr->mode == HISSATSU_MAJIN) && one_in_(2))
134 * @brief 直接攻撃の命中を処理するメインルーチン
135 * @param attacker_ptr プレーヤーへの参照ポインタ
136 * @param pa_ptr 直接攻撃構造体への参照ポインタ
137 * @param chance 基本命中値
138 * @return 当たればTRUE、外れればFALSE
140 bool process_attack_hit(player_type *attacker_ptr, player_attack_type *pa_ptr, int chance)
142 object_type *o_ptr = &attacker_ptr->inventory_list[INVEN_MAIN_HAND + pa_ptr->hand];
143 if (decide_attack_hit(attacker_ptr, pa_ptr, chance))
146 pa_ptr->backstab = FALSE; /* Clumsy! */
147 pa_ptr->surprise_attack = FALSE; /* Clumsy! */
149 if ((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE) && one_in_(3)) {
150 process_death_scythe_reflection(attacker_ptr, pa_ptr);
153 msg_format(_("ミス! %sにかわされた。", "You miss %s."), pa_ptr->m_name);