OSDN Git Service

[Refactor] #40514 calc_to_hit_misc() を calc_bonuses() から分離. / Separated calc_to_hit_m...
authordeskull <deskull@users.sourceforge.jp>
Sun, 12 Jul 2020 13:08:31 +0000 (22:08 +0900)
committerdeskull <deskull@users.sourceforge.jp>
Sun, 12 Jul 2020 13:08:31 +0000 (22:08 +0900)
src/object/object-kind.c
src/player/player-effects.c
src/player/player-status.c

index 88ff87e..efe77fb 100644 (file)
@@ -33,7 +33,6 @@ void calc_equipment_status(player_type* creature_ptr) {
             default_hand = 1;
     }
 
-
        for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         int bonus_to_h, bonus_to_d;
         o_ptr = &creature_ptr->inventory_list[i];
@@ -290,7 +289,6 @@ void calc_equipment_status(player_type* creature_ptr) {
         }
 
         creature_ptr->to_h_b += (s16b)bonus_to_h;
-        creature_ptr->to_h_m += (s16b)bonus_to_h;
         creature_ptr->to_d_m += (s16b)bonus_to_d;
 
         if (object_is_known(o_ptr))
index bb7d50a..a59c3b2 100644 (file)
@@ -3914,7 +3914,6 @@ void calc_timelimit_status(player_type *creature_ptr)
         creature_ptr->to_h[0] -= 20;
         creature_ptr->to_h[1] -= 20;
         creature_ptr->to_h_b -= 20;
-        creature_ptr->to_h_m -= 20;
         creature_ptr->dis_to_h[0] -= 20;
         creature_ptr->dis_to_h[1] -= 20;
         creature_ptr->dis_to_h_b -= 20;
@@ -3927,7 +3926,6 @@ void calc_timelimit_status(player_type *creature_ptr)
         creature_ptr->to_h[0] -= 5;
         creature_ptr->to_h[1] -= 5;
         creature_ptr->to_h_b -= 5;
-        creature_ptr->to_h_m -= 5;
         creature_ptr->dis_to_h[0] -= 5;
         creature_ptr->dis_to_h[1] -= 5;
         creature_ptr->dis_to_h_b -= 5;
@@ -3951,7 +3949,6 @@ void calc_timelimit_status(player_type *creature_ptr)
         creature_ptr->to_h[0] += 10;
         creature_ptr->to_h[1] += 10;
         creature_ptr->to_h_b += 10;
-        creature_ptr->to_h_m += 10;
         creature_ptr->dis_to_h[0] += 10;
         creature_ptr->dis_to_h[1] += 10;
         creature_ptr->dis_to_h_b += 10;
@@ -3969,7 +3966,6 @@ void calc_timelimit_status(player_type *creature_ptr)
         creature_ptr->to_h[0] += 12;
         creature_ptr->to_h[1] += 12;
         creature_ptr->to_h_b += 12;
-        creature_ptr->to_h_m += 12;
         creature_ptr->dis_to_h[0] += 12;
         creature_ptr->dis_to_h[1] += 12;
         creature_ptr->dis_to_h_b += 12;
@@ -3979,7 +3975,6 @@ void calc_timelimit_status(player_type *creature_ptr)
         creature_ptr->to_h[0] += 12;
         creature_ptr->to_h[1] += 12;
         creature_ptr->to_h_b -= 12;
-        creature_ptr->to_h_m += 12;
         creature_ptr->to_d[0] += 3 + (creature_ptr->lev / 5);
         creature_ptr->to_d[1] += 3 + (creature_ptr->lev / 5);
         creature_ptr->to_d_m += 3 + (creature_ptr->lev / 5);
index 2b114e2..5b65c56 100644 (file)
@@ -112,6 +112,8 @@ static void calc_ind_status(player_type *creature_ptr, int status);
 static void calc_riding_weapon_penalty(player_type *creature_ptr);
 static void put_equipment_warning(player_type *creature_ptr);
 
