From c0acbdf98f1f66419727fb786f138590cccf2af4 Mon Sep 17 00:00:00 2001 From: dshaligram Date: Tue, 30 Oct 2007 05:35:40 +0000 Subject: Place altar to Lugonu randomly, not necessarily in LOS. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2678 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/abyss.cc | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) (limited to 'crawl-ref') diff --git a/crawl-ref/source/abyss.cc b/crawl-ref/source/abyss.cc index 17885b967b..a3ca3b9a77 100644 --- a/crawl-ref/source/abyss.cc +++ b/crawl-ref/source/abyss.cc @@ -35,6 +35,35 @@ #include "view.h" #include "xom.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) { @@ -61,9 +90,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) { @@ -506,7 +535,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(); } -- cgit v1.2.3-54-g00ecf