]> granicus.if.org Git - nethack/commitdiff
fix #H7536 - pet vampire behavior
authorPatR <rankin@nethack.org>
Wed, 14 Nov 2018 00:29:48 +0000 (16:29 -0800)
committerPatR <rankin@nethack.org>
Wed, 14 Nov 2018 00:29:48 +0000 (16:29 -0800)
Vampires tend to take vampire bat form and stay that way, unless/until
there's a closed door they want to pass in which case they change to
fog cloud form.  Those shifted forms are weak, so pet vampires tend
not to attack other monsters, and if they don't take damage, they
won't change to vampire form.  So, when comparing relative strength of
self and foe while deciding whether to attack another monster, treat
their own strength in weak form as if in vampire form, making them be
more aggressive.

Hostile vampires shouldn't need any comparable change.  They don't use
relative strengths when deciding whether to attack something.

doc/fixes36.2
src/dogmove.c

index 79b7520a46c8ab178c32b6f483e371dc2ffccbb4..8e6718ec58d050c13e4a60eda0ec2406553b2693 100644 (file)
@@ -197,6 +197,7 @@ avoid potential buffer overflow if object with very long name knocks other
 clairvoyance would show trap instead of a monster on/in that trap, which was
        intentional, but when clairvoyance finished the monster wasn't shown
 nurse corpse/tin chance to convey poison resistance when eaten was not honored
+make tame vampires be more aggressive when shifted to bat/fog/wolf form
 
 
 Fixes to Post-3.6.1 Problems that Were Exposed Via git Repository
index 2ec72551eaae40a98fa1d36636fc0fa3680d6761..e21d4e3f5a41c7033436a179fd838f70b036d89f 100644 (file)
@@ -721,6 +721,7 @@ struct monst *mtmp, *mtarg;
     /* Give 1 in 3 chance of safe breathing even if pet is confused or
      * if you're on the quest start level */
     if (!mtmp->mconf || !rn2(3) || Is_qstart(&u.uz)) {
+        int mtmp_lev;
         aligntyp align1 = A_NONE, align2 = A_NONE; /* For priests, minions */
         boolean faith1 = TRUE,  faith2 = TRUE;
 
@@ -774,10 +775,26 @@ struct monst *mtmp, *mtarg;
             || (mtmp->m_lev > 12 && mtarg->m_lev < mtmp->m_lev - 9
                 && u.ulevel > 8 && mtarg->m_lev < u.ulevel - 7))
             score -= 25;
+        /* for strength purposes, a vampshifter in weak form (vampire bat,
+           fog cloud, maybe wolf) will attack as if in vampire form;
+           otherwise if won't do much and usually wouldn't suffer enough
+           damage (from counterattacks) to switch back to vampire form;
+           make it be more aggressive by behaving as if stronger */
+        mtmp_lev = mtmp->m_lev;
+        if (is_vampshifter(mtmp) && mtmp->data->mlet != S_VAMPIRE) {
+            /* is_vampshifter() implies (mtmp->cham >= LOW_PM) */
+            mtmp_lev = mons[mtmp->cham].mlevel;
+            /* actual vampire level would range from 1.0*mlvl to 1.5*mlvl */
+            mtmp_lev += rn2(mtmp_lev / 2 + 1);
+            /* we don't expect actual level in weak form to exceed
+               base level of strong form, but handle that if it happens */
+            if (mtmp->m_lev > mtmp_lev)
+                mtmp_lev = mtmp->m_lev;
+        }
         /* And pets will hesitate to attack vastly stronger foes.
            This penalty will be discarded if master's in trouble. */
-        if (mtarg->m_lev > mtmp->m_lev + 4L)
-            score -= (mtarg->m_lev - mtmp->m_lev) * 20L;
+        if (mtarg->m_lev > mtmp_lev + 4L)
+            score -= (mtarg->m_lev - mtmp_lev) * 20L;
         /* All things being the same, go for the beefiest monster. This
            bonus should not be large enough to override the pet's aversion
            to attacking much stronger monsters. */