#include "angband.h"
#include "util.h"
+#include "term.h"
#include "floor.h"
#include "world.h"
#include "object-flavor.h"
#include "object-hook.h"
+#include "dungeon.h"
#include "floor-generate.h"
#include "grid.h"
#include "trap.h"
#include "monster-status.h"
#include "player-status.h"
#include "player-effects.h"
+#include "player-class.h"
#include "spells.h"
#include "view-mainwindow.h"
+#include "realm-song.h"
+
+#define MONSTER_FLOW_DEPTH 32 /*!< 敵のプレイヤーに対する移動道のりの最大値(この値以上は処理を打ち切る) / OPTION: Maximum flow depth when using "MONSTER_FLOW" */
+
+/*
+ * Feature action flags
+ */
+#define FAF_DESTROY 0x01
+#define FAF_NO_DROP 0x02
+#define FAF_CRASH_GLASS 0x04
+
+/*!
+ * @brief 地形状態フラグテーブル /
+ * The table of features' actions
+ */
+static const byte feature_action_flags[FF_FLAG_MAX] =
+{
+ 0, /* LOS */
+ 0, /* PROJECT */
+ 0, /* MOVE */
+ 0, /* PLACE */
+ 0, /* DROP */
+ 0, /* SECRET */
+ 0, /* NOTICE */
+ 0, /* REMEMBER */
+ 0, /* OPEN */
+ 0, /* CLOSE */
+ FAF_CRASH_GLASS, /* BASH */
+ 0, /* SPIKE */
+ FAF_DESTROY, /* DISARM */
+ 0, /* STORE */
+ FAF_DESTROY | FAF_CRASH_GLASS, /* TUNNEL */
+ 0, /* MAY_HAVE_GOLD */
+ 0, /* HAS_GOLD */
+ 0, /* HAS_ITEM */
+ 0, /* DOOR */
+ 0, /* TRAP */
+ 0, /* STAIRS */
+ 0, /* GLYPH */
+ 0, /* LESS */
+ 0, /* MORE */
+ 0, /* RUN */
+ 0, /* FLOOR */
+ 0, /* WALL */
+ 0, /* PERMANENT */
+ 0, /* INNER */
+ 0, /* OUTER */
+ 0, /* SOLID */
+ 0, /* HIT_TRAP */
+
+ 0, /* BRIDGE */
+ 0, /* RIVER */
+ 0, /* LAKE */
+ 0, /* BRIDGED */
+ 0, /* COVERED */
+ 0, /* GLOW */
+ 0, /* ENSECRET */
+ 0, /* WATER */
+ 0, /* LAVA */
+ 0, /* SHALLOW */
+ 0, /* DEEP */
+ 0, /* FILLED */
+ FAF_DESTROY | FAF_CRASH_GLASS, /* HURT_ROCK */
+ 0, /* HURT_FIRE */
+ 0, /* HURT_COLD */
+ 0, /* HURT_ACID */
+ 0, /* ICE */
+ 0, /* ACID */
+ 0, /* OIL */
+ 0, /* XXX04 */
+ 0, /* CAN_CLIMB */
+ 0, /* CAN_FLY */
+ 0, /* CAN_SWIM */
+ 0, /* CAN_PASS */
+ 0, /* CAN_OOZE */
+ 0, /* CAN_DIG */
+ 0, /* HIDE_ITEM */
+ 0, /* HIDE_SNEAK */
+ 0, /* HIDE_SWIM */
+ 0, /* HIDE_DIG */
+ 0, /* KILL_HUGE */
+ 0, /* KILL_MOVE */
+
+ 0, /* PICK_TRAP */
+ 0, /* PICK_DOOR */
+ 0, /* ALLOC */
+ 0, /* CHEST */
+ 0, /* DROP_1D2 */
+ 0, /* DROP_2D2 */
+ 0, /* DROP_GOOD */
+ 0, /* DROP_GREAT */
+ 0, /* HURT_POIS */
+ 0, /* HURT_ELEC */
+ 0, /* HURT_WATER */
+ 0, /* HURT_BWATER */
+ 0, /* USE_FEAT */
+ 0, /* GET_FEAT */
+ 0, /* GROUND */
+ 0, /* OUTSIDE */
+ 0, /* EASY_HIDE */
+ 0, /* EASY_CLIMB */
+ 0, /* MUST_CLIMB */
+ 0, /* TREE */
+ 0, /* NEED_TREE */
+ 0, /* BLOOD */
+ 0, /* DUST */
+ 0, /* SLIME */
+ 0, /* PLANT */
+ 0, /* XXX2 */
+ 0, /* INSTANT */
+ 0, /* EXPLODE */
+ 0, /* TIMED */
+ 0, /* ERUPT */
+ 0, /* STRIKE */
+ 0, /* SPREAD */
+
+ 0, /* SPECIAL */
+ FAF_DESTROY | FAF_NO_DROP | FAF_CRASH_GLASS, /* HURT_DISI */
+ 0, /* QUEST_ENTER */
+ 0, /* QUEST_EXIT */
+ 0, /* QUEST */
+ 0, /* SHAFT */
+ 0, /* MOUNTAIN */
+ 0, /* BLDG */
+ 0, /* MINOR_GLYPH */
+ 0, /* PATTERN */
+ 0, /* TOWN */
+ 0, /* ENTRANCE */
+ 0, /* MIRROR */
+ 0, /* UNPERM */
+ 0, /* TELEPORTABLE */
+ 0, /* CONVERT */
+ 0, /* GLASS */
+};
/*!
* @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;
grid_type *g_ptr;
feature_type *f_ptr;
- /* Place the player */
while (max_attempts--)
{
/* Pick a legal spot */
- y = (POSITION)rand_range(1, current_floor_ptr->height - 2);
- x = (POSITION)rand_range(1, 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 = ¤t_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 (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(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;
}
bool up_stairs = TRUE;
bool down_stairs = TRUE;
grid_type *g_ptr;
- g_ptr = ¤t_floor_ptr->grid_array[y][x];
+ g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
if (!is_floor_grid(g_ptr) || g_ptr->o_idx) return;
- /* Town */
- if (!current_floor_ptr->dun_level) up_stairs = FALSE;
-
- /* Ironman */
+ if (!p_ptr->current_floor_ptr->dun_level) up_stairs = FALSE;
if (ironman_downward) up_stairs = FALSE;
-
- /* Bottom */
- if (current_floor_ptr->dun_level >= d_info[p_ptr->dungeon_idx].maxdepth) down_stairs = FALSE;
-
- /* Quest-level */
- if (quest_number(current_floor_ptr->dun_level) && (current_floor_ptr->dun_level > 1)) down_stairs = FALSE;
+ if (p_ptr->current_floor_ptr->dun_level >= d_info[p_ptr->dungeon_idx].maxdepth) down_stairs = FALSE;
+ if (quest_number(p_ptr->current_floor_ptr->dun_level) && (p_ptr->current_floor_ptr->dun_level > 1)) down_stairs = FALSE;
/* We can't place both */
if (down_stairs && up_stairs)
}
/* Place the stairs */
- if (up_stairs) place_up_stairs(y, x);
- else if (down_stairs) place_down_stairs(y, x);
+ if (up_stairs) set_cave_feat(p_ptr->current_floor_ptr, y, x, feat_up_stair);
+ else if (down_stairs) set_cave_feat(p_ptr->current_floor_ptr, y, x, feat_down_stair);
}
/*!
{
int tmp, type;
FEAT_IDX feat = feat_none;
- grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
+ grid_type *g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
/* Initialize mimic info */
g_ptr->mimic = 0;
{
if (feat != feat_none)
{
- set_cave_feat(y, x, feat);
+ set_cave_feat(p_ptr->current_floor_ptr, y, x, feat);
}
else
{
cave_set_feat(y, x, feat);
/* Now it is not floor */
- current_floor_ptr->grid_array[y][x].info &= ~(CAVE_MASK);
+ p_ptr->current_floor_ptr->grid_array[y][x].info &= ~(CAVE_MASK);
}
else
{
}
}
-/*!
-* @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(y, x, feat_locked_door_random((d_info[p_ptr->dungeon_idx].flags1 & DF1_GLASS_DOOR) ? DOOR_GLASS_DOOR : DOOR_DOOR));
- 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 = ¤t_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);
* @param y1 基準となるマスのY座標
* @param x1 基準となるマスのX座標
* @return 通路の数
-* @note Assumes "in_bounds(y1, x1)"
+* @note Assumes "in_bounds(p_ptr->current_floor_ptr, y1, x1)"
* @details
* XXX XXX This routine currently only counts actual "empty floor"\n
* grids which are not in rooms. We might want to also count stairs,\n
/* Scan adjacent grids */
for (i = 0; i < 4; i++)
{
- /* Extract the location */
y = y1 + ddy_ddd[i];
x = x1 + ddx_ddd[i];
- g_ptr = ¤t_floor_ptr->grid_array[y][x];
+ g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
/* Skip non floors */
if (cave_have_flag_grid(g_ptr, FF_WALL)) continue;
* @param y 判定を行いたいマスのY座標
* @param x 判定を行いたいマスのX座標
* @return ドアを設置可能ならばTRUEを返す
-* @note Assumes "in_bounds(y1, x1)"
+* @note Assumes "in_bounds(p_ptr->current_floor_ptr, y1, x1)"
* @details
* \n
-* Assumes "in_bounds(y, x)"\n
+* Assumes "in_bounds(p_ptr->current_floor_ptr, y, x)"\n
*/
static bool possible_doorway(POSITION y, POSITION x)
{
* @return なし
*/
void try_door(POSITION y, POSITION x)
-{ if (!in_bounds(y, x)) return;
+{ if (!in_bounds(p_ptr->current_floor_ptr, y, x)) return;
/* Ignore walls */
if (cave_have_flag_bold(y, x, FF_WALL)) return;
/* Ignore room grids */
- if (current_floor_ptr->grid_array[y][x].info & (CAVE_ROOM)) return;
+ if (p_ptr->current_floor_ptr->grid_array[y][x].info & (CAVE_ROOM)) return;
/* Occasional door (if allowed) */
if ((randint0(100) < dun_tun_jct) && possible_doorway(y, x) && !(d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_DOORS))
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);
}
}
}
j = rand_spread(y, 2);
k = rand_spread(x, 3);
dummy++;
- if (!in_bounds(j, k)) continue;
+ if (!in_bounds(p_ptr->current_floor_ptr, j, k)) continue;
break;
}
}
/* Require "clean" floor space */
- g_ptr = ¤t_floor_ptr->grid_array[j][k];
+ g_ptr = &p_ptr->current_floor_ptr->grid_array[j][k];
if (!is_floor_grid(g_ptr) || g_ptr->o_idx) continue;
if (randint0(100) < 75)
y1 = rand_spread(y, yd);
x1 = rand_spread(x, xd);
dummy++;
- if (!in_bounds(y1, x1)) continue;
+ if (!in_bounds(p_ptr->current_floor_ptr, y1, x1)) continue;
break;
}
}
/* Require "naked" floor grids */
- g_ptr = ¤t_floor_ptr->grid_array[y1][x1];
+ g_ptr = &p_ptr->current_floor_ptr->grid_array[y1][x1];
if (!is_floor_grid(g_ptr) || g_ptr->o_idx || g_ptr->m_idx) continue;
/* Place the trap */
scatter(&y, &x, y1, x1, d, 0);
/* Require "empty" floor grids */
- g_ptr = ¤t_floor_ptr->grid_array[y][x];
+ g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
if (!cave_empty_grid(g_ptr)) continue;
/* Place the monster (allow groups) */
- current_floor_ptr->monster_level = current_floor_ptr->base_level + 2;
+ p_ptr->current_floor_ptr->monster_level = p_ptr->current_floor_ptr->base_level + 2;
(void)place_monster(y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
- current_floor_ptr->monster_level = current_floor_ptr->base_level;
+ p_ptr->current_floor_ptr->monster_level = p_ptr->current_floor_ptr->base_level;
}
}
}
*/
bool get_is_floor(POSITION x, POSITION y)
{
- if (!in_bounds(y, x))
+ if (!in_bounds(p_ptr->current_floor_ptr, y, x))
{
/* Out of bounds */
return (FALSE);
}
/* 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);
}
*/
void set_floor(POSITION x, POSITION y)
{
- if (!in_bounds(y, x))
+ if (!in_bounds(p_ptr->current_floor_ptr, y, x))
{
/* Out of bounds */
return;
}
- if (current_floor_ptr->grid_array[y][x].info & CAVE_ROOM)
+ if (p_ptr->current_floor_ptr->grid_array[y][x].info & CAVE_ROOM)
{
/* A room border don't touch. */
return;
}
/* 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);
}
#ifdef COMPLEX_WALL_ILLUMINATION /* COMPLEX_WALL_ILLUMINATION */
/* Check for "complex" illumination */
- if ((feat_supports_los(get_feat_mimic(¤t_floor_ptr->grid_array[yy][xx])) &&
- (current_floor_ptr->grid_array[yy][xx].info & CAVE_GLOW)) ||
- (feat_supports_los(get_feat_mimic(¤t_floor_ptr->grid_array[y][xx])) &&
- (current_floor_ptr->grid_array[y][xx].info & CAVE_GLOW)) ||
- (feat_supports_los(get_feat_mimic(¤t_floor_ptr->grid_array[yy][x])) &&
- (current_floor_ptr->grid_array[yy][x].info & CAVE_GLOW)))
+ if ((feat_supports_los(get_feat_mimic(&p_ptr->current_floor_ptr->grid_array[yy][xx])) &&
+ (p_ptr->current_floor_ptr->grid_array[yy][xx].info & CAVE_GLOW)) ||
+ (feat_supports_los(get_feat_mimic(&p_ptr->current_floor_ptr->grid_array[y][xx])) &&
+ (p_ptr->current_floor_ptr->grid_array[y][xx].info & CAVE_GLOW)) ||
+ (feat_supports_los(get_feat_mimic(&p_ptr->current_floor_ptr->grid_array[yy][x])) &&
+ (p_ptr->current_floor_ptr->grid_array[yy][x].info & CAVE_GLOW)))
{
return TRUE;
}
#else /* COMPLEX_WALL_ILLUMINATION */
/* Check for "simple" illumination */
- return (current_floor_ptr->grid_array[yy][xx].info & CAVE_GLOW) ? TRUE : FALSE;
+ return (p_ptr->current_floor_ptr->grid_array[yy][xx].info & CAVE_GLOW) ? TRUE : FALSE;
#endif /* COMPLEX_WALL_ILLUMINATION */
}
if (player_has_los_bold((Y), (X))) \
{ \
/* Update the monster */ \
- if (current_floor_ptr->grid_array[(Y)][(X)].m_idx) update_monster(current_floor_ptr->grid_array[(Y)][(X)].m_idx, FALSE); \
+ if (p_ptr->current_floor_ptr->grid_array[(Y)][(X)].m_idx) update_monster(p_ptr->current_floor_ptr->grid_array[(Y)][(X)].m_idx, FALSE); \
\
/* Notice and redraw */ \
note_spot((Y), (X)); \
/*!
* @brief 指定された座標の照明状態を更新する / Update "local" illumination
- * @param y y座標
- * @param x x座標
+ * @param creature_ptr 視界元のクリーチャー
+ * @param y 視界先y座標
+ * @param x 視界先x座標
* @return なし
*/
-void update_local_illumination(POSITION y, POSITION x)
+void update_local_illumination(player_type * creature_ptr, POSITION y, POSITION x)
{
int i;
POSITION yy, xx;
- if (!in_bounds(y, x)) return;
+ if (!in_bounds(p_ptr->current_floor_ptr, y, x)) return;
#ifdef COMPLEX_WALL_ILLUMINATION /* COMPLEX_WALL_ILLUMINATION */
- if ((y != p_ptr->y) && (x != p_ptr->x))
+ if ((y != creature_ptr->y) && (x != creature_ptr->x))
{
- yy = (y < p_ptr->y) ? (y - 1) : (y + 1);
- xx = (x < p_ptr->x) ? (x - 1) : (x + 1);
+ yy = (y < creature_ptr->y) ? (y - 1) : (y + 1);
+ xx = (x < creature_ptr->x) ? (x - 1) : (x + 1);
update_local_illumination_aux(yy, xx);
update_local_illumination_aux(y, xx);
update_local_illumination_aux(yy, x);
}
- else if (x != p_ptr->x) /* y == p_ptr->y */
+ else if (x != creature_ptr->x) /* y == creature_ptr->y */
{
- xx = (x < p_ptr->x) ? (x - 1) : (x + 1);
+ xx = (x < creature_ptr->x) ? (x - 1) : (x + 1);
for (i = -1; i <= 1; i++)
{
yy = y + i;
yy = y + 1;
update_local_illumination_aux(yy, x);
}
- else if (y != p_ptr->y) /* x == p_ptr->x */
+ else if (y != creature_ptr->y) /* x == creature_ptr->x */
{
- yy = (y < p_ptr->y) ? (y - 1) : (y + 1);
+ yy = (y < creature_ptr->y) ? (y - 1) : (y + 1);
for (i = -1; i <= 1; i++)
{
xx = x + i;
#else /* COMPLEX_WALL_ILLUMINATION */
- if ((y != p_ptr->y) && (x != p_ptr->x))
+ if ((y != creature_ptr->y) && (x != creature_ptr->x))
{
- yy = (y < p_ptr->y) ? (y - 1) : (y + 1);
- xx = (x < p_ptr->x) ? (x - 1) : (x + 1);
+ yy = (y < creature_ptr->y) ? (y - 1) : (y + 1);
+ xx = (x < creature_ptr->x) ? (x - 1) : (x + 1);
update_local_illumination_aux(yy, xx);
}
- else if (x != p_ptr->x) /* y == p_ptr->y */
+ else if (x != creature_ptr->x) /* y == creature_ptr->y */
{
- xx = (x < p_ptr->x) ? (x - 1) : (x + 1);
+ xx = (x < creature_ptr->x) ? (x - 1) : (x + 1);
for (i = -1; i <= 1; i++)
{
yy = y + i;
update_local_illumination_aux(yy, xx);
}
}
- else if (y != p_ptr->y) /* x == p_ptr->x */
+ else if (y != creature_ptr->y) /* x == creature_ptr->x */
{
- yy = (y < p_ptr->y) ? (y - 1) : (y + 1);
+ yy = (y < creature_ptr->y) ? (y - 1) : (y + 1);
for (i = -1; i <= 1; i++)
{
xx = x + i;
/*!
- * @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 = ¤t_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);
-}
-
-/*!
* @brief 指定された座標をプレイヤー収められていない状態かどうか / Returns true if the player's grid is dark
* @return 視覚に収められていないならTRUEを返す
* @details player_can_see_bold()関数の返り値の否定を返している。
*/
bool cave_valid_bold(POSITION y, POSITION x)
{
- grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
+ grid_type *g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
OBJECT_IDX this_o_idx, next_o_idx = 0;
/* Forbid perma-grids */
for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
{
object_type *o_ptr;
- o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
+ o_ptr = &p_ptr->current_floor_ptr->o_list[this_o_idx];
next_o_idx = o_ptr->next_o_idx;
/* Forbid artifact grids */
return (TRUE);
}
-/*
- * Moves the cursor to a given MAP (y,x) location
- */
-void move_cursor_relative(int row, int col)
-{
- /* Real co-ords convert to screen positions */
- row -= panel_row_prt;
-
- /* Go there */
- Term_gotoxy(panel_col_of(col), row);
-}
-
/*
*/
void note_spot(POSITION y, POSITION x)
{
- grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
+ grid_type *g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
OBJECT_IDX this_o_idx, next_o_idx = 0;
/* Blind players see nothing */
/* Hack -- memorize objects */
for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
{
- object_type *o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
+ object_type *o_ptr = &p_ptr->current_floor_ptr->o_list[this_o_idx];
next_o_idx = o_ptr->next_o_idx;
/* Memorize objects */
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;
}
}
-
-/*
- * print project path
- */
-void prt_path(POSITION y, POSITION x)
-{
- int i;
- int path_n;
- u16b path_g[512];
- byte_hack default_color = TERM_SLATE;
-
- if (!display_path) return;
- if (-1 == project_length)
- return;
-
- /* Get projection path */
- path_n = project_path(path_g, (project_length ? project_length : MAX_RANGE), p_ptr->y, p_ptr->x, y, x, PROJECT_PATH | PROJECT_THRU);
-
- p_ptr->redraw |= (PR_MAP);
- handle_stuff();
-
- /* Draw path */
- for (i = 0; i < path_n; i++)
- {
- POSITION ny = GRID_Y(path_g[i]);
- POSITION nx = GRID_X(path_g[i]);
- grid_type *g_ptr = ¤t_floor_ptr->grid_array[ny][nx];
-
- if (panel_contains(ny, nx))
- {
- TERM_COLOR a = default_color;
- char c;
-
- TERM_COLOR ta = default_color;
- char tc = '*';
-
- if (g_ptr->m_idx && current_floor_ptr->m_list[g_ptr->m_idx].ml)
- {
- /* Determine what is there */
- map_info(ny, nx, &a, &c, &ta, &tc);
-
- if (!is_ascii_graphics(a))
- a = default_color;
- else if (c == '.' && (a == TERM_WHITE || a == TERM_L_WHITE))
- a = default_color;
- else if (a == default_color)
- a = TERM_WHITE;
- }
-
- if (!use_graphics)
- {
- if (current_world_ptr->timewalk_m_idx) a = TERM_DARK;
- else if (IS_INVULN() || p_ptr->timewalk) a = TERM_WHITE;
- else if (p_ptr->wraith_form) a = TERM_L_DARK;
- }
-
- c = '*';
-
- /* Hack -- Queue it */
- Term_queue_bigchar(panel_col_of(nx), ny - panel_row_prt, a, c, ta, tc);
- }
-
- /* Known Wall */
- if ((g_ptr->info & CAVE_MARK) && !cave_have_flag_grid(g_ptr, FF_PROJECT)) break;
-
- /* Change color */
- if (nx == x && ny == y) default_color = TERM_L_DARK;
- }
-}
-
/*
* Some comments on the grid flags. -BEN-
*
* To simplify various things, a grid may be marked as "CAVE_MARK", meaning
* that even if the player cannot "see" the grid, he "knows" the terrain in
* that grid. This is used to "remember" walls/doors/stairs/floors when they
- * are "seen" or "detected", and also to "memorize" floors, after "wiz_lite()",
+ * are "seen" or "detected", and also to "memorize" floors, after "wiz_lite(p_ptr, )",
* or when one of the "memorize floor grids" options induces memorization.
*
* Objects are "memorized" in a different way, using a special "marked" flag
grid_type *g_ptr;
/* Update needed grids */
- for (i = 0; i < current_floor_ptr->redraw_n; i++)
+ for (i = 0; i < p_ptr->current_floor_ptr->redraw_n; i++)
{
- y = current_floor_ptr->redraw_y[i];
- x = current_floor_ptr->redraw_x[i];
- g_ptr = ¤t_floor_ptr->grid_array[y][x];
+ y = p_ptr->current_floor_ptr->redraw_y[i];
+ x = p_ptr->current_floor_ptr->redraw_x[i];
+ g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
/* Update only needed grids (prevent multiple updating) */
if (!(g_ptr->info & CAVE_REDRAW)) continue;
}
/* None left */
- current_floor_ptr->redraw_n = 0;
-}
-
-
-/*
- * Hack -- forget the "flow" information
- */
-void forget_flow(void)
-{
- POSITION x, y;
-
- /* Check the entire dungeon */
- for (y = 0; y < current_floor_ptr->height; y++)
- {
- for (x = 0; x < current_floor_ptr->width; x++)
- {
- /* Forget the old data */
- current_floor_ptr->grid_array[y][x].dist = 0;
- current_floor_ptr->grid_array[y][x].cost = 0;
- current_floor_ptr->grid_array[y][x].when = 0;
- }
- }
+ p_ptr->current_floor_ptr->redraw_n = 0;
}
if (tmp_pos.n) return;
/* The last way-point is on the map */
- if (running && in_bounds(flow_y, flow_x))
+ if (p_ptr->running && in_bounds(p_ptr->current_floor_ptr, flow_y, flow_x))
{
/* The way point is in sight - do not update. (Speedup) */
- if (current_floor_ptr->grid_array[flow_y][flow_x].info & CAVE_VIEW) return;
+ if (p_ptr->current_floor_ptr->grid_array[flow_y][flow_x].info & CAVE_VIEW) return;
}
/* Erase all of the current flow information */
- for (y = 0; y < current_floor_ptr->height; y++)
+ for (y = 0; y < p_ptr->current_floor_ptr->height; y++)
{
- for (x = 0; x < current_floor_ptr->width; x++)
+ for (x = 0; x < p_ptr->current_floor_ptr->width; x++)
{
- current_floor_ptr->grid_array[y][x].cost = 0;
- 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].dist = 0;
}
}
for (d = 0; d < 8; d++)
{
int old_head = flow_head;
- byte_hack m = current_floor_ptr->grid_array[ty][tx].cost + 1;
- byte_hack n = current_floor_ptr->grid_array[ty][tx].dist + 1;
+ byte_hack m = p_ptr->current_floor_ptr->grid_array[ty][tx].cost + 1;
+ byte_hack n = p_ptr->current_floor_ptr->grid_array[ty][tx].dist + 1;
grid_type *g_ptr;
/* Child location */
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 = ¤t_floor_ptr->grid_array[y][x];
+ g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
if (is_closed_door(g_ptr->feat)) m += 3;
}
}
-
-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 < current_floor_ptr->height; y++)
- {
- for (x = 0; x < current_floor_ptr->width; x++)
- {
- int w = current_floor_ptr->grid_array[y][x].when;
- 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(y, x)) continue;
-
- g_ptr = ¤t_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
*/
void cave_set_feat(POSITION y, POSITION x, FEAT_IDX feat)
{
- grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
+ grid_type *g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
feature_type *f_ptr = &f_info[feat];
bool old_los, old_mirror;
- if (!character_dungeon)
+ if (!current_world_ptr->character_dungeon)
{
/* Clear mimic type */
g_ptr->mimic = 0;
{
yy = y + ddy_ddd[i];
xx = x + ddx_ddd[i];
- if (!in_bounds2(yy, xx)) continue;
- current_floor_ptr->grid_array[yy][xx].info |= CAVE_GLOW;
+ if (!in_bounds2(p_ptr->current_floor_ptr, yy, xx)) continue;
+ p_ptr->current_floor_ptr->grid_array[yy][xx].info |= CAVE_GLOW;
}
}
g_ptr->info &= ~(CAVE_GLOW);
if (!view_torch_grids) g_ptr->info &= ~(CAVE_MARK);
- update_local_illumination(y, x);
+ update_local_illumination(p_ptr, y, x);
}
/* Check for change to boring grid */
#ifdef COMPLEX_WALL_ILLUMINATION /* COMPLEX_WALL_ILLUMINATION */
- update_local_illumination(y, x);
+ update_local_illumination(p_ptr, y, x);
#endif /* COMPLEX_WALL_ILLUMINATION */
{
yy = y + ddy_ddd[i];
xx = x + ddx_ddd[i];
- if (!in_bounds2(yy, xx)) continue;
- cc_ptr = ¤t_floor_ptr->grid_array[yy][xx];
+ 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 (player_has_los_grid(cc_ptr))
lite_spot(yy, xx);
}
- update_local_illumination(yy, xx);
+ update_local_illumination(p_ptr, yy, xx);
}
if (p_ptr->special_defense & NINJA_S_STEALTH)
{
- if (current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info & CAVE_GLOW) set_superstealth(FALSE);
+ if (p_ptr->current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info & CAVE_GLOW) set_superstealth(p_ptr, FALSE);
}
}
}
-
FEAT_IDX conv_dungeon_feat(FEAT_IDX newfeat)
{
feature_type *f_ptr = &f_info[newfeat];
void cave_alter_feat(POSITION y, POSITION x, int action)
{
/* Set old feature */
- FEAT_IDX oldfeat = current_floor_ptr->grid_array[y][x].feat;
+ FEAT_IDX oldfeat = p_ptr->current_floor_ptr->grid_array[y][x].feat;
/* Get the new feat */
FEAT_IDX newfeat = feat_state(oldfeat, action);
}
/* Handle item */
- if (have_flag(old_f_ptr->flags, FF_HAS_ITEM) && !have_flag(f_ptr->flags, FF_HAS_ITEM) && (randint0(100) < (15 - current_floor_ptr->dun_level / 2)))
+ if (have_flag(old_f_ptr->flags, FF_HAS_ITEM) && !have_flag(f_ptr->flags, FF_HAS_ITEM) && (randint0(100) < (15 - p_ptr->current_floor_ptr->dun_level / 2)))
{
/* Place object */
place_object(y, x, 0L);
found = TRUE;
}
- if (found && character_dungeon && player_can_see_bold(y, x))
+ if (found && current_world_ptr->character_dungeon && player_can_see_bold(y, x))
{
msg_print(_("何かを発見した!", "You have found something!"));
}
{
feature_type *old_f_ptr = &f_info[oldfeat];
- if (have_flag(old_f_ptr->flags, FF_GLASS) && character_dungeon)
+ if (have_flag(old_f_ptr->flags, FF_GLASS) && current_world_ptr->character_dungeon)
{
- project(PROJECT_WHO_GLASS_SHARDS, 1, y, x, MIN(current_floor_ptr->dun_level, 100) / 4, GF_SHARDS,
+ project(PROJECT_WHO_GLASS_SHARDS, 1, y, x, MIN(p_ptr->current_floor_ptr->dun_level, 100) / 4, GF_SHARDS,
(PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_HIDE | PROJECT_JUMP | PROJECT_NO_HANGEKI), -1);
}
}
/* Remove a mirror */
void remove_mirror(POSITION y, POSITION x)
{
- grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
+ grid_type *g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
/* Remove the mirror */
g_ptr->info &= ~(CAVE_OBJECT);
if (!view_torch_grids) g_ptr->info &= ~(CAVE_MARK);
if (g_ptr->m_idx) update_monster(g_ptr->m_idx, FALSE);
- update_local_illumination(y, x);
+ update_local_illumination(p_ptr, y, x);
}
note_spot(y, x);
return FALSE;
}
-
-/*
- * Hack -- track the given monster race
- */
-void monster_race_track(MONRACE_IDX r_idx)
-{
- /* Save this monster ID */
- p_ptr->monster_race_idx = r_idx;
-
- p_ptr->window |= (PW_MONSTER);
-}
-
-
-
-/*
- * Hack -- track the given object kind
- */
-void object_kind_track(KIND_OBJECT_IDX k_idx)
-{
- /* Save this monster ID */
- p_ptr->object_kind_idx = k_idx;
-
- p_ptr->window |= (PW_OBJECT);
-}
-
-
/*!
* @brief 指定されたマスがモンスターのテレポート可能先かどうかを判定する。
* @param m_idx モンスターID
*/
bool cave_monster_teleportable_bold(MONSTER_IDX m_idx, POSITION y, POSITION x, BIT_FLAGS mode)
{
- monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
- grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
+ monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[m_idx];
+ grid_type *g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
feature_type *f_ptr = &f_info[g_ptr->feat];
/* Require "teleportable" space */
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;
*/
bool cave_player_teleportable_bold(POSITION y, POSITION x, BIT_FLAGS mode)
{
- grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
+ grid_type *g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
feature_type *f_ptr = &f_info[g_ptr->feat];
/* Require "teleportable" space */
{
feature_type *f_ptr = &f_info[feature];
- if (p_ptr->riding) return monster_can_cross_terrain(feature, &r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx], mode | CEM_RIDING);
+ if (p_ptr->riding) return monster_can_cross_terrain(feature, &r_info[p_ptr->current_floor_ptr->m_list[p_ptr->riding].r_idx], mode | CEM_RIDING);
if (have_flag(f_ptr->flags, FF_PATTERN))
{