変愚蛮怒のメインリポジトリです
Revision | e5f17cc608943bdd8594463c5c45465f630f3ff0 (tree) |
---|---|
Time | 2021-01-29 12:07:45 |
Author | dis- <dis.rogue@gmai...> |
Commiter | dis- |
[Fix] 殺戮修正の計算がおかしい
とてもbuggyなのでナイーブに列挙した。いずれRefactorしたい。
@@ -1573,6 +1573,33 @@ BIT_FLAGS has_immune_dark(player_type *creature_ptr) | ||
1573 | 1573 | return result; |
1574 | 1574 | } |
1575 | 1575 | |
1576 | +melee_type player_melee_type(player_type *creature_ptr) | |
1577 | +{ | |
1578 | + if (has_two_handed_weapons(creature_ptr)) | |
1579 | + return WEAPON_TWOHAND; | |
1580 | + | |
1581 | + if (has_melee_weapon(creature_ptr, INVEN_RARM)) { | |
1582 | + if (has_melee_weapon(creature_ptr, INVEN_LARM)) { | |
1583 | + return WEAPON_DOUBLE; | |
1584 | + } | |
1585 | + return WEAPON_RIGHT; | |
1586 | + } | |
1587 | + | |
1588 | + if (has_melee_weapon(creature_ptr, INVEN_LARM)) | |
1589 | + return WEAPON_LEFT; | |
1590 | + | |
1591 | + if (empty_hands(creature_ptr, FALSE) == (EMPTY_HAND_RARM | EMPTY_HAND_LARM)) | |
1592 | + return BAREHAND_TWO; | |
1593 | + | |
1594 | + if (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_RARM) | |
1595 | + return BAREHAND_RIGHT; | |
1596 | + | |
1597 | + if (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_LARM) | |
1598 | + return BAREHAND_LEFT; | |
1599 | + | |
1600 | + return SHIELD_DOUBLE; | |
1601 | +} | |
1602 | + | |
1576 | 1603 | /* |
1577 | 1604 | * @brief 右手(利き手)が武器を持っているかどうかを判定する |
1578 | 1605 | * @detail Includes martial arts and hand combats as weapons. |
@@ -22,6 +22,17 @@ enum flag_cause { | ||
22 | 22 | FLAG_CAUSE_MAX = 18 |
23 | 23 | }; |
24 | 24 | |
25 | +typedef enum melee_type { | |
26 | + BAREHAND_TWO = 0, | |
27 | + BAREHAND_RIGHT = 1, | |
28 | + BAREHAND_LEFT = 2, | |
29 | + WEAPON_RIGHT = 3, | |
30 | + WEAPON_LEFT = 4, | |
31 | + WEAPON_TWOHAND = 5, | |
32 | + WEAPON_DOUBLE = 6, | |
33 | + SHIELD_DOUBLE = 7 | |
34 | +} melee_type; | |
35 | + | |
25 | 36 | enum aggravate_state { |
26 | 37 | AGGRAVATE_NONE = 0x00000000L, |
27 | 38 | AGGRAVATE_S_FAIRY = 0x00000001L, |
@@ -119,4 +130,5 @@ bool has_icky_wield_weapon(player_type *creature_ptr, int i); | ||
119 | 130 | bool has_riding_wield_weapon(player_type *creature_ptr, int i); |
120 | 131 | bool has_good_luck(player_type *creature_ptr); |
121 | 132 | BIT_FLAGS player_aggravate_state(player_type *creature_ptr); |
133 | +melee_type player_melee_type(player_type *creature_ptr); | |
122 | 134 | bool has_aggravate(player_type *creature_ptr); |
@@ -2969,15 +2969,48 @@ static s16b calc_to_damage(player_type *creature_ptr, INVENTORY_IDX slot, bool i | ||
2969 | 2969 | bonus_to_d = (o_ptr->to_d + 1) / 2; |
2970 | 2970 | } |
2971 | 2971 | |
2972 | - if ((i == INVEN_LEFT || i == INVEN_RIGHT) && !has_two_handed_weapons(creature_ptr)) { | |
2973 | - damage += (s16b)bonus_to_d; | |
2974 | - } else if (has_right_hand_weapon(creature_ptr) && has_left_hand_weapon(creature_ptr)) { | |
2975 | - if (id == 0) | |
2976 | - damage += (bonus_to_d > 0) ? (bonus_to_d + 1) / 2 : bonus_to_d; | |
2977 | - if (id == 1) | |
2978 | - damage += (bonus_to_d > 0) ? bonus_to_d / 2 : bonus_to_d; | |
2979 | - } else if (id == get_default_hand(creature_ptr)) { | |
2980 | - damage += (s16b)bonus_to_d; | |
2972 | + switch (player_melee_type(creature_ptr)) { | |
2973 | + case BAREHAND_TWO: /* fall through */ | |
2974 | + case WEAPON_TWOHAND: | |
2975 | + if (id == get_default_hand(creature_ptr)) | |
2976 | + damage += (s16b)bonus_to_d; | |
2977 | + break; | |
2978 | + | |
2979 | + case BAREHAND_RIGHT: /* fall through */ | |
2980 | + case WEAPON_RIGHT: | |
2981 | + if ((id == 0) && (i != INVEN_LEFT)) | |
2982 | + damage += (s16b)bonus_to_d; | |
2983 | + break; | |
2984 | + | |
2985 | + case BAREHAND_LEFT: /* fall through */ | |
2986 | + case WEAPON_LEFT: | |
2987 | + if ((id == 1) && (i != INVEN_RIGHT)) | |
2988 | + damage += (s16b)bonus_to_d; | |
2989 | + break; | |
2990 | + | |
2991 | + case WEAPON_DOUBLE: | |
2992 | + if ((id == 0)) { | |
2993 | + if (i == INVEN_RIGHT) { | |
2994 | + damage += (s16b)bonus_to_d; | |
2995 | + } | |
2996 | + else if (i != INVEN_LEFT) { | |
2997 | + damage += (bonus_to_d > 0) ? (bonus_to_d + 1) / 2 : bonus_to_d; | |
2998 | + } | |
2999 | + } | |
3000 | + if ((id == 1)) { | |
3001 | + if (i == INVEN_LEFT) { | |
3002 | + damage += (s16b)bonus_to_d; | |
3003 | + } else if (i != INVEN_RIGHT) { | |
3004 | + damage += (bonus_to_d > 0) ? bonus_to_d / 2 : bonus_to_d; | |
3005 | + } | |
3006 | + } | |
3007 | + break; | |
3008 | + | |
3009 | + case SHIELD_DOUBLE: | |
3010 | + break; | |
3011 | + | |
3012 | + default: | |
3013 | + break; | |
2981 | 3014 | } |
2982 | 3015 | } |
2983 | 3016 |
@@ -3156,22 +3189,48 @@ static s16b calc_to_hit(player_type *creature_ptr, INVENTORY_IDX slot, bool is_t | ||
3156 | 3189 | bonus_to_h = (o_ptr->to_h + 1) / 2; |
3157 | 3190 | } |
3158 | 3191 | |
3159 | - if ((i == INVEN_LEFT || i == INVEN_RIGHT) && !has_two_handed_weapons(creature_ptr)) { | |
3160 | - hit += (s16b)bonus_to_h; | |
3161 | - continue; | |
3162 | - } | |
3192 | + switch (player_melee_type(creature_ptr)) { | |
3193 | + case BAREHAND_TWO: /* fall through */ | |
3194 | + case WEAPON_TWOHAND: | |
3195 | + if (id == get_default_hand(creature_ptr)) | |
3196 | + hit += (s16b)bonus_to_h; | |
3197 | + break; | |
3163 | 3198 | |
3164 | - /* When wields two weapons on each hand */ | |
3165 | - if (has_right_hand_weapon(creature_ptr) && has_left_hand_weapon(creature_ptr)) { | |
3166 | - if (default_hand == 0) | |
3167 | - hit += (bonus_to_h > 0) ? (bonus_to_h + 1) / 2 : bonus_to_h; | |
3168 | - if (default_hand == 1) | |
3169 | - hit += (bonus_to_h > 0) ? bonus_to_h / 2 : bonus_to_h; | |
3170 | - continue; | |
3171 | - } | |
3199 | + case BAREHAND_RIGHT: /* fall through */ | |
3200 | + case WEAPON_RIGHT: | |
3201 | + if ((id == 0) && (i != INVEN_LEFT)) | |
3202 | + hit += (s16b)bonus_to_h; | |
3203 | + break; | |
3204 | + | |
3205 | + case BAREHAND_LEFT: /* fall through */ | |
3206 | + case WEAPON_LEFT: | |
3207 | + if ((id == 1) && (i != INVEN_RIGHT)) | |
3208 | + hit += (s16b)bonus_to_h; | |
3209 | + break; | |
3210 | + | |
3211 | + case WEAPON_DOUBLE: | |
3212 | + if ((id == 0)) { | |
3213 | + if (i == INVEN_RIGHT) { | |
3214 | + hit += (s16b)bonus_to_h; | |
3215 | + } else if (i != INVEN_LEFT) { | |
3216 | + hit += (bonus_to_h > 0) ? (bonus_to_h + 1) / 2 : bonus_to_h; | |
3217 | + } | |
3218 | + } | |
3219 | + if ((id == 1)) { | |
3220 | + if (i == INVEN_LEFT) { | |
3221 | + hit += (s16b)bonus_to_h; | |
3222 | + } else if (i != INVEN_RIGHT) { | |
3223 | + hit += (bonus_to_h > 0) ? bonus_to_h / 2 : bonus_to_h; | |
3224 | + } | |
3225 | + } | |
3226 | + break; | |
3227 | + | |
3228 | + case SHIELD_DOUBLE: | |
3229 | + break; | |
3172 | 3230 | |
3173 | - if (default_hand == id) | |
3174 | - hit += (s16b)bonus_to_h; | |
3231 | + default: | |
3232 | + break; | |
3233 | + } | |
3175 | 3234 | } |
3176 | 3235 | |
3177 | 3236 | /* Martial arts bonus */ |
@@ -4034,22 +4093,15 @@ int calc_weapon_weight_limit(player_type *creature_ptr) | ||
4034 | 4093 | |
4035 | 4094 | static int get_default_hand(player_type *creature_ptr) |
4036 | 4095 | { |
4037 | - int default_hand = 0; | |
4038 | - | |
4039 | - if (has_melee_weapon(creature_ptr, INVEN_LARM)) { | |
4040 | - if (!has_right_hand_weapon(creature_ptr)) | |
4041 | - default_hand = 1; | |
4042 | - } | |
4043 | - | |
4044 | - if (can_two_hands_wielding(creature_ptr)) { | |
4045 | - if (has_right_hand_weapon(creature_ptr) && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_LARM) | |
4046 | - && object_allow_two_hands_wielding(&creature_ptr->inventory_list[INVEN_RARM])) { | |
4047 | - } else if (has_left_hand_weapon(creature_ptr) && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_RARM) | |
4048 | - && object_allow_two_hands_wielding(&creature_ptr->inventory_list[INVEN_LARM])) { | |
4049 | - } else { | |
4050 | - default_hand = 1; | |
4051 | - } | |
4096 | + switch (player_melee_type(creature_ptr)) { | |
4097 | + case BAREHAND_TWO: return 0; | |
4098 | + case BAREHAND_RIGHT: return 0; | |
4099 | + case BAREHAND_LEFT: return 1; | |
4100 | + case WEAPON_RIGHT: return 0; | |
4101 | + case WEAPON_LEFT: return 1; | |
4102 | + case WEAPON_TWOHAND: return 0; | |
4103 | + case WEAPON_DOUBLE: return 0; | |
4104 | + case SHIELD_DOUBLE: return 0; | |
4052 | 4105 | } |
4053 | - | |
4054 | - return default_hand; | |
4106 | + return 0; | |
4055 | 4107 | } |