summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCharles Otto <ottochar@gmail.com>2009-11-06 21:31:29 -0500
committerCharles Otto <ottochar@gmail.com>2009-11-06 21:45:52 -0500
commit799b97da52e06001a68b482049ac1a72fcb16bb8 (patch)
treeb9959027bf630fdcdd702c3b22627ea3e54413c2
parenteef51d7a1ec7ce7e471d76f82154d2b147d6228b (diff)
downloadcrawl-ref-799b97da52e06001a68b482049ac1a72fcb16bb8.tar.gz
crawl-ref-799b97da52e06001a68b482049ac1a72fcb16bb8.zip
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.
-rw-r--r--crawl-ref/source/godabil.cc23
-rw-r--r--crawl-ref/source/monster.cc11
2 files changed, 17 insertions, 17 deletions
diff --git a/crawl-ref/source/godabil.cc b/crawl-ref/source/godabil.cc
index b176f06005..e55d2bb69b 100644
--- a/crawl-ref/source/godabil.cc
+++ b/crawl-ref/source/godabil.cc
@@ -538,27 +538,22 @@ bool sunlight()
if (grd(target) != ftype)
{
- grd(target) = ftype;
+ dungeon_terrain_changed(target, ftype);
if (observe_cell(target))
evap_count++;
}
monsters *mons = monster_at(target);
- // Pop submerged status.
- if (mons && mons_habitat(mons) == HT_WATER)
- {
- mons->del_ench(ENCH_SUBMERGED);
- if (ftype == DNGN_FLOOR)
- mons->add_ench(mon_enchant(ENCH_AQUATIC_LAND, 0, KC_YOU));
- }
-
if (victim)
{
if (!mons)
you.backlight();
else
+ {
backlight_monsters(target, 1, 0);
+ behaviour_event(mons, ME_ALERT, MHITYOU);
+ }
}
else if (one_chance_in(100)
&& ftype >= DNGN_FLOOR_MIN
@@ -899,13 +894,7 @@ int rain(const coord_def &target)
// Turn regular floor squares only into shallow water.
if (ftype >= DNGN_FLOOR_MIN && ftype <= DNGN_FLOOR_MAX)
{
- grd(*rad) = DNGN_SHALLOW_WATER;
- // Remove blood stains as well.
- env.map(*rad).property &= ~(FPROP_BLOODY);
-
- monsters *mon = monster_at(*rad);
- if (mon && mon->has_ench(ENCH_AQUATIC_LAND))
- mon->del_ench(ENCH_AQUATIC_LAND);
+ dungeon_terrain_changed(*rad, DNGN_SHALLOW_WATER);
}
// We can also turn shallow water into deep water, but we're
// just going to skip cases where there is something on the
@@ -915,7 +904,7 @@ int rain(const coord_def &target)
&& igrd(*rad) == NON_ITEM
&& ftype == DNGN_SHALLOW_WATER)
{
- grd(*rad) = DNGN_DEEP_WATER;
+ dungeon_terrain_changed(*rad, DNGN_DEEP_WATER);
}
if (ftype >= DNGN_MINMOVE)
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: