From 085498ba288c1821f530bbf33e5fb4d6b7355b3b Mon Sep 17 00:00:00 2001 From: "nethack.rankin" Date: Mon, 11 Mar 2002 08:46:54 +0000 Subject: [PATCH] unleashing untame monsters Fix several cases that earlier patches didn't address. If a leashed monster becomes untame, detach the leash. --- doc/fixes34.0 | 3 ++- src/dog.c | 35 ++++++++++++++++++++++------------- src/hack.c | 3 ++- src/steed.c | 8 ++++++-- 4 files changed, 32 insertions(+), 17 deletions(-) diff --git a/doc/fixes34.0 b/doc/fixes34.0 index 3130f49d8..799fc8bab 100644 --- a/doc/fixes34.0 +++ b/doc/fixes34.0 @@ -332,7 +332,8 @@ keep monster from forgetting its weapon is cursed every other round multiple shot throwing stops immediately whenever you hurtle backwards don't panic if being billed for a burning or other timed object food that makes a monster peaceful should not re-anger it at the same time -abusing a leashed pet can result in a leashed peaceful monster +abusing a leashed pet could result in a leashed peaceful monster +couldn't unleash steed while mounted trying and failing to wield an item could leave current weapon flagged as both "weapon in hand" and "alternate weapon" when `pushweapon' option is set handle OBJ_CONTAINED case for corpse revival so that trolls can revive diff --git a/src/dog.c b/src/dog.c index 0811fdcb9..31089d2fc 100644 --- a/src/dog.c +++ b/src/dog.c @@ -91,6 +91,7 @@ boolean quietly; if (!quietly) You("get a bad feeling about this."); mtmp->mpeaceful = 0; + set_malign(mtmp); } } /* if figurine has been named, give same name to the monster */ @@ -413,6 +414,13 @@ long nmv; /* number of moves */ mtmp->mtame = mtmp->mpeaceful = 0; } + if (!mtmp->mtame && mtmp->mleashed) { + /* leashed monsters should always be with hero, consequently + never losing any time to be accounted for later */ + impossible("catching up for leashed monster?"); + m_unleash(mtmp, FALSE); + } + /* recover lost hit points */ if (!regenerates(mtmp->data)) imv /= 20; if (mtmp->mhp + imv >= mtmp->mhpmax) @@ -463,11 +471,10 @@ boolean pets_only; /* true for ascension or final escape */ pline("%s is still trapped.", Monnam(mtmp)); stay_behind = TRUE; } - if (stay_behind #ifdef STEED - && mtmp != u.usteed + if (mtmp == u.usteed) stay_behind = FALSE; #endif - ) { + if (stay_behind) { if (mtmp->mleashed) { pline("%s leash suddenly comes loose.", humanoid(mtmp->data) @@ -550,14 +557,13 @@ migrate_to_level(mtmp, tolev, xyloc, cc) obj->no_charge = 0; } + if (mtmp->mleashed) { + mtmp->mtame--; + m_unleash(mtmp, TRUE); + } relmon(mtmp); mtmp->nmon = migrating_mons; migrating_mons = mtmp; - if (mtmp->mleashed) { - m_unleash(mtmp, FALSE); - mtmp->mtame--; - pline_The("leash comes off!"); - } newsym(mtmp->mx,mtmp->my); new_lev.dnum = ledger_to_dnum((xchar)tolev); @@ -809,7 +815,12 @@ boolean quietly; mtmp->mpeaceful = mtmp->mtame = 0; } } - if (!mtmp->mtame) newsym(mtmp->mx, mtmp->my); + if (!mtmp->mtame) { + newsym(mtmp->mx, mtmp->my); + /* a life-saved monster might be leashed; + don't leave it that way if it's no longer tame */ + if (mtmp->mleashed) m_unleash(mtmp, TRUE); + } /* if its still a pet, start a clean pet-slate now */ if (has_edog && mtmp->mtame) { @@ -831,10 +842,8 @@ struct monst *mtmp; if (mtmp->mtame && !mtmp->isminion) EDOG(mtmp)->abuse++; - if (!mtmp->mtame && mtmp->mleashed) { - pline("%s breaks loose of %s leash!", Monnam(mtmp), mhis(mtmp)); - m_unleash(mtmp, FALSE); - } + if (!mtmp->mtame && mtmp->mleashed) + m_unleash(mtmp, TRUE); /* don't make a sound if pet is in the middle of leaving the level */ /* newsym isn't necessary in this case either */ diff --git a/src/hack.c b/src/hack.c index f1d5d8914..b9e820f9b 100644 --- a/src/hack.c +++ b/src/hack.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)hack.c 3.4 2002/02/05 */ +/* SCCS Id: @(#)hack.c 3.4 2002/03/09 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1166,6 +1166,7 @@ domove() if (mtmp->mtrapped) { if (!rn2(mtmp->mtame)) { mtmp->mtame = mtmp->mpeaceful = mtmp->msleeping = 0; + if (mtmp->mleashed) m_unleash(mtmp, TRUE); growl(mtmp); } else { yelp(mtmp); diff --git a/src/steed.c b/src/steed.c index a25738a96..deeeb4580 100644 --- a/src/steed.c +++ b/src/steed.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)steed.c 3.4 2001/04/12 */ +/* SCCS Id: @(#)steed.c 3.4 2002/03/09 */ /* Copyright (c) Kevin Hugo, 1998-1999. */ /* NetHack may be freely redistributed. See license for details. */ @@ -272,8 +272,11 @@ mount_steed(mtmp, force) return (FALSE); } if (!force && !Role_if(PM_KNIGHT) && !(--mtmp->mtame)) { + /* no longer tame */ newsym(mtmp->mx, mtmp->my); - pline("%s resists!", Monnam(mtmp)); + pline("%s resists%s!", Monnam(mtmp), + mtmp->mleashed ? " and its leash comes off" : ""); + if (mtmp->mleashed) m_unleash(mtmp, FALSE); return (FALSE); } if (!force && Underwater && !is_swimmer(ptr)) { @@ -385,6 +388,7 @@ kick_steed() /* Make the steed less tame and check if it resists */ if (u.usteed->mtame) u.usteed->mtame--; + if (!u.usteed->mtame && u.usteed->mleashed) m_unleash(u.usteed, TRUE); if (!u.usteed->mtame || (u.ulevel+u.usteed->mtame < rnd(MAXULEV/2+5))) { newsym(u.usteed->mx, u.usteed->my); dismount_steed(DISMOUNT_THROWN);