From ce98344521c1789c9a97fc3d603c020e7d594dcb Mon Sep 17 00:00:00 2001 From: deskull Date: Sun, 12 Jul 2020 22:08:31 +0900 Subject: [PATCH] =?utf8?q?[Refactor]=20#40514=20calc=5Fto=5Fhit=5Fmisc()?= =?utf8?q?=20=E3=82=92=20calc=5Fbonuses()=E3=80=80=E3=81=8B=E3=82=89?= =?utf8?q?=E5=88=86=E9=9B=A2=EF=BC=8E=20/=20Separated=20calc=5Fto=5Fhit=5F?= =?utf8?q?misc()=20from=20calc=5Fbonuses().?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/object/object-kind.c | 2 -- src/player/player-effects.c | 5 ----- src/player/player-status.c | 49 ++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 44 insertions(+), 12 deletions(-) diff --git a/src/object/object-kind.c b/src/object/object-kind.c index 88ff87e7c..efe77fb67 100644 --- a/src/object/object-kind.c +++ b/src/object/object-kind.c @@ -33,7 +33,6 @@ void calc_equipment_status(player_type* creature_ptr) { default_hand = 1; } - for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) { int bonus_to_h, bonus_to_d; o_ptr = &creature_ptr->inventory_list[i]; @@ -290,7 +289,6 @@ void calc_equipment_status(player_type* creature_ptr) { } creature_ptr->to_h_b += (s16b)bonus_to_h; - creature_ptr->to_h_m += (s16b)bonus_to_h; creature_ptr->to_d_m += (s16b)bonus_to_d; if (object_is_known(o_ptr)) diff --git a/src/player/player-effects.c b/src/player/player-effects.c index bb7d50ade..a59c3b201 100644 --- a/src/player/player-effects.c +++ b/src/player/player-effects.c @@ -3914,7 +3914,6 @@ void calc_timelimit_status(player_type *creature_ptr) creature_ptr->to_h[0] -= 20; creature_ptr->to_h[1] -= 20; creature_ptr->to_h_b -= 20; - creature_ptr->to_h_m -= 20; creature_ptr->dis_to_h[0] -= 20; creature_ptr->dis_to_h[1] -= 20; creature_ptr->dis_to_h_b -= 20; @@ -3927,7 +3926,6 @@ void calc_timelimit_status(player_type *creature_ptr) creature_ptr->to_h[0] -= 5; creature_ptr->to_h[1] -= 5; creature_ptr->to_h_b -= 5; - creature_ptr->to_h_m -= 5; creature_ptr->dis_to_h[0] -= 5; creature_ptr->dis_to_h[1] -= 5; creature_ptr->dis_to_h_b -= 5; @@ -3951,7 +3949,6 @@ void calc_timelimit_status(player_type *creature_ptr) creature_ptr->to_h[0] += 10; creature_ptr->to_h[1] += 10; creature_ptr->to_h_b += 10; - creature_ptr->to_h_m += 10; creature_ptr->dis_to_h[0] += 10; creature_ptr->dis_to_h[1] += 10; creature_ptr->dis_to_h_b += 10; @@ -3969,7 +3966,6 @@ void calc_timelimit_status(player_type *creature_ptr) creature_ptr->to_h[0] += 12; creature_ptr->to_h[1] += 12; creature_ptr->to_h_b += 12; - creature_ptr->to_h_m += 12; creature_ptr->dis_to_h[0] += 12; creature_ptr->dis_to_h[1] += 12; creature_ptr->dis_to_h_b += 12; @@ -3979,7 +3975,6 @@ void calc_timelimit_status(player_type *creature_ptr) creature_ptr->to_h[0] += 12; creature_ptr->to_h[1] += 12; creature_ptr->to_h_b -= 12; - creature_ptr->to_h_m += 12; creature_ptr->to_d[0] += 3 + (creature_ptr->lev / 5); creature_ptr->to_d[1] += 3 + (creature_ptr->lev / 5); creature_ptr->to_d_m += 3 + (creature_ptr->lev / 5); diff --git a/src/player/player-status.c b/src/player/player-status.c index 2b114e211..5b65c56eb 100644 --- a/src/player/player-status.c +++ b/src/player/player-status.c @@ -112,6 +112,8 @@ static void calc_ind_status(player_type *creature_ptr, int status); static void calc_riding_weapon_penalty(player_type *creature_ptr); static void put_equipment_warning(player_type *creature_ptr); +static void calc_to_hit_misc(player_type *creature_ptr); + /*! * @brief 能力値テーブル / Abbreviations of healthy stats */ @@ -499,7 +501,6 @@ static void clear_creature_bonuses(player_type *creature_ptr) creature_ptr->dis_to_d[0] = creature_ptr->to_d[0] = 0; creature_ptr->dis_to_d[1] = creature_ptr->to_d[1] = 0; creature_ptr->dis_to_h_b = creature_ptr->to_h_b = 0; - creature_ptr->to_h_m = 0; creature_ptr->to_d_m = 0; creature_ptr->to_dd[0] = creature_ptr->to_ds[0] = 0; creature_ptr->to_dd[1] = creature_ptr->to_ds[1] = 0; @@ -791,11 +792,9 @@ void calc_bonuses(player_type *creature_ptr) creature_ptr->to_h[0] += ((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128); creature_ptr->to_h[1] += ((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128); creature_ptr->to_h_b += ((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128); - creature_ptr->to_h_m += ((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128); creature_ptr->to_h[0] += ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128); creature_ptr->to_h[1] += ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128); creature_ptr->to_h_b += ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128); - creature_ptr->to_h_m += ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128); creature_ptr->dis_to_d[0] += ((int)(adj_str_td[creature_ptr->stat_ind[A_STR]]) - 128); creature_ptr->dis_to_d[1] += ((int)(adj_str_td[creature_ptr->stat_ind[A_STR]]) - 128); creature_ptr->dis_to_h[0] += ((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128); @@ -826,7 +825,8 @@ void calc_bonuses(player_type *creature_ptr) if (creature_ptr->ryoute) hold *= 2; - for (int i = 0; i < 2; i++) { + + for (int i = 0; i < 2; i++) { o_ptr = &creature_ptr->inventory_list[INVEN_RARM + i]; object_flags(o_ptr, flgs); @@ -1096,7 +1096,8 @@ void calc_bonuses(player_type *creature_ptr) calc_to_hit_melee(creature_ptr); calc_to_hit_shoot(creature_ptr); calc_to_hit_throw(creature_ptr); - calc_dig(creature_ptr); + calc_to_hit_misc(creature_ptr); + calc_dig(creature_ptr); if (current_world_ptr->character_xtra) return; @@ -3488,6 +3489,44 @@ void put_equipment_warning(player_type *creature_ptr) { } } +static void calc_to_hit_misc(player_type* creature_ptr) { + object_type *o_ptr; + BIT_FLAGS flgs[TR_FLAG_SIZE]; + + creature_ptr->to_h_m = 0; + + for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) { + int bonus_to_h, bonus_to_d; + o_ptr = &creature_ptr->inventory_list[i]; + if (!o_ptr->k_idx) + continue; + + object_flags(o_ptr, flgs); + creature_ptr->to_h_m += (s16b)o_ptr->to_h; + } + + if (is_blessed(creature_ptr)) { + creature_ptr->to_h_m += 10; + } + + if (IS_HERO(creature_ptr)) { + creature_ptr->to_h_m += 12; + } + + if (creature_ptr->shero) { + creature_ptr->to_h_m += 12; + } + + if (creature_ptr->stun > 50) { + creature_ptr->to_h_m -= 20; + } else if (creature_ptr->stun) { + creature_ptr->to_h_m -= 5; + } + + creature_ptr->to_h_m += ((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128); + creature_ptr->to_h_m += ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128); +} + /*! * @brief プレイヤーの所持重量制限を計算する / * Computes current weight limit. -- 2.11.0