* @param x 方角を確認したX座標
* @return 方向ID
*/
-DIRECTION coords_to_dir(POSITION y, POSITION x)
+DIRECTION coords_to_dir(player_type *creature_ptr, POSITION y, POSITION x)
{
DIRECTION d[3][3] = { {7, 4, 1}, {8, 5, 2}, {9, 6, 3} };
POSITION dy, dx;
- dy = y - p_ptr->y;
- dx = x - p_ptr->x;
+ dy = y - creature_ptr->y;
+ dx = x - creature_ptr->x;
if (ABS(dx) > 1 || ABS(dy) > 1) return (0);
return d[dx + 1][dy + 1];
if (flg & (PROJECT_STOP))
{
if ((n > 0) &&
- (player_bold(y, x) || current_floor_ptr->grid_array[y][x].m_idx != 0))
+ (player_bold(y, x) || p_ptr->current_floor_ptr->grid_array[y][x].m_idx != 0))
break;
}
- if (!in_bounds(current_floor_ptr, y, x)) break;
+ if (!in_bounds(p_ptr->current_floor_ptr, y, x)) break;
/* Slant */
if (m)
if (flg & (PROJECT_STOP))
{
if ((n > 0) &&
- (player_bold(y, x) || current_floor_ptr->grid_array[y][x].m_idx != 0))
+ (player_bold(y, x) || p_ptr->current_floor_ptr->grid_array[y][x].m_idx != 0))
break;
}
- if (!in_bounds(current_floor_ptr, y, x)) break;
+ if (!in_bounds(p_ptr->current_floor_ptr, y, x)) break;
/* Slant */
if (m)
if (flg & (PROJECT_STOP))
{
if ((n > 0) &&
- (player_bold(y, x) || current_floor_ptr->grid_array[y][x].m_idx != 0))
+ (player_bold(y, x) || p_ptr->current_floor_ptr->grid_array[y][x].m_idx != 0))
break;
}
- if (!in_bounds(current_floor_ptr, y, x)) break;
+ if (!in_bounds(p_ptr->current_floor_ptr, y, x)) break;
/* Advance (Y) */
y += sy;
/* Paranoia -- require "safe" origin */
- /* if (!in_bounds(current_floor_ptr, y1, x1)) return FALSE; */
- /* if (!in_bounds(current_floor_ptr, y2, x2)) return FALSE; */
+ /* if (!in_bounds(p_ptr->current_floor_ptr, y1, x1)) return FALSE; */
+ /* if (!in_bounds(p_ptr->current_floor_ptr, y2, x2)) return FALSE; */
/* Directly South/North */
nx = rand_spread(x, d);
/* Ignore annoying locations */
- if (!in_bounds(current_floor_ptr, ny, nx)) continue;
+ if (!in_bounds(p_ptr->current_floor_ptr, ny, nx)) continue;
/* Ignore "excessively distant" locations */
if ((d > 1) && (distance(y, x, ny, nx) > d)) continue;
(*xp) = nx;
}
+
+/*!
+ * @brief 指定された座標をプレイヤーが視覚に収められるかを返す。 / Can the player "see" the given grid in detail?
+ * @param y y座標
+ * @param x x座標
+ * @return 視覚に収められる状態ならTRUEを返す
+ * @details
+ * He must have vision, illumination, and line of sight.\n
+ * \n
+ * Note -- "CAVE_LITE" is only set if the "torch" has "los()".\n
+ * So, given "CAVE_LITE", we know that the grid is "fully visible".\n
+ *\n
+ * Note that "CAVE_GLOW" makes little sense for a wall, since it would mean\n
+ * that a wall is visible from any direction. That would be odd. Except\n
+ * under wizard light, which might make sense. Thus, for walls, we require\n
+ * not only that they be "CAVE_GLOW", but also, that they be adjacent to a\n
+ * grid which is not only "CAVE_GLOW", but which is a non-wall, and which is\n
+ * in line of sight of the player.\n
+ *\n
+ * This extra check is expensive, but it provides a more "correct" semantics.\n
+ *\n
+ * Note that we should not run this check on walls which are "outer walls" of\n
+ * the dungeon, or we will induce a memory fault, but actually verifying all\n
+ * of the locations would be extremely expensive.\n
+ *\n
+ * Thus, to speed up the function, we assume that all "perma-walls" which are\n
+ * "CAVE_GLOW" are "illuminated" from all sides. This is correct for all cases\n
+ * except "vaults" and the "buildings" in town. But the town is a hack anyway,\n
+ * and the player has more important things on his mind when he is attacking a\n
+ * monster vault. It is annoying, but an extremely important optimization.\n
+ *\n
+ * Note that "glowing walls" are only considered to be "illuminated" if the\n
+ * grid which is next to the wall in the direction of the player is also a\n
+ * "glowing" grid. This prevents the player from being able to "see" the\n
+ * walls of illuminated rooms from a corridor outside the room.\n
+ */
+bool player_can_see_bold(POSITION y, POSITION x)
+{
+ grid_type *g_ptr;
+
+ /* Blind players see nothing */
+ if (p_ptr->blind) return FALSE;
+
+ g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
+
+ /* Note that "torch-lite" yields "illumination" */
+ if (g_ptr->info & (CAVE_LITE | CAVE_MNLT)) return TRUE;
+
+ /* Require line of sight to the grid */
+ if (!player_has_los_bold(y, x)) return FALSE;
+
+ /* Noctovision of Ninja */
+ if (p_ptr->see_nocto) return TRUE;
+
+ /* Require "perma-lite" of the grid */
+ if ((g_ptr->info & (CAVE_GLOW | CAVE_MNDK)) != CAVE_GLOW) return FALSE;
+
+ /* Feature code (applying "mimic" field) */
+ /* Floors are simple */
+ if (feat_supports_los(get_feat_mimic(g_ptr))) return TRUE;
+
+ /* Check for "local" illumination */
+ return check_local_illumination(y, x);
+}
+
/*
* Calculate "incremental motion". Used by project() and shoot().
* Assumes that (*y,*x) lies on the path from (y1,x1) to (y2,x2).