OSDN Git Service

[Refactor] #40514 calc_to_damage() と calc_to_damage_display() を統合. / Merged calc_to_d...
authordeskull <deskull@users.sourceforge.jp>
Thu, 20 Aug 2020 16:39:07 +0000 (01:39 +0900)
committerdeskull <deskull@users.sourceforge.jp>
Thu, 20 Aug 2020 16:39:07 +0000 (01:39 +0900)
src/player/player-status.c

index 8714a41..ceda4fe 100644 (file)
@@ -133,8 +133,7 @@ static void calc_ind_status(player_type *creature_ptr, int status);
 static s16b calc_riding_bow_penalty(player_type *creature_ptr);
 static void put_equipment_warning(player_type *creature_ptr);
 
-static s16b calc_to_damage(player_type *creature_ptr, INVENTORY_IDX slot);
-static s16b calc_to_damage_display(player_type *creature_ptr, INVENTORY_IDX slot);
+static s16b calc_to_damage(player_type *creature_ptr, INVENTORY_IDX slot, bool is_true_value);
 static void calc_to_hit(player_type *creature_ptr, INVENTORY_IDX slot);
 static void calc_to_hit_display(player_type *creature_ptr, INVENTORY_IDX slot);
 
@@ -486,10 +485,10 @@ void calc_bonuses(player_type *creature_ptr)
     creature_ptr->skill_thn = calc_to_hit_melee(creature_ptr);
     creature_ptr->skill_thb = calc_to_hit_shoot(creature_ptr);
     creature_ptr->skill_tht = calc_to_hit_throw(creature_ptr);
-    creature_ptr->to_d[0] = calc_to_damage(creature_ptr, INVEN_RARM);
-    creature_ptr->to_d[1] = calc_to_damage(creature_ptr, INVEN_LARM);
-    creature_ptr->dis_to_d[0] = calc_to_damage_display(creature_ptr, INVEN_RARM);
-    creature_ptr->dis_to_d[1] = calc_to_damage_display(creature_ptr, INVEN_LARM);
+    creature_ptr->to_d[0] = calc_to_damage(creature_ptr, INVEN_RARM, TRUE);
+    creature_ptr->to_d[1] = calc_to_damage(creature_ptr, INVEN_LARM, TRUE);
+    creature_ptr->dis_to_d[0] = calc_to_damage(creature_ptr, INVEN_RARM, FALSE);
+    creature_ptr->dis_to_d[1] = calc_to_damage(creature_ptr, INVEN_LARM, FALSE);
     calc_to_hit(creature_ptr, INVEN_RARM);
     calc_to_hit(creature_ptr, INVEN_LARM);
     calc_to_hit_display(creature_ptr, INVEN_RARM);
@@ -2958,7 +2957,7 @@ void put_equipment_warning(player_type *creature_ptr)
     }
 }
 
-static s16b calc_to_damage(player_type *creature_ptr, INVENTORY_IDX slot)
+static s16b calc_to_damage(player_type *creature_ptr, INVENTORY_IDX slot, bool is_true_value)
 {
     object_type *o_ptr = &creature_ptr->inventory_list[slot];
     int id = slot - INVEN_RARM;
@@ -3007,23 +3006,15 @@ static s16b calc_to_damage(player_type *creature_ptr, INVENTORY_IDX slot)
         }
     }
 
-    if (get_default_hand(creature_ptr) == id) {
-        if ((is_martial_arts_mode(creature_ptr) && empty_hands(creature_ptr, FALSE) == (EMPTY_HAND_RARM | EMPTY_HAND_LARM))
-            || !is_disable_two_handed_bonus(creature_ptr, 0)) {
-            int bonus_to_d = 0;
-            bonus_to_d = ((int)(adj_str_td[creature_ptr->stat_ind[A_STR]]) - 128) / 2;
-            damage += MAX(bonus_to_d, 1);
-        }
-    }
-
-    // 武器以外の装備による修正
     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
-        int bonus_to_d;
+        int bonus_to_d = 0;
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx || o_ptr->tval == TV_CAPTURE || (i == INVEN_RARM && has_melee_weapon(creature_ptr, i))
             || (i == INVEN_LARM && has_melee_weapon(creature_ptr, i)) || i == INVEN_BOW)
             continue;
 
