Пример #1
0
/**
 * True if the square is empty (an open square without any items).
 */
bool square_isempty(struct chunk *c, int y, int x) {
	return square_isopen(c, y, x) && !square_object(c, y, x);
}
Пример #2
0
/**
 * True if the square is empty (an open square without any items).
 */
bool square_isempty(struct chunk *c, int y, int x) {
	if (square_isplayertrap(c, y, x)) return FALSE;
	return square_isopen(c, y, x) && !square_object(c, y, x);
}
Пример #3
0
/**
 * Helper function to place monsters that appear as friends or escorts
 */
 bool place_friends(struct chunk *c, int y, int x, struct monster_race *race,
					struct monster_race *friends_race, int total, bool sleep,
					byte origin)
 {
	int extra_chance;

	/* Find the difference between current dungeon depth and monster level */
	int level_difference = player->depth - friends_race->level + 5;

	/* Handle unique monsters */
	bool is_unique = rf_has(friends_race->flags, RF_UNIQUE);

	/* Make sure the unique hasn't been killed already */
	if (is_unique) {
		total = friends_race->cur_num < friends_race->max_num ? 1 : 0;
	}

	/* More than 4 levels OoD, no groups allowed */
	if (level_difference <= 0 && !is_unique) {
		return false;
	}

	/* Reduce group size within 5 levels of natural depth*/
	if (level_difference < 10 && !is_unique) {
		extra_chance = (total * level_difference) % 10;
		total = total * level_difference / 10;

		/* Instead of flooring the group value, we use the decimal place
		   as a chance of an extra monster */
		if (randint0(10) > extra_chance) {
			total += 1;
		}
	}

	/* No monsters in this group */
	if (total > 0) {
		/* Handle friends same as original monster */
		if (race->ridx == friends_race->ridx) {
			return place_new_monster_group(c, y, x, race, sleep, total, origin);
		} else {
			int j;
			int nx = 0;
			int ny = 0;

			/* Find a nearby place to put the other groups */
			for (j = 0; j < 50; j++) {
				scatter(c, &ny, &nx, y, x, GROUP_DISTANCE, false);
				if (square_isopen(c, ny, nx)) {
					break;
				}
			}

			/* Place the monsters */
			bool success = place_new_monster_one(c, ny, nx, friends_race, sleep, origin);
			if (total > 1)
				success = place_new_monster_group(c, ny, nx, friends_race, sleep, total, origin);

			return success;
		}
	}

	return false;
}