From 35ba8b004c75685d14d2b48a31c89e6471bd01ff Mon Sep 17 00:00:00 2001 From: Habu Date: Thu, 27 May 2021 19:29:53 +0900 Subject: [PATCH] =?utf8?q?[Fix]=20=E3=83=A2=E3=83=B3=E3=82=B9=E3=82=BF?= =?utf8?q?=E3=83=BC=E3=81=8C=E3=83=86=E3=83=AC=E3=83=9D=E3=83=BC=E3=83=88?= =?utf8?q?=E8=BF=BD=E5=B0=BE=E3=81=97=E3=81=AA=E3=81=84=20#1157?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit テレポートした後の座標の周囲のモンスターをスキャン しているのでついてこれるわけがない。 テレポート前の座標の周囲をスキャンするようにする。 また、is_resistible という変数名の意味が分かりづらい ので can_follow に変更する。 --- src/spell-kind/spells-teleport.cpp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/spell-kind/spells-teleport.cpp b/src/spell-kind/spells-teleport.cpp index d7d62003f..a058b65b6 100644 --- a/src/spell-kind/spells-teleport.cpp +++ b/src/spell-kind/spells-teleport.cpp @@ -374,12 +374,13 @@ bool teleport_player_aux(player_type *creature_ptr, POSITION dis, bool is_quantu */ void teleport_player(player_type *creature_ptr, POSITION dis, BIT_FLAGS mode) { + const POSITION oy = creature_ptr->y; + const POSITION ox = creature_ptr->x; + if (!teleport_player_aux(creature_ptr, dis, FALSE, static_cast(mode))) return; /* Monsters with teleport ability may follow the player */ - POSITION oy = creature_ptr->y; - POSITION ox = creature_ptr->x; for (POSITION xx = -1; xx < 2; xx++) { for (POSITION yy = -1; yy < 2; yy++) { MONSTER_IDX tmp_m_idx = creature_ptr->current_floor_ptr->grid_array[oy + yy][ox + xx].m_idx; @@ -387,10 +388,10 @@ void teleport_player(player_type *creature_ptr, POSITION dis, BIT_FLAGS mode) monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[tmp_m_idx]; monster_race *r_ptr = &r_info[m_ptr->r_idx]; - bool is_resistible = r_ptr->ability_flags.has(RF_ABILITY::TPORT); - is_resistible &= (r_ptr->flagsr & RFR_RES_TELE) == 0; - is_resistible &= monster_csleep_remaining(m_ptr) == 0; - if (is_resistible) { + bool can_follow = r_ptr->ability_flags.has(RF_ABILITY::TPORT); + can_follow &= none_bits(r_ptr->flagsr, RFR_RES_TELE); + can_follow &= monster_csleep_remaining(m_ptr) == 0; + if (can_follow) { teleport_monster_to(creature_ptr, tmp_m_idx, creature_ptr->y, creature_ptr->x, r_ptr->level, TELEPORT_SPONTANEOUS); } } @@ -407,12 +408,13 @@ void teleport_player(player_type *creature_ptr, POSITION dis, BIT_FLAGS mode) */ void teleport_player_away(MONSTER_IDX m_idx, player_type *target_ptr, POSITION dis, bool is_quantum_effect) { + const POSITION oy = target_ptr->y; + const POSITION ox = target_ptr->x; + if (!teleport_player_aux(target_ptr, dis, is_quantum_effect, TELEPORT_PASSIVE)) return; /* Monsters with teleport ability may follow the player */ - POSITION oy = target_ptr->y; - POSITION ox = target_ptr->x; for (POSITION xx = -1; xx < 2; xx++) { for (POSITION yy = -1; yy < 2; yy++) { MONSTER_IDX tmp_m_idx = target_ptr->current_floor_ptr->grid_array[oy + yy][ox + xx].m_idx; @@ -426,10 +428,10 @@ void teleport_player_away(MONSTER_IDX m_idx, player_type *target_ptr, POSITION d monster_type *m_ptr = &target_ptr->current_floor_ptr->m_list[tmp_m_idx]; monster_race *r_ptr = &r_info[m_ptr->r_idx]; - bool is_resistible = r_ptr->ability_flags.has(RF_ABILITY::TPORT); - is_resistible &= (r_ptr->flagsr & RFR_RES_TELE) == 0; - is_resistible &= monster_csleep_remaining(m_ptr) == 0; - if (is_resistible) { + bool can_follow = r_ptr->ability_flags.has(RF_ABILITY::TPORT); + can_follow &= none_bits(r_ptr->flagsr, RFR_RES_TELE); + can_follow &= monster_csleep_remaining(m_ptr) == 0; + if (can_follow) { teleport_monster_to(target_ptr, tmp_m_idx, target_ptr->y, target_ptr->x, r_ptr->level, TELEPORT_SPONTANEOUS); } } -- 2.11.0