+               if (!object_is_known(o_ptr) && !is_true_value)
+            continue;
         bonus_to_d = o_ptr->to_d;
 
         if (creature_ptr->pclass == CLASS_NINJA) {
@@ -3032,114 +3023,31 @@ static s16b calc_to_damage(player_type *creature_ptr, INVENTORY_IDX slot)
         }
 
         if ((i == INVEN_LEFT || i == INVEN_RIGHT) && !have_two_handed_weapons(creature_ptr)) {
-            creature_ptr->to_d[i - INVEN_RIGHT] += (s16b)bonus_to_d;
-            if (object_is_known(o_ptr)) {
-                creature_ptr->dis_to_d[i - INVEN_RIGHT] += (s16b)bonus_to_d;
-            }
-            continue;
-        }
-
-        if (have_right_hand_weapon(creature_ptr) && have_left_hand_weapon(creature_ptr)) {
-            if (id == 0) damage += (bonus_to_d > 0) ? (bonus_to_d + 1) / 2 : bonus_to_d;
-            if (id == 1) damage += (bonus_to_d > 0) ? bonus_to_d / 2 : bonus_to_d;
-            continue;
-        } else if (id == get_default_hand(creature_ptr))
-                       damage += (s16b)bonus_to_d;
-    }
-
-       if (is_martial_arts_mode(creature_ptr) && (!heavy_armor(creature_ptr) || creature_ptr->pclass != CLASS_BERSERKER)) {
-        damage += (creature_ptr->lev / 6);
-    }
-
-       return damage;
-}
-
-static s16b calc_to_damage_display(player_type *creature_ptr, INVENTORY_IDX slot)
-{
-    int id = slot - INVEN_RARM;
-    object_type *o_ptr = &creature_ptr->inventory_list[slot];
-    BIT_FLAGS flgs[TR_FLAG_SIZE];
-    object_flags(creature_ptr, o_ptr, flgs);
-
-    s16b damage = 0;
-    damage += ((int)(adj_str_td[creature_ptr->stat_ind[A_STR]]) - 128);
-
-    if (creature_ptr->shero) {
-        damage += 3 + (creature_ptr->lev / 5);
-    }
-
-    if (creature_ptr->stun > 50) {
-        damage -= 20;
-    } else if (creature_ptr->stun) {
-        damage -= 5;
-    }
-
-    if ((creature_ptr->pclass == CLASS_PRIEST) && (!(have_flag(flgs, TR_BLESSED))) && ((o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM))) {
-        damage -= 2;
-    } else if (creature_ptr->pclass == CLASS_BERSERKER) {
-        damage += creature_ptr->lev / 6;
-        if (((id == 0) && !have_left_hand_weapon(creature_ptr)) || have_two_handed_weapons(creature_ptr)) {
-            damage += creature_ptr->lev / 6;
-        }
-    } else if (creature_ptr->pclass == CLASS_SORCERER) {
-        if (!((o_ptr->tval == TV_HAFTED) && ((o_ptr->sval == SV_WIZSTAFF) || (o_ptr->sval == SV_NAMAKE_HAMMER)))) {
-            damage -= 200;
-        } else {
-            damage -= 10;
+            damage += (s16b)bonus_to_d;
+        } else if (have_right_hand_weapon(creature_ptr) && have_left_hand_weapon(creature_ptr)) {
+            if (id == 0)
+                damage += (bonus_to_d > 0) ? (bonus_to_d + 1) / 2 : bonus_to_d;
+            if (id == 1)
+                damage += (bonus_to_d > 0) ? bonus_to_d / 2 : bonus_to_d;
+        } else if (id == get_default_hand(creature_ptr)) {
+            damage += (s16b)bonus_to_d;
         }
     }
 
-    if ((creature_ptr->realm1 == REALM_HEX) && object_is_cursed(o_ptr)) {
-        if (hex_spelling(creature_ptr, HEX_RUNESWORD)) {
-            if (o_ptr->curse_flags & (TRC_CURSED)) {
-                damage += 5;
-            }
-            if (o_ptr->curse_flags & (TRC_HEAVY_CURSE)) {
-                damage += 7;
-            }
-            if (o_ptr->curse_flags & (TRC_PERMA_CURSE)) {
-                damage += 13;
-            }
+    if (get_default_hand(creature_ptr) == id) {
+        if ((is_martial_arts_mode(creature_ptr) && empty_hands(creature_ptr, FALSE) == (EMPTY_HAND_RARM | EMPTY_HAND_LARM))
+            || !is_disable_two_handed_bonus(creature_ptr, 0)) {
+            int bonus_to_d = 0;
+            bonus_to_d = ((int)(adj_str_td[creature_ptr->stat_ind[A_STR]]) - 128) / 2;
+            damage += MAX(bonus_to_d, 1);
         }
     }
 
-    // 武器以外の装備による修正
-    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
-        int bonus_to_d = 0;
-        o_ptr = &creature_ptr->inventory_list[i];
-
-        if (!o_ptr->k_idx || o_ptr->tval == TV_CAPTURE || (i == INVEN_RARM && has_melee_weapon(creature_ptr, i))
-            || (i == INVEN_LARM && has_melee_weapon(creature_ptr, i)) || i == INVEN_BOW)
-            continue;
-
-        if (!object_is_known(o_ptr))
-            continue;
-
-        bonus_to_d = o_ptr->to_d;
-
-        if (creature_ptr->pclass == CLASS_NINJA) {
-            if (o_ptr->to_d > 0) bonus_to_d = (o_ptr->to_d + 1) / 2;
-        }
-
-        if ((i == INVEN_LEFT || i == INVEN_RIGHT) && !have_two_handed_weapons(creature_ptr)) {
-            creature_ptr->dis_to_d[i - INVEN_RIGHT] += (s16b)bonus_to_d;
-            continue;
-        }
-
-        if (have_right_hand_weapon(creature_ptr) && have_left_hand_weapon(creature_ptr)) {
-            if(id == 0) damage += (bonus_to_d > 0) ? (bonus_to_d + 1) / 2 : bonus_to_d;
-            if(id == 1) damage += (bonus_to_d > 0) ? bonus_to_d / 2 : bonus_to_d;
-        } else if (id == get_default_hand(creature_ptr)) {
-            creature_ptr->to_d[id] += (s16b)bonus_to_d;
-        }
-                               
-       }
-
-       if (is_martial_arts_mode(creature_ptr) && (!heavy_armor(creature_ptr) || creature_ptr->pclass != CLASS_BERSERKER)) {
+    if (is_martial_arts_mode(creature_ptr) && (!heavy_armor(creature_ptr) || creature_ptr->pclass != CLASS_BERSERKER)) {
         damage += (creature_ptr->lev / 6);
     }
 
-       return damage;
+    return damage;
 }
 
 static void calc_to_hit(player_type *creature_ptr, INVENTORY_IDX slot)