From 48fb9d37e391bd74cc393f3f17b042749a2b3a3f Mon Sep 17 00:00:00 2001 From: deskull Date: Sun, 26 Jul 2020 21:11:09 +0900 Subject: [PATCH] =?utf8?q?[Refactor]=20#40514=20have=5Fesp=5Ftelepathy()?= =?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=20have=5Fesp=5Ftelep?= =?utf8?q?athy()=20from=20calc=5Fbonuses().?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/mutation/mutation.c | 4 --- src/player/player-class.c | 2 -- src/player/player-race.c | 5 --- src/player/player-status-flags.c | 67 +++++++++++++++++++++++++++++++++------- src/player/player-status-flags.h | 1 + src/player/player-status.c | 8 +---- 6 files changed, 58 insertions(+), 29 deletions(-) diff --git a/src/mutation/mutation.c b/src/mutation/mutation.c index be7bd7f45..754249987 100644 --- a/src/mutation/mutation.c +++ b/src/mutation/mutation.c @@ -1923,10 +1923,6 @@ void set_mutation_flags(player_type *creature_ptr) creature_ptr->regenerate = TRUE; } - if (creature_ptr->muta3 & MUT3_ESP) { - creature_ptr->telepathy = 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 3d95244a7..d66adad00 100644 --- a/src/player/player-class.c +++ b/src/player/player-class.c @@ -1224,8 +1224,6 @@ void calc_class_status(player_type *creature_ptr) creature_ptr->sustain_wis = TRUE; if (creature_ptr->lev > 29) creature_ptr->resist_conf = TRUE; - if (creature_ptr->lev > 39) - creature_ptr->telepathy = TRUE; break; case CLASS_MONK: case CLASS_FORCETRAINER: diff --git a/src/player/player-race.c b/src/player/player-race.c index 4fde5c0db..2c0f5e8cc 100644 --- a/src/player/player-race.c +++ b/src/player/player-race.c @@ -155,7 +155,6 @@ void calc_race_status(player_type *creature_ptr) creature_ptr->resist_fear = TRUE; creature_ptr->sh_fire = TRUE; creature_ptr->see_inv = TRUE; - creature_ptr->telepathy = TRUE; creature_ptr->levitation = TRUE; break; case MIMIC_VAMPIRE: @@ -265,8 +264,6 @@ void calc_race_status(player_type *creature_ptr) creature_ptr->sustain_wis = TRUE; if (creature_ptr->lev > 14) creature_ptr->see_inv = TRUE; - if (creature_ptr->lev > 29) - creature_ptr->telepathy = TRUE; break; case RACE_IMP: creature_ptr->resist_fire = TRUE; @@ -317,8 +314,6 @@ void calc_race_status(player_type *creature_ptr) creature_ptr->slow_digest = TRUE; creature_ptr->resist_cold = TRUE; creature_ptr->pass_wall = TRUE; - if (creature_ptr->lev > 34) - creature_ptr->telepathy = TRUE; break; case RACE_SPRITE: creature_ptr->levitation = TRUE; diff --git a/src/player/player-status-flags.c b/src/player/player-status-flags.c index 78c6c4525..6cc02c4cb 100644 --- a/src/player/player-status-flags.c +++ b/src/player/player-status-flags.c @@ -1,22 +1,22 @@ -#include "player/player-status.h" -#include "player/player-race.h" +#include "inventory/inventory-slot-types.h" +#include "monster-race/monster-race.h" +#include "monster-race/race-flags2.h" +#include "mutation/mutation-flag-types.h" +#include "object-enchant/tr-types.h" +#include "object/object-flags.h" #include "player/player-race-types.h" +#include "player/player-race.h" +#include "player/player-status.h" +#include "player/special-defense-types.h" #include "realm/realm-hex-numbers.h" -#include "realm/realm-types.h" #include "realm/realm-song-numbers.h" +#include "realm/realm-types.h" #include "spell-realm/spells-hex.h" -#include "system/monster-type-definition.h" -#include "monster-race/race-flags2.h" -#include "monster-race/monster-race.h" -#include "system/monster-type-definition.h" #include "system/floor-type-definition.h" +#include "system/monster-type-definition.h" #include "system/object-type-definition.h" -#include "inventory/inventory-slot-types.h" -#include "object-enchant/tr-types.h" -#include "object/object-flags.h" #include "util/bit-flags-calculator.h" - void have_kill_wall(player_type *creature_ptr) { creature_ptr->kill_wall = FALSE; @@ -308,3 +308,48 @@ void have_esp_unique(player_type *creature_ptr) creature_ptr->esp_unique = TRUE; } } + +void have_esp_telepathy(player_type *creature_ptr) +{ + object_type *o_ptr; + BIT_FLAGS flgs[TR_FLAG_SIZE]; + + creature_ptr->telepathy = FALSE; + + if (is_time_limit_esp(creature_ptr)) { + creature_ptr->telepathy = TRUE; + } + + if (creature_ptr->muta3 & MUT3_ESP) { + creature_ptr->telepathy = TRUE; + } + + if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_MIND_FLAYER && creature_ptr->lev > 29) + creature_ptr->telepathy = TRUE; + + if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_SPECTRE && creature_ptr->lev > 34) + creature_ptr->telepathy = TRUE; + + if (creature_ptr->pclass == CLASS_MINDCRAFTER && creature_ptr->lev > 39) + creature_ptr->telepathy = TRUE; + + if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) { + creature_ptr->telepathy = TRUE; + } + + if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) { + creature_ptr->telepathy = 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_TELEPATHY)) + creature_ptr->telepathy = TRUE; + } +} diff --git a/src/player/player-status-flags.h b/src/player/player-status-flags.h index 78e35e73d..3cb2bdbc8 100644 --- a/src/player/player-status-flags.h +++ b/src/player/player-status-flags.h @@ -15,5 +15,6 @@ void have_esp_human(player_type *creature_ptr); void have_esp_good(player_type *creature_ptr); void have_esp_nonliving(player_type *creature_ptr); void have_esp_unique(player_type *creature_ptr); +void have_esp_telepathy(player_type *creature_ptr); diff --git a/src/player/player-status.c b/src/player/player-status.c index c9bd9fc62..362cf216f 100644 --- a/src/player/player-status.c +++ b/src/player/player-status.c @@ -577,7 +577,6 @@ static void clear_creature_bonuses(player_type *creature_ptr) creature_ptr->can_swim = FALSE; creature_ptr->levitation = FALSE; creature_ptr->hold_exp = FALSE; - creature_ptr->telepathy = FALSE; creature_ptr->lite = FALSE; creature_ptr->sustain_str = FALSE; creature_ptr->sustain_int = FALSE; @@ -711,6 +710,7 @@ void calc_bonuses(player_type *creature_ptr) have_esp_good(creature_ptr); have_esp_nonliving(creature_ptr); have_esp_unique(creature_ptr); + have_esp_telepathy(creature_ptr); calc_race_status(creature_ptr); @@ -4532,7 +4532,6 @@ void calc_timelimit_status(player_type *creature_ptr) creature_ptr->regenerate = TRUE; creature_ptr->levitation = TRUE; creature_ptr->hold_exp = TRUE; - creature_ptr->telepathy = TRUE; creature_ptr->lite = TRUE; creature_ptr->sustain_str = TRUE; creature_ptr->sustain_int = TRUE; @@ -4586,9 +4585,6 @@ void calc_timelimit_status(player_type *creature_ptr) creature_ptr->levitation = TRUE; } - if (is_time_limit_esp(creature_ptr)) { - creature_ptr->telepathy = TRUE; - } if (creature_ptr->ele_immune) { if (creature_ptr->special_defense & DEFENSE_ACID) @@ -4702,8 +4698,6 @@ void calc_equipment_status(player_type *creature_ptr) creature_ptr->slow_digest = TRUE; if (have_flag(flgs, TR_REGEN)) creature_ptr->regenerate = TRUE; - if (have_flag(flgs, TR_TELEPATHY)) - creature_ptr->telepathy = TRUE; if (have_flag(flgs, TR_SEE_INVIS)) creature_ptr->see_inv = TRUE; -- 2.11.0