summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/areas.cc
diff options
context:
space:
mode:
authorRobert Vollmert <rvollmert@gmx.net>2009-11-21 11:14:07 +0100
committerRobert Vollmert <rvollmert@gmx.net>2009-11-21 11:20:30 +0100
commit0f564ac5ed46902bd3a7b733c01db8842643d3ad (patch)
tree6f60f73f627a21ccc3978e6ab18ca9d3e7f15641 /crawl-ref/source/areas.cc
parent2fb6a7e3d921cde7222b816bda2aaf161005371a (diff)
downloadcrawl-ref-0f564ac5ed46902bd3a7b733c01db8842643d3ad.tar.gz
crawl-ref-0f564ac5ed46902bd3a7b733c01db8842643d3ad.zip
Merge halo.cc into areas.cc.
Diffstat (limited to 'crawl-ref/source/areas.cc')
-rw-r--r--crawl-ref/source/areas.cc49
1 files changed, 49 insertions, 0 deletions
diff --git a/crawl-ref/source/areas.cc b/crawl-ref/source/areas.cc
index 43dc1e4b97..7477f83180 100644
--- a/crawl-ref/source/areas.cc
+++ b/crawl-ref/source/areas.cc
@@ -23,6 +23,7 @@
#include "player.h"
#include "religion.h"
#include "stuff.h"
+#include "terrain.h"
#include "traps.h"
#include "travel.h"
#include "viewgeom.h"
@@ -255,3 +256,51 @@ bool silenced(const coord_def& p)
return (you.duration[DUR_SILENCE] && distance(p, you.pos()) <= 6*6 + 1);
}
+/////////////
+// Halos
+
+bool actor::haloed() const
+{
+ return (you.halo_contains(pos()));
+}
+
+bool actor::halo_contains(const coord_def &c) const
+{
+ int r = halo_radius();
+ return (r > 0 && (c - pos()).abs() <= r * r && see_cell(c));
+}
+
+int player::halo_radius() const
+{
+ if (you.religion == GOD_SHINING_ONE && you.piety >= piety_breakpoint(0)
+ && !you.penance[GOD_SHINING_ONE])
+ {
+ return (std::min(LOS_RADIUS, you.piety / 20));
+ }
+
+ return (0);
+}
+
+int monsters::halo_radius() const
+{
+ // Angels and Daevas are haloed.
+ if (holiness() == MH_HOLY)
+ return (2);
+ else
+ return (0);
+}
+
+// XXX: This might become too expensive; possibly, keep
+// a mapping of cell -> list of monsters in view of cell
+// and just iterate through that.
+std::list<actor*> haloers(const coord_def &c)
+{
+ std::list<actor*> ret;
+ for (radius_iterator ri(c, LOS_RADIUS, false); ri; ++ri)
+ {
+ actor* a = actor_at(*ri);
+ if (a && a->halo_contains(c))
+ ret.push_back(a);
+ }
+ return (ret);
+}