diff options
author | j-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573> | 2009-07-21 17:53:49 +0000 |
---|---|---|
committer | j-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573> | 2009-07-21 17:53:49 +0000 |
commit | 41f78a696154902ae7baa22e116d39b6d321fc62 (patch) | |
tree | 3cb6f681c0124314d7293c90ea242ce2f5385ed5 /crawl-ref/source/monstuff.cc | |
parent | a17368df4fcbdf37e3452c6bc4935ba4372aabd8 (diff) | |
download | crawl-ref-41f78a696154902ae7baa22e116d39b6d321fc62.tar.gz crawl-ref-41f78a696154902ae7baa22e116d39b6d321fc62.zip |
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
Diffstat (limited to 'crawl-ref/source/monstuff.cc')
-rw-r--r-- | crawl-ref/source/monstuff.cc | 50 |
1 files changed, 47 insertions, 3 deletions
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<coord_def> adj_water; + std::vector<coord_def> 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<coord_def> 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); |