From 39525c2be72a05850591d51f47476f5bba66db26 Mon Sep 17 00:00:00 2001 From: deskull Date: Fri, 7 Aug 2020 01:45:26 +0900 Subject: [PATCH] =?utf8?q?[Refactor]=20#40514=20have=5Flevitation()=20?= =?utf8?q?=E3=82=92=20calc=5Fbonuses()=E3=80=80=E3=81=8B=E3=82=89=E5=88=86?= =?utf8?q?=E9=9B=A2=EF=BC=8E=20/=20Separated=20have=5Flevitation()=20from?= =?utf8?q?=20calc=5Fbonuses().?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/player/player-race.c | 10 -------- src/player/player-status-flags.c | 51 ++++++++++++++++++++++++++++++++++++++++ src/player/player-status-flags.h | 1 + src/player/player-status.c | 18 +------------- 4 files changed, 53 insertions(+), 27 deletions(-) diff --git a/src/player/player-race.c b/src/player/player-race.c index eee27c58c..d167e2953 100644 --- a/src/player/player-race.c +++ b/src/player/player-race.c @@ -150,7 +150,6 @@ void calc_race_status(player_type *creature_ptr) creature_ptr->resist_disen = TRUE; creature_ptr->resist_nexus = TRUE; creature_ptr->resist_fear = TRUE; - creature_ptr->levitation = TRUE; break; case MIMIC_VAMPIRE: creature_ptr->resist_dark = TRUE; @@ -226,7 +225,6 @@ void calc_race_status(player_type *creature_ptr) creature_ptr->resist_dark = TRUE; break; case RACE_DRACONIAN: - creature_ptr->levitation = TRUE; if (creature_ptr->lev > 4) creature_ptr->resist_fire = TRUE; if (creature_ptr->lev > 9) @@ -267,7 +265,6 @@ void calc_race_status(player_type *creature_ptr) creature_ptr->lite = TRUE; break; case RACE_SPECTRE: - creature_ptr->levitation = TRUE; creature_ptr->resist_neth = TRUE; creature_ptr->resist_pois = TRUE; creature_ptr->slow_digest = TRUE; @@ -275,16 +272,12 @@ void calc_race_status(player_type *creature_ptr) creature_ptr->pass_wall = TRUE; break; case RACE_SPRITE: - creature_ptr->levitation = TRUE; creature_ptr->resist_lite = TRUE; break; case RACE_BEASTMAN: creature_ptr->resist_conf = TRUE; creature_ptr->resist_sound = TRUE; break; - case RACE_ARCHON: - creature_ptr->levitation = TRUE; - break; case RACE_BALROG: creature_ptr->resist_fire = TRUE; creature_ptr->resist_neth = TRUE; @@ -294,9 +287,6 @@ void calc_race_status(player_type *creature_ptr) } break; - case RACE_S_FAIRY: - creature_ptr->levitation = TRUE; - break; case RACE_KUTAR: creature_ptr->resist_conf = TRUE; break; diff --git a/src/player/player-status-flags.c b/src/player/player-status-flags.c index 712a67fd6..4d65840ba 100644 --- a/src/player/player-status-flags.c +++ b/src/player/player-status-flags.c @@ -21,6 +21,7 @@ #include "util/bit-flags-calculator.h" #include "util/quarks.h" #include "util/string-processor.h" +#include "monster-race/race-flags7.h" void have_kill_wall(player_type *creature_ptr) { @@ -1075,3 +1076,53 @@ void have_sustain_chr(player_type *creature_ptr) creature_ptr->sustain_chr = TRUE; } } + +void have_levitation(player_type *creature_ptr) +{ + object_type *o_ptr; + BIT_FLAGS flgs[TR_FLAG_SIZE]; + creature_ptr->levitation = FALSE; + + if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) { + creature_ptr->levitation = TRUE; + } + + if (!creature_ptr->mimic_form + && (creature_ptr->prace == RACE_DRACONIAN || creature_ptr->prace == RACE_SPECTRE || creature_ptr->prace == RACE_SPRITE + || creature_ptr->prace == RACE_ARCHON || creature_ptr->prace == RACE_S_FAIRY)) { + creature_ptr->levitation = TRUE; + } + + if (creature_ptr->special_defense & KAMAE_SEIRYU || creature_ptr->special_defense & KAMAE_SUZAKU) { + creature_ptr->levitation = TRUE; + } + + if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) { + creature_ptr->slow_digest = TRUE; + creature_ptr->regenerate = TRUE; + } + + if (creature_ptr->magicdef) { + creature_ptr->levitation = TRUE; + } + + if (creature_ptr->riding) { + 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]; + creature_ptr->levitation = (riding_r_ptr->flags7 & RF7_CAN_FLY) ? TRUE : FALSE; + } + + if (creature_ptr->tim_levitation) { + creature_ptr->levitation = 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_LEVITATION)) + creature_ptr->levitation = TRUE; + } +} diff --git a/src/player/player-status-flags.h b/src/player/player-status-flags.h index 6def3d544..b0e45f402 100644 --- a/src/player/player-status-flags.h +++ b/src/player/player-status-flags.h @@ -42,5 +42,6 @@ void have_sustain_wis(player_type *creature_ptr); void have_sustain_dex(player_type *creature_ptr); void have_sustain_con(player_type *creature_ptr); void have_sustain_chr(player_type *creature_ptr); +void have_levitation(player_type *creature_ptr); diff --git a/src/player/player-status.c b/src/player/player-status.c index bf060cdd4..f884901e1 100644 --- a/src/player/player-status.c +++ b/src/player/player-status.c @@ -570,8 +570,6 @@ static void clear_creature_bonuses(player_type *creature_ptr) creature_ptr->slow_digest = FALSE; creature_ptr->regenerate = FALSE; creature_ptr->can_swim = FALSE; - creature_ptr->levitation = FALSE; - creature_ptr->lite = FALSE; creature_ptr->resist_acid = FALSE; creature_ptr->resist_elec = FALSE; creature_ptr->resist_fire = FALSE; @@ -738,6 +736,7 @@ void calc_bonuses(player_type *creature_ptr) have_sustain_dex(creature_ptr); have_sustain_con(creature_ptr); have_sustain_chr(creature_ptr); + have_levitation(creature_ptr); calc_race_status(creature_ptr); @@ -820,8 +819,6 @@ void calc_bonuses(player_type *creature_ptr) monster_race *riding_r_ptr = &r_info[riding_m_ptr->r_idx]; if (riding_r_ptr->flags7 & (RF7_CAN_SWIM | RF7_AQUATIC)) creature_ptr->can_swim = TRUE; - - creature_ptr->levitation = (riding_r_ptr->flags7 & RF7_CAN_FLY) ? TRUE : FALSE; } creature_ptr->hold = adj_str_hold[creature_ptr->stat_ind[A_STR]]; @@ -2111,7 +2108,6 @@ static void calc_num_blow(player_type *creature_ptr, int i) creature_ptr->resist_elec = TRUE; creature_ptr->resist_cold = TRUE; creature_ptr->resist_pois = TRUE; - creature_ptr->levitation = TRUE; } else if (creature_ptr->special_defense & KAMAE_GENBU) { creature_ptr->to_a += (creature_ptr->lev * creature_ptr->lev) / 50; creature_ptr->dis_to_a += (creature_ptr->lev * creature_ptr->lev) / 50; @@ -2127,7 +2123,6 @@ static void calc_num_blow(player_type *creature_ptr, int i) creature_ptr->dis_to_h[i] -= (creature_ptr->lev / 3); creature_ptr->dis_to_d[i] -= (creature_ptr->lev / 6); creature_ptr->num_blow[i] /= 2; - creature_ptr->levitation = TRUE; } creature_ptr->num_blow[i] += 1 + creature_ptr->extra_blows[0]; @@ -4482,7 +4477,6 @@ void calc_timelimit_status(player_type *creature_ptr) if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) { creature_ptr->slow_digest = TRUE; creature_ptr->regenerate = TRUE; - creature_ptr->levitation = TRUE; creature_ptr->lite = TRUE; creature_ptr->resist_acid = TRUE; creature_ptr->resist_elec = TRUE; @@ -4510,14 +4504,11 @@ void calc_timelimit_status(player_type *creature_ptr) creature_ptr->resist_time = TRUE; } - if (creature_ptr->magicdef) { creature_ptr->resist_blind = TRUE; creature_ptr->resist_conf = TRUE; - creature_ptr->levitation = TRUE; } - if (creature_ptr->ele_immune) { if (creature_ptr->special_defense & DEFENSE_ACID) creature_ptr->immune_acid = TRUE; @@ -4533,10 +4524,6 @@ void calc_timelimit_status(player_type *creature_ptr) creature_ptr->regenerate = TRUE; } - if (creature_ptr->tim_levitation) { - creature_ptr->levitation = TRUE; - } - if (is_hero(creature_ptr) || creature_ptr->shero) { creature_ptr->resist_fear = TRUE; } @@ -4619,9 +4606,6 @@ void calc_equipment_status(player_type *creature_ptr) if (have_flag(flgs, TR_REGEN)) creature_ptr->regenerate = TRUE; - if (have_flag(flgs, TR_LEVITATION)) - creature_ptr->levitation = TRUE; - if (have_flag(flgs, TR_TELEPORT)) { if (object_is_cursed(o_ptr)) creature_ptr->cursed |= TRC_TELEPORT; -- 2.11.0