]> granicus.if.org Git - nethack/commitdiff
Correction and clarification for "balk" math comment
authorcopperwater <aosdict@gmail.com>
Sat, 28 May 2022 01:35:05 +0000 (21:35 -0400)
committercopperwater <aosdict@gmail.com>
Sat, 28 May 2022 01:35:05 +0000 (21:35 -0400)
Andrio pointed out at some point that the "below 25% HP: pet will not
attack at all" mentioned in this comment was wrong. It will not attack
*peaceful monsters* at all, but will still attack hostile monsters.

Also, the math behind the balk variable has confused several people,
thinking it's off by one and allowing the pet to attack one level higher
than stated. This is not the case, since it's the lowest level they
*won't* attack. Clarify that.

src/dogmove.c

index 6669f4c721e2f41286490ca69c46d99f80a62fc7..5a5f5f68aa88f25a1e64c0958e9f05e55c95a9ce 100644 (file)
@@ -1034,7 +1034,12 @@ dog_move(register struct monst *mtmp,
              * 60% to 80%:  up to level
              * 40% to 60%:  up to level - 1
              * 25% to 40%:  up to level - 2
-             *  below 25%:  prevented from attacking at all by a different case
+             *  below 25%:  won't attack peacefuls of any level (different case)
+             *  below 20%:  up to level - 3
+             *
+             * note that balk's maximum value is +3, as it is the lowest level
+             * the pet will balk at attacking rather than the highest level they
+             * are willing to attack; note the >= used when comparing it.
              */
             int balk = mtmp->m_lev + ((5 * mtmp->mhp) / mtmp->mhpmax) - 2;