OSDN Git Service

[Refactor] #40514 calc_conf_damage_rate() 実装. / Implement calc_conf_damage_rate().
authordeskull <deskull@users.sourceforge.jp>
Sun, 13 Sep 2020 10:54:44 +0000 (19:54 +0900)
committerdeskull <deskull@users.sourceforge.jp>
Sun, 13 Sep 2020 10:54:44 +0000 (19:54 +0900)
src/effect/effect-player-resist-hurt.c
src/object/warning.c
src/player/player-status-resist.c
src/player/player-status-resist.h

index 03fc5f3..852b87f 100644 (file)
@@ -263,10 +263,10 @@ void effect_player_confusion(player_type *target_ptr, effect_player_type *ep_ptr
 {
     if (target_ptr->blind)
         msg_print(_("何か混乱するもので攻撃された!", "You are hit by something puzzling!"));
-    if (target_ptr->resist_conf) {
-        ep_ptr->dam *= 5;
-        ep_ptr->dam /= (randint1(4) + 7);
-    } else if (!check_multishadow(target_ptr)) {
+
+    ep_ptr->dam = ep_ptr->dam * calc_conf_damage_rate(target_ptr, CALC_RAND) / 100;
+
+    if (!target_ptr->resist_conf && !check_multishadow(target_ptr)) {
         (void)set_confused(target_ptr, target_ptr->confused + randint1(20) + 10);
     }
 
index db52d73..c18ab91 100644 (file)
@@ -152,8 +152,7 @@ static void spell_damcalc(player_type *target_ptr, monster_type *m_ptr, EFFECT_I
         break;
 
     case GF_CONFUSION:
-        if (target_ptr->resist_conf)
-            dam = dam * 5 / 8; /* Worst case of 5 / (d4 + 7) */
+        dam = dam * calc_conf_damage_rate(target_ptr, CALC_MAX) / 100;
         break;
 
     case GF_CHAOS:
index f0014f1..0d4e1d1 100644 (file)
@@ -238,6 +238,18 @@ PERCENTAGE calc_sound_damage_rate(player_type *creature_ptr, rate_calc_type_mode
     return per;
 }
 
+PERCENTAGE calc_conf_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
+{
+    PERCENTAGE per = 100;
+
+    if (creature_ptr->resist_conf) {
+        per *= 500;
+        per /= randrate(4, 7, mode);
+    }
+
+    return per;
+}
+
 PERCENTAGE calc_nether_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
 {
     PERCENTAGE per = 100;
index 6298bba..6a7fa78 100644 (file)
@@ -17,6 +17,8 @@ PERCENTAGE calc_nuke_damage_rate(player_type *creature_ptr);
 PERCENTAGE calc_lite_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode);
 PERCENTAGE calc_dark_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode);
 PERCENTAGE calc_shards_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode);
+PERCENTAGE calc_sound_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode);
+PERCENTAGE calc_conf_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode);
 PERCENTAGE calc_nether_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode);
 PERCENTAGE calc_holy_fire_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode);
 PERCENTAGE calc_hell_fire_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode);