diff options
author | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-10-30 05:38:13 +0000 |
---|---|---|
committer | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-10-30 05:38:13 +0000 |
commit | ba525b627e249490228e7f0aa17f07c395858a06 (patch) | |
tree | 114fbb58e249fab7989d802148b34a27d7a8fafb | |
parent | 6a07f6efbab1d8d67bb82df5c86123104ddf3439 (diff) | |
download | crawl-ref-ba525b627e249490228e7f0aa17f07c395858a06.tar.gz crawl-ref-ba525b627e249490228e7f0aa17f07c395858a06.zip |
Trunk->0.3 merge (2678): Lugonu altar placement change.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/branches/stone_soup-0.3@2679 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r-- | crawl-ref/source/abyss.cc | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/crawl-ref/source/abyss.cc b/crawl-ref/source/abyss.cc index 84c8f02fb5..06fa718286 100644 --- a/crawl-ref/source/abyss.cc +++ b/crawl-ref/source/abyss.cc @@ -34,6 +34,35 @@ #include "traps.h" #include "view.h" +static bool place_feature_near( const coord_def ¢re, + int radius, + dungeon_feature_type candidate, + dungeon_feature_type replacement, + int tries ) +{ + const int radius2 = radius * radius + 1; + for (int i = 0; i < tries; ++i) + { + const coord_def &cp = + centre + coord_def(random_range(-radius, radius), + random_range(-radius, radius)); + if (cp == centre || (cp - centre).abs() > radius2 || !in_bounds(cp)) + continue; + + if (grd(cp) == candidate) + { +#ifdef DEBUG_DIAGNOSTICS + mprf(MSGCH_DIAGNOSTICS, "Placing %s at (%d,%d)", + dungeon_feature_name(replacement), + cp.x, cp.y); +#endif + grd(cp) = replacement; + return (true); + } + } + return (false); +} + // public for abyss generation void generate_abyss(void) { @@ -56,9 +85,9 @@ void generate_abyss(void) grd[45][35] = DNGN_FLOOR; if ( one_chance_in(5) ) - grd[46][35] = DNGN_ALTAR_LUGONU; -} // end generate_abyss() - + place_feature_near( coord_def(45, 35), LOS_RADIUS, + DNGN_FLOOR, DNGN_ALTAR_LUGONU, 50 ); +} static void generate_area(int gx1, int gy1, int gx2, int gy2) { @@ -369,7 +398,8 @@ void abyss_teleport( bool new_area ) grd[you.x_pos][you.y_pos] = DNGN_FLOOR; if ( one_chance_in(5) ) - grd[you.x_pos + 1][you.y_pos] = DNGN_ALTAR_LUGONU; + place_feature_near( you.pos(), LOS_RADIUS, + DNGN_FLOOR, DNGN_ALTAR_LUGONU, 50 ); place_transiting_monsters(); } |