OSDN Git Service

[Refactor] #40416 Moved process_attack_hit() from player-attack.c to attack-accuracy.c/h
authorHourier <hourier@users.sourceforge.jp>
Sat, 23 May 2020 01:32:00 +0000 (10:32 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sat, 23 May 2020 01:32:00 +0000 (10:32 +0900)
src/combat/attack-accuracy.c
src/combat/attack-accuracy.h
src/combat/player-attack.c

index c8bdc92..0f7befe 100644 (file)
@@ -1,5 +1,6 @@
 #include "system/angband.h"
 #include "combat/attack-accuracy.h"
+#include "main/sound-definitions-table.h"
 
 /*!
  * @brief プレイヤーからモンスターへの打撃命中判定 /
@@ -87,3 +88,62 @@ int check_hit_from_monster_to_monster(int power, DEPTH level, ARMOUR_CLASS ac, i
         return TRUE;
     return FALSE;
 }
+
+/*!
+ * @brief 攻撃が当たるかどうかを判定する
+ * @param attacker_ptr プレーヤーへの参照ポインタ
+ * @param pa_ptr 直接攻撃構造体への参照ポインタ
+ * @param chance 基本命中値
+ * @return なし
+ */
+static bool decide_attack_hit(player_type *attacker_ptr, player_attack_type *pa_ptr, int chance)
+{
+    bool success_hit = FALSE;
+    object_type *o_ptr = &attacker_ptr->inventory_list[INVEN_RARM + pa_ptr->hand];
+    monster_race *r_ptr = &r_info[pa_ptr->m_ptr->r_idx];
+    if (((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_POISON_NEEDLE)) || (pa_ptr->mode == HISSATSU_KYUSHO)) {
+        int n = 1;
+
+        if (attacker_ptr->migite && attacker_ptr->hidarite)
+            n *= 2;
+
+        if (pa_ptr->mode == HISSATSU_3DAN)
+            n *= 2;
+
+        success_hit = one_in_(n);
+    } else if ((attacker_ptr->pclass == CLASS_NINJA) && ((pa_ptr->backstab || pa_ptr->suprise_attack) && !(r_ptr->flagsr & RFR_RES_ALL)))
+        success_hit = TRUE;
+    else
+        success_hit = test_hit_norm(attacker_ptr, chance, r_ptr->ac, pa_ptr->m_ptr->ml);
+
+    if ((pa_ptr->mode == HISSATSU_MAJIN) && one_in_(2))
+        success_hit = FALSE;
+
+    return success_hit;
+}
+
+/*!
+ * @brief 直接攻撃の命中を処理するメインルーチン
+ * @param attacker_ptr プレーヤーへの参照ポインタ
+ * @param pa_ptr 直接攻撃構造体への参照ポインタ
+ * @param chance 基本命中値
+ * @return 当たればTRUE、外れればFALSE
+ */
+bool process_attack_hit(player_type *attacker_ptr, player_attack_type *pa_ptr, int chance)
+{
+    object_type *o_ptr = &attacker_ptr->inventory_list[INVEN_RARM + pa_ptr->hand];
+    if (decide_attack_hit(attacker_ptr, pa_ptr, chance))
+        return TRUE;
+
+    pa_ptr->backstab = FALSE; /* Clumsy! */
+    pa_ptr->suprise_attack = FALSE; /* Clumsy! */
+
+    if ((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE) && one_in_(3)) {
+        process_death_scythe_reflection(attacker_ptr, pa_ptr);
+    } else {
+        sound(SOUND_MISS);
+        msg_format(_("ミス! %sにかわされた。", "You miss %s."), pa_ptr->m_name);
+    }
+
+    return FALSE;
+}
index cb75a8b..e673d9a 100644 (file)
@@ -1,6 +1,9 @@
 #pragma once
 
+#include "combat/player-attack-util.h"
+
 bool test_hit_norm(player_type *attacker_ptr, HIT_RELIABILITY chance, ARMOUR_CLASS ac, bool visible);
 PERCENTAGE hit_chance(player_type *attacker_ptr, HIT_RELIABILITY chance, ARMOUR_CLASS ac);
 int check_hit_from_monster_to_player(player_type *target_ptr, int power, DEPTH level, int stun);
 int check_hit_from_monster_to_monster(int power, DEPTH level, ARMOUR_CLASS ac, int stun);
+bool process_attack_hit(player_type *attacker_ptr, player_attack_type *pa_ptr, int chance);
index 5f6e211..7f91bf6 100644 (file)
@@ -193,65 +193,6 @@ static void calc_num_blow(player_type *attacker_ptr, player_attack_type *pa_ptr)
         pa_ptr->num_blow = 1;
 }
 
-/*!
- * @brief 攻撃が当たるかどうかを判定する
- * @param attacker_ptr プレーヤーへの参照ポインタ
- * @param pa_ptr 直接攻撃構造体への参照ポインタ
- * @param chance 基本命中値
- * @return なし
- */
-static bool decide_attack_hit(player_type *attacker_ptr, player_attack_type *pa_ptr, int chance)
-{
-    bool success_hit = FALSE;
-    object_type *o_ptr = &attacker_ptr->inventory_list[INVEN_RARM + pa_ptr->hand];
-    monster_race *r_ptr = &r_info[pa_ptr->m_ptr->r_idx];
-    if (((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_POISON_NEEDLE)) || (pa_ptr->mode == HISSATSU_KYUSHO)) {
-        int n = 1;
-
-        if (attacker_ptr->migite && attacker_ptr->hidarite)
-            n *= 2;
-
-        if (pa_ptr->mode == HISSATSU_3DAN)
-            n *= 2;
-
-        success_hit = one_in_(n);
-    } else if ((attacker_ptr->pclass == CLASS_NINJA) && ((pa_ptr->backstab || pa_ptr->suprise_attack) && !(r_ptr->flagsr & RFR_RES_ALL)))
-        success_hit = TRUE;
-    else
-        success_hit = test_hit_norm(attacker_ptr, chance, r_ptr->ac, pa_ptr->m_ptr->ml);
-
-    if ((pa_ptr->mode == HISSATSU_MAJIN) && one_in_(2))
-        success_hit = FALSE;
-
-    return success_hit;
-}
-
-/*!
- * @brief 直接攻撃の命中を処理するメインルーチン
- * @param attacker_ptr プレーヤーへの参照ポインタ
- * @param pa_ptr 直接攻撃構造体への参照ポインタ
- * @param chance 基本命中値
- * @return 当たればTRUE、外れればFALSE
- */
-static bool process_attack_hit(player_type *attacker_ptr, player_attack_type *pa_ptr, int chance)
-{
-    object_type *o_ptr = &attacker_ptr->inventory_list[INVEN_RARM + pa_ptr->hand];
-    if (decide_attack_hit(attacker_ptr, pa_ptr, chance))
-        return TRUE;
-
-    pa_ptr->backstab = FALSE; /* Clumsy! */
-    pa_ptr->suprise_attack = FALSE; /* Clumsy! */
-
-    if ((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE) && one_in_(3)) {
-        process_death_scythe_reflection(attacker_ptr, pa_ptr);
-    } else {
-        sound(SOUND_MISS);
-        msg_format(_("ミス! %sにかわされた。", "You miss %s."), pa_ptr->m_name);
-    }
-
-    return FALSE;
-}
-
 static void print_suprise_attack(player_attack_type *pa_ptr)
 {
     if (pa_ptr->backstab)