*/
#include "angband.h"
+#include "util.h"
+
+#include "artifact.h"
+#include "dungeon.h"
#include "floor.h"
-#include "generate.h"
+#include "floor-events.h"
+#include "floor-generate.h"
+#include "feature.h"
#include "grid.h"
#include "monster.h"
#include "quest.h"
#include "wild.h"
#include "spells-floor.h"
-
+#include "monster-status.h"
+#include "object-hook.h"
+#include "cmd-pet.h"
+#include "cmd-basic.h"
+#include "files.h"
+#include "player-effects.h"
+#include "world.h"
static FLOOR_IDX new_floor_id; /*!<次のフロアのID / floor_id of the destination */
static u32b change_floor_mode; /*!<フロア移行処理に関するフラグ / Mode flags for changing floor */
static void kill_saved_floor(saved_floor_type *sf_ptr)
{
char floor_savefile[1024];
-
- /* Paranoia */
if (!sf_ptr) return;
/* Already empty */
{
monster_type *m_ptr = ¤t_floor_ptr->m_list[i];
- if (!m_ptr->r_idx) continue;
+ if (!monster_is_valid(m_ptr)) continue;
if (!is_pet(m_ptr)) continue;
if (i == p_ptr->riding) continue;
monster_type *m_ptr = ¤t_floor_ptr->m_list[i];
GAME_TEXT m_name[MAX_NLEN];
- if (!m_ptr->r_idx) continue;
+ if (!monster_is_valid(m_ptr)) continue;
if (!is_pet(m_ptr)) continue;
if (!m_ptr->nickname) continue;
if (p_ptr->riding == i) continue;
m_ptr = &party_mon[i];
/* Skip empty monsters */
- if (!m_ptr->r_idx) continue;
+ if (!monster_is_valid(m_ptr)) continue;
/* Hack -- Increase the racial counter */
real_r_ptr(m_ptr)->cur_num++;
m_ptr->fx = cx;
m_ptr->ml = TRUE;
m_ptr->mtimed[MTIMED_CSLEEP] = 0;
-
- /* Paranoia */
m_ptr->hold_o_idx = 0;
m_ptr->target_y = 0;
monster_race *r_ptr;
monster_type *m_ptr = ¤t_floor_ptr->m_list[i];
- /* Skip dead monsters */
- if (!m_ptr->r_idx) continue;
+ if (!monster_is_valid(m_ptr)) continue;
/* Extract real monster race */
r_ptr = real_r_ptr(m_ptr);
}
/* Maintain artifatcs */
- for (i = 1; i < o_max; i++)
+ for (i = 1; i < current_floor_ptr->o_max; i++)
{
object_type *o_ptr = ¤t_floor_ptr->o_list[i];
}
/*!
- * マス構造体のspecial要素を利用する地形かどうかを判定するマクロ / Is this feature has special meaning (except floor_id) with g_ptr->special?
- */
-#define feat_uses_special(F) (have_flag(f_info[(F)].flags, FF_SPECIAL))
-
-
-/*!
* @brief 新フロアに移動元フロアに繋がる階段を配置する / Virtually teleport onto the stairs that is connecting between two floors.
* @param sf_ptr 移動元の保存フロア構造体参照ポインタ
* @return なし
monster_race *r_ptr;
monster_type *m_ptr = ¤t_floor_ptr->m_list[i];
- /* Skip dead monsters */
- if (!m_ptr->r_idx) continue;
+ if (!monster_is_valid(m_ptr)) continue;
/* Only maintain quest monsters */
if (quest_r_idx != m_ptr->r_idx) continue;
/* Check if there is a same item */
for (i = 0; i < INVEN_PACK; i++)
{
- object_type *o_ptr = &inventory[i];
+ object_type *o_ptr = &p_ptr->inventory_list[i];
/* Skip dead objects */
if (!o_ptr->k_idx) continue;
/* Get out of the my way! */
get_out_monster();
- /* Record the last visit turn of current floor */
- sf_ptr->last_visit = turn;
+ /* Record the last visit current_world_ptr->game_turn of current floor */
+ sf_ptr->last_visit = current_world_ptr->game_turn;
forget_lite();
forget_view();
panel_col_max = 0;
/* Mega-Hack -- not ambushed on the wildness? */
- ambush_flag = FALSE;
+ p_ptr->ambush_flag = FALSE;
/* No saved floors (On the surface etc.) */
if (!(change_floor_mode & CFM_SAVE_FLOORS) &&
int alloc_chance = d_info[p_ptr->dungeon_idx].max_m_alloc_chance;
GAME_TURN alloc_times;
- while (tmp_last_visit > turn) tmp_last_visit -= TURNS_PER_TICK * TOWN_DAWN;
- absence_ticks = (turn - tmp_last_visit) / TURNS_PER_TICK;
+ while (tmp_last_visit > current_world_ptr->game_turn) tmp_last_visit -= TURNS_PER_TICK * TOWN_DAWN;
+ absence_ticks = (current_world_ptr->game_turn - tmp_last_visit) / TURNS_PER_TICK;
/* Maintain monsters */
for (i = 1; i < m_max; i++)
monster_race *r_ptr;
monster_type *m_ptr = ¤t_floor_ptr->m_list[i];
- /* Skip dead monsters */
- if (!m_ptr->r_idx) continue;
+ if (!monster_is_valid(m_ptr)) continue;
if (!is_pet(m_ptr))
{
}
/* Maintain artifatcs */
- for (i = 1; i < o_max; i++)
+ for (i = 1; i < current_floor_ptr->o_max; i++)
{
object_type *o_ptr = ¤t_floor_ptr->o_list[i];
generate_random_floor();
}
- /* Record last visit turn */
- sf_ptr->last_visit = turn;
+ /* Record last visit current_world_ptr->game_turn */
+ sf_ptr->last_visit = current_world_ptr->game_turn;
/* Set correct current_floor_ptr->dun_level value */
sf_ptr->dun_level = current_floor_ptr->dun_level;
/*
* Update visit mark
*
- * The "turn" is not always different number because
- * the level teleport doesn't take any turn. Use
- * visit mark instead of last visit turn to find the
+ * The "current_world_ptr->game_turn" is not always different number because
+ * the level teleport doesn't take any current_world_ptr->game_turn. Use
+ * visit mark instead of last visit current_world_ptr->game_turn to find the
* oldest saved floor.
*/
sf_ptr->visit_mark = latest_visit_mark++;
wiz_lite((bool)(p_ptr->pclass == CLASS_NINJA));
/* Remember when this level was "created" */
- old_turn = turn;
+ current_floor_ptr->generated_turn = current_world_ptr->game_turn;
/* No dungeon feeling yet */
- p_ptr->feeling_turn = old_turn;
+ p_ptr->feeling_turn = current_floor_ptr->generated_turn;
p_ptr->feeling = 0;
/* Clear all flags */
select_floor_music();
}
-
-/*!
- * @brief プレイヤーの手による能動的な階段生成処理 /
- * Create stairs at or move previously created stairs into the player location.
- * @return なし
- */
-void stair_creation(void)
-{
- saved_floor_type *sf_ptr;
- saved_floor_type *dest_sf_ptr;
-
- bool up = TRUE;
- bool down = TRUE;
- FLOOR_IDX dest_floor_id = 0;
-
-
- /* Forbid up staircases on Ironman mode */
- if (ironman_downward) up = FALSE;
-
- /* Forbid down staircases on quest level */
- if (quest_number(current_floor_ptr->dun_level) || (current_floor_ptr->dun_level >= d_info[p_ptr->dungeon_idx].maxdepth)) down = FALSE;
-
- /* No effect out of standard dungeon floor */
- if (!current_floor_ptr->dun_level || (!up && !down) ||
- (p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) ||
- p_ptr->inside_arena || p_ptr->inside_battle)
- {
- /* arena or quest */
- msg_print(_("効果がありません!", "There is no effect!"));
- return;
- }
-
- /* Artifacts resists */
- if (!cave_valid_bold(p_ptr->y, p_ptr->x))
- {
- msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
- return;
- }
-
- /* Destroy all objects in the grid */
- delete_object(p_ptr->y, p_ptr->x);
-
- /* Extract current floor data */
- sf_ptr = get_sf_ptr(p_ptr->floor_id);
-
- /* Paranoia */
- if (!sf_ptr)
- {
- /* No floor id? -- Create now! */
- p_ptr->floor_id = get_new_floor_id();
- sf_ptr = get_sf_ptr(p_ptr->floor_id);
- }
-
- /* Choose randomly */
- if (up && down)
- {
- if (randint0(100) < 50) up = FALSE;
- else down = FALSE;
- }
-
- /* Destination is already fixed */
- if (up)
- {
- if (sf_ptr->upper_floor_id) dest_floor_id = sf_ptr->upper_floor_id;
- }
- else
- {
- if (sf_ptr->lower_floor_id) dest_floor_id = sf_ptr->lower_floor_id;
- }
-
-
- /* Search old stairs leading to the destination */
- if (dest_floor_id)
- {
- POSITION x, y;
-
- for (y = 0; y < current_floor_ptr->height; y++)
- {
- for (x = 0; x < current_floor_ptr->width; x++)
- {
- grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
-
- if (!g_ptr->special) continue;
- if (feat_uses_special(g_ptr->feat)) continue;
- if (g_ptr->special != dest_floor_id) continue;
-
- /* Remove old stairs */
- g_ptr->special = 0;
- cave_set_feat(y, x, feat_ground_type[randint0(100)]);
- }
- }
- }
-
- /* No old destination -- Get new one now */
- else
- {
- dest_floor_id = get_new_floor_id();
-
- /* Fix it */
- if (up)
- sf_ptr->upper_floor_id = dest_floor_id;
- else
- sf_ptr->lower_floor_id = dest_floor_id;
- }
-
- /* Extract destination floor data */
- dest_sf_ptr = get_sf_ptr(dest_floor_id);
-
-
- /* Create a staircase */
- if (up)
- {
- cave_set_feat(p_ptr->y, p_ptr->x,
- (dest_sf_ptr->last_visit && (dest_sf_ptr->dun_level <= current_floor_ptr->dun_level - 2)) ?
- feat_state(feat_up_stair, FF_SHAFT) : feat_up_stair);
- }
- else
- {
- cave_set_feat(p_ptr->y, p_ptr->x,
- (dest_sf_ptr->last_visit && (dest_sf_ptr->dun_level >= current_floor_ptr->dun_level + 2)) ?
- feat_state(feat_down_stair, FF_SHAFT) : feat_down_stair);
- }
-
-
- /* Connect this stairs to the destination */
- current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].special = dest_floor_id;
-}