OSDN Git Service

[Refactor] #40514 calc_base_ac() を calc_bonuses() から分離. / Separated calc_base_ac...
authordeskull <deskull@users.sourceforge.jp>
Fri, 3 Jul 2020 16:47:04 +0000 (01:47 +0900)
committerdeskull <deskull@users.sourceforge.jp>
Fri, 3 Jul 2020 16:47:04 +0000 (01:47 +0900)
src/object/object-kind.c
src/player/player-status.c

index 0b69c0e..ce681f2 100644 (file)
@@ -249,7 +249,6 @@ void calc_equipment_status(player_type* creature_ptr) {
         if (o_ptr->tval == TV_CAPTURE)
             continue;
 
-        creature_ptr->ac += o_ptr->ac;
         creature_ptr->dis_ac += o_ptr->ac;
         creature_ptr->to_a += o_ptr->to_a;
         if (object_is_known(o_ptr))
index 35d6043..4a84849 100644 (file)
@@ -101,6 +101,7 @@ static void calc_dexterity_addition(player_type *creature_ptr);
 static void calc_constitution_addition(player_type *creature_ptr);
 static void calc_charisma_addition(player_type *creature_ptr);
 static void calc_to_magic_chance(player_type *creature_ptr);
+static void calc_base_ac(player_type *creature_ptr);
 
 /*!
  * @brief 能力値テーブル / Abbreviations of healthy stats
@@ -1231,7 +1232,7 @@ int spell_exp_level(int spell_exp)
  */
 static void clear_creature_bonuses(player_type *creature_ptr)
 {
-    creature_ptr->dis_ac = creature_ptr->ac = 0;
+    creature_ptr->dis_ac = 0;
     creature_ptr->dis_to_h[0] = creature_ptr->to_h[0] = 0;
     creature_ptr->dis_to_h[1] = creature_ptr->to_h[1] = 0;
     creature_ptr->dis_to_d[0] = creature_ptr->to_d[0] = 0;
@@ -1458,7 +1459,6 @@ void calc_bonuses(player_type *creature_ptr)
 
        if (object_is_armour(&creature_ptr->inventory_list[INVEN_RARM]) || object_is_armour(&creature_ptr->inventory_list[INVEN_LARM]))
        {
-               creature_ptr->ac += creature_ptr->skill_exp[GINOU_SHIELD] * (1 + creature_ptr->lev / 22) / 2000;
                creature_ptr->dis_ac += creature_ptr->skill_exp[GINOU_SHIELD] * (1 + creature_ptr->lev / 22) / 2000;
        }
 
@@ -1562,7 +1562,7 @@ void calc_bonuses(player_type *creature_ptr)
     calc_constitution_addition(creature_ptr);
     calc_charisma_addition(creature_ptr);
     calc_to_magic_chance(creature_ptr);
-
+    calc_base_ac(creature_ptr);
 
        int count = 0;
        for (int i = 0; i < A_MAX; i++)
@@ -3984,6 +3984,23 @@ static void calc_to_magic_chance(player_type* creature_ptr)
 }
 
 
+static void calc_base_ac(player_type *creature_ptr) 
+{ 
+       creature_ptr->ac = 0;
+
+       for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+        object_type *o_ptr;
+        o_ptr = &creature_ptr->inventory_list[i];
+        if (!o_ptr->k_idx)
+            continue;
+        creature_ptr->ac += o_ptr->ac;
+    }
+       if (object_is_armour(&creature_ptr->inventory_list[INVEN_RARM]) || object_is_armour(&creature_ptr->inventory_list[INVEN_LARM])) {
+        creature_ptr->ac += creature_ptr->skill_exp[GINOU_SHIELD] * (1 + creature_ptr->lev / 22) / 2000;
+    }
+}
+
+
 /*!
  * @brief プレイヤーの所持重量制限を計算する /
  * Computes current weight limit.