summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/dungeon.cc
diff options
context:
space:
mode:
authorDarshan Shaligram <dshaligram@users.sourceforge.net>2009-12-29 08:26:24 +0530
committerDarshan Shaligram <dshaligram@users.sourceforge.net>2009-12-29 08:26:24 +0530
commit22c9c1dd3fe93c8ccab01eec647fb002877018f8 (patch)
tree61647db7597a0c8b9055bfdba86ee1ffcaa5fb10 /crawl-ref/source/dungeon.cc
parentda206768a436941bf7acfc67f005a518fb90ca7e (diff)
downloadcrawl-ref-22c9c1dd3fe93c8ccab01eec647fb002877018f8.tar.gz
crawl-ref-22c9c1dd3fe93c8ccab01eec647fb002877018f8.zip
Merfolk (water/ice) elementalists join the Shoals guard.
Diffstat (limited to 'crawl-ref/source/dungeon.cc')
-rw-r--r--crawl-ref/source/dungeon.cc41
1 files changed, 41 insertions, 0 deletions
diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc
index 04ce67e162..1c1d27f642 100644
--- a/crawl-ref/source/dungeon.cc
+++ b/crawl-ref/source/dungeon.cc
@@ -13,6 +13,7 @@
#include <set>
#include <sstream>
#include <algorithm>
+#include <cmath>
#include "abyss.h"
#include "artefact.h"
@@ -7619,6 +7620,46 @@ static coord_def _dgn_find_closest_to_stone_stairs(coord_def base_pos)
return (np.nearest);
}
+
+double dgn_degrees_to_radians(int degrees)
+{
+ return degrees * M_PI / 180;
+}
+
+coord_def dgn_random_point_from(const coord_def &c, int radius, int margin)
+{
+ int attempts = 70;
+ while (attempts-- > 0)
+ {
+ const double angle = dgn_degrees_to_radians(random2(360));
+ const coord_def res = c + coord_def(radius * cos(angle),
+ radius * sin(angle));
+ if (res.x >= margin && res.x < GXM - margin
+ && res.y >= margin && res.y < GYM - margin)
+ {
+ return res;
+ }
+ }
+ return coord_def();
+}
+
+coord_def dgn_random_point_visible_from(const coord_def &c,
+ int radius,
+ int margin,
+ int tries)
+{
+ while (tries-- > 0)
+ {
+ const coord_def point = dgn_random_point_from(c, radius, margin);
+ if (point.origin())
+ continue;
+ if (!cell_see_cell(c, point))
+ continue;
+ return point;
+ }
+ return coord_def();
+}
+
coord_def dgn_find_feature_marker(dungeon_feature_type feat)
{
std::vector<map_marker*> markers = env.markers.get_all();