diff --git a/include/extern.h b/include/extern.h index 0f7c04a00..1b31ea989 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1827,6 +1827,7 @@ extern void mon_track_add(struct monst *, coordxy, coordxy) NONNULLARG1; extern void mon_track_clear(struct monst *) NONNULLARG1; extern boolean monhaskey(struct monst *, boolean) NONNULLARG1; extern void mon_regen(struct monst *, boolean) NONNULLARG1; +extern void m_postmove_effect(struct monst *) NONNULLARG1; extern int dochugw(struct monst *, boolean) NONNULLARG1; extern boolean onscary(coordxy, coordxy, struct monst *) NONNULLARG3; extern struct monst *find_pmmonst(int); diff --git a/src/hack.c b/src/hack.c index 3a449ab3d..59d126055 100644 --- a/src/hack.c +++ b/src/hack.c @@ -2692,6 +2692,9 @@ domove_core(void) /* tentatively move the hero plus steed; leave CLIPPING til later */ u.ux += u.dx; u.uy += u.dy; + + m_postmove_effect(&gy.youmonst); + if (u.usteed) { u.usteed->mx = u.ux; u.usteed->my = u.uy; diff --git a/src/monmove.c b/src/monmove.c index b0a25e3ae..dfd39f2f7 100644 --- a/src/monmove.c +++ b/src/monmove.c @@ -593,6 +593,26 @@ mind_blast(struct monst *mtmp) } } +/* do whatever effects monster has after moving. + called for both monsters and polyed hero. + for hero, called after location changes, + to prevent spam messages for hero getting enveloped in a cloud. + for monsters, called before location changes, + because monsters don't have "previous location" field */ +void +m_postmove_effect(struct monst *mtmp) +{ + boolean is_u = (mtmp == &gy.youmonst) ? TRUE : FALSE; + coordxy x = is_u ? u.ux0 : mtmp->mx, + y = is_u ? u.uy0 : mtmp->my; + + /* Hezrous create clouds of stench. This does not cost a move. */ + if (mtmp->data == &mons[PM_HEZROU]) /* stench */ + create_gas_cloud(x, y, 1, 8); + else if (mtmp->data == &mons[PM_STEAM_VORTEX] && !mtmp->mcan) + create_gas_cloud(x, y, 1, 0); /* harmless vapor */ +} + /* returns 1 if monster died moving, 0 otherwise */ /* The whole dochugw/m_move/distfleeck/mfndpos section is serious spaghetti * code. --KAA @@ -780,12 +800,6 @@ dochug(struct monst *mtmp) * PHASE THREE: Now the actual movement phase */ - /* Hezrous create clouds of stench. This does not cost a move. */ - if (mtmp->data == &mons[PM_HEZROU]) /* stench */ - create_gas_cloud(mtmp->mx, mtmp->my, 1, 8); - else if (mtmp->data == &mons[PM_STEAM_VORTEX] && !mtmp->mcan) - create_gas_cloud(mtmp->mx, mtmp->my, 1, 0); /* harmless vapor */ - /* A killer bee may eat honey in order to turn into a queen bee, costing it a move. */ if (mdat == &mons[PM_KILLER_BEE] @@ -1887,6 +1901,8 @@ m_move(struct monst *mtmp, int after) return MMOVE_DONE; } + m_postmove_effect(mtmp); + /* move a normal monster; for a long worm, remove_monster() and place_monster() only manipulate the head; they leave tail as-is */ remove_monster(omx, omy);