summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crawl-ref/source/actor.h9
-rw-r--r--crawl-ref/source/describe.cc4
-rw-r--r--crawl-ref/source/halo.cc34
-rw-r--r--crawl-ref/source/makefile.obj1
-rw-r--r--crawl-ref/source/monster.cc5
-rw-r--r--crawl-ref/source/monster.h2
-rw-r--r--crawl-ref/source/player.cc9
-rw-r--r--crawl-ref/source/player.h2
-rw-r--r--crawl-ref/source/showsymb.cc2
-rw-r--r--crawl-ref/source/spells3.cc19
-rw-r--r--crawl-ref/source/spells3.h2
-rw-r--r--crawl-ref/source/tilepick.cc2
-rw-r--r--crawl-ref/source/tilereg.cc2
13 files changed, 52 insertions, 41 deletions
diff --git a/crawl-ref/source/actor.h b/crawl-ref/source/actor.h
index 000eba813f..0ca4e19c33 100644
--- a/crawl-ref/source/actor.h
+++ b/crawl-ref/source/actor.h
@@ -200,8 +200,15 @@ public:
virtual bool confused() const = 0;
virtual bool caught() const = 0;
virtual bool asleep() const { return (false); }
+
virtual bool backlit(bool check_haloed = true) const = 0;
- virtual bool haloed() const = 0;
+ // Within player halo.
+ virtual bool haloed() const;
+ // Halo radius.
+ virtual int halo_radius() const = 0;
+ // Is the given point within this actor's halo?
+ virtual bool inside_halo(const coord_def &c) const;
+
virtual bool petrified() const = 0;
virtual bool handle_trap();
diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc
index 19783947ab..2239229119 100644
--- a/crawl-ref/source/describe.cc
+++ b/crawl-ref/source/describe.cc
@@ -3146,9 +3146,9 @@ static std::string _religion_help(god_type god)
case GOD_SHINING_ONE:
result += "You can pray at an altar to sacrifice evil items.";
- if (you.haloed())
+ int halo_size = you.halo_radius();
+ if (halo_size > 0)
{
- int halo_size = halo_radius();
result += "You radiate a ";
if (halo_size > 6)
diff --git a/crawl-ref/source/halo.cc b/crawl-ref/source/halo.cc
new file mode 100644
index 0000000000..555df0048b
--- /dev/null
+++ b/crawl-ref/source/halo.cc
@@ -0,0 +1,34 @@
+#include "AppHdr.h"
+
+#include "actor.h"
+#include "player.h"
+#include "monster.h"
+#include "religion.h"
+
+// TODO: generalize.
+bool actor::haloed() const
+{
+ return (you.inside_halo(pos()));
+}
+
+bool actor::inside_halo(const coord_def &c) const
+{
+ int r = halo_radius();
+ return ((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
+{
+ return 0;
+}
diff --git a/crawl-ref/source/makefile.obj b/crawl-ref/source/makefile.obj
index 90bc0375b9..30e1a78ab0 100644
--- a/crawl-ref/source/makefile.obj
+++ b/crawl-ref/source/makefile.obj
@@ -46,6 +46,7 @@ ghost.o \
godabil.o \
goditem.o \
godwrath.o \
+halo.o \
hiscores.o \
initfile.o \
invent.o \
diff --git a/crawl-ref/source/monster.cc b/crawl-ref/source/monster.cc
index 2c3a549479..c082ac30cd 100644
--- a/crawl-ref/source/monster.cc
+++ b/crawl-ref/source/monster.cc
@@ -2809,11 +2809,6 @@ bool monsters::backlit(bool check_haloed) const
|| ((check_haloed) ? haloed() : false));
}
-bool monsters::haloed() const
-{
- return (inside_halo(pos()));
-}
-
bool monsters::caught() const
{
return this->has_ench(ENCH_HELD);
diff --git a/crawl-ref/source/monster.h b/crawl-ref/source/monster.h
index 00e6186747..30c2533ba5 100644
--- a/crawl-ref/source/monster.h
+++ b/crawl-ref/source/monster.h
@@ -333,7 +333,7 @@ public:
bool caught() const;
bool asleep() const;
bool backlit(bool check_haloed = true) const;
- bool haloed() const;
+ int halo_radius() const;
bool petrified() const;
bool friendly() const;
diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc
index 0c6725c3da..35ff2be90e 100644
--- a/crawl-ref/source/player.cc
+++ b/crawl-ref/source/player.cc
@@ -3585,9 +3585,9 @@ void display_char_status()
else
mpr("You are alive.");
- if (you.haloed())
+ const int halo_size = you.halo_radius();
+ if (halo_size > 0)
{
- const int halo_size = halo_radius();
if (halo_size > 6)
mpr("You are illuminated by a large divine halo.");
else if (halo_size > 3)
@@ -6906,11 +6906,6 @@ void player::backlight()
}
}
-bool player::haloed() const
-{
- return (halo_radius());
-}
-
bool player::can_mutate() const
{
return (true);
diff --git a/crawl-ref/source/player.h b/crawl-ref/source/player.h
index ce99e8a38c..ff225c1105 100644
--- a/crawl-ref/source/player.h
+++ b/crawl-ref/source/player.h
@@ -456,7 +456,7 @@ public:
bool confused() const;
bool caught() const;
bool backlit(bool check_haloed = true) const;
- bool haloed() const;
+ int halo_radius() const;
bool petrified() const;
bool asleep() const;
diff --git a/crawl-ref/source/showsymb.cc b/crawl-ref/source/showsymb.cc
index faa95207ea..a4734219e8 100644
--- a/crawl-ref/source/showsymb.cc
+++ b/crawl-ref/source/showsymb.cc
@@ -106,7 +106,7 @@ static unsigned short _feat_colour(const coord_def &where,
if (feat >= DNGN_FLOOR_MIN && feat <= DNGN_FLOOR_MAX
|| feat == DNGN_UNDISCOVERED_TRAP)
{
- if (inside_halo(where))
+ if (you.inside_halo(where))
{
if (silenced(where))
colour = LIGHTCYAN;
diff --git a/crawl-ref/source/spells3.cc b/crawl-ref/source/spells3.cc
index 519be912fa..bd4df15d81 100644
--- a/crawl-ref/source/spells3.cc
+++ b/crawl-ref/source/spells3.cc
@@ -1979,25 +1979,6 @@ bool cast_sanctuary(const int power)
return (true);
}
-int halo_radius()
-{
- 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;
-}
-
-bool inside_halo(const coord_def& where)
-{
- if (!halo_radius())
- return (false);
-
- return (_inside_circle(where, halo_radius()) != -1);
-}
-
void cast_poison_ammo()
{
const int ammo = you.equip[EQ_WEAPON];
diff --git a/crawl-ref/source/spells3.h b/crawl-ref/source/spells3.h
index 945078f45b..0aac012c80 100644
--- a/crawl-ref/source/spells3.h
+++ b/crawl-ref/source/spells3.h
@@ -23,8 +23,6 @@ bool cast_smiting(int power, const coord_def& where);
bool remove_sanctuary(bool did_attack = false);
void decrease_sanctuary_radius();
bool cast_sanctuary(const int power);
-int halo_radius();
-bool inside_halo(const coord_def& where);
bool project_noise();
bool detect_curse(bool suppress_msg);
bool entomb(int powc);
diff --git a/crawl-ref/source/tilepick.cc b/crawl-ref/source/tilepick.cc
index 17dab2ff75..5200803458 100644
--- a/crawl-ref/source/tilepick.cc
+++ b/crawl-ref/source/tilepick.cc
@@ -4762,7 +4762,7 @@ void tile_finish_dngn(unsigned int *tileb, int cx, int cy)
if (in_bounds)
{
bool print_blood = true;
- if (inside_halo(gc))
+ if (you.inside_halo(gc))
{
monsters *mon = monster_at(gc);
if (observe_cell(gc) && mon)
diff --git a/crawl-ref/source/tilereg.cc b/crawl-ref/source/tilereg.cc
index e6559e97b5..7500cd0950 100644
--- a/crawl-ref/source/tilereg.cc
+++ b/crawl-ref/source/tilereg.cc
@@ -644,7 +644,7 @@ static void _fill_doll_equipment(dolls_data &result)
// Halo.
if (result.parts[TILEP_PART_HALO] == TILEP_SHOW_EQUIP)
{
- const bool halo = inside_halo(you.pos());
+ const bool halo = you.haloed();
result.parts[TILEP_PART_HALO] = halo ? TILEP_HALO_TSO : 0;
}
// Enchantments.