From 512696e788bbd4172853b8a1d7cca95497c98a6a Mon Sep 17 00:00:00 2001 From: dshaligram Date: Tue, 10 Apr 2007 16:04:14 +0000 Subject: 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 --- crawl-ref/source/mon-util.cc | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) (limited to 'crawl-ref/source/mon-util.cc') 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 -- cgit v1.2.3-54-g00ecf