From 61cd699405db5d54d3c1254d467c93661060e989 Mon Sep 17 00:00:00 2001 From: "nethack.rankin" Date: Sat, 2 Jun 2007 22:00:29 +0000 Subject: [PATCH] monst vs steed tidbit I came across an old bug report which stated that steeds missed out on their chance to counterattack if the hero had just taken some action other than moving. [1: monster attacks steed instead of hero ] [2: if monster died while attacking, return 1 ] if (i & MM_DEF_DIED || u.ux != u.ux0 || u.uy != u.uy0) return (0); [4: otherwise, steed counterattacks monster ] Sometime since whatever version the 2001 report was for, but before the current cvs repository was set up someone addressed this by changing it to be if (i & MM_DEF_DIED || !u.umoved) return (0); but I think that fixed the wrong thing. I believe that the original code was attempting to make sure that the steed was still in position to be able to counterattack. There's no reason to care about the hero's most recent action; he had to have done something that caused time to elapse in order for the other monster to have initiated an attack in the first. (The new range check is actually redundant; mattackm() also enforces it.) --- src/mhitu.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/mhitu.c b/src/mhitu.c index 1e38b0c8d..141eecee4 100644 --- a/src/mhitu.c +++ b/src/mhitu.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)mhitu.c 3.5 2007/03/09 */ +/* SCCS Id: @(#)mhitu.c 3.5 2007/06/02 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -334,7 +334,9 @@ mattacku(mtmp) i = mattackm(mtmp, u.usteed); if ((i & MM_AGR_DIED)) return (1); - if (i & MM_DEF_DIED || u.umoved) + /* make sure steed is still alive and within range */ + if ((i & MM_DEF_DIED) || !u.usteed || + distu(mtmp->mx, mtmp->my) > 2) return (0); /* Let your steed retaliate */ return (!!(mattackm(u.usteed, mtmp) & MM_DEF_DIED));