From 85b02c94b3646a5201a7c45b742a4164821bfa87 Mon Sep 17 00:00:00 2001 From: haranp Date: Mon, 9 Jul 2007 13:47:27 +0000 Subject: 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 --- crawl-ref/source/misc.cc | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'crawl-ref/source/misc.cc') 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; +} -- cgit v1.2.3-54-g00ecf