spider can't see any enemies and is on a floor square it will "submurge" into the floor and only come out if an enemy moves right next to it or if something attacks it from a distance. Most of this is done with the new monster behavour BEH_LURK.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5477 c06c8d41-db1a-0410-9941-cceddc491573
3HGELZU7NELOQ635HZO6IJIYLBSNCJ5VPH46IE22KA3OSLEFK7AQC
MDFQRJ6QZNFUBVSFWLXUJ6EBXOU47T3CVDI2XKBGNNRF4DXDKESQC
K2CS6TCX2NDVL2ASEHGP4J4K4IJ6FP3ANNKTSIWVG43HPYSBX6ZQC
LP5MU6UP3OYGF6NFKN25QOQI7WDXZYGX5CHW37VN4L37BT65REFAC
66DDSFAHW4O32QBBARNSYI6HHZFCQL6LEUKRVKJVGFUFAAJGS4IQC
KAOE5HB3THUKVGFZRO5EZESHEB3Q34WUO5DFMLWIKOBF47LZTIYAC
P5TRGRH7XMQSPCZKM5IEEO34TY6WMLGHHX7BU6Y453JFRXLUR2VQC
VQD5BW56OTUNPILMCASXZ6YZ3OQGXKQ7CSNDMNZUX72AQZXKOE3QC
ZJSJGWYEOMUS4VK7VWFVLKW2E42X7KPFLK6HAA5LN3URQWISQULQC
4HATGRJJE7Q6LXHJ3ZGYTNBLG542KAUEK6ERKARIYRKRWY6VTDKQC
OSGS3PH2L5CBTDVZCZS6OCFQNA4A7RMEXBYJQB7DDZBYYJW7QSSAC
NVSFIV2ZKP44XHCSCXG6OZVGL67OIFINC34J2EMKTA4KULCERUEAC
JESCEQPAFC23D6BUZMBOB4M54XT3GQZJYT7NCJ556LEUCHRER3SQC
LTX72QGIPNUGWQN5ULPOMFCOPZTK7472DQY4AYX5WM3WHSUVXI5QC
RPOZZWKG5GLPHVZZ7ZKMKS64ZMV2LDCQSARBJFJ6FZOTOKCQO7FAC
OP6CTAKWCAU64JXQ3USQYR5E5IFHQHNCACII5UMVRXUTZXJQOAZAC
GTXKQTORYHZ7XB2VIH6372UM5GMWAN7IVRXWY5FGBCHFGBV6D6NAC
C5U3HSOOQ7BKXKXIDS7MLVXUKDTHAWJ5NXNX6YDXTM3GWY5UWX4QC
OONYLF4DAPLIYLBNNRW74IVT5BBTWI4XHQBXSNSPVRX3FTKJBTRAC
QNIQ2NBBIERVCA2YTD3O3P6QPJ5M6VDVGGX7V2BWXTW5553T4PVAC
JJULXW764V5C2HJKZNWQAEWB6QM5YZADD7ZCE35LYTBFEM6PMYCAC
X5WLJCJVW55SXZVP7IKP7ADCJIGNKN4PKAXFECVR6TNK7XSMZR7QC
RBAGQ2PB7V5YAM5KSHSZR2E3MLKDSRVM5XYGI2TIXP5QMVBOQHDQC
3WHI3KM43ZCN4ITJLFQQBQBC4OJPRS7QTBPIQ6QBCUVKRSK476SAC
JZCODQCOUBBBPPR4TLOAPIB4BQLDY3ORTJXTWEQSUJVJ7DMK7FVAC
if (old_behaviour == BEH_LURK && mon->behaviour != BEH_LURK)
{
switch(event)
{
case ME_EVAL:
case ME_DISTURB:
case ME_ALERT:
// Lurking monsters won't stop lurking just because they
// noticed something.
mon->behaviour = BEH_LURK;
break;
default:
if (mon->has_ench(ENCH_SUBMERGED))
mon->del_ench(ENCH_SUBMERGED);
break;
}
}
}
}
}
if (monster->behaviour == BEH_LURK)
{
// Lurking monsters only stop lurking if their target is right
// next tp them, otherwise they just sit there.
if (monster->foe != MHITNOT
&& abs(monster->target_x - monster->x) <= 1
&& abs(monster->target_y - monster->y) <= 1)
{
if (monster->has_ench(ENCH_SUBMERGED))
{
// Don't unsubmerge if the player is right on top,
// if the monster is too damaged or if the monster
// is afraid.
if (monster->pos() == you.pos()
|| monster->hit_points <= monster->max_hit_points / 2
|| monster->has_ench(ENCH_FEAR))
{
monster->speed_increment -= non_move_energy;
continue;
}
monster->del_ench(ENCH_SUBMERGED);
// Trapdoor spiders hide if they can't see their target.
bool can_see;
if (monster->foe == MHITNOT)
can_see = false;
else if (monster->foe == MHITYOU)
can_see = monster->can_see(&you);
else
can_see = monster->can_see(&menv[monster->foe]);
if (monster_can_submerge(monster, grd[monster->x][monster->y])
&& !can_see && !mons_is_confused(monster)
&& !monster->has_ench(ENCH_BERSERK))
{
monster->add_ench(ENCH_SUBMERGED);
monster->behaviour = BEH_LURK;
return false;
}
}
if (type == MONS_AIR_ELEMENTAL && mons_near(this) && !quiet)
// XXX: What if the monster was invisible before submerging?
if (mons_near(this) && !quiet)
{
if (type == MONS_AIR_ELEMENTAL)
{
mprf("%s merges itself into the air.",
name(DESC_CAP_A, true).c_str() );
}
else if (type == MONS_TRAPDOOR_SPIDER)
{
mprf("%s hides itself under the floor.",
name(DESC_CAP_A, true).c_str() );
}
}
break;
case ENCH_CONFUSION:
if (type == MONS_TRAPDOOR_SPIDER && has_ench(ENCH_SUBMERGED))
del_ench(ENCH_SUBMERGED);
if (behaviour == BEH_LURK)
MONS_TRAPDOOR_SPIDER, 's', BROWN, "trapdoor spider",
M_NO_FLAGS,
MR_VUL_POISON,
800, 10, MONS_WOLF_SPIDER, MONS_WOLF_SPIDER, MH_NATURAL, -3,
{ {AT_BITE, AF_POISON_MEDIUM, 20}, AT_NO_ATK, AT_NO_ATK, AT_NO_ATK },
{ 8, 3, 5, 0 },
3, 10, MST_NO_SPELLS, CE_POISONOUS, Z_BIG, S_HISS, I_INSECT,
HT_LAND, 15, DEFAULT_ENERGY, MONUSE_NOTHING, SIZE_TINY
},
{