summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/dungeon.cc
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2010-01-10 15:12:43 -0600
committerJesse Luehrs <doy@tozt.net>2010-01-10 15:17:09 -0600
commit61087e629ee493bbd7a0f61795fbf0d8a99984aa (patch)
treeefba2f89ffed489c1250e6f4a77cec578e59365f /crawl-ref/source/dungeon.cc
parent4ccdb5ec4e12b427f1a2069174db8c38bf65fd40 (diff)
downloadcrawl-ref-61087e629ee493bbd7a0f61795fbf0d8a99984aa.tar.gz
crawl-ref-61087e629ee493bbd7a0f61795fbf0d8a99984aa.zip
parameterize ruin_level
Diffstat (limited to 'crawl-ref/source/dungeon.cc')
-rw-r--r--crawl-ref/source/dungeon.cc120
1 files changed, 68 insertions, 52 deletions
diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc
index bc66d16e9b..219505db77 100644
--- a/crawl-ref/source/dungeon.cc
+++ b/crawl-ref/source/dungeon.cc
@@ -155,7 +155,8 @@ static bool _join_the_dots_rigorous(const coord_def &from,
static void _build_river(dungeon_feature_type river_type); //mv
static void _build_lake(dungeon_feature_type lake_type); //mv
-static void _ruin_level();
+static void _ruin_level(int iterations = 1, int ruination = 10,
+ int plant_density = 5);
static void _add_plant_clumps();
static void _bigger_room();
@@ -1841,7 +1842,8 @@ static void _build_dungeon_level(int level_number, int level_type)
if (player_in_branch(BRANCH_LAIR))
{
- _ruin_level();
+ int depth = player_branch_depth() + 1;
+ _ruin_level(depth / 2, 10, 5 + depth / 2);
_add_plant_clumps();
}
@@ -7738,71 +7740,85 @@ static void _build_lake(dungeon_feature_type lake_type) //mv
}
}
-static void _ruin_level()
+static void _ruin_level(int iterations /* = 1 */, int ruination /* = 10 */,
+ int plant_density /* = 5 */)
{
- std::vector<coord_def> to_replace;
+ for (; iterations; iterations--) {
+ std::vector<coord_def> to_replace;
- for (rectangle_iterator ri(1); ri; ++ri)
- {
- /* only try to replace wall and door tiles */
- if (!feat_is_wall(grd(*ri)) && !feat_is_door(grd(*ri)))
- {
- continue;
- }
-
- int floor_count = 0;
- for (adjacent_iterator ai(*ri); ai; ++ai)
+ for (rectangle_iterator ri(1); ri; ++ri)
{
- if (!feat_is_wall(grd(*ai)) && !feat_is_door(grd(*ai)))
+ /* only try to replace wall and door tiles */
+ if (!feat_is_wall(grd(*ri)) && !feat_is_door(grd(*ri)))
{
- floor_count++;
+ continue;
}
- }
- /* chance of removing the tile is dependent on the number of adjacent
- * floor tiles */
- if (x_chance_in_y(floor_count, 10))
- {
- to_replace.push_back(*ri);
- }
- }
+ /* don't mess with permarock */
+ if (grd(*ri) == DNGN_PERMAROCK_WALL) {
+ continue;
+ }
- for (std::vector<coord_def>::const_iterator it = to_replace.begin();
- it != to_replace.end();
- ++it)
- {
- /* only remove some doors, to preserve tactical options */
- /* XXX: should this pick a random adjacent floor type, rather than
- * just hardcoding DNGN_FLOOR? */
- if (feat_is_wall(grd(*it)) || (coinflip() && feat_is_door(grd(*it)))) {
- grd(*it) = DNGN_FLOOR;
+ int floor_count = 0;
+ for (adjacent_iterator ai(*ri); ai; ++ai)
+ {
+ if (!feat_is_wall(grd(*ai)) && !feat_is_door(grd(*ai)))
+ {
+ floor_count++;
+ }
+ }
+
+ /* chance of removing the tile is dependent on the number of adjacent
+ * floor tiles */
+ if (x_chance_in_y(floor_count, 20 - ruination))
+ {
+ to_replace.push_back(*ri);
+ }
}
- /* but remove doors if we've removed all adjacent walls */
- for (adjacent_iterator wai(*it); wai; ++wai)
+ for (std::vector<coord_def>::const_iterator it = to_replace.begin();
+ it != to_replace.end();
+ ++it)
{
- if (feat_is_door(grd(*wai))) {
- bool remove = true;
- for (adjacent_iterator dai(*wai); dai; ++dai)
+ /* only remove some doors, to preserve tactical options */
+ /* XXX: should this pick a random adjacent floor type, rather than
+ * just hardcoding DNGN_FLOOR? */
+ if (feat_is_wall(grd(*it)) ||
+ (coinflip() && feat_is_door(grd(*it))))
+ {
+ grd(*it) = DNGN_FLOOR;
+ }
+
+ /* but remove doors if we've removed all adjacent walls */
+ for (adjacent_iterator wai(*it); wai; ++wai)
+ {
+ if (feat_is_door(grd(*wai)))
{
- if (feat_is_wall(grd(*dai))) {
- remove = false;
+ bool remove = true;
+ for (adjacent_iterator dai(*wai); dai; ++dai)
+ {
+ if (feat_is_wall(grd(*dai)))
+ {
+ remove = false;
+ }
+ }
+ if (remove)
+ {
+ grd(*wai) = DNGN_FLOOR;
}
- }
- if (remove) {
- grd(*wai) = DNGN_FLOOR;
}
}
- }
- /* replace some ruined walls with plants/fungi/bushes */
- if (one_chance_in(5)) {
- mgen_data mg;
- mg.cls = one_chance_in(20) ? MONS_BUSH :
- coinflip() ? MONS_PLANT :
- MONS_FUNGUS;
- mg.pos = *it;
- mons_place(mgen_data(mg));
+ /* replace some ruined walls with plants/fungi/bushes */
+ if (one_chance_in(plant_density))
+ {
+ mgen_data mg;
+ mg.cls = one_chance_in(20) ? MONS_BUSH :
+ coinflip() ? MONS_PLANT :
+ MONS_FUNGUS;
+ mg.pos = *it;
+ mons_place(mgen_data(mg));
+ }
}
}
}