OSDN Git Service

[Fix] 殺戮修正の計算がおかしい
authordis- <dis.rogue@gmail.com>
Fri, 29 Jan 2021 03:07:45 +0000 (12:07 +0900)
committerdis- <dis.rogue@gmail.com>
Fri, 29 Jan 2021 03:07:45 +0000 (12:07 +0900)
とてもbuggyなのでナイーブに列挙した。いずれRefactorしたい。

src/player/player-status-flags.c
src/player/player-status-flags.h
src/player/player-status.c

index d92510f..962c087 100644 (file)
@@ -1573,6 +1573,33 @@ BIT_FLAGS has_immune_dark(player_type *creature_ptr)
     return result;
 }
 
+melee_type player_melee_type(player_type *creature_ptr)
+{
+    if (has_two_handed_weapons(creature_ptr))
+        return WEAPON_TWOHAND;
+
+    if (has_melee_weapon(creature_ptr, INVEN_RARM)) {
+        if (has_melee_weapon(creature_ptr, INVEN_LARM)) {
+            return WEAPON_DOUBLE;
+        }
+        return WEAPON_RIGHT;
+    }
+
+    if (has_melee_weapon(creature_ptr, INVEN_LARM))
+        return WEAPON_LEFT;
+
+    if (empty_hands(creature_ptr, FALSE) == (EMPTY_HAND_RARM | EMPTY_HAND_LARM))
+        return BAREHAND_TWO; 
+
+    if (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_RARM)
+        return BAREHAND_RIGHT;
+
+    if (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_LARM)
+        return BAREHAND_LEFT;
+
+    return SHIELD_DOUBLE;
+}
+
 /*
  * @brief 右手(利き手)が武器を持っているかどうかを判定する
  * @detail Includes martial arts and hand combats as weapons.
index 1a6ec63..6384fb8 100644 (file)
@@ -22,6 +22,17 @@ enum flag_cause {
     FLAG_CAUSE_MAX = 18
 };
 
+typedef enum melee_type {
+    BAREHAND_TWO = 0,
+    BAREHAND_RIGHT = 1,
+    BAREHAND_LEFT = 2,
+    WEAPON_RIGHT = 3,
+    WEAPON_LEFT = 4,
+    WEAPON_TWOHAND = 5,
+    WEAPON_DOUBLE = 6,
+    SHIELD_DOUBLE = 7
+} melee_type;
+
 enum aggravate_state {
     AGGRAVATE_NONE = 0x00000000L,
     AGGRAVATE_S_FAIRY = 0x00000001L,
@@ -119,4 +130,5 @@ bool has_icky_wield_weapon(player_type *creature_ptr, int i);
 bool has_riding_wield_weapon(player_type *creature_ptr, int i);
 bool has_good_luck(player_type *creature_ptr);
 BIT_FLAGS player_aggravate_state(player_type *creature_ptr);
+melee_type player_melee_type(player_type *creature_ptr);
 bool has_aggravate(player_type *creature_ptr);
index 9d76255..aa5f136 100644 (file)
@@ -2969,15 +2969,48 @@ static s16b calc_to_damage(player_type *creature_ptr, INVENTORY_IDX slot, bool i
                 bonus_to_d = (o_ptr->to_d + 1) / 2;
         }
 
-        if ((i == INVEN_LEFT || i == INVEN_RIGHT) && !has_two_handed_weapons(creature_ptr)) {
-            damage += (s16b)bonus_to_d;
-        } else if (has_right_hand_weapon(creature_ptr) && has_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;
+        switch (player_melee_type(creature_ptr)) {
+            case BAREHAND_TWO: /* fall through */
+            case WEAPON_TWOHAND: 
+                if (id == get_default_hand(creature_ptr))
+                    damage += (s16b)bonus_to_d;
+                break;
+
+            case BAREHAND_RIGHT: /* fall through */
+            case WEAPON_RIGHT:
+                if ((id == 0) && (i != INVEN_LEFT))
+                    damage += (s16b)bonus_to_d;
+                break;
+
+            case BAREHAND_LEFT: /* fall through */
+            case WEAPON_LEFT:
+                if ((id == 1) && (i != INVEN_RIGHT))
+                    damage += (s16b)bonus_to_d;
+                break;
+
+            case WEAPON_DOUBLE:
+                if ((id == 0)) {
+                    if (i == INVEN_RIGHT) {
+                        damage += (s16b)bonus_to_d;
+                    } 
+                    else if (i != INVEN_LEFT) {
+                        damage += (bonus_to_d > 0) ? (bonus_to_d + 1) / 2 : bonus_to_d;
+                    }
+                }
+                if ((id == 1)) {
+                    if (i == INVEN_LEFT) {
+                        damage += (s16b)bonus_to_d;
+                    } else if (i != INVEN_RIGHT) {
+                        damage += (bonus_to_d > 0) ? bonus_to_d / 2 : bonus_to_d;
+                    }
+                }
+                break;
+
+            case SHIELD_DOUBLE:
+                break;
+
+            default:
+                break;
         }
     }
 
