From 799b97da52e06001a68b482049ac1a72fcb16bb8 Mon Sep 17 00:00:00 2001 From: Charles Otto Date: Fri, 6 Nov 2009 21:31:29 -0500 Subject: Simplify rain and sunlight a bit Use dungeon_terrain_changed in rain and sunlight, inflict and remove ENCH_AQUATIC_LAND solely in monsters::apply_location_effects. Make sunlight alert monsters it affects. --- crawl-ref/source/monster.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'crawl-ref/source/monster.cc') diff --git a/crawl-ref/source/monster.cc b/crawl-ref/source/monster.cc index e077ca32da..c04cbbc9a4 100644 --- a/crawl-ref/source/monster.cc +++ b/crawl-ref/source/monster.cc @@ -5262,6 +5262,12 @@ void monsters::apply_location_effects(const coord_def &oldpos) if (oldpos != pos()) dungeon_events.fire_position_event(DET_MONSTER_MOVED, pos()); + if (alive() && mons_habitat(this) == HT_WATER + && !feat_is_watery( grd(pos()) ) && !has_ench(ENCH_AQUATIC_LAND)) + { + add_ench(ENCH_AQUATIC_LAND); + } + if (alive() && has_ench(ENCH_AQUATIC_LAND)) { if (!feat_is_watery( grd(pos()) )) @@ -5271,6 +5277,11 @@ void monsters::apply_location_effects(const coord_def &oldpos) simple_monster_message(this, " dives back into the water!"); del_ench(ENCH_AQUATIC_LAND); } + // This may have been called via dungeon_terrain_changed instead + // of by the monster moving move, in that case grd(oldpos) will + // be the current position that became watery. + else + del_ench(ENCH_AQUATIC_LAND); } // Monsters stepping on traps: -- cgit v1.2.3-54-g00ecf