--- /dev/null
+#include "monster-lore/lore-store.h"
+#include "floor/floor.h"
+#include "monster-race/race-flags1.h"
+#include "monster/monster2.h" // todo 依存しているのは気持ち悪い。後で消したい.
+#include "system/monster-type-definition.h"
+
+/*!
+ * @brief モンスターの調査による思い出補完処理 / Learn about a monster (by "probing" it)
+ * @param player_ptr プレーヤーへの参照ポインタ
+ * @param r_idx 補完されるモンスター種族ID
+ * @return 明らかになった情報の度数
+ * @details
+ * Return the number of new flags learnt. -Mogami-
+ */
+int lore_do_probe(player_type *player_ptr, MONRACE_IDX r_idx)
+{
+ int n = 0;
+ monster_race *r_ptr = &r_info[r_idx];
+ if (r_ptr->r_wake != MAX_UCHAR)
+ n++;
+ if (r_ptr->r_ignore != MAX_UCHAR)
+ n++;
+ r_ptr->r_wake = r_ptr->r_ignore = MAX_UCHAR;
+
+ for (int i = 0; i < 4; i++) {
+ if (r_ptr->blow[i].effect || r_ptr->blow[i].method) {
+ if (r_ptr->r_blows[i] != MAX_UCHAR)
+ n++;
+ r_ptr->r_blows[i] = MAX_UCHAR;
+ }
+ }
+
+ byte tmp_byte = (((r_ptr->flags1 & RF1_DROP_4D2) ? 8 : 0) + ((r_ptr->flags1 & RF1_DROP_3D2) ? 6 : 0) + ((r_ptr->flags1 & RF1_DROP_2D2) ? 4 : 0)
+ + ((r_ptr->flags1 & RF1_DROP_1D2) ? 2 : 0) + ((r_ptr->flags1 & RF1_DROP_90) ? 1 : 0) + ((r_ptr->flags1 & RF1_DROP_60) ? 1 : 0));
+
+ if (!(r_ptr->flags1 & RF1_ONLY_GOLD)) {
+ if (r_ptr->r_drop_item != tmp_byte)
+ n++;
+ r_ptr->r_drop_item = tmp_byte;
+ }
+ if (!(r_ptr->flags1 & RF1_ONLY_ITEM)) {
+ if (r_ptr->r_drop_gold != tmp_byte)
+ n++;
+ r_ptr->r_drop_gold = tmp_byte;
+ }
+
+ if (r_ptr->r_cast_spell != MAX_UCHAR)
+ n++;
+ r_ptr->r_cast_spell = MAX_UCHAR;
+
+ for (int i = 0; i < 32; i++) {
+ if (!(r_ptr->r_flags1 & (1L << i)) && (r_ptr->flags1 & (1L << i)))
+ n++;
+ if (!(r_ptr->r_flags2 & (1L << i)) && (r_ptr->flags2 & (1L << i)))
+ n++;
+ if (!(r_ptr->r_flags3 & (1L << i)) && (r_ptr->flags3 & (1L << i)))
+ n++;
+ if (!(r_ptr->r_flags4 & (1L << i)) && (r_ptr->flags4 & (1L << i)))
+ n++;
+ if (!(r_ptr->r_flags5 & (1L << i)) && (r_ptr->a_ability_flags1 & (1L << i)))
+ n++;
+ if (!(r_ptr->r_flags6 & (1L << i)) && (r_ptr->a_ability_flags2 & (1L << i)))
+ n++;
+ if (!(r_ptr->r_flagsr & (1L << i)) && (r_ptr->flagsr & (1L << i)))
+ n++;
+ }
+
+ r_ptr->r_flags1 = r_ptr->flags1;
+ r_ptr->r_flags2 = r_ptr->flags2;
+ r_ptr->r_flags3 = r_ptr->flags3;
+ r_ptr->r_flags4 = r_ptr->flags4;
+ r_ptr->r_flags5 = r_ptr->a_ability_flags1;
+ r_ptr->r_flags6 = r_ptr->a_ability_flags2;
+ r_ptr->r_flagsr = r_ptr->flagsr;
+
+ if (!(r_ptr->r_xtra1 & MR1_SINKA))
+ n++;
+ r_ptr->r_xtra1 |= MR1_SINKA;
+
+ if (player_ptr->monster_race_idx == r_idx) {
+ player_ptr->window |= (PW_MONSTER);
+ }
+
+ return n;
+}
+
+/*!
+ * @brief モンスターの撃破に伴うドロップ情報の記憶処理 / Take note that the given monster just dropped some treasure
+ * @param player_ptr プレーヤーへの参照ポインタ
+ * @param m_idx モンスター情報のID
+ * @param num_item 手に入れたアイテム数
+ * @param num_gold 手に入れた財宝の単位数
+ * @return なし
+ */
+void lore_treasure(player_type *player_ptr, MONSTER_IDX m_idx, ITEM_NUMBER num_item, ITEM_NUMBER num_gold)
+{
+ monster_type *m_ptr = &player_ptr->current_floor_ptr->m_list[m_idx];
+ monster_race *r_ptr = &r_info[m_ptr->r_idx];
+
+ if (!is_original_ap(m_ptr))
+ return;
+
+ if (num_item > r_ptr->r_drop_item)
+ r_ptr->r_drop_item = num_item;
+ if (num_gold > r_ptr->r_drop_gold)
+ r_ptr->r_drop_gold = num_gold;
+
+ if (r_ptr->flags1 & (RF1_DROP_GOOD))
+ r_ptr->r_flags1 |= (RF1_DROP_GOOD);
+ if (r_ptr->flags1 & (RF1_DROP_GREAT))
+ r_ptr->r_flags1 |= (RF1_DROP_GREAT);
+ if (player_ptr->monster_race_idx == m_ptr->r_idx)
+ player_ptr->window |= (PW_MONSTER);
+}
/*!
- * @brief モンスターの調査による思い出補完処理 / Learn about a monster (by "probing" it)
- * @param player_ptr プレーヤーへの参照ポインタ
- * @param r_idx 補完されるモンスター種族ID
- * @return 明らかになった情報の度数
- * @details
- * Return the number of new flags learnt. -Mogami-
- */
-int lore_do_probe(player_type *player_ptr, MONRACE_IDX r_idx)
-{
- int n = 0;
- monster_race *r_ptr = &r_info[r_idx];
- if (r_ptr->r_wake != MAX_UCHAR) n++;
- if (r_ptr->r_ignore != MAX_UCHAR) n++;
- r_ptr->r_wake = r_ptr->r_ignore = MAX_UCHAR;
-
- for (int i = 0; i < 4; i++)
- {
- if (r_ptr->blow[i].effect || r_ptr->blow[i].method)
- {
- if (r_ptr->r_blows[i] != MAX_UCHAR) n++;
- r_ptr->r_blows[i] = MAX_UCHAR;
- }
- }
-
- byte tmp_byte =
- (((r_ptr->flags1 & RF1_DROP_4D2) ? 8 : 0) +
- ((r_ptr->flags1 & RF1_DROP_3D2) ? 6 : 0) +
- ((r_ptr->flags1 & RF1_DROP_2D2) ? 4 : 0) +
- ((r_ptr->flags1 & RF1_DROP_1D2) ? 2 : 0) +
- ((r_ptr->flags1 & RF1_DROP_90) ? 1 : 0) +
- ((r_ptr->flags1 & RF1_DROP_60) ? 1 : 0));
-
- if (!(r_ptr->flags1 & RF1_ONLY_GOLD))
- {
- if (r_ptr->r_drop_item != tmp_byte) n++;
- r_ptr->r_drop_item = tmp_byte;
- }
- if (!(r_ptr->flags1 & RF1_ONLY_ITEM))
- {
- if (r_ptr->r_drop_gold != tmp_byte) n++;
- r_ptr->r_drop_gold = tmp_byte;
- }
-
- if (r_ptr->r_cast_spell != MAX_UCHAR) n++;
- r_ptr->r_cast_spell = MAX_UCHAR;
-
- for (int i = 0; i < 32; i++)
- {
- if (!(r_ptr->r_flags1 & (1L << i)) &&
- (r_ptr->flags1 & (1L << i))) n++;
- if (!(r_ptr->r_flags2 & (1L << i)) &&
- (r_ptr->flags2 & (1L << i))) n++;
- if (!(r_ptr->r_flags3 & (1L << i)) &&
- (r_ptr->flags3 & (1L << i))) n++;
- if (!(r_ptr->r_flags4 & (1L << i)) &&
- (r_ptr->flags4 & (1L << i))) n++;
- if (!(r_ptr->r_flags5 & (1L << i)) &&
- (r_ptr->a_ability_flags1 & (1L << i))) n++;
- if (!(r_ptr->r_flags6 & (1L << i)) &&
- (r_ptr->a_ability_flags2 & (1L << i))) n++;
- if (!(r_ptr->r_flagsr & (1L << i)) &&
- (r_ptr->flagsr & (1L << i))) n++;
- }
-
- r_ptr->r_flags1 = r_ptr->flags1;
- r_ptr->r_flags2 = r_ptr->flags2;
- r_ptr->r_flags3 = r_ptr->flags3;
- r_ptr->r_flags4 = r_ptr->flags4;
- r_ptr->r_flags5 = r_ptr->a_ability_flags1;
- r_ptr->r_flags6 = r_ptr->a_ability_flags2;
- r_ptr->r_flagsr = r_ptr->flagsr;
-
- if (!(r_ptr->r_xtra1 & MR1_SINKA)) n++;
- r_ptr->r_xtra1 |= MR1_SINKA;
-
- if (player_ptr->monster_race_idx == r_idx)
- {
- player_ptr->window |= (PW_MONSTER);
- }
-
- return n;
-}
-
-
-/*!
- * @brief モンスターの撃破に伴うドロップ情報の保管処理 / Take note that the given monster just dropped some treasure
- * @param player_ptr プレーヤーへの参照ポインタ
- * @param m_idx モンスター情報のID
- * @param num_item 手に入れたアイテム数
- * @param num_gold 手に入れた財宝の単位数
- * @return なし
- * @details
- * Note that learning the "GOOD"/"GREAT" flags gives information
- * about the treasure (even when the monster is killed for the first
- * time, such as uniques, and the treasure has not been examined yet).
- *
- * This "indirect" method is used to prevent the player from learning
- * exactly how much treasure a monster can drop from observing only
- * a single example of a drop. This method actually observes how much
- * gold and items are dropped, and remembers that information to be
- * described later by the monster recall code.
- */
-void lore_treasure(player_type *player_ptr, MONSTER_IDX m_idx, ITEM_NUMBER num_item, ITEM_NUMBER num_gold)
-{
- monster_type *m_ptr = &player_ptr->current_floor_ptr->m_list[m_idx];
- monster_race *r_ptr = &r_info[m_ptr->r_idx];
-
- if (!is_original_ap(m_ptr)) return;
-
- if (num_item > r_ptr->r_drop_item) r_ptr->r_drop_item = num_item;
- if (num_gold > r_ptr->r_drop_gold) r_ptr->r_drop_gold = num_gold;
-
- if (r_ptr->flags1 & (RF1_DROP_GOOD)) r_ptr->r_flags1 |= (RF1_DROP_GOOD);
- if (r_ptr->flags1 & (RF1_DROP_GREAT)) r_ptr->r_flags1 |= (RF1_DROP_GREAT);
- if (player_ptr->monster_race_idx == m_ptr->r_idx) player_ptr->window |= (PW_MONSTER);
-}
-
-
-/*!
* @brief モンスターの各情報を更新する / This function updates the monster record of the given monster
* @param m_idx 更新するモンスター情報のID
* @param full プレイヤーとの距離更新を行うならばtrue
* @return なし
- * @details
- * This involves extracting the distance to the player (if requested),
- * and then checking for visibility (natural, infravision, see-invis,
- * telepathy), updating the monster visibility flag, redrawing (or
- * erasing) the monster when its visibility changes, and taking note
- * of any interesting monster flags (cold-blooded, invisible, etc).
- *
- * Note the new "mflag" field which encodes several monster state flags,
- * including "view" for when the monster is currently in line of sight,
- * and "mark" for when the monster is currently visible via detection.
- *
- * The only monster fields that are changed here are "cdis" (the
- * distance from the player), "ml" (visible to the player), and
- * "mflag" (to maintain the "MFLAG_VIEW" flag).
- *
- * Note the special "update_monsters()" function which can be used to
- * call this function once for every monster.
- *
- * Note the "full" flag which requests that the "cdis" field be updated,
- * this is only needed when the monster (or the player) has moved.
- *
- * Every time a monster moves, we must call this function for that
- * monster, and update the distance, and the visibility. Every time
- * the player moves, we must call this function for every monster, and
- * update the distance, and the visibility. Whenever the player "state"
- * changes in certain ways ("blindness", "infravision", "telepathy",
- * and "see invisible"), we must call this function for every monster,
- * and update the visibility.
- *
- * Routines that change the "illumination" of a grid must also call this
- * function for any monster in that grid, since the "visibility" of some
- * monsters may be based on the illumination of their grid.
- *
- * Note that this function is called once per monster every time the
- * player moves. When the player is running, this function is one
- * of the primary bottlenecks, along with "update_view()" and the
- * "process_monsters()" code, so efficiency is important.
- *
- * Note the optimized "inline" version of the "distance()" function.
- *
- * A monster is "visible" to the player if (1) it has been detected
- * by the player, (2) it is close to the player and the player has
- * telepathy, or (3) it is close to the player, and in line of sight
- * of the player, and it is "illuminated" by some combination of
- * infravision, torch light, or permanent light (invisible monsters
- * are only affected by "light" if the player can see invisible).
- *
- * Monsters which are not on the current panel may be "visible" to
- * the player, and their descriptions will include an "offscreen"
- * reference. Currently, offscreen monsters cannot be targetted
- * or viewed directly, but old targets will remain set. XXX XXX
- *
- * The player can choose to be disturbed by several things, including
- * "disturb_move" (monster which is viewable moves in some way), and
- * "disturb_near" (monster which is "easily" viewable moves in some
- * way). Note that "moves" includes "appears" and "disappears".
*/
void update_monster(player_type *subject_ptr, MONSTER_IDX m_idx, bool full)
{
{
return m_idx > 0 && is_friendly(&player_ptr->current_floor_ptr->m_list[(m_idx)]);
}
+
+bool is_original_ap(monster_type* m_ptr) { return m_ptr->ap_r_idx == m_ptr->r_idx; }