git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6923 c06c8d41-db1a-0410-9941-cceddc491573
IBITKTCFECTUF6E6WMQVWXQT5Z52O5B4IZBWOLP5DWXGUHGC62AQC
SIDH2P7NBIG5KEOE27XHD3ZT2NQ2OJZFN6VZXWNWYFFY5YVXSSVQC
W6JMQP26KNVIZOJTITBWR447OX63DUKBIQE442Q7QYLUUKJVBELAC
ZJSJGWYEOMUS4VK7VWFVLKW2E42X7KPFLK6HAA5LN3URQWISQULQC
K2CS6TCX2NDVL2ASEHGP4J4K4IJ6FP3ANNKTSIWVG43HPYSBX6ZQC
3HGELZU7NELOQ635HZO6IJIYLBSNCJ5VPH46IE22KA3OSLEFK7AQC
VQD5BW56OTUNPILMCASXZ6YZ3OQGXKQ7CSNDMNZUX72AQZXKOE3QC
TGJZXTUIAKCFZQJ54ZQEBGFBVZSJCAX6AWDRSH3TP7UJRLGUM5SAC
LFBNFE3PZBXTR2ROPKYPARUWLJAYWAKGTS7VBWADZWVVSJ5CLX6AC
CG4TL4AKSN4J7CMATZFJ5N7PSDCQXLS3QYX7PZ3K67KMMBT675OQC
RBAGQ2PB7V5YAM5KSHSZR2E3MLKDSRVM5XYGI2TIXP5QMVBOQHDQC
R22TTMI6WXWULC7ODKFF3QCB7MOTETQQ6IR4BUCUPOCQKQNCTT5AC
OSRZEPPGBIMSZBWIVBTZTTIMV6TEUGVZRZ5AI2ZJW7CVZZQBUIMQC
&& (one_chance_in(5)
|| grid_distance(monster->pos(),
you.pos()) > 1
// FIXME This is better expressed as a
// function such as
// monster_has_ranged_attack:
&& monster->type != MONS_ELECTRICAL_EEL
&& monster->type != MONS_LAVA_SNAKE
&& (monster->type != MONS_MERMAID
|| you.species == SP_MERFOLK)
// Don't submerge if we just unsubmerged for
// the sake of shouting.
&& monster->seen_context != "bursts forth shouting"
&& !one_chance_in(20)
|| monster->hit_points <= monster->max_hit_points / 2
|| env.cgrid(monster->pos()) != EMPTY_CLOUD))
&& monster->wants_submerge())
}
bool monsters::wants_submerge() const
{
// If we're in distress, we usually want to submerge.
if (env.cgrid(pos()) != EMPTY_CLOUD
|| (hit_points < max_hit_points / 2
&& random2(max_hit_points + 1) >= hit_points))
return (true);
const bool has_ranged_attack =
type == MONS_ELECTRICAL_EEL
|| type == MONS_LAVA_SNAKE
|| (type == MONS_MERMAID && you.species != SP_MERFOLK);
const actor *tfoe = get_foe();
int roll = 8;
// Shallow water takes a little more effort to submerge in, so we're
// less likely to bother.
if (grd(pos()) == DNGN_SHALLOW_WATER)
roll = roll * 7 / 5;
if (foe && grid_distance(tfoe->pos(), pos()) > 1 && !has_ranged_attack)
roll /= 2;
// Don't submerge if we just unsubmerged to shout
return (one_chance_in(roll) && seen_context != "bursts forth shouting");