OSDN Git Service

[Fix] 素手ボーナスが二重に適用されている
[hengbandforosx/hengbandosx.git] / src / player / player-status.c
index 5a337d8..88d1071 100644 (file)
@@ -141,7 +141,7 @@ static s16b calc_to_hit_misc(player_type *creature_ptr);
 static DICE_NUMBER calc_to_weapon_dice_num(player_type *creature_ptr, INVENTORY_IDX slot);
 static DICE_NUMBER calc_to_weapon_dice_side(player_type *creature_ptr, INVENTORY_IDX slot);
 
-static int get_default_hand(player_type *creature_ptr);
+static player_hand get_default_hand(player_type *creature_ptr);
 
 /*** Player information ***/
 
@@ -482,6 +482,7 @@ void calc_bonuses(player_type *creature_ptr)
         return;
 
     put_equipment_warning(creature_ptr);
+    check_no_flowed(creature_ptr);
 }
 
 static void calc_alignment(player_type *creature_ptr)
@@ -1259,7 +1260,7 @@ static ACTION_SKILL_POWER calc_stealth(player_type *creature_ptr)
         if (hex_spelling_any(creature_ptr))
             pow -= (1 + casting_hex_num(creature_ptr));
     }
-    if ((is_specific_player_race(creature_ptr, RACE_S_FAIRY)) && (creature_ptr->pseikaku != PERSONALITY_SEXY) && (creature_ptr->cursed & TRC_AGGRAVATE)) {
+    if (player_aggravate_state(creature_ptr) == AGGRAVATE_S_FAIRY) {
         pow = MIN(pow - 3, (pow + 2) / 2);
     }
 
@@ -1267,11 +1268,13 @@ static ACTION_SKILL_POWER calc_stealth(player_type *creature_ptr)
         pow -= 7;
     }
 
