예제 #1
0
/**
 * Place a trap near (x, y), with a given displacement.
 * \param c the current chunk
 * \param y co-ordinates to place the trap near
 * \param x co-ordinates to place the trap near
 * \param yd how far afield to look for a place
 * \param xd how far afield to look for a place
 */
static void vault_trap_aux(struct chunk *c, int y, int x, int yd, int xd)
{
    int tries, y1, x1;

    /* Find a nearby empty grid and place a trap */
    for (tries = 0; tries <= 5; tries++) {
		find_nearby_grid(c, &y1, y, yd, &x1, x, xd);
		if (!square_isempty(c, y1, x1)) continue;

		square_add_trap(c, y1, x1);
		break;
    }
}
예제 #2
0
/* Make traps */
static void project_feature_handler_MAKE_TRAP(project_feature_handler_context_t *context)
{
	const int x = context->x;
	const int y = context->y;

	/* Require an "empty", non-warded floor grid */
	if (!square_isempty(cave, y, x)) return;
	if (square_iswarded(cave, y, x)) return;

	/* Create a trap */
	square_add_trap(cave, y, x);
	context->obvious = true;
}