OSDN Git Service

[Refactor] #40514 calc_disenchant_damage_rate() 実装. / Implement calc_disenchant_damag...
authordeskull <deskull@users.sourceforge.jp>
Sun, 13 Sep 2020 11:03:57 +0000 (20:03 +0900)
committerdeskull <deskull@users.sourceforge.jp>
Sun, 13 Sep 2020 11:03:57 +0000 (20:03 +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 992d205..286f76d 100644 (file)
@@ -275,10 +275,10 @@ void effect_player_disenchant(player_type *target_ptr, effect_player_type *ep_pt
 {
     if (target_ptr->blind)
         msg_print(_("何かさえないもので攻撃された!", "You are hit by something static!"));
-    if (target_ptr->resist_disen) {
-        ep_ptr->dam *= 6;
-        ep_ptr->dam /= (randint1(4) + 7);
-    } else if (!check_multishadow(target_ptr)) {
+
+    ep_ptr->dam = ep_ptr->dam * calc_disenchant_damage_rate(target_ptr, CALC_RAND) / 100;
+
+    if (!target_ptr->resist_disen && !check_multishadow(target_ptr)) {
         (void)apply_disenchant(target_ptr, 0);
     }
 
index 315be1c..30a1200 100644 (file)
@@ -168,8 +168,7 @@ static void spell_damcalc(player_type *target_ptr, monster_type *m_ptr, EFFECT_I
         break;
 
     case GF_DISENCHANT:
-        if (target_ptr->resist_disen)
-            dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
+        dam = dam * calc_disenchant_damage_rate(target_ptr, CALC_MAX) / 100;
         break;
 
     case GF_NEXUS:
index 94fd8e0..57f8120 100644 (file)
@@ -262,6 +262,18 @@ PERCENTAGE calc_chaos_damage_rate(player_type *creature_ptr, rate_calc_type_mode
     return per;
 }
 
+PERCENTAGE calc_disenchant_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode)
+{
+    PERCENTAGE per = 100;
+
+    if (creature_ptr->resist_disen) {
+        per *= 600;
+        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 03267dc..15f49e6 100644 (file)
@@ -21,5 +21,6 @@ PERCENTAGE calc_sound_damage_rate(player_type *creature_ptr, rate_calc_type_mode
 PERCENTAGE calc_conf_damage_rate(player_type *creature_ptr, rate_calc_type_mode mode);
 PERCENTAGE calc_chaos_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_disenchant_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);