From: deskull Date: Sun, 2 Aug 2020 07:13:02 +0000 (+0900) Subject: [Refactor] #40514 have_free_act() を calc_bonuses() から分離. / Separated have_free_act... X-Git-Tag: vmacos3.0.0-alpha52~740 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=19d5edfad43633db82d9a5fed0c8f39cdf129ce8;p=hengbandforosx%2Fhengbandosx.git [Refactor] #40514 have_free_act() を calc_bonuses() から分離. / Separated have_free_act() from calc_bonuses(). --- diff --git a/src/mutation/mutation-calculator.c b/src/mutation/mutation-calculator.c index a6cab7643..a9fc7f4b1 100644 --- a/src/mutation/mutation-calculator.c +++ b/src/mutation/mutation-calculator.c @@ -75,6 +75,4 @@ void set_mutation_flags(player_type *creature_ptr) if (creature_ptr->muta3 & MUT3_REGEN) creature_ptr->regenerate = TRUE; - if (creature_ptr->muta3 & MUT3_MOTION) - creature_ptr->free_act = TRUE; } diff --git a/src/player/player-class.c b/src/player/player-class.c index cd11365bf..e1cd10216 100644 --- a/src/player/player-class.c +++ b/src/player/player-class.c @@ -1225,14 +1225,6 @@ void calc_class_status(player_type *creature_ptr) if (creature_ptr->lev > 29) creature_ptr->resist_conf = TRUE; break; - case CLASS_MONK: - case CLASS_FORCETRAINER: - if (!(heavy_armor(creature_ptr))) { - if (creature_ptr->lev > 24) - creature_ptr->free_act = TRUE; - } - - break; case CLASS_BARD: creature_ptr->resist_sound = TRUE; break; @@ -1246,7 +1238,6 @@ void calc_class_status(player_type *creature_ptr) creature_ptr->sustain_dex = TRUE; creature_ptr->sustain_con = TRUE; creature_ptr->regenerate = TRUE; - creature_ptr->free_act = TRUE; creature_ptr->redraw |= PR_STATUS; break; case CLASS_NINJA: @@ -1255,8 +1246,6 @@ void calc_class_status(player_type *creature_ptr) } else if ((!creature_ptr->inventory_list[INVEN_RARM].k_idx || creature_ptr->right_hand_weapon) && (!creature_ptr->inventory_list[INVEN_LARM].k_idx || creature_ptr->left_hand_weapon)) { creature_ptr->skill_stl += (creature_ptr->lev) / 10; - if (creature_ptr->lev > 24) - creature_ptr->free_act = TRUE; } if ((!creature_ptr->inventory_list[INVEN_RARM].k_idx || creature_ptr->right_hand_weapon) diff --git a/src/player/player-race.c b/src/player/player-race.c index 2534b7eca..b1a1ad558 100644 --- a/src/player/player-race.c +++ b/src/player/player-race.c @@ -166,9 +166,6 @@ void calc_race_status(player_type *creature_ptr) case RACE_ELF: creature_ptr->resist_lite = TRUE; break; - case RACE_GNOME: - creature_ptr->free_act = TRUE; - break; case RACE_DWARF: creature_ptr->resist_blind = TRUE; break; @@ -255,7 +252,6 @@ void calc_race_status(player_type *creature_ptr) break; case RACE_GOLEM: creature_ptr->slow_digest = TRUE; - creature_ptr->free_act = TRUE; creature_ptr->resist_pois = TRUE; break; case RACE_SKELETON: @@ -281,7 +277,6 @@ void calc_race_status(player_type *creature_ptr) break; case RACE_SPECTRE: creature_ptr->levitation = TRUE; - creature_ptr->free_act = TRUE; creature_ptr->resist_neth = TRUE; creature_ptr->resist_pois = TRUE; creature_ptr->slow_digest = TRUE; @@ -319,7 +314,6 @@ void calc_race_status(player_type *creature_ptr) break; case RACE_ANDROID: creature_ptr->slow_digest = TRUE; - creature_ptr->free_act = TRUE; creature_ptr->resist_pois = TRUE; break; case RACE_MERFOLK: diff --git a/src/player/player-status-flags.c b/src/player/player-status-flags.c index 1ac8cb95a..03240d7b5 100644 --- a/src/player/player-status-flags.c +++ b/src/player/player-status-flags.c @@ -859,3 +859,65 @@ void have_see_inv(player_type *creature_ptr) creature_ptr->see_inv = TRUE; } } + +void have_free_act(player_type *creature_ptr) +{ + object_type *o_ptr; + BIT_FLAGS flgs[TR_FLAG_SIZE]; + creature_ptr->free_act = FALSE; + + if (creature_ptr->muta3 & MUT3_MOTION) + creature_ptr->free_act = TRUE; + + if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_GNOME) { + creature_ptr->free_act = TRUE; + } + + if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_GOLEM) { + creature_ptr->free_act = TRUE; + } + + if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_SPECTRE) { + creature_ptr->free_act = TRUE; + } + + if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_ANDROID) { + creature_ptr->free_act = TRUE; + } + + if (heavy_armor(creature_ptr) && (!creature_ptr->inventory_list[INVEN_RARM].k_idx || creature_ptr->right_hand_weapon) + && (!creature_ptr->inventory_list[INVEN_LARM].k_idx || creature_ptr->left_hand_weapon)) { + if (creature_ptr->lev > 24) + creature_ptr->free_act = TRUE; + } + + if (creature_ptr->pclass == CLASS_MONK || creature_ptr->pclass == CLASS_FORCETRAINER) { + if (!(heavy_armor(creature_ptr))) { + if (creature_ptr->lev > 24) + creature_ptr->free_act = TRUE; + } + } + + if (creature_ptr->pclass == CLASS_BERSERKER) { + creature_ptr->free_act = TRUE; + } + + if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) { + creature_ptr->free_act = TRUE; + } + + if (creature_ptr->magicdef) { + creature_ptr->free_act = TRUE; + } + + + for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) { + o_ptr = &creature_ptr->inventory_list[i]; + if (!o_ptr->k_idx) + continue; + + object_flags(creature_ptr, o_ptr, flgs); + if (have_flag(flgs, TR_FREE_ACT)) + creature_ptr->free_act = TRUE; + } +} diff --git a/src/player/player-status-flags.h b/src/player/player-status-flags.h index c7cee2b6a..5afc5a70f 100644 --- a/src/player/player-status-flags.h +++ b/src/player/player-status-flags.h @@ -35,5 +35,6 @@ void have_easy_spell(player_type *creature_ptr); void have_heavy_spell(player_type *creature_ptr); void have_hold_exp(player_type *creature_ptr); void have_see_inv(player_type *creature_ptr); +void have_free_act(player_type *creature_ptr); diff --git a/src/player/player-status.c b/src/player/player-status.c index ef9155c0e..d62861037 100644 --- a/src/player/player-status.c +++ b/src/player/player-status.c @@ -567,7 +567,6 @@ static void clear_creature_bonuses(player_type *creature_ptr) creature_ptr->cursed = 0L; creature_ptr->impact[0] = FALSE; creature_ptr->impact[1] = FALSE; - creature_ptr->free_act = FALSE; creature_ptr->slow_digest = FALSE; creature_ptr->regenerate = FALSE; creature_ptr->can_swim = FALSE; @@ -674,6 +673,36 @@ void calc_bonuses(player_type *creature_ptr) clear_creature_bonuses(creature_ptr); + if (has_melee_weapon(creature_ptr, INVEN_RARM)) + creature_ptr->right_hand_weapon = TRUE; + if (has_melee_weapon(creature_ptr, INVEN_LARM)) { + creature_ptr->left_hand_weapon = TRUE; + if (!creature_ptr->right_hand_weapon) + default_hand = 1; + } + + if (can_two_hands_wielding(creature_ptr)) { + if (creature_ptr->right_hand_weapon && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_LARM) + && object_allow_two_hands_wielding(&creature_ptr->inventory_list[INVEN_RARM])) { + creature_ptr->two_handed_weapon = TRUE; + } else if (creature_ptr->left_hand_weapon && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_RARM) + && object_allow_two_hands_wielding(&creature_ptr->inventory_list[INVEN_LARM])) { + creature_ptr->two_handed_weapon = TRUE; + } else { + switch (creature_ptr->pclass) { + case CLASS_MONK: + case CLASS_FORCETRAINER: + case CLASS_BERSERKER: + if (empty_hands(creature_ptr, FALSE) == (EMPTY_HAND_RARM | EMPTY_HAND_LARM)) { + creature_ptr->right_hand_weapon = TRUE; + creature_ptr->two_handed_weapon = TRUE; + } + } + + default_hand = 1; + } + } + have_pass_wall(creature_ptr); have_kill_wall(creature_ptr); have_xtra_might(creature_ptr); @@ -708,38 +737,10 @@ void calc_bonuses(player_type *creature_ptr) have_heavy_spell(creature_ptr); have_hold_exp(creature_ptr); have_see_inv(creature_ptr); + have_free_act(creature_ptr); calc_race_status(creature_ptr); - if (has_melee_weapon(creature_ptr, INVEN_RARM)) - creature_ptr->right_hand_weapon = TRUE; - if (has_melee_weapon(creature_ptr, INVEN_LARM)) { - creature_ptr->left_hand_weapon = TRUE; - if (!creature_ptr->right_hand_weapon) - default_hand = 1; - } - - if (can_two_hands_wielding(creature_ptr)) { - if (creature_ptr->right_hand_weapon && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_LARM) - && object_allow_two_hands_wielding(&creature_ptr->inventory_list[INVEN_RARM])) { - creature_ptr->two_handed_weapon = TRUE; - } else if (creature_ptr->left_hand_weapon && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_RARM) - && object_allow_two_hands_wielding(&creature_ptr->inventory_list[INVEN_LARM])) { - creature_ptr->two_handed_weapon = TRUE; - } else { - switch (creature_ptr->pclass) { - case CLASS_MONK: - case CLASS_FORCETRAINER: - case CLASS_BERSERKER: - if (empty_hands(creature_ptr, FALSE) == (EMPTY_HAND_RARM | EMPTY_HAND_LARM)) { - creature_ptr->right_hand_weapon = TRUE; - creature_ptr->two_handed_weapon = TRUE; - } - } - - default_hand = 1; - } - } if (creature_ptr->special_defense & KAMAE_MASK) { if (!(empty_hands_status & EMPTY_HAND_RARM)) { @@ -4479,7 +4480,6 @@ bool is_echizen(player_type *creature_ptr) void calc_timelimit_status(player_type *creature_ptr) { if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) { - creature_ptr->free_act = TRUE; creature_ptr->slow_digest = TRUE; creature_ptr->regenerate = TRUE; creature_ptr->levitation = TRUE; @@ -4520,7 +4520,6 @@ void calc_timelimit_status(player_type *creature_ptr) if (creature_ptr->magicdef) { creature_ptr->resist_blind = TRUE; creature_ptr->resist_conf = TRUE; - creature_ptr->free_act = TRUE; creature_ptr->levitation = TRUE; } @@ -4628,8 +4627,6 @@ void calc_equipment_status(player_type *creature_ptr) if (have_flag(flgs, TR_LEVITATION)) creature_ptr->levitation = TRUE; - if (have_flag(flgs, TR_FREE_ACT)) - creature_ptr->free_act = TRUE; if (have_flag(flgs, TR_TELEPORT)) { if (object_is_cursed(o_ptr))