• R/O
  • HTTP
  • SSH
  • HTTPS

hengband: Commit

変愚蛮怒のメインリポジトリです


Commit MetaInfo

Revisão013f02850cda51c1d1136e9aba9ac6600acabc41 (tree)
Hora2020-02-17 23:09:53
AutorHourier <hourier@user...>
CommiterHourier

Mensagem de Log

[Refactor] #40030 decide_monster_movement_direction() からdecide_pet_movement_direction() を分離 / Separated decide_pet_movement_direction() from decide_monster_movement_direction()

Mudança Sumário

Diff

--- a/src/monster-process.c
+++ b/src/monster-process.c
@@ -90,6 +90,7 @@ void produce_quantum_effect(player_type *target_ptr, MONSTER_IDX m_idx, bool see
9090 bool explode_monster(player_type *target_ptr, MONSTER_IDX m_idx);
9191 bool decide_monster_multiplication(player_type *target_ptr, MONSTER_IDX m_idx, POSITION oy, POSITION ox);
9292 bool decide_monster_movement_direction(player_type *target_ptr, DIRECTION *mm, MONSTER_IDX m_idx, bool aware);
93+bool decide_pet_movement_direction(player_type *target_ptr, DIRECTION *mm, MONSTER_IDX m_idx);
9394 bool runaway_monster(player_type *target_ptr, turn_flags *turn_flags_ptr, MONSTER_IDX m_idx);
9495 void escape_monster(player_type *target_ptr, turn_flags *turn_flags_ptr, monster_type *m_ptr, GAME_TEXT *m_name);
9596 void process_special(player_type *target_ptr, MONSTER_IDX m_idx);
@@ -1451,7 +1452,6 @@ void produce_quantum_effect(player_type *target_ptr, MONSTER_IDX m_idx, bool see
14511452 if (target)
14521453 {
14531454 (void)monspell_to_monster(target_ptr, blink, m_ptr->fy, m_ptr->fx, m_idx, m_idx);
1454-
14551455 }
14561456 else
14571457 {
@@ -1655,29 +1655,7 @@ bool decide_monster_movement_direction(player_type *target_ptr, DIRECTION *mm, M
16551655 return TRUE;
16561656 }
16571657
1658- if (is_pet(m_ptr))
1659- {
1660- bool avoid = ((target_ptr->pet_follow_distance < 0) && (m_ptr->cdis <= (0 - target_ptr->pet_follow_distance)));
1661- bool lonely = (!avoid && (m_ptr->cdis > target_ptr->pet_follow_distance));
1662- bool distant = (m_ptr->cdis > PET_SEEK_DIST);
1663- mm[0] = mm[1] = mm[2] = mm[3] = 5;
1664- if (!get_enemy_dir(target_ptr, m_idx, mm))
1665- {
1666- if (avoid || lonely || distant)
1667- {
1668- POSITION dis = target_ptr->pet_follow_distance;
1669- if (target_ptr->pet_follow_distance > PET_SEEK_DIST)
1670- {
1671- target_ptr->pet_follow_distance = PET_SEEK_DIST;
1672- }
1673-
1674- (void)get_moves(target_ptr, m_idx, mm);
1675- target_ptr->pet_follow_distance = (s16b)dis;
1676- }
1677- }
1678-
1679- return TRUE;
1680- }
1658+ if (decide_pet_movement_direction(target_ptr, mm, m_idx)) return TRUE;
16811659
16821660 if (!is_hostile(m_ptr))
16831661 {
@@ -1695,6 +1673,37 @@ bool decide_monster_movement_direction(player_type *target_ptr, DIRECTION *mm, M
16951673 /*!
16961674 * @brief ペットや友好的なモンスターがフロアから逃げる処理を行う
16971675 * @param target_ptr プレーヤーへの参照ポインタ
1676+ * @param mm 移動方向
1677+ * @param m_idx モンスターID
1678+ * @return モンスターがペットであればTRUE
1679+ */
1680+bool decide_pet_movement_direction(player_type *target_ptr, DIRECTION *mm, MONSTER_IDX m_idx)
1681+{
1682+ monster_type *m_ptr = &target_ptr->current_floor_ptr->m_list[m_idx];
1683+ if (!is_pet(m_ptr)) return FALSE;
1684+
1685+ bool avoid = ((target_ptr->pet_follow_distance < 0) && (m_ptr->cdis <= (0 - target_ptr->pet_follow_distance)));
1686+ bool lonely = (!avoid && (m_ptr->cdis > target_ptr->pet_follow_distance));
1687+ bool distant = (m_ptr->cdis > PET_SEEK_DIST);
1688+ mm[0] = mm[1] = mm[2] = mm[3] = 5;
1689+ if (get_enemy_dir(target_ptr, m_idx, mm)) return TRUE;
1690+ if (!avoid && !lonely && !distant) return TRUE;
1691+
1692+ POSITION dis = target_ptr->pet_follow_distance;
1693+ if (target_ptr->pet_follow_distance > PET_SEEK_DIST)
1694+ {
1695+ target_ptr->pet_follow_distance = PET_SEEK_DIST;
1696+ }
1697+
1698+ (void)get_moves(target_ptr, m_idx, mm);
1699+ target_ptr->pet_follow_distance = (s16b)dis;
1700+ return TRUE;
1701+}
1702+
1703+
1704+/*!
1705+ * @brief ペットや友好的なモンスターがフロアから逃げる処理を行う
1706+ * @param target_ptr プレーヤーへの参照ポインタ
16981707 * @param m_idx モンスターID
16991708 * @param is_riding_mon 騎乗状態ならばTRUE
17001709 * @param see_m モンスターが視界内にいたらTRUE
@@ -1930,7 +1939,6 @@ bool process_monster_movement(player_type *target_ptr, turn_flags *turn_flags_pt
19301939 }
19311940
19321941 update_object_by_monster_movement(target_ptr, turn_flags_ptr, m_idx, ny, nx);
1933-
19341942 if (turn_flags_ptr->do_turn) break;
19351943
19361944 *count++;
Show on old repository browser