+static void calc_to_hit_misc(player_type *creature_ptr);
+
 /*!
  * @brief 能力値テーブル / Abbreviations of healthy stats
  */
@@ -499,7 +501,6 @@ static void clear_creature_bonuses(player_type *creature_ptr)
     creature_ptr->dis_to_d[0] = creature_ptr->to_d[0] = 0;
     creature_ptr->dis_to_d[1] = creature_ptr->to_d[1] = 0;
     creature_ptr->dis_to_h_b = creature_ptr->to_h_b = 0;
-    creature_ptr->to_h_m = 0;
     creature_ptr->to_d_m = 0;
     creature_ptr->to_dd[0] = creature_ptr->to_ds[0] = 0;
     creature_ptr->to_dd[1] = creature_ptr->to_ds[1] = 0;
@@ -791,11 +792,9 @@ void calc_bonuses(player_type *creature_ptr)
     creature_ptr->to_h[0] += ((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
     creature_ptr->to_h[1] += ((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
     creature_ptr->to_h_b += ((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
-    creature_ptr->to_h_m += ((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
     creature_ptr->to_h[0] += ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128);
     creature_ptr->to_h[1] += ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128);
     creature_ptr->to_h_b += ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128);
-    creature_ptr->to_h_m += ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128);
     creature_ptr->dis_to_d[0] += ((int)(adj_str_td[creature_ptr->stat_ind[A_STR]]) - 128);
     creature_ptr->dis_to_d[1] += ((int)(adj_str_td[creature_ptr->stat_ind[A_STR]]) - 128);
     creature_ptr->dis_to_h[0] += ((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
@@ -826,7 +825,8 @@ void calc_bonuses(player_type *creature_ptr)
 
     if (creature_ptr->ryoute)
         hold *= 2;
-    for (int i = 0; i < 2; i++) {
+
+       for (int i = 0; i < 2; i++) {
         o_ptr = &creature_ptr->inventory_list[INVEN_RARM + i];
         object_flags(o_ptr, flgs);
 
@@ -1096,7 +1096,8 @@ void calc_bonuses(player_type *creature_ptr)
     calc_to_hit_melee(creature_ptr);
     calc_to_hit_shoot(creature_ptr);
     calc_to_hit_throw(creature_ptr);
-    calc_dig(creature_ptr);
+    calc_to_hit_misc(creature_ptr);
+       calc_dig(creature_ptr);
 
     if (current_world_ptr->character_xtra)
         return;
@@ -3488,6 +3489,44 @@ void put_equipment_warning(player_type *creature_ptr) {
     }
 }
 
+static void calc_to_hit_misc(player_type* creature_ptr) {
+    object_type *o_ptr;
+    BIT_FLAGS flgs[TR_FLAG_SIZE];
+
+       creature_ptr->to_h_m = 0;
+
+       for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+        int bonus_to_h, bonus_to_d;
+        o_ptr = &creature_ptr->inventory_list[i];
+        if (!o_ptr->k_idx)
+            continue;
+
+        object_flags(o_ptr, flgs);
+        creature_ptr->to_h_m += (s16b)o_ptr->to_h;
+       }
+
+       if (is_blessed(creature_ptr)) {
+        creature_ptr->to_h_m += 10;
+    }
+
+    if (IS_HERO(creature_ptr)) {
+        creature_ptr->to_h_m += 12;
+    }
+
+    if (creature_ptr->shero) {
+        creature_ptr->to_h_m += 12;
+    }
+
+       if (creature_ptr->stun > 50) {
+        creature_ptr->to_h_m -= 20;
+    } else if (creature_ptr->stun) {
+        creature_ptr->to_h_m -= 5;
+    }
+
+    creature_ptr->to_h_m += ((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
+    creature_ptr->to_h_m += ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128);
+}
+
 /*!
  * @brief プレイヤーの所持重量制限を計算する /
  * Computes current weight limit.