-    if (creature_ptr->pclass == CLASS_NINJA && heavy_armor(creature_ptr)) {
-        pow -= (creature_ptr->lev) / 10;
-    } else if ((!creature_ptr->inventory_list[INVEN_RARM].k_idx || has_right_hand_weapon(creature_ptr))
-        && (!creature_ptr->inventory_list[INVEN_LARM].k_idx || has_left_hand_weapon(creature_ptr))) {
-        pow += (creature_ptr->lev) / 10;
+    if (creature_ptr->pclass == CLASS_NINJA) {
+        if (heavy_armor(creature_ptr)) {
+            pow -= (creature_ptr->lev) / 10;
+        } else if ((!creature_ptr->inventory_list[INVEN_RARM].k_idx || has_right_hand_weapon(creature_ptr))
+            && (!creature_ptr->inventory_list[INVEN_LARM].k_idx || has_left_hand_weapon(creature_ptr))) {
+            pow += (creature_ptr->lev) / 10;
+        }
     }
 
     if (is_time_limit_stealth(creature_ptr))
@@ -1656,14 +1659,12 @@ static s16b calc_num_blow(player_type *creature_ptr, int i)
 {
     object_type *o_ptr;
     BIT_FLAGS flgs[TR_FLAG_SIZE];
-    s16b num_blow = 0;
+    s16b num_blow = 1;
 
     o_ptr = &creature_ptr->inventory_list[INVEN_RARM + i];
     object_flags(creature_ptr, o_ptr, flgs);
     creature_ptr->heavy_wield[i] = FALSE;
-    if (!has_melee_weapon(creature_ptr, INVEN_RARM + i)) {
-        num_blow = 1;
-    } else {
+    if (has_melee_weapon(creature_ptr, INVEN_RARM + i)) {
         if (calc_weapon_weight_limit(creature_ptr) < o_ptr->weight / 10) {
             creature_ptr->heavy_wield[i] = TRUE;
         }
@@ -1866,7 +1867,6 @@ static s16b calc_strength_addition(player_type *creature_ptr)
     }
 
     if (creature_ptr->muta3) {
-
         if (creature_ptr->muta3 & MUT3_HYPER_STR) {
             pow += 4;
         }
@@ -1994,7 +1994,6 @@ static s16b calc_wisdom_addition(player_type *creature_ptr)
     }
 
     if (creature_ptr->muta3) {
-
         if (creature_ptr->muta3 & MUT3_HYPER_INT) {
             pow += 4;
         }
@@ -2548,7 +2547,7 @@ static s16b calc_speed(player_type *creature_ptr)
             }
         }
 
-        if (creature_ptr->pclass == CLASS_FORCETRAINER && !(heavy_armor(creature_ptr))) {
+        if ((creature_ptr->pclass == CLASS_MONK || creature_ptr->pclass == CLASS_FORCETRAINER) && !(heavy_armor(creature_ptr))) {
             if (!(is_specific_player_race(creature_ptr, RACE_KLACKON) || is_specific_player_race(creature_ptr, RACE_SPRITE)
                     || (creature_ptr->pseikaku == PERSONALITY_MUNCHKIN)))
                 pow += (creature_ptr->lev) / 10;
@@ -2591,7 +2590,6 @@ static s16b calc_speed(player_type *creature_ptr)
             pow += 10;
 
         if (creature_ptr->muta3) {
-
             if (creature_ptr->muta3 & MUT3_XTRA_FAT) {
                 pow -= 2;
             }
@@ -2622,7 +2620,6 @@ static s16b calc_speed(player_type *creature_ptr)
         count = (int)calc_weight_limit(creature_ptr);
         if (j > count)
             pow -= ((j - count) / (count / 5));
-
     } else {
         monster_type *riding_m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
         monster_race *riding_r_ptr = &r_info[riding_m_ptr->r_idx];
@@ -2906,10 +2903,15 @@ void put_equipment_warning(player_type *creature_ptr)
 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;
     BIT_FLAGS flgs[TR_FLAG_SIZE];
     object_flags(creature_ptr, o_ptr, flgs);
 
+    player_hand calc_hand = PLAYER_HAND_OTHER;
+    if (slot == INVEN_RARM)
+        calc_hand = PLAYER_HAND_RIGHT;
+    if (slot == INVEN_LARM)
+        calc_hand = PLAYER_HAND_LEFT;
+
     s16b damage = 0;
     damage += ((int)(adj_str_td[creature_ptr->stat_ind[A_STR]]) - 128);
 
@@ -2927,7 +2929,7 @@ static s16b calc_to_damage(player_type *creature_ptr, INVENTORY_IDX slot, bool i
         damage -= 2;
     } else if (creature_ptr->pclass == CLASS_BERSERKER) {
         damage += creature_ptr->lev / 6;
-        if (((id == 0) && !has_left_hand_weapon(creature_ptr)) || has_two_handed_weapons(creature_ptr)) {
+        if (((calc_hand == PLAYER_HAND_RIGHT) && !has_left_hand_weapon(creature_ptr)) || has_two_handed_weapons(creature_ptr)) {
             damage += creature_ptr->lev / 6;
         }
     } else if (creature_ptr->pclass == CLASS_SORCERER) {
@@ -2968,19 +2970,51 @@ 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 MELEE_TYPE_BAREHAND_TWO: /* fall through */
+        case MELEE_TYPE_WEAPON_TWOHAND:
+            if (calc_hand == get_default_hand(creature_ptr))
+                damage += (s16b)bonus_to_d;
+            break;
+
+        case MELEE_TYPE_BAREHAND_RIGHT: /* fall through */
+        case MELEE_TYPE_WEAPON_RIGHT:
+            if ((calc_hand == PLAYER_HAND_RIGHT) && (i != INVEN_LEFT))
+                damage += (s16b)bonus_to_d;
+            break;
+
+        case MELEE_TYPE_BAREHAND_LEFT: /* fall through */
+        case MELEE_TYPE_WEAPON_LEFT:
+            if ((calc_hand == PLAYER_HAND_LEFT) && (i != INVEN_RIGHT))
+                damage += (s16b)bonus_to_d;
+            break;
+
+        case MELEE_TYPE_WEAPON_DOUBLE:
+            if ((calc_hand == PLAYER_HAND_RIGHT)) {
+                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 ((calc_hand == PLAYER_HAND_LEFT)) {
+                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 MELEE_TYPE_SHIELD_DOUBLE:
+            break;
+
+        default:
+            break;
         }
     }
 
-    if (get_default_hand(creature_ptr) == id) {
+    if (get_default_hand(creature_ptr) == calc_hand) {
         if ((is_martial_arts_mode(creature_ptr) && empty_hands(creature_ptr, FALSE) == (EMPTY_HAND_RARM | EMPTY_HAND_LARM))
             || !has_disable_two_handed_bonus(creature_ptr, 0)) {
             int bonus_to_d = 0;
@@ -3028,13 +3062,24 @@ static s16b calc_to_hit(player_type *creature_ptr, INVENTORY_IDX slot, bool is_t
         hit -= 5;
     }
 
+    player_hand calc_hand = PLAYER_HAND_OTHER;
+    if (slot == INVEN_RARM)
+        calc_hand = PLAYER_HAND_RIGHT;
+    if (slot == INVEN_LARM)
+        calc_hand = PLAYER_HAND_LEFT;
+
     /* Default hand bonuses */
-    int id = slot - INVEN_RARM;
-    int default_hand = get_default_hand(creature_ptr);
-    if (default_hand == id) {
-        /* Add trained bonus of empty hands' combat when having no weapon and riding */
-        if ((!has_right_hand_weapon(creature_ptr) && (empty_hands(creature_ptr, TRUE) & EMPTY_HAND_LARM))
-            || (!has_left_hand_weapon(creature_ptr) && (empty_hands(creature_ptr, TRUE) & EMPTY_HAND_RARM))) {
+    if (get_default_hand(creature_ptr) == calc_hand) {
+        switch (player_melee_type(creature_ptr)) {
+        case MELEE_TYPE_BAREHAND_RIGHT:
+            if (creature_ptr->riding)
+                break;
+            /* fall through */
+        case MELEE_TYPE_BAREHAND_LEFT:
+            if (creature_ptr->riding)
+                break;
+            /* fall through */
+        case MELEE_TYPE_BAREHAND_TWO:
             hit += (creature_ptr->skill_exp[GINOU_SUDE] - WEAPON_EXP_BEGINNER) / 200;
         }
 
@@ -3081,7 +3126,6 @@ static s16b calc_to_hit(player_type *creature_ptr, INVENTORY_IDX slot, bool is_t
 
         if (creature_ptr->riding != 0 && !(o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE))
             && !has_flag(flgs, TR_RIDING)) {
-
             int penalty;
             if ((creature_ptr->pclass == CLASS_BEASTMASTER) || (creature_ptr->pclass == CLASS_CAVALRY)) {
                 penalty = 5;
@@ -3099,7 +3143,7 @@ static s16b calc_to_hit(player_type *creature_ptr, INVENTORY_IDX slot, bool is_t
             hit -= 2;
         } else if (creature_ptr->pclass == CLASS_BERSERKER) {
             hit += creature_ptr->lev / 5;
-            if (((id == 0) && !has_left_hand_weapon(creature_ptr)) || has_two_handed_weapons(creature_ptr)) {
+            if (((calc_hand == PLAYER_HAND_RIGHT) && !has_left_hand_weapon(creature_ptr)) || has_two_handed_weapons(creature_ptr)) {
                 hit += creature_ptr->lev / 5;
             }
         } else if (creature_ptr->pclass == CLASS_SORCERER) {
@@ -3110,7 +3154,7 @@ static s16b calc_to_hit(player_type *creature_ptr, INVENTORY_IDX slot, bool is_t
             }
         }
 
-        if (has_not_ninja_weapon(creature_ptr, id) || has_not_monk_weapon(creature_ptr, id)) {
+        if (has_not_ninja_weapon(creature_ptr, (int)calc_hand) || has_not_monk_weapon(creature_ptr, (int)calc_hand)) {
             hit -= 40;
         }
 
@@ -3136,11 +3180,8 @@ static s16b calc_to_hit(player_type *creature_ptr, INVENTORY_IDX slot, bool is_t
         object_type *o_ptr = &creature_ptr->inventory_list[i];
 
         /* Ignore empty hands, handed weapons, bows and capture balls */
-        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)
+        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;
 
         /* Fake value does not include unknown objects' value */
@@ -3155,22 +3196,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 MELEE_TYPE_BAREHAND_TWO: /* fall through */
+        case MELEE_TYPE_WEAPON_TWOHAND:
+            if (calc_hand == 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 MELEE_TYPE_BAREHAND_RIGHT: /* fall through */
+        case MELEE_TYPE_WEAPON_RIGHT:
+            if ((calc_hand == PLAYER_HAND_RIGHT) && (i != INVEN_LEFT))
+                hit += (s16b)bonus_to_h;
+            break;
+
+        case MELEE_TYPE_BAREHAND_LEFT: /* fall through */
+        case MELEE_TYPE_WEAPON_LEFT:
+            if ((calc_hand == PLAYER_HAND_LEFT) && (i != INVEN_RIGHT))
+                hit += (s16b)bonus_to_h;
+            break;
+
+        case MELEE_TYPE_WEAPON_DOUBLE:
+            if ((calc_hand == PLAYER_HAND_RIGHT)) {
+                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 ((calc_hand == PLAYER_HAND_LEFT)) {
+                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 MELEE_TYPE_SHIELD_DOUBLE:
+            break;
 
-        if (default_hand == id)
-            hit += (s16b)bonus_to_h;
+        default:
+            break;
+        }
     }
 
     /* Martial arts bonus */
@@ -3352,7 +3419,6 @@ static DICE_NUMBER calc_to_weapon_dice_num(player_type *creature_ptr, INVENTORY_
     DICE_NUMBER dn = 0;
 
     if (creature_ptr->riding) {
-
         if ((o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE))) {
             dn += 2;
         }
@@ -4031,24 +4097,25 @@ int calc_weapon_weight_limit(player_type *creature_ptr)
     return weight;
 }
 
-static int get_default_hand(player_type *creature_ptr)
+static player_hand 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;
+    switch (player_melee_type(creature_ptr)) {
+    case MELEE_TYPE_BAREHAND_TWO:
+        return PLAYER_HAND_RIGHT;
+    case MELEE_TYPE_BAREHAND_RIGHT:
+        return PLAYER_HAND_RIGHT;
+    case MELEE_TYPE_BAREHAND_LEFT:
+        return PLAYER_HAND_LEFT;
+    case MELEE_TYPE_WEAPON_RIGHT:
+        return PLAYER_HAND_RIGHT;
+    case MELEE_TYPE_WEAPON_LEFT:
+        return PLAYER_HAND_LEFT;
+    case MELEE_TYPE_WEAPON_TWOHAND:
+        return PLAYER_HAND_RIGHT;
+    case MELEE_TYPE_WEAPON_DOUBLE:
+        return PLAYER_HAND_RIGHT;
+    case MELEE_TYPE_SHIELD_DOUBLE:
+        return PLAYER_HAND_RIGHT;
     }
-
-    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;
-        }
-    }
-
-    return default_hand;
-}
+    return 0;
+}
\ No newline at end of file