From: Pasi Kallinen Date: Mon, 21 Dec 2015 17:12:02 +0000 (+0200) Subject: Displace a pet rather than stop travel X-Git-Tag: NetHack-3.6.1_RC01~1130 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=715fd7e3d9aa109284f775f2b334ce96d054c4a2;p=nethack Displace a pet rather than stop travel ... and stop travel if you take damage from any source. Original patch via Acehack by Alex Smith --- diff --git a/doc/fixes36.1 b/doc/fixes36.1 index 41c835997..c71710f43 100644 --- a/doc/fixes36.1 +++ b/doc/fixes36.1 @@ -52,6 +52,7 @@ stack splitting for dipping large quantities of potions was done poorly dipping fruit juice into enlightenment gave different result than the inverse make travel walk up to a trap and stop when the trap blocks the only way forward, instead of trying to go straight line +travel will displace pets rather than stop Platform- and/or Interface-Specific Fixes diff --git a/src/hack.c b/src/hack.c index 2f45d10fd..3f6514678 100644 --- a/src/hack.c +++ b/src/hack.c @@ -1370,8 +1370,9 @@ domove() } mtmp = m_at(x, y); - if (mtmp) { + if (mtmp && !is_safepet(mtmp)) { /* Don't attack if you're running, and can see it */ + /* It's fine to displace pets, though */ /* We should never get here if forcefight */ if (context.run && ((!Blind && mon_visible(mtmp) && ((mtmp->m_ap_type != M_AP_FURNITURE @@ -1393,7 +1394,10 @@ domove() /* attack monster */ if (mtmp) { - nomul(0); + /* don't stop travel when displacing pets; if the + displace fails for some reason, attack() in uhitm.c + will stop travel rather than domove */ + if (!is_safepet(mtmp) || context.forcefight) nomul(0); /* only attack if we know it's there */ /* or if we used the 'F' command to fight blindly */ /* or if it hides_under, in which case we call attack() to print @@ -1409,7 +1413,7 @@ domove() * attack_check(), which still wastes a turn, but prints a * different message and makes the player remember the monster. */ - if (context.nopick + if (context.nopick && !context.travel && (canspotmon(mtmp) || glyph_is_invisible(levl[x][y].glyph))) { if (mtmp->m_ap_type && !Protection_from_shape_changers && !sensemon(mtmp)) @@ -2415,7 +2419,7 @@ lookaround() && mtmp->m_ap_type != M_AP_OBJECT && (!mtmp->minvis || See_invisible) && !mtmp->mundetected) { if ((context.run != 1 && !mtmp->mtame) - || (x == u.ux + u.dx && y == u.uy + u.dy)) + || (x == u.ux + u.dx && y == u.uy + u.dy && !context.travel)) goto stop; } @@ -2678,6 +2682,8 @@ boolean k_format; u.uhp -= n; if (u.uhp > u.uhpmax) u.uhpmax = u.uhp; /* perhaps n was negative */ + else + context.travel = context.travel1 = context.mv = context.run = 0; context.botl = 1; if (u.uhp < 1) { killer.format = k_format; diff --git a/src/uhitm.c b/src/uhitm.c index d41f71669..24c6fd870 100644 --- a/src/uhitm.c +++ b/src/uhitm.c @@ -350,10 +350,12 @@ register struct monst *mtmp; Strcpy(buf, y_monnam(mtmp)); buf[0] = highc(buf[0]); You("stop. %s is in the way!", buf); + context.travel = context.travel1 = context.mv = context.run = 0; return TRUE; } else if ((mtmp->mfrozen || (!mtmp->mcanmove) || (mtmp->data->mmove == 0)) && rn2(6)) { pline("%s doesn't seem to move!", Monnam(mtmp)); + context.travel = context.travel1 = context.mv = context.run = 0; return TRUE; } else return FALSE;