/*!
* @brief モンスター情報配列を圧縮する / Compact and Reorder the monster list
+ * @param player_ptr プレーヤーへの参照ポインタ
* @param size 圧縮後のモンスター件数目標
* @return なし
* @details
* After "compacting" (if needed), we "reorder" the monsters into a more
* compact order, and we reset the allocation info, and the "live" array.
*/
-void compact_monsters(int size)
+void compact_monsters(player_type *player_ptr, int size)
{
MONSTER_IDX i;
int num, cnt;
if (size) msg_print(_("モンスター情報を圧縮しています...", "Compacting monsters..."));
/* Compact at least 'size' objects */
- floor_type *floor_ptr = p_ptr->current_floor_ptr;
+ floor_type *floor_ptr = player_ptr->current_floor_ptr;
for (num = 0, cnt = 1; num < size; cnt++)
{
/* Get more vicious each iteration */
/* Hack -- High level monsters start out "immune" */
if (r_ptr->level > cur_lev) continue;
- if (i == p_ptr->riding) continue;
+ if (i == player_ptr->riding) continue;
/* Ignore nearby monsters */
if ((cur_dis > 0) && (m_ptr->cdis < cur_dis)) continue;
{
GAME_TEXT m_name[MAX_NLEN];
monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
- exe_write_diary(p_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_COMPACT, m_name);
+ exe_write_diary(player_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_COMPACT, m_name);
}
delete_monster_idx(i);
if (m_ptr->r_idx) continue;
/* Move last monster into open hole */
- compact_monsters_aux(p_ptr, floor_ptr->m_max - 1, i);
+ compact_monsters_aux(player_ptr, floor_ptr->m_max - 1, i);
/* Compress "floor_ptr->m_max" */
floor_ptr->m_max--;
/*!
+ * todo ここには本来floor_type*を追加したいが、monster.hにfloor.hの参照を追加するとコンパイルエラーが出るので保留
* @brief プレイヤーのフロア離脱に伴う全モンスター配列の消去 / Delete/Remove all the monsters when the player leaves the level
+ * @param player_ptr プレーヤーへの参照ポインタ
* @return なし
* @details
* This is an efficient method of simulating multiple calls to the
* "delete_monster()" function, with no visual effects.
*/
-void wipe_m_list(void)
+void wipe_monsters_list(player_type *player_ptr)
{
int i;
}
/* Delete all the monsters */
- floor_type *floor_ptr = p_ptr->current_floor_ptr;
+ floor_type *floor_ptr = player_ptr->current_floor_ptr;
for (i = floor_ptr->m_max - 1; i >= 1; i--)
{
monster_type *m_ptr = &floor_ptr->m_list[i];
/* Hack -- no more target */
target_who = 0;
- p_ptr->pet_t_m_idx = 0;
- p_ptr->riding_t_m_idx = 0;
+ player_ptr->pet_t_m_idx = 0;
+ player_ptr->riding_t_m_idx = 0;
- health_track(p_ptr, 0);
+ health_track(player_ptr, 0);
}
/*!
+ * todo ここには本来floor_type*を追加したいが、monster.hにfloor.hの参照を追加するとコンパイルエラーが出るので保留
* @brief モンスター配列の空きを探す / Acquires and returns the index of a "free" monster.
* @return 利用可能なモンスター配列の添字
* @details
* This routine should almost never fail, but it *can* happen.
*/
-MONSTER_IDX m_pop(void)
+MONSTER_IDX m_pop(player_type *player_ptr)
{
MONSTER_IDX i;
/* Normal allocation */
- floor_type *floor_ptr = p_ptr->current_floor_ptr;
+ floor_type *floor_ptr = player_ptr->current_floor_ptr;
if (floor_ptr->m_max < current_world_ptr->max_m_idx)
{
/* Access the next hole */
}
-
-
/*!
* @var summon_specific_type
* @brief 召喚条件を指定するグローバル変数 / Hack -- the "type" of the current "summon specific"
*/
static int summon_specific_who = -1;
+
/*!
* @var summon_unique_okay
* @brief 召喚対象にユニークを含めるかを示すグローバル変数 / summoning unique enable
*/
static bool summon_unique_okay = FALSE;
+
/*!
* @brief 指定されたモンスター種族がsummon_specific_typeで指定された召喚条件に合うかどうかを返す
+ * @param player_ptr プレーヤーへの参照ポインタ
* @return 召喚条件が一致するならtrue
* @details
*/
-static bool summon_specific_aux(MONRACE_IDX summoner_idx, MONRACE_IDX r_idx)
+static bool summon_specific_aux(player_type *player_ptr, MONRACE_IDX summoner_idx, MONRACE_IDX r_idx)
{
monster_race *r_ptr = &r_info[r_idx];
int okay = FALSE;
}
else
{
- summon_kin_type = get_summon_symbol_from_player(p_ptr);
+ summon_kin_type = get_summon_symbol_from_player(player_ptr);
}
okay = ((r_ptr->d_char == summon_kin_type) && (r_idx != MON_HAGURE));
/*!
+ * todo ここには本来floor_type*を追加したいが、monster.hにfloor.hの参照を追加するとコンパイルエラーが出るので保留
* @brief 指定されたモンスター種族がダンジョンの制限にかかるかどうかをチェックする / Some dungeon types restrict the possible monsters.
+ * @param player_ptr プレーヤーへの参照ポインタ
* @param r_idx チェックするモンスター種族ID
* @return 召喚条件が一致するならtrue / Return TRUE is the monster is OK and FALSE otherwise
*/
-static bool restrict_monster_to_dungeon(DUNGEON_IDX d_idx, MONRACE_IDX r_idx)
+static bool restrict_monster_to_dungeon(player_type *player_ptr, MONRACE_IDX r_idx)
{
+ DUNGEON_IDX d_idx = player_ptr->dungeon_idx;
dungeon_type *d_ptr = &d_info[d_idx];
monster_race *r_ptr = &r_info[r_idx];
byte a;
return FALSE;
}
- floor_type *floor_ptr = p_ptr->current_floor_ptr;
+ floor_type *floor_ptr = player_ptr->current_floor_ptr;
if (d_ptr->flags1 & DF1_BEGINNER)
{
if (r_ptr->level > floor_ptr->dun_level)
/*!
* @brief モンスター生成制限関数最大2つから / Apply a "monster restriction function" to the "monster allocation table"
+ * @param player_ptr プレーヤーへの参照ポインタ
* @param monster_hook 制限関数1
* @param monster_hook2 制限関数2
* @return エラーコード
*/
-errr get_mon_num_prep(monsterrace_hook_type monster_hook,
- monsterrace_hook_type monster_hook2)
+errr get_mon_num_prep(player_type *player_ptr, monsterrace_hook_type monster_hook, monsterrace_hook_type monster_hook2)
{
int i;
get_mon_num2_hook = monster_hook2;
/* Scan the allocation table */
- floor_type *floor_ptr = p_ptr->current_floor_ptr;
+ floor_type *floor_ptr = player_ptr->current_floor_ptr;
for (i = 0; i < alloc_race_size; i++)
{
monster_race *r_ptr;
(get_mon_num2_hook && !((*get_mon_num2_hook)(entry->index))))
continue;
- if (!p_ptr->phase_out && !chameleon_change_m_idx &&
+ if (!player_ptr->phase_out && !chameleon_change_m_idx &&
summon_specific_type != SUMMON_GUARDIANS)
{
/* Hack -- don't create questors */
entry->prob2 = entry->prob1;
if (floor_ptr->dun_level && (!floor_ptr->inside_quest || is_fixed_quest_idx(floor_ptr->inside_quest)) &&
- !restrict_monster_to_dungeon(p_ptr->dungeon_idx, entry->index) && !p_ptr->phase_out)
+ !restrict_monster_to_dungeon(player_ptr, entry->index) && !player_ptr->phase_out)
{
- int hoge = entry->prob2 * d_info[p_ptr->dungeon_idx].special_div;
+ int hoge = entry->prob2 * d_info[player_ptr->dungeon_idx].special_div;
entry->prob2 = hoge / 64;
if (randint0(64) < (hoge & 0x3f)) entry->prob2++;
}
/*!
* @brief 生成モンスター種族を1種生成テーブルから選択する
+ * @param player_ptr プレーヤーへの参照ポインタ
* @param level 生成階
* @return 選択されたモンスター生成種族
* @details
* Note that if no monsters are "appropriate", then this function will
* fail, and return zero, but this should *almost* never happen.
*/
-MONRACE_IDX get_mon_num(DEPTH level)
+MONRACE_IDX get_mon_num(player_type *player_ptr, DEPTH level)
{
int i, j, p;
MONRACE_IDX r_idx;
pls_kakuritu = MAX(NASTY_MON_MAX, NASTY_MON_BASE - ((current_world_ptr->dungeon_turn / (TURNS_PER_TICK * 5000L) - delay / 10)));
pls_level = MIN(NASTY_MON_PLUS_MAX, 3 + current_world_ptr->dungeon_turn / (TURNS_PER_TICK * 40000L) - delay / 40 + MIN(5, level / 10));
- if (d_info[p_ptr->dungeon_idx].flags1 & DF1_MAZE)
+ if (d_info[player_ptr->dungeon_idx].flags1 & DF1_MAZE)
{
pls_kakuritu = MIN(pls_kakuritu / 2, pls_kakuritu - 10);
if (pls_kakuritu < 2) pls_kakuritu = 2;
}
/* Boost the level */
- if (!p_ptr->phase_out && !(d_info[p_ptr->dungeon_idx].flags1 & DF1_BEGINNER))
+ if (!player_ptr->phase_out && !(d_info[player_ptr->dungeon_idx].flags1 & DF1_BEGINNER))
{
/* Nightmare mode allows more out-of depth monsters */
if (ironman_nightmare && !randint0(pls_kakuritu))
/* Access the actual race */
r_ptr = &r_info[r_idx];
- if (!p_ptr->phase_out && !chameleon_change_m_idx)
+ if (!player_ptr->phase_out && !chameleon_change_m_idx)
{
/* Hack -- "unique" monsters must be "unique" */
if (((r_ptr->flags1 & (RF1_UNIQUE)) ||
/*!
* @brief モンスターの変身処理
+ * @param player_ptr プレーヤーへの参照ポインタ
* @param m_idx 変身処理を受けるモンスター情報のID
* @param born 生成時の初変身先指定ならばtrue
* @param r_idx 旧モンスター種族のID
* @return なし
*/
-void choose_new_monster(MONSTER_IDX m_idx, bool born, MONRACE_IDX r_idx)
+void choose_new_monster(player_type *player_ptr, MONSTER_IDX m_idx, bool born, MONRACE_IDX r_idx)
{
int oldmaxhp;
- floor_type *floor_ptr = p_ptr->current_floor_ptr;
+ floor_type *floor_ptr = player_ptr->current_floor_ptr;
monster_type *m_ptr = &floor_ptr->m_list[m_idx];
monster_race *r_ptr;
char old_m_name[MAX_NLEN];
chameleon_change_m_idx = m_idx;
if (old_unique)
- get_mon_num_prep(monster_hook_chameleon_lord, NULL);
+ get_mon_num_prep(player_ptr, monster_hook_chameleon_lord, NULL);
else
- get_mon_num_prep(monster_hook_chameleon, NULL);
+ get_mon_num_prep(player_ptr, monster_hook_chameleon, NULL);
if (old_unique)
level = r_info[MON_CHAMELEON_K].level;
else if (!floor_ptr->dun_level)
- level = wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].level;
+ level = wilderness[player_ptr->wilderness_y][player_ptr->wilderness_x].level;
else
level = floor_ptr->dun_level;
- if (d_info[p_ptr->dungeon_idx].flags1 & DF1_CHAMELEON) level += 2 + randint1(3);
+ if (d_info[player_ptr->dungeon_idx].flags1 & DF1_CHAMELEON) level += 2 + randint1(3);
- r_idx = get_mon_num(level);
+ r_idx = get_mon_num(player_ptr, level);
r_ptr = &r_info[r_idx];
chameleon_change_m_idx = 0;
m_ptr->r_idx = r_idx;
m_ptr->ap_r_idx = r_idx;
- update_monster(p_ptr, m_idx, FALSE);
+ update_monster(player_ptr, m_idx, FALSE);
lite_spot(m_ptr->fy, m_ptr->fx);
if ((r_info[old_r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK)) ||
(r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK)))
- p_ptr->update |= (PU_MON_LITE);
+ player_ptr->update |= (PU_MON_LITE);
if (born)
{
return;
}
- if (m_idx == p_ptr->riding)
+ if (m_idx == player_ptr->riding)
{
GAME_TEXT m_name[MAX_NLEN];
monster_desc(m_name, m_ptr, 0);
msg_format(_("突然%sが変身した。", "Suddenly, %s transforms!"), old_m_name);
if (!(r_ptr->flags7 & RF7_RIDING))
- if (rakuba(p_ptr, 0, TRUE)) msg_format(_("地面に落とされた。", "You have fallen from %s."), m_name);
+ if (rakuba(player_ptr, 0, TRUE)) msg_format(_("地面に落とされた。", "You have fallen from %s."), m_name);
}
/* Extract the monster base speed */
/*!
+ * @param player_ptr プレーヤーへの参照ポインタ
* @brief モンスターの表層IDを設定する / Set initial racial appearance of a monster
* @param r_idx モンスター種族ID
* @return モンスター種族の表層ID
*/
-static MONRACE_IDX initial_r_appearance(MONRACE_IDX r_idx, BIT_FLAGS generate_mode)
+static MONRACE_IDX initial_r_appearance(player_type *player_ptr, MONRACE_IDX r_idx, BIT_FLAGS generate_mode)
{
floor_type *floor_ptr = p_ptr->current_floor_ptr;
int attempts = 1000;
if (!(r_info[r_idx].flags7 & RF7_TANUKI))
return r_idx;
- get_mon_num_prep(monster_hook_tanuki, NULL);
+ get_mon_num_prep(player_ptr, monster_hook_tanuki, NULL);
while (--attempts)
{
- ap_r_idx = get_mon_num(floor_ptr->base_level + 10);
+ ap_r_idx = get_mon_num(player_ptr, floor_ptr->base_level + 10);
if (r_info[ap_r_idx].level >= min) return ap_r_idx;
}
if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL) || (r_ptr->level < 10)) mode &= ~PM_KAGE;
/* Make a new monster */
- g_ptr->m_idx = m_pop();
+ g_ptr->m_idx = m_pop(player_ptr);
hack_m_idx_ii = g_ptr->m_idx;
/* Mega-Hack -- catch "failure" */
/* Save the race */
m_ptr->r_idx = r_idx;
- m_ptr->ap_r_idx = initial_r_appearance(r_idx, mode);
+ m_ptr->ap_r_idx = initial_r_appearance(player_ptr, r_idx, mode);
/* No flags */
m_ptr->mflag = 0;
if (r_ptr->flags7 & RF7_CHAMELEON)
{
- choose_new_monster(g_ptr->m_idx, TRUE, 0);
+ choose_new_monster(player_ptr, g_ptr->m_idx, TRUE, 0);
r_ptr = &r_info[m_ptr->r_idx];
m_ptr->mflag2 |= MFLAG2_CHAMELEON;
/* Require empty grids */
if (!cave_empty_bold2(player_ptr->current_floor_ptr, ny, nx)) continue;
- get_mon_num_prep(place_monster_can_escort, get_monster_hook2(player_ptr, ny, nx));
+ get_mon_num_prep(player_ptr, place_monster_can_escort, get_monster_hook2(player_ptr, ny, nx));
/* Pick a random race */
- z = get_mon_num(r_ptr->level);
+ z = get_mon_num(player_ptr, r_ptr->level);
/* Handle failure */
if (!z) break;
bool place_monster(player_type *player_ptr, POSITION y, POSITION x, BIT_FLAGS mode)
{
MONRACE_IDX r_idx;
- get_mon_num_prep(get_monster_hook(player_ptr), get_monster_hook2(player_ptr, y, x));
+ get_mon_num_prep(player_ptr, get_monster_hook(player_ptr), get_monster_hook2(player_ptr, y, x));
/* Pick a monster */
- r_idx = get_mon_num(player_ptr->current_floor_ptr->monster_level);
+ r_idx = get_mon_num(player_ptr, player_ptr->current_floor_ptr->monster_level);
/* Handle failure */
if (!r_idx) return FALSE;
int attempts = 1000;
POSITION cy = y;
POSITION cx = x;
- get_mon_num_prep(get_monster_hook(player_ptr), get_monster_hook2(player_ptr, y, x));
+ get_mon_num_prep(player_ptr, get_monster_hook(player_ptr), get_monster_hook2(player_ptr, y, x));
floor_type *floor_ptr = player_ptr->current_floor_ptr;
while (--attempts)
{
/* Pick a monster */
- r_idx = get_mon_num(floor_ptr->monster_level);
+ r_idx = get_mon_num(player_ptr, floor_ptr->monster_level);
/* Handle failure */
if (!r_idx) return FALSE;
if ((r_ptr->flags7 & RF7_CHAMELEON) && (d_info[p_ptr->dungeon_idx].flags1 & DF1_CHAMELEON)) return TRUE;
- return (summon_specific_aux(m_ptr->r_idx, r_idx));
+ return (summon_specific_aux(p_ptr, m_ptr->r_idx, r_idx));
}
summon_specific_type = type;
summon_unique_okay = (mode & PM_ALLOW_UNIQUE) ? TRUE : FALSE;
- get_mon_num_prep(summon_specific_okay, get_monster_hook2(player_ptr, y, x));
+ get_mon_num_prep(player_ptr, summon_specific_okay, get_monster_hook2(player_ptr, y, x));
/* Pick a monster, using the level calculation */
- r_idx = get_mon_num((floor_ptr->dun_level + lev) / 2 + 5);
+ r_idx = get_mon_num(player_ptr, (floor_ptr->dun_level + lev) / 2 + 5);
/* Handle failure */
if (!r_idx)