summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/mon-util.cc
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-04-10 16:04:14 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-04-10 16:04:14 +0000
commit512696e788bbd4172853b8a1d7cca95497c98a6a (patch)
treed6477f6a71ab70118cc8126711557eafdb979e03 /crawl-ref/source/mon-util.cc
parent684f80b554daadb08cf2c40b8e905737e8655530 (diff)
downloadcrawl-ref-512696e788bbd4172853b8a1d7cca95497c98a6a.tar.gz
crawl-ref-512696e788bbd4172853b8a1d7cca95497c98a6a.zip
Allow player ghosts to use corona.
Breaks save compatibility, upped save major version. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1282 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/mon-util.cc')
-rw-r--r--crawl-ref/source/mon-util.cc33
1 files changed, 23 insertions, 10 deletions
diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc
index 03bb6a72cb..8595bd08dd 100644
--- a/crawl-ref/source/mon-util.cc
+++ b/crawl-ref/source/mon-util.cc
@@ -1879,6 +1879,13 @@ bool ms_waste_of_time( const monsters *mon, spell_type monspell )
// handled here as well. -- bwr
switch (monspell)
{
+ case SPELL_BACKLIGHT:
+ {
+ const actor *foe = mon->get_foe();
+ ret = !foe || foe->backlit() || foe->invisible();
+ break;
+ }
+
case SPELL_BERSERKER_RAGE:
if (!mon->needs_berserk(false))
ret = true;
@@ -2484,6 +2491,11 @@ bool monsters::asleep() const
return (mons_is_sleeping(this));
}
+bool monsters::backlit() const
+{
+ return (has_ench(ENCH_BACKLIGHT));
+}
+
int monsters::shield_bonus() const
{
// XXX: Monsters don't actually get shields yet.
@@ -3609,21 +3621,22 @@ void monsters::check_speed()
}
}
-int monsters::foe_distance() const
+actor *monsters::get_foe() const
{
- // early out -- no foe!
if (foe == MHITNOT)
- return (INFINITE_DISTANCE);
-
- if (foe == MHITYOU)
- return grid_distance(x, y, you.x_pos, you.y_pos);
+ return (NULL);
+ else if (foe == MHITYOU)
+ return (&you);
// must be a monster
- const monsters *my_foe = &menv[foe];
- if (my_foe->alive())
- return grid_distance(x, y, my_foe->x, my_foe->y);
+ monsters *my_foe = &menv[foe];
+ return (my_foe->alive()? my_foe : NULL);
+}
- return (INFINITE_DISTANCE);
+int monsters::foe_distance() const
+{
+ const actor *afoe = get_foe();
+ return (afoe? pos().distance_from(afoe->pos()) : INFINITE_DISTANCE);
}
bool monsters::can_go_berserk() const