summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/misc.cc
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-07-09 13:47:27 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-07-09 13:47:27 +0000
commit85b02c94b3646a5201a7c45b742a4164821bfa87 (patch)
treeb26fe5cc88bbbe5b58623bb6ef14e3342a698927 /crawl-ref/source/misc.cc
parent8348fa729646872032b8231fee14d5dd35a3451a (diff)
downloadcrawl-ref-85b02c94b3646a5201a7c45b742a4164821bfa87.tar.gz
crawl-ref-85b02c94b3646a5201a7c45b742a4164821bfa87.zip
Implemented Spade and Trowel (except for vault generation.)
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1819 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/misc.cc')
-rw-r--r--crawl-ref/source/misc.cc23
1 files changed, 23 insertions, 0 deletions
diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc
index a78614471c..7d492a148b 100644
--- a/crawl-ref/source/misc.cc
+++ b/crawl-ref/source/misc.cc
@@ -2264,3 +2264,26 @@ void run_environment_effects()
}
}
}
+
+coord_def pick_adjacent_free_square(int x, int y)
+{
+ int num_ok = 0;
+ coord_def result(-1, -1);
+ for ( int ux = x-1; ux <= x+1; ++ux )
+ {
+ for ( int uy = y-1; uy <= y+1; ++uy )
+ {
+ if ( ux == x && uy == y )
+ continue;
+
+ if ( ux >= 0 && ux < GXM && uy >= 0 && uy < GYM &&
+ grd[ux][uy] == DNGN_FLOOR && mgrd[ux][uy] == NON_MONSTER )
+ {
+ ++num_ok;
+ if ( one_chance_in(num_ok) )
+ result.set(ux, uy);
+ }
+ }
+ }
+ return result;
+}