From c0aa968809c8d8ef88048edd667b12b297a68602 Mon Sep 17 00:00:00 2001 From: Darshan Shaligram Date: Sat, 16 Jan 2010 22:50:34 +0530 Subject: Experimental level builder changes for Swamp. The Swamp now gets a border of trees and uses trees instead of walls. Swamp:5 vaults may need tweaking to fit in better. --- crawl-ref/source/dungeon.cc | 78 +++++++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 41 deletions(-) (limited to 'crawl-ref/source/dungeon.cc') diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc index a663cf2ebb..94850d8bb8 100644 --- a/crawl-ref/source/dungeon.cc +++ b/crawl-ref/source/dungeon.cc @@ -25,6 +25,7 @@ #include "coordit.h" #include "defines.h" #include "dgn-shoals.h" +#include "dgn-swamp.h" #include "effects.h" #include "env.h" #include "enum.h" @@ -133,7 +134,6 @@ static void _place_minivaults(const std::string &tag = "", static int _place_uniques(int level_number, char level_type); static void _place_traps( int level_number ); static void _place_fog_machines( int level_number ); -static void _prepare_swamp(); static void _prepare_water( int level_number ); static void _check_doors(); static void _hide_doors(); @@ -1821,9 +1821,11 @@ static void _build_dungeon_level(int level_number, int level_type) // Stairs must exist by this point (except in Shoals where they are // yet to be placed). Some items and monsters already exist. +#if OLD_SWAMP_LAYOUT // Time to make the swamp or shoals {dlb}: if (player_in_branch(BRANCH_SWAMP)) - _prepare_swamp(); + dgn_prepare_swamp(); +#endif if (dgn_level_vetoed) return; @@ -2078,42 +2080,6 @@ static void _connected_flood(int margin, int i, int j, bool taken[GXM][GYM]) _connected_flood(margin, i + idelta, j + jdelta, taken); } -static void _prepare_swamp() -{ - dgn_Build_Method += " swamp"; - dgn_Layout_Type = "swamp"; - - const int margin = 5; - - for (int i = margin; i < (GXM - margin); i++) - for (int j = margin; j < (GYM - margin); j++) - { - // Don't apply Swamp prep in vaults. - if (!unforbidden(coord_def(i, j), MMT_VAULT)) - continue; - - // doors -> floors {dlb} - if (grd[i][j] == DNGN_CLOSED_DOOR || grd[i][j] == DNGN_SECRET_DOOR) - grd[i][j] = DNGN_FLOOR; - - // floors -> shallow water 1 in 3 times {dlb} - if (grd[i][j] == DNGN_FLOOR && one_chance_in(3)) - grd[i][j] = DNGN_SHALLOW_WATER; - - // walls -> deep/shallow water or remain unchanged {dlb} - if (grd[i][j] == DNGN_ROCK_WALL) - { - const int temp_rand = random2(6); - - if (temp_rand > 0) // 17% chance unchanged {dlb} - { - grd[i][j] = ((temp_rand > 2) ? DNGN_SHALLOW_WATER // 50% - : DNGN_DEEP_WATER); // 33% - } - } - } -} - // Gives water which is next to ground/shallow water a chance of being // shallow. Checks each water space. static void _prepare_water( int level_number ) @@ -2451,6 +2417,8 @@ static builder_rc_type _builder_by_branch(int level_number) { dgn_Build_Method += " random_map_for_place"; _ensure_vault_placed_ex( _build_vaults(level_number, vault), vault ); + if (!dgn_level_vetoed && player_in_branch(BRANCH_SWAMP)) + dgn_build_swamp_level(level_number); return BUILD_SKIP; } @@ -2468,8 +2436,13 @@ static builder_rc_type _builder_by_branch(int level_number) spotty_level(false, iterations, false); return BUILD_SKIP; } + case BRANCH_SHOALS: - prepare_shoals(level_number); + dgn_build_shoals_level(level_number); + return BUILD_SKIP; + + case BRANCH_SWAMP: + dgn_build_swamp_level(level_number); return BUILD_SKIP; default: @@ -2925,6 +2898,29 @@ static void _place_fog_machines(int level_number) } } +void dgn_place_feature_at_random_floor_square(dungeon_feature_type feat, + unsigned mask = MMT_VAULT) +{ + const coord_def place = + dgn_random_point_in_bounds(DNGN_FLOOR, mask, DNGN_FLOOR); + if (place.origin()) + dgn_veto_level(); + else + grd(place) = feat; +} + +// Create randomly-placed stone stairs. +void dgn_place_stone_stairs() +{ + for (int i = 0; i < 3; ++i) + { + dgn_place_feature_at_random_floor_square( + static_cast(DNGN_STONE_STAIRS_DOWN_I + i)); + dgn_place_feature_at_random_floor_square( + static_cast(DNGN_STONE_STAIRS_UP_I + i)); + } +} + bool dgn_has_adjacent_feat(coord_def c, dungeon_feature_type feat) { for (adjacent_iterator ai(c); ai; ++ai) @@ -7885,8 +7881,8 @@ coord_def dgn_random_point_from(const coord_def &c, int radius, int margin) const coord_def res = c + coord_def(static_cast(radius * cos(angle)), static_cast(radius * sin(angle))); - if (res.x >= margin && res.x < GXM - margin - && res.y >= margin && res.y < GYM - margin) + if (res.x >= margin && res.x < GXM - margin - 1 + && res.y >= margin && res.y < GYM - margin - 1) { return res; } -- cgit v1.2.3-54-g00ecf