}
/* Update scent trail */
- update_smell();
+ update_smell(creature_ptr->current_floor_ptr);
}
/*!
delete_monster(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(floor_type *floor_ptr)
+{
+ 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 < floor_ptr->height; y++)
+ {
+ for (x = 0; x < floor_ptr->width; x++)
+ {
+ int w = floor_ptr->grid_array[y][x].when;
+ 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(floor_ptr, y, x)) continue;
+
+ g_ptr = &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];
+ }
+ }
+}
+
#define GRID_X(G) \
((int)((G) % 256U))
+extern void update_smell(floor_type *floor_ptr);
+
extern void place_secret_door(floor_type *floor_ptr, POSITION y, POSITION x, int type);
extern void place_locked_door(floor_type *floor_ptr, POSITION y, POSITION 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
*/
extern void delayed_visual_update(void);
extern void forget_flow(void);
extern void update_flow(void);
-extern void update_smell(void);
extern void cave_set_feat(POSITION y, POSITION x, FEAT_IDX feat);
extern FEAT_IDX conv_dungeon_feat(FEAT_IDX newfeat);
extern FEAT_IDX feat_state(FEAT_IDX feat, int action);