OSDN Git Service

[Refactor] #40416 Separated process_terrify_attack() from make_attack_normal()
authorHourier <hourier@users.sourceforge.jp>
Sun, 31 May 2020 05:48:04 +0000 (14:48 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sun, 31 May 2020 05:48:04 +0000 (14:48 +0900)
src/combat/monster-attack-player.c

index f54e08d..5f4d612 100644 (file)
@@ -219,6 +219,28 @@ static void process_blind_attack(player_type *target_ptr, monap_type *monap_ptr)
     monap_ptr->obvious = TRUE;
 }
 
+static void process_terrify_attack(player_type *target_ptr, monap_type *monap_ptr)
+{
+    if (check_multishadow(target_ptr))
+        return;
+
+    monster_race *r_ptr = &r_info[monap_ptr->m_ptr->r_idx];
+    if (target_ptr->resist_fear) {
+        msg_print(_("しかし恐怖に侵されなかった!", "You stand your ground!"));
+        monap_ptr->obvious = TRUE;
+        return;
+    }
+
+    if (randint0(100 + r_ptr->level / 2) < target_ptr->skill_sav) {
+        msg_print(_("しかし恐怖に侵されなかった!", "You stand your ground!"));
+        monap_ptr->obvious = TRUE;
+        return;
+    }
+
+    if (set_afraid(target_ptr, target_ptr->afraid + 3 + randint1(monap_ptr->rlev)))
+        monap_ptr->obvious = TRUE;
+}
+
 /*!
  * @brief モンスターからプレイヤーへの打撃処理 / Attack the player via physical attacks.
  * @param m_idx 打撃を行うモンスターのID
@@ -457,20 +479,7 @@ bool make_attack_normal(player_type *target_ptr, MONSTER_IDX m_idx)
                 if (target_ptr->is_dead)
                     break;
 
-                if (check_multishadow(target_ptr)) {
-                    /* Do nothing */
-                } else if (target_ptr->resist_fear) {
-                    msg_print(_("しかし恐怖に侵されなかった!", "You stand your ground!"));
-                    monap_ptr->obvious = TRUE;
-                } else if (randint0(100 + r_ptr->level / 2) < target_ptr->skill_sav) {
-                    msg_print(_("しかし恐怖に侵されなかった!", "You stand your ground!"));
-                    monap_ptr->obvious = TRUE;
-                } else {
-                    if (set_afraid(target_ptr, target_ptr->afraid + 3 + randint1(monap_ptr->rlev))) {
-                        monap_ptr->obvious = TRUE;
-                    }
-                }
-
+                process_terrify_attack(target_ptr, monap_ptr);
                 update_smart_learn(target_ptr, m_idx, DRS_FEAR);
                 break;
             }