]> granicus.if.org Git - nethack/commitdiff
monst vs steed tidbit
authornethack.rankin <nethack.rankin>
Sat, 2 Jun 2007 22:00:29 +0000 (22:00 +0000)
committernethack.rankin <nethack.rankin>
Sat, 2 Jun 2007 22:00:29 +0000 (22:00 +0000)
     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

index 1e38b0c8d69a39fff508989bac563b4cc0a43085..141eecee489fa9bb6006e338ea36b872b28c214f 100644 (file)
@@ -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));