• R/O
  • HTTP
  • SSH
  • HTTPS

hengband: Commit

変愚蛮怒のメインリポジトリです


Commit MetaInfo

Revisione5f17cc608943bdd8594463c5c45465f630f3ff0 (tree)
Time2021-01-29 12:07:45
Authordis- <dis.rogue@gmai...>
Commiterdis-

Log Message

[Fix] 殺戮修正の計算がおかしい
とてもbuggyなのでナイーブに列挙した。いずれRefactorしたい。

Change Summary

Incremental Difference

--- a/src/player/player-status-flags.c
+++ b/src/player/player-status-flags.c
@@ -1573,6 +1573,33 @@ BIT_FLAGS has_immune_dark(player_type *creature_ptr)
15731573 return result;
15741574 }
15751575
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+
15761603 /*
15771604 * @brief 右手(利き手)が武器を持っているかどうかを判定する
15781605 * @detail Includes martial arts and hand combats as weapons.
--- a/src/player/player-status-flags.h
+++ b/src/player/player-status-flags.h
@@ -22,6 +22,17 @@ enum flag_cause {
2222 FLAG_CAUSE_MAX = 18
2323 };
2424
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+
2536 enum aggravate_state {
2637 AGGRAVATE_NONE = 0x00000000L,
2738 AGGRAVATE_S_FAIRY = 0x00000001L,
@@ -119,4 +130,5 @@ bool has_icky_wield_weapon(player_type *creature_ptr, int i);
119130 bool has_riding_wield_weapon(player_type *creature_ptr, int i);
120131 bool has_good_luck(player_type *creature_ptr);
121132 BIT_FLAGS player_aggravate_state(player_type *creature_ptr);
133+melee_type player_melee_type(player_type *creature_ptr);
122134 bool has_aggravate(player_type *creature_ptr);
--- a/src/player/player-status.c
+++ b/src/player/player-status.c
@@ -2969,15 +2969,48 @@ static s16b calc_to_damage(player_type *creature_ptr, INVENTORY_IDX slot, bool i
29692969 bonus_to_d = (o_ptr->to_d + 1) / 2;
29702970 }
29712971
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;
29813014 }
29823015 }
29833016
@@ -3156,22 +3189,48 @@ static s16b calc_to_hit(player_type *creature_ptr, INVENTORY_IDX slot, bool is_t
31563189 bonus_to_h = (o_ptr->to_h + 1) / 2;
31573190 }
31583191
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;
31633198
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;
31723230
3173- if (default_hand == id)
3174- hit += (s16b)bonus_to_h;
3231+ default:
3232+ break;
3233+ }
31753234 }
31763235
31773236 /* Martial arts bonus */
@@ -4034,22 +4093,15 @@ int calc_weapon_weight_limit(player_type *creature_ptr)
40344093
40354094 static int get_default_hand(player_type *creature_ptr)
40364095 {
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;
40524105 }
4053-
4054- return default_hand;
4106+ return 0;
40554107 }
Show on old repository browser