@@ -3156,22 +3189,48 @@ static s16b calc_to_hit(player_type *creature_ptr, INVENTORY_IDX slot, bool is_t
                 bonus_to_h = (o_ptr->to_h + 1) / 2;
         }
 
-        if ((i == INVEN_LEFT || i == INVEN_RIGHT) && !has_two_handed_weapons(creature_ptr)) {
-            hit += (s16b)bonus_to_h;
-            continue;
-        }
+        switch (player_melee_type(creature_ptr)) {
+            case BAREHAND_TWO: /* fall through */
+            case WEAPON_TWOHAND:
+                if (id == get_default_hand(creature_ptr))
+                    hit += (s16b)bonus_to_h;
+                break;
 
-        /* When wields two weapons on each hand */
-        if (has_right_hand_weapon(creature_ptr) && has_left_hand_weapon(creature_ptr)) {
-            if (default_hand == 0)
-                hit += (bonus_to_h > 0) ? (bonus_to_h + 1) / 2 : bonus_to_h;
-            if (default_hand == 1)
-                hit += (bonus_to_h > 0) ? bonus_to_h / 2 : bonus_to_h;
-            continue;
-        }
+            case BAREHAND_RIGHT: /* fall through */
+            case WEAPON_RIGHT:
+                if ((id == 0) && (i != INVEN_LEFT))
+                    hit += (s16b)bonus_to_h;
+                break;
+
+            case BAREHAND_LEFT: /* fall through */
+            case WEAPON_LEFT:
+                if ((id == 1) && (i != INVEN_RIGHT))
+                    hit += (s16b)bonus_to_h;
+                break;
+
+            case WEAPON_DOUBLE:
+                if ((id == 0)) {
+                    if (i == INVEN_RIGHT) {
+                        hit += (s16b)bonus_to_h;
+                    } else if (i != INVEN_LEFT) {
+                        hit += (bonus_to_h > 0) ? (bonus_to_h + 1) / 2 : bonus_to_h;
+                    }
+                }
+                if ((id == 1)) {
+                    if (i == INVEN_LEFT) {
+                        hit += (s16b)bonus_to_h;
+                    } else if (i != INVEN_RIGHT) {
+                        hit += (bonus_to_h > 0) ? bonus_to_h / 2 : bonus_to_h;
+                    }
+                }
+                break;
+
+            case SHIELD_DOUBLE:
+                break;
 
-        if (default_hand == id)
-            hit += (s16b)bonus_to_h;
+            default:
+                break;
+        }
     }
 
     /* Martial arts bonus */
@@ -4034,22 +4093,15 @@ int calc_weapon_weight_limit(player_type *creature_ptr)
 
 static int get_default_hand(player_type *creature_ptr)
 {
-    int default_hand = 0;
-
-    if (has_melee_weapon(creature_ptr, INVEN_LARM)) {
-        if (!has_right_hand_weapon(creature_ptr))
-            default_hand = 1;
-    }
-
-    if (can_two_hands_wielding(creature_ptr)) {
-        if (has_right_hand_weapon(creature_ptr) && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_LARM)
-            && object_allow_two_hands_wielding(&creature_ptr->inventory_list[INVEN_RARM])) {
-        } else if (has_left_hand_weapon(creature_ptr) && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_RARM)
-            && object_allow_two_hands_wielding(&creature_ptr->inventory_list[INVEN_LARM])) {
-        } else {
-            default_hand = 1;
-        }
+    switch (player_melee_type(creature_ptr)) {
+        case BAREHAND_TWO: return 0;
+        case BAREHAND_RIGHT: return 0;
+        case BAREHAND_LEFT: return 1;
+        case WEAPON_RIGHT: return 0;
+        case WEAPON_LEFT: return 1;
+        case WEAPON_TWOHAND: return 0;
+        case WEAPON_DOUBLE: return 0;
+        case SHIELD_DOUBLE: return 0;
     }
-
-    return default_hand;
+    return 0;
 }