From: nethack.rankin Date: Thu, 17 Aug 2006 04:35:08 +0000 (+0000) Subject: fix grab/engulf by tame/peaceful monster (trunk only) X-Git-Tag: MOVE2GIT~930 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e6bf8af74e11c452c57c7caf580bc9ab6d8a1ab0;p=nethack fix grab/engulf by tame/peaceful monster (trunk only) reported being swallowed by his pet purple worm during Conflict, then being stuck inside once Conflict ended. I'm not entirely sure what dog_move() intended by the "swallowed case handled above" comment. It returns without letting the pet move when the distance between pet and hero is 0; that wasn't much in the way of "handling" being swallowed. Grabbing pets did let go, but peaceful monsters didn't until you actually attempted to move away from them. Now all four combinations (grabbed or swallowed by tame or peaceful monster) are handled the same: the monster will let the hero go next time it gets a chance to try to move, using up its move in the process. --- diff --git a/doc/fixes35.0 b/doc/fixes35.0 index 33f4c8e87..fbf416760 100644 --- a/doc/fixes35.0 +++ b/doc/fixes35.0 @@ -155,6 +155,7 @@ make region ttl field a long instead of short to get rid of lint warnings pushing a boulder onto a level teleporter trap could issue repeat messages if shopkeeper or priest gets teleported while inside his shop or temple, give locations inside that room preference when choosing destination +tame/peaceful grabber/engulfer will release hero after conflict ends Platform- and/or Interface-Specific Fixes diff --git a/src/dogmove.c b/src/dogmove.c index 88224d431..6b7518fcf 100644 --- a/src/dogmove.c +++ b/src/dogmove.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)dogmove.c 3.5 2005/10/14 */ +/* SCCS Id: @(#)dogmove.c 3.5 2006/08/16 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -635,11 +635,13 @@ register int after; /* this is extra fast monster movement */ return 2; /* current monster is gone */ } } +#if 0 /* [this is now handled in dochug()] */ if (!Conflict && !mtmp->mconf && mtmp == u.ustuck && !sticks(youmonst.data)) { unstuck(mtmp); /* swallowed case handled above */ You("get released!"); } +#endif if (!nohands(mtmp->data) && !verysmall(mtmp->data)) { allowflags |= OPENDOOR; if (monhaskey(mtmp, TRUE)) allowflags |= UNLOCKDOOR; diff --git a/src/monmove.c b/src/monmove.c index 21a89afad..f3aacb73f 100644 --- a/src/monmove.c +++ b/src/monmove.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)monmove.c 3.5 2005/10/14 */ +/* SCCS Id: @(#)monmove.c 3.5 2006/08/16 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -8,13 +8,13 @@ extern boolean notonhead; +STATIC_DCL void FDECL(watch_on_duty,(struct monst *)); STATIC_DCL int FDECL(disturb,(struct monst *)); +STATIC_DCL void FDECL(release_hero, (struct monst *)); STATIC_DCL void FDECL(distfleeck,(struct monst *,int *,int *,int *)); STATIC_DCL int FDECL(m_arrival, (struct monst *)); -STATIC_DCL void FDECL(watch_on_duty,(struct monst *)); STATIC_DCL boolean FDECL(stuff_prevents_passage, (struct monst *)); -STATIC_OVL int FDECL(vamp_shift, (struct monst *,struct permonst *)); - +STATIC_DCL int FDECL(vamp_shift, (struct monst *,struct permonst *)); boolean /* TRUE : mtmp died */ mb_trapped(mtmp) @@ -203,6 +203,21 @@ disturb(mtmp) return(0); } +/* ungrab/expel held/swallowed hero */ +STATIC_OVL void +release_hero(mon) +struct monst *mon; +{ + if (mon == u.ustuck) { + if (u.uswallow) { + expels(mon, mon->data, TRUE); + } else if (!sticks(youmonst.data)) { + unstuck(mon); /* let go */ + You("get released!"); + } + } +} + /* monster begins fleeing for the specified time, 0 means untimed flee * if first, only adds fleetime if monster isn't already fleeing * if fleemsg, prints a message about new flight, otherwise, caller should */ @@ -213,14 +228,7 @@ int fleetime; boolean first; boolean fleemsg; { - if (u.ustuck == mtmp) { - if (u.uswallow) - expels(mtmp, mtmp->data, TRUE); - else if (!sticks(youmonst.data)) { - unstuck(mtmp); /* monster lets go when fleeing */ - You("get released!"); - } - } + if (mtmp == u.ustuck) release_hero(mtmp); /* expels/unstuck */ if (!first || !mtmp->mflee) { /* don't lose untimed scare */ @@ -360,6 +368,12 @@ register struct monst *mtmp; if (mtmp->mflee && !mtmp->mfleetim && mtmp->mhp == mtmp->mhpmax && !rn2(25)) mtmp->mflee = 0; + /* cease conflict-induced swallow/grab if conflict has ended */ + if (mtmp == u.ustuck && mtmp->mpeaceful && !mtmp->mconf && !Conflict) { + release_hero(mtmp); + return 0; /* uses up monster's turn */ + } + set_apparxy(mtmp); /* Must be done after you move and before the monster does. The * set_apparxy() call in m_move() doesn't suffice since the variables @@ -1517,4 +1531,5 @@ struct permonst *ptr; } return reslt; } + /*monmove.c*/