From c5226b18761737e0c8722b66db54d4ed472da509 Mon Sep 17 00:00:00 2001 From: deskull Date: Sat, 4 Jul 2020 14:25:05 +0900 Subject: [PATCH] =?utf8?q?[Refactor]=20#40514=20calc=5Fspeed()=20=E3=82=92?= =?utf8?q?=20calc=5Fbonuses()=E3=80=80=E3=81=8B=E3=82=89=E5=88=86=E9=9B=A2?= =?utf8?q?=EF=BC=8E=20/=20Separated=20calc=5Fspeed()=20from=20calc=5Fbonus?= =?utf8?q?es().?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/mutation/mutation.c | 11 ------ src/player/player-effects.c | 8 ----- src/player/player-personality.c | 3 -- src/player/player-race.c | 5 +-- src/player/player-status.c | 76 +++++++++++++++++++++++++++++++++++------ 5 files changed, 67 insertions(+), 36 deletions(-) diff --git a/src/mutation/mutation.c b/src/mutation/mutation.c index 9b10a0b1c..e62ecf35c 100644 --- a/src/mutation/mutation.c +++ b/src/mutation/mutation.c @@ -1891,22 +1891,11 @@ void set_mutation_flags(player_type *creature_ptr) { if (creature_ptr->muta3) { - if (creature_ptr->muta3 & MUT3_XTRA_FAT) { - creature_ptr->pspeed -= 2; - } if (creature_ptr->muta3 & MUT3_FLESH_ROT) { creature_ptr->regenerate = FALSE; } - if (creature_ptr->muta3 & MUT3_XTRA_LEGS) { - creature_ptr->pspeed += 3; - } - - if (creature_ptr->muta3 & MUT3_SHORT_LEG) { - creature_ptr->pspeed -= 3; - } - if (creature_ptr->muta3 & MUT3_ELEC_TOUC) { creature_ptr->sh_elec = TRUE; } diff --git a/src/player/player-effects.c b/src/player/player-effects.c index 498e0ced8..0754d53ef 100644 --- a/src/player/player-effects.c +++ b/src/player/player-effects.c @@ -4000,14 +4000,6 @@ void calc_timelimit_status(player_type *creature_ptr) creature_ptr->skill_dig += 30; } - if (IS_FAST(creature_ptr)) { - creature_ptr->pspeed += 10; - } - - if (creature_ptr->slow) { - creature_ptr->pspeed -= 10; - } - if (is_time_limit_esp(creature_ptr)) { creature_ptr->telepathy = TRUE; } diff --git a/src/player/player-personality.c b/src/player/player-personality.c index 0e20cf1de..4dfa59765 100644 --- a/src/player/player-personality.c +++ b/src/player/player-personality.c @@ -157,8 +157,5 @@ void set_personality_flags(player_type *creature_ptr) creature_ptr->hold_exp = TRUE; if (creature_ptr->pclass != CLASS_NINJA) creature_ptr->lite = TRUE; - - if ((creature_ptr->prace != RACE_KLACKON) && (creature_ptr->prace != RACE_SPRITE)) - creature_ptr->pspeed += (creature_ptr->lev) / 10 + 5; } } diff --git a/src/player/player-race.c b/src/player/player-race.c index ccca6813a..142ab9b09 100644 --- a/src/player/player-race.c +++ b/src/player/player-race.c @@ -121,7 +121,7 @@ bool is_specific_player_race(player_type *creature_ptr, player_race_type prace) void calc_race_status(player_type *creature_ptr) { const player_race *tmp_rp_ptr; - if (creature_ptr->mimic_form) + if (creature_ptr->mimic_form) tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form]; else tmp_rp_ptr = &race_info[creature_ptr->prace]; @@ -135,7 +135,6 @@ void calc_race_status(player_type *creature_ptr) creature_ptr->resist_fire = TRUE; creature_ptr->oppose_fire = 1; creature_ptr->see_inv = TRUE; - creature_ptr->pspeed += 3; creature_ptr->redraw |= PR_STATUS; creature_ptr->to_a += 10; creature_ptr->dis_to_a += 10; @@ -159,7 +158,6 @@ void calc_race_status(player_type *creature_ptr) creature_ptr->telepathy = TRUE; creature_ptr->levitation = TRUE; creature_ptr->kill_wall = TRUE; - creature_ptr->pspeed += 5; creature_ptr->to_a += 20; creature_ptr->dis_to_a += 20; break; @@ -170,7 +168,6 @@ void calc_race_status(player_type *creature_ptr) creature_ptr->resist_cold = TRUE; creature_ptr->resist_pois = TRUE; creature_ptr->see_inv = TRUE; - creature_ptr->pspeed += 3; creature_ptr->to_a += 10; creature_ptr->dis_to_a += 10; if (creature_ptr->pclass != CLASS_NINJA) diff --git a/src/player/player-status.c b/src/player/player-status.c index 682be5a04..e3fc22e71 100644 --- a/src/player/player-status.c +++ b/src/player/player-status.c @@ -102,6 +102,8 @@ static void calc_constitution_addition(player_type *creature_ptr); static void calc_charisma_addition(player_type *creature_ptr); static void calc_to_magic_chance(player_type *creature_ptr); static void calc_base_ac(player_type *creature_ptr); +static void calc_base_ac_display(player_type *creature_ptr); +static void calc_speed(player_type *creature_ptr); /*! * @brief 能力値テーブル / Abbreviations of healthy stats @@ -1319,7 +1321,6 @@ static void clear_creature_bonuses(player_type *creature_ptr) creature_ptr->migite = FALSE; creature_ptr->hidarite = FALSE; creature_ptr->no_flowed = FALSE; - creature_ptr->pspeed = 110; creature_ptr->yoiyami = FALSE; creature_ptr->easy_2weapon = FALSE; creature_ptr->down_saving = FALSE; @@ -2063,15 +2064,7 @@ void calc_bonuses(player_type *creature_ptr) if (creature_ptr->num_blow[i] < 1) creature_ptr->num_blow[i] = 1; } - /* Maximum speed is (+99). (internally it's 110 + 99) */ - /* Temporary lightspeed forces to be maximum speed */ - if ((creature_ptr->lightspeed && !creature_ptr->riding) || (creature_ptr->pspeed > 209)) - { - creature_ptr->pspeed = 209; - } - - /* Minimum speed is (-99). (internally it's 110 - 99) */ - if (creature_ptr->pspeed < 11) creature_ptr->pspeed = 11; + calc_speed(creature_ptr); if (creature_ptr->pspeed != old_speed) { @@ -4011,6 +4004,69 @@ static void calc_base_ac_display(player_type *creature_ptr) } } +static void calc_speed(player_type *creature_ptr) +{ + creature_ptr->pspeed = 110; + + const player_race *tmp_rp_ptr; + if (creature_ptr->mimic_form) + tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form]; + else + tmp_rp_ptr = &race_info[creature_ptr->prace]; + + if (creature_ptr->mimic_form) { + switch (creature_ptr->mimic_form) { + case MIMIC_DEMON: + creature_ptr->pspeed += 3; + break; + case MIMIC_DEMON_LORD: + creature_ptr->pspeed += 5; + break; + case MIMIC_VAMPIRE: + creature_ptr->pspeed += 3; + break; + } + } + + if (creature_ptr->pseikaku == PERSONALITY_MUNCHKIN && creature_ptr->prace != RACE_KLACKON && creature_ptr->prace != RACE_SPRITE) + { + creature_ptr->pspeed += (creature_ptr->lev) / 10 + 5; + } + + if (IS_FAST(creature_ptr)) { + creature_ptr->pspeed += 10; + } + + if (creature_ptr->slow) { + creature_ptr->pspeed -= 10; + } + + if (creature_ptr->muta3) { + + if (creature_ptr->muta3 & MUT3_XTRA_FAT) { + creature_ptr->pspeed -= 2; + } + + if (creature_ptr->muta3 & MUT3_XTRA_LEGS) { + creature_ptr->pspeed += 3; + } + + if (creature_ptr->muta3 & MUT3_SHORT_LEG) { + creature_ptr->pspeed -= 3; + } + } + + /* Maximum speed is (+99). (internally it's 110 + 99) */ + /* Temporary lightspeed forces to be maximum speed */ + if ((creature_ptr->lightspeed && !creature_ptr->riding) || (creature_ptr->pspeed > 209)) { + creature_ptr->pspeed = 209; + } + + /* Minimum speed is (-99). (internally it's 110 - 99) */ + if (creature_ptr->pspeed < 11) + creature_ptr->pspeed = 11; +} + /*! * @brief プレイヤーの所持重量制限を計算する / -- 2.11.0