From 41f78a696154902ae7baa22e116d39b6d321fc62 Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Tue, 21 Jul 2009 17:53:49 +0000 Subject: Make fish on dry land (due to Feawn's Sunlight power) flop about and lose hit points until back in water, using ENCH_AQUATIC_LAND. (Bug 2824663) Also fix tiles compilation (patch 2824632) and add DATA_DIR_PATH to tiled icons (patch 2824635). Both patches (and some more) by Trent W. Buck. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@10364 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/monstuff.cc | 50 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 3 deletions(-) (limited to 'crawl-ref/source/monstuff.cc') diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc index bf3c5b2276..530e768313 100644 --- a/crawl-ref/source/monstuff.cc +++ b/crawl-ref/source/monstuff.cc @@ -3963,8 +3963,8 @@ static void _check_wander_target(monsters *mon, bool isPacified = false, if (!can_move) { - can_move = (mons_amphibious(mon)) - ? DNGN_DEEP_WATER : DNGN_SHALLOW_WATER; + can_move = (mons_amphibious(mon) ? DNGN_DEEP_WATER + : DNGN_SHALLOW_WATER); } if (mon->is_travelling()) @@ -8624,7 +8624,7 @@ static bool _monster_move(monsters *monster) if (monster->type == MONS_TRAPDOOR_SPIDER) { if (mons_is_submerged(monster)) - return (false); + return (false); // Trapdoor spiders hide if they can't see their foe. // (Note that friendly trapdoor spiders will thus hide even @@ -8683,6 +8683,50 @@ static bool _monster_move(monsters *monster) return (false); } + // If a water monster is currently flopping around on land, it cannot + // really control where it wants to move, though there's a 50% chance + // of flopping into an adjacent water grid. + if (monster->has_ench(ENCH_AQUATIC_LAND)) + { + std::vector adj_water; + std::vector adj_move; + for (adjacent_iterator ai(monster->pos()); ai; ++ai) + { + if (!grid_is_solid(*ai)) + { + adj_move.push_back(*ai); + if (grid_is_watery(grd(*ai))) + adj_water.push_back(*ai); + } + } + if (adj_move.empty()) + { + simple_monster_message(monster, " flops around on dry land!"); + return (false); + } + + std::vector moves = adj_water; + if (adj_water.empty() || coinflip()) + moves = adj_move; + + coord_def newpos = monster->pos(); + int count = 0; + for (unsigned int i = 0; i < moves.size(); ++i) + if (one_chance_in(++count)) + newpos = moves[i]; + + const monsters *mon2 = monster_at(newpos); + if (newpos == you.pos() && mons_wont_attack(monster) + || (mon2 && mons_wont_attack(monster) == mons_wont_attack(mon2))) + { + + simple_monster_message(monster, " flops around on dry land!"); + return (false); + } + + return _do_move_monster(monster, newpos - monster->pos()); + } + // Let's not even bother with this if mmov is zero. if (mmov.origin()) return (false); -- cgit v1.2.3-54-g00ecf