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 "specific-object/death-scythe.h"
9 #include "sv-definition/sv-weapon-types.h"
10 #include "view/display-messages.h"
13 * @brief プレイヤーからモンスターへの打撃命中判定 /
14 * Determine if the player "hits" a monster (normal combat).
17 * @param visible 目標を視界に捕らえているならばTRUEを指定
18 * @return 命中と判定された場合TRUEを返す
19 * @note Always miss 5%, always hit 5%, otherwise random.
21 bool test_hit_norm(player_type *attacker_ptr, HIT_RELIABILITY chance, ARMOUR_CLASS ac, bool visible)
24 chance = (chance + 1) / 2;
25 return hit_chance(attacker_ptr, chance, ac) >= randint1(100);
29 * @brief モンスターへの命中率の計算
30 * @param player_ptr プレーヤーへの参照ポインタ
35 PERCENTAGE hit_chance(player_type *attacker_ptr, HIT_RELIABILITY reli, ARMOUR_CLASS ac)
37 PERCENTAGE chance = 5, chance_left = 90;
40 if (attacker_ptr->pseikaku == PERSONALITY_LAZY)
41 chance_left = (chance_left * 19 + 9) / 20;
42 chance += (100 - ((ac * 75) / reli)) * chance_left / 100;
49 * @brief モンスター打撃の命中を判定する /
50 * Determine if a monster attack against the player succeeds.
51 * @param power 打撃属性毎の基本命中値
52 * @param level モンスターのレベル
53 * @param stun モンスターの朦朧値
56 * Always miss 5% of the time, Always hit 5% of the time.
57 * Otherwise, match monster power against player armor.
59 int check_hit_from_monster_to_player(player_type *target_ptr, int power, DEPTH level, int stun)
61 int k = randint0(100);
62 if (stun && one_in_(2))
66 int i = (power + (level * 3));
68 int ac = target_ptr->ac + target_ptr->to_a;
69 if (target_ptr->special_attack & ATTACK_SUIKEN)
70 ac += (target_ptr->lev * 2);
72 if ((i > 0) && (randint1(i) > ((ac * 3) / 4)))
78 * @brief モンスターから敵モンスターへの命中判定
79 * @param power 打撃属性による基本命中値
80 * @param level 攻撃側モンスターのレベル
81 * @param ac 目標モンスターのAC
82 * @param stun 攻撃側モンスターが朦朧状態ならTRUEを返す
83 * @return 命中ならばTRUEを返す
85 int check_hit_from_monster_to_monster(int power, DEPTH level, ARMOUR_CLASS ac, int stun)
87 int k = randint0(100);
88 if (stun && one_in_(2))
92 int i = (power + (level * 3));
94 if ((i > 0) && (randint1(i) > ((ac * 3) / 4)))
100 * @brief 攻撃が当たるかどうかを判定する
101 * @param attacker_ptr プレーヤーへの参照ポインタ
102 * @param pa_ptr 直接攻撃構造体への参照ポインタ
103 * @param chance 基本命中値
106 static bool decide_attack_hit(player_type *attacker_ptr, player_attack_type *pa_ptr, int chance)
108 bool success_hit = FALSE;
109 object_type *o_ptr = &attacker_ptr->inventory_list[INVEN_RARM + pa_ptr->hand];
110 monster_race *r_ptr = &r_info[pa_ptr->m_ptr->r_idx];
111 if (((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_POISON_NEEDLE)) || (pa_ptr->mode == HISSATSU_KYUSHO)) {
114 if (attacker_ptr->right_hand_weapon && attacker_ptr->left_hand_weapon)
117 if (pa_ptr->mode == HISSATSU_3DAN)
120 success_hit = one_in_(n);
121 } else if ((attacker_ptr->pclass == CLASS_NINJA) && ((pa_ptr->backstab || pa_ptr->surprise_attack) && !(r_ptr->flagsr & RFR_RES_ALL)))
124 success_hit = test_hit_norm(attacker_ptr, chance, r_ptr->ac, pa_ptr->m_ptr->ml);
126 if ((pa_ptr->mode == HISSATSU_MAJIN) && one_in_(2))
133 * @brief 直接攻撃の命中を処理するメインルーチン
134 * @param attacker_ptr プレーヤーへの参照ポインタ
135 * @param pa_ptr 直接攻撃構造体への参照ポインタ
136 * @param chance 基本命中値
137 * @return 当たればTRUE、外れればFALSE
139 bool process_attack_hit(player_type *attacker_ptr, player_attack_type *pa_ptr, int chance)
141 object_type *o_ptr = &attacker_ptr->inventory_list[INVEN_RARM + pa_ptr->hand];
142 if (decide_attack_hit(attacker_ptr, pa_ptr, chance))
145 pa_ptr->backstab = FALSE; /* Clumsy! */
146 pa_ptr->surprise_attack = FALSE; /* Clumsy! */
148 if ((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE) && one_in_(3)) {
149 process_death_scythe_reflection(attacker_ptr, pa_ptr);
152 msg_format(_("ミス! %sにかわされた。", "You miss %s."), pa_ptr->m_name);