#define FAF_NO_DROP 0x02
#define FAF_CRASH_GLASS 0x04
-#define feat_locked_door_random(DOOR_TYPE) \
- (feat_door[(DOOR_TYPE)].num_locked ? \
- feat_door[(DOOR_TYPE)].locked[randint0(feat_door[(DOOR_TYPE)].num_locked)] : feat_none)
-
-#define feat_jammed_door_random(DOOR_TYPE) \
- (feat_door[(DOOR_TYPE)].num_jammed ? \
- feat_door[(DOOR_TYPE)].jammed[randint0(feat_door[(DOOR_TYPE)].num_jammed)] : feat_none)
-
/*!
* @brief 地形状態フラグテーブル /
* The table of features' actions
/*!
* @brief 新規フロアに入りたてのプレイヤーをランダムな場所に配置する / Returns random co-ordinates for player/monster/object
+ * @param creature_ptr 配置したいクリーチャーの参照ポインタ
* @return 配置に成功したらTRUEを返す
*/
-bool new_player_spot(void)
+bool new_player_spot(player_type *creature_ptr)
{
POSITION y = 0, x = 0;
int max_attempts = 10000;
while (max_attempts--)
{
/* Pick a legal spot */
- y = (POSITION)rand_range(1, p_ptr->current_floor_ptr->height - 2);
- x = (POSITION)rand_range(1, p_ptr->current_floor_ptr->width - 2);
+ y = (POSITION)rand_range(1, creature_ptr->current_floor_ptr->height - 2);
+ x = (POSITION)rand_range(1, creature_ptr->current_floor_ptr->width - 2);
- g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
+ g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
/* Must be a "naked" floor grid */
if (g_ptr->m_idx) continue;
- if (p_ptr->current_floor_ptr->dun_level)
+ if (creature_ptr->current_floor_ptr->dun_level)
{
f_ptr = &f_info[g_ptr->feat];
if (!have_flag(f_ptr->flags, FF_TELEPORTABLE)) continue;
}
if (!player_can_enter(g_ptr->feat, 0)) continue;
- if (!in_bounds(p_ptr->current_floor_ptr, y, x)) continue;
+ if (!in_bounds(creature_ptr->current_floor_ptr, y, x)) continue;
/* Refuse to start on anti-teleport grids */
if (g_ptr->info & (CAVE_ICKY)) continue;
return FALSE;
/* Save the new player grid */
- p_ptr->y = y;
- p_ptr->x = x;
+ creature_ptr->y = y;
+ creature_ptr->x = x;
return TRUE;
}
}
}
-/*!
-* @brief 鍵のかかったドアを配置する
-* @param y 配置したいフロアのY座標
-* @param x 配置したいフロアのX座標
-* @return なし
-*/
-void place_locked_door(POSITION y, POSITION x)
-{
- if (d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_DOORS)
- {
- place_floor_bold(y, x);
- }
- else
- {
- set_cave_feat(p_ptr->current_floor_ptr, y, x, feat_locked_door_random((d_info[p_ptr->dungeon_idx].flags1 & DF1_GLASS_DOOR) ? DOOR_GLASS_DOOR : DOOR_DOOR));
- p_ptr->current_floor_ptr->grid_array[y][x].info &= ~(CAVE_FLOOR);
- delete_monster(y, x);
- }
-}
-
-
-/*!
-* @brief 隠しドアを配置する
-* @param y 配置したいフロアのY座標
-* @param x 配置したいフロアのX座標
-* @param type DOOR_DEFAULT / DOOR_DOOR / DOOR_GLASS_DOOR / DOOR_CURTAIN のいずれか
-* @return なし
-*/
-void place_secret_door(POSITION y, POSITION x, int type)
-{
- if (d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_DOORS)
- {
- place_floor_bold(y, x);
- }
- else
- {
- grid_type *g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
-
- if (type == DOOR_DEFAULT)
- {
- type = ((d_info[p_ptr->dungeon_idx].flags1 & DF1_CURTAIN) &&
- one_in_((d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_CAVE) ? 16 : 256)) ? DOOR_CURTAIN :
- ((d_info[p_ptr->dungeon_idx].flags1 & DF1_GLASS_DOOR) ? DOOR_GLASS_DOOR : DOOR_DOOR);
- }
-
- /* Create secret door */
- place_closed_door(y, x, type);
-
- if (type != DOOR_CURTAIN)
- {
- /* Hide by inner wall because this is used in rooms only */
- g_ptr->mimic = feat_wall_inner;
-
- /* Floor type terrain cannot hide a door */
- if (feat_supports_los(g_ptr->mimic) && !feat_supports_los(g_ptr->feat))
- {
- if (have_flag(f_info[g_ptr->mimic].flags, FF_MOVE) || have_flag(f_info[g_ptr->mimic].flags, FF_CAN_FLY))
- {
- g_ptr->feat = one_in_(2) ? g_ptr->mimic : feat_ground_type[randint0(100)];
- }
- g_ptr->mimic = 0;
- }
- }
-
- g_ptr->info &= ~(CAVE_FLOOR);
- delete_monster(y, x);
- }
-}
-
/*
* Routine used by the random vault creators to add a door to a location
* Note that range checking has to be done in the calling routine.
void add_door(POSITION x, POSITION y)
{
/* Need to have a wall in the center square */
- if (!is_outer_bold(y, x)) return;
+ if (!is_outer_bold(p_ptr->current_floor_ptr, y, x)) return;
/* look at:
* x#x
* .=floor, #=wall
*/
- if (is_floor_bold(y - 1, x) && is_floor_bold(y + 1, x) &&
- (is_outer_bold(y, x - 1) && is_outer_bold(y, x + 1)))
+ if (is_floor_bold(p_ptr->current_floor_ptr, y - 1, x) && is_floor_bold(p_ptr->current_floor_ptr, y + 1, x) &&
+ (is_outer_bold(p_ptr->current_floor_ptr, y, x - 1) && is_outer_bold(p_ptr->current_floor_ptr, y, x + 1)))
{
/* secret door */
- place_secret_door(y, x, DOOR_DEFAULT);
+ place_secret_door(p_ptr->current_floor_ptr, y, x, DOOR_DEFAULT);
/* set boundarys so don't get wide doors */
place_solid_bold(y, x - 1);
* where x = don't care
* .=floor, #=wall
*/
- if (is_outer_bold(y - 1, x) && is_outer_bold(y + 1, x) &&
- is_floor_bold(y, x - 1) && is_floor_bold(y, x + 1))
+ if (is_outer_bold(p_ptr->current_floor_ptr, y - 1, x) && is_outer_bold(p_ptr->current_floor_ptr, y + 1, x) &&
+ is_floor_bold(p_ptr->current_floor_ptr, y, x - 1) && is_floor_bold(p_ptr->current_floor_ptr, y, x + 1))
{
/* secret door */
- place_secret_door(y, x, DOOR_DEFAULT);
+ place_secret_door(p_ptr->current_floor_ptr, y, x, DOOR_DEFAULT);
/* set boundarys so don't get wide doors */
place_solid_bold(y - 1, x);
for (x = x1 - 1; x <= x2 + 1; x++)
{
place_floor_bold(y, x);
- add_cave_info(y, x, CAVE_ROOM);
- if (light) add_cave_info(y, x, CAVE_GLOW);
+ add_cave_info(p_ptr->current_floor_ptr, y, x, CAVE_ROOM);
+ if (light) add_cave_info(p_ptr->current_floor_ptr, y, x, CAVE_GLOW);
}
}
}
}
/* Do the real check */
- if (is_floor_bold(y, x)) return (TRUE);
+ if (is_floor_bold(p_ptr->current_floor_ptr, y, x)) return (TRUE);
return (FALSE);
}
}
/* Set to be floor if is a wall (don't touch lakes). */
- if (is_extra_bold(y, x))
+ if (is_extra_bold(p_ptr->current_floor_ptr, y, x))
place_floor_bold(y, x);
}
void lite_spot(POSITION y, POSITION x)
{
/* Redraw if on screen */
- if (panel_contains(y, x) && in_bounds2(y, x))
+ if (panel_contains(y, x) && in_bounds2(p_ptr->current_floor_ptr, y, x))
{
TERM_COLOR a;
SYMBOL_CODE c;
/*
- * Hack -- forget the "flow" information
- */
-void forget_flow(void)
-{
- POSITION x, y;
-
- /* Check the entire dungeon */
- for (y = 0; y < p_ptr->current_floor_ptr->height; y++)
- {
- for (x = 0; x < p_ptr->current_floor_ptr->width; x++)
- {
- /* Forget the old data */
- p_ptr->current_floor_ptr->grid_array[y][x].dist = 0;
- p_ptr->current_floor_ptr->grid_array[y][x].cost = 0;
- p_ptr->current_floor_ptr->grid_array[y][x].when = 0;
- }
- }
-}
-
-
-/*
* Hack - speed up the update_flow algorithm by only doing
* it everytime the player moves out of LOS of the last
* "way-point".
x = tx + ddx_ddd[d];
/* Ignore player's grid */
- if (player_bold(y, x)) continue;
+ if (player_bold(p_ptr, y, x)) continue;
g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
}
}
-
-static int scent_when = 0;
-
-/*
- * Characters leave scent trails for perceptive monsters to track.
- *
- * Smell is rather more limited than sound. Many creatures cannot use
- * it at all, it doesn't extend very far outwards from the character's
- * current position, and monsters can use it to home in the character,
- * but not to run away from him.
- *
- * Smell is valued according to age. When a character takes his current_world_ptr->game_turn,
- * scent is aged by one, and new scent of the current age is laid down.
- * Speedy characters leave more scent, true, but it also ages faster,
- * which makes it harder to hunt them down.
- *
- * Whenever the age count loops, most of the scent trail is erased and
- * the age of the remainder is recalculated.
- */
-void update_smell(void)
-{
- POSITION i, j;
- POSITION y, x;
-
- /* Create a table that controls the spread of scent */
- const int scent_adjust[5][5] =
- {
- { -1, 0, 0, 0,-1 },
- { 0, 1, 1, 1, 0 },
- { 0, 1, 2, 1, 0 },
- { 0, 1, 1, 1, 0 },
- { -1, 0, 0, 0,-1 },
- };
-
- /* Loop the age and adjust scent values when necessary */
- if (++scent_when == 254)
- {
- /* Scan the entire dungeon */
- for (y = 0; y < p_ptr->current_floor_ptr->height; y++)
- {
- for (x = 0; x < p_ptr->current_floor_ptr->width; x++)
- {
- int w = p_ptr->current_floor_ptr->grid_array[y][x].when;
- p_ptr->current_floor_ptr->grid_array[y][x].when = (w > 128) ? (w - 128) : 0;
- }
- }
-
- /* Restart */
- scent_when = 126;
- }
-
-
- /* Lay down new scent */
- for (i = 0; i < 5; i++)
- {
- for (j = 0; j < 5; j++)
- {
- grid_type *g_ptr;
-
- /* Translate table to map grids */
- y = i + p_ptr->y - 2;
- x = j + p_ptr->x - 2;
-
- /* Check Bounds */
- if (!in_bounds(p_ptr->current_floor_ptr, y, x)) continue;
-
- g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
-
- /* Walls, water, and lava cannot hold scent. */
- if (!cave_have_flag_grid(g_ptr, FF_MOVE) && !is_closed_door(g_ptr->feat)) continue;
-
- /* Grid must not be blocked by walls from the character */
- if (!player_has_los_bold(y, x)) continue;
-
- /* Note grids that are too far away */
- if (scent_adjust[i][j] == -1) continue;
-
- /* Mark the grid with new scent */
- g_ptr->when = scent_when + scent_adjust[i][j];
- }
- }
-}
-
-
-
/*
* Change the "feat" flag for a grid, and notice/redraw the grid
*/
{
yy = y + ddy_ddd[i];
xx = x + ddx_ddd[i];
- if (!in_bounds2(yy, xx)) continue;
+ if (!in_bounds2(p_ptr->current_floor_ptr, yy, xx)) continue;
p_ptr->current_floor_ptr->grid_array[yy][xx].info |= CAVE_GLOW;
}
}
{
yy = y + ddy_ddd[i];
xx = x + ddx_ddd[i];
- if (!in_bounds2(yy, xx)) continue;
+ if (!in_bounds2(p_ptr->current_floor_ptr, yy, xx)) continue;
cc_ptr = &p_ptr->current_floor_ptr->grid_array[yy][xx];
cc_ptr->info |= CAVE_GLOW;
if (!have_flag(f_ptr->flags, FF_TELEPORTABLE)) return FALSE;
if (g_ptr->m_idx && (g_ptr->m_idx != m_idx)) return FALSE;
- if (player_bold(y, x)) return FALSE;
+ if (player_bold(p_ptr, y, x)) return FALSE;
/* Hack -- no teleport onto glyph of warding */
if (is_glyph_grid(g_ptr)) return FALSE;