summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/abyss.cc
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-10-30 05:35:40 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-10-30 05:35:40 +0000
commitc0acbdf98f1f66419727fb786f138590cccf2af4 (patch)
tree809d5266fe44b3a7ea1ff7aa4a0ac10cb1584dd6 /crawl-ref/source/abyss.cc
parentef823a353aba810c62754850f68d1fa619a44a66 (diff)
downloadcrawl-ref-c0acbdf98f1f66419727fb786f138590cccf2af4.tar.gz
crawl-ref-c0acbdf98f1f66419727fb786f138590cccf2af4.zip
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
Diffstat (limited to 'crawl-ref/source/abyss.cc')
-rw-r--r--crawl-ref/source/abyss.cc38
1 files changed, 34 insertions, 4 deletions
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 &centre,
+ 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();
}