]> granicus.if.org Git - nethack/commitdiff
fix U100 - vampire stoning buf
authornethack.rankin <nethack.rankin>
Fri, 18 Oct 2002 06:49:34 +0000 (06:49 +0000)
committernethack.rankin <nethack.rankin>
Fri, 18 Oct 2002 06:49:34 +0000 (06:49 +0000)
     Fix the reported bug of a vampire that is wearing gloves being
able to bite a cockatrice without becoming petrified.

include/extern.h
src/mhitm.c
src/mhitu.c
src/uhitm.c

index 21f519b0e9e955626921399143f8fd5a77143f9f..26480c43662762d6ad611c9871f5177ec8112d2a 100644 (file)
@@ -941,6 +941,7 @@ E int FDECL(mattackm, (struct monst *,struct monst *));
 E int FDECL(noattacks, (struct permonst *));
 E int FDECL(sleep_monst, (struct monst *,int,int));
 E void FDECL(slept_monst, (struct monst *));
+E long FDECL(attk_protection, (int));
 
 /* ### mhitu.c ### */
 
index 1d5d81b198680860a81bc49ac74efcb80533aa70..18f41cfdba47408d6a2c1d2073f0590f372f59b9 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)mhitm.c    3.4     2002/09/08      */
+/*     SCCS Id: @(#)mhitm.c    3.4     2002/10/17      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -563,19 +563,20 @@ mdamagem(magr, mdef, mattk)
        register struct monst   *magr, *mdef;
        register struct attack  *mattk;
 {
-       struct  permonst *pa = magr->data, *pd = mdef->data;
-       int     tmp = d((int)mattk->damn,(int)mattk->damd);
        struct obj *obj;
        char buf[BUFSZ];
-       int protector =
-           mattk->aatyp == AT_TENT ? 0 :
-           mattk->aatyp == AT_KICK ? W_ARMF : W_ARMG;
-       int num;
-
-       if (touch_petrifies(pd) && !resists_ston(magr) &&
-          (mattk->aatyp != AT_WEAP || !otmp) &&
-          (mattk->aatyp != AT_GAZE && mattk->aatyp != AT_EXPL) &&
-          !(magr->misc_worn_check & protector)) {
+       struct permonst *pa = magr->data, *pd = mdef->data;
+       int num, tmp = d((int)mattk->damn, (int)mattk->damd);
+
+       if (touch_petrifies(pd) && !resists_ston(magr)) {
+           long protector = attk_protection(mattk->aatyp),
+                wornitems = magr->misc_worn_check;
+
+           /* wielded weapon gives same protection as gloves here */
+           if (otmp != 0) wornitems |= W_ARMG;
+
+           if (protector == 0L ||
+                 (protector != ~0L && (wornitems & protector) != protector)) {
                if (poly_when_stoned(pa)) {
                    mon_to_stone(magr);
                    return MM_HIT; /* no damage during the polymorph */
@@ -586,6 +587,7 @@ mdamagem(magr, mdef, mattk)
                else if (magr->mtame && !vis)
                    You(brief_feeling, "peculiarly sad");
                return MM_AGR_DIED;
+           }
        }
 
        switch(mattk->adtyp) {
@@ -1366,6 +1368,49 @@ int mdead;
        return (mdead | mhit);
 }
 
+/* "aggressive defense"; what type of armor prevents specified attack
+   from touching its target? */
+long
+attk_protection(aatyp)
+int aatyp;
+{
+    long w_mask = 0L;
+
+    switch (aatyp) {
+    case AT_NONE:
+    case AT_SPIT:
+    case AT_EXPL:
+    case AT_BOOM:
+    case AT_GAZE:
+    case AT_BREA:
+    case AT_MAGC:
+       w_mask = ~0L;           /* special case; no defense needed */
+       break;
+    case AT_CLAW:
+    case AT_TUCH:
+    case AT_WEAP:
+       w_mask = W_ARMG;        /* caller needs to check for weapon */
+       break;
+    case AT_KICK:
+       w_mask = W_ARMF;
+       break;
+    case AT_BUTT:
+       w_mask = W_ARMH;
+       break;
+    case AT_HUGS:
+       w_mask = (W_ARMC|W_ARMG); /* attacker needs both to be protected */
+       break;
+    case AT_BITE:
+    case AT_STNG:
+    case AT_ENGL:
+    case AT_TENT:
+    default:
+       w_mask = 0L;            /* no defense available */
+       break;
+    }
+    return w_mask;
+}
+
 #endif /* OVLB */
 
 /*mhitm.c*/
index df9350aba2a2c9e33593bf68290cba3618618c25..1b3de8cb07f78814352a1562c9b80348fedb64f5 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)mhitu.c    3.4     2002/03/29      */
+/*     SCCS Id: @(#)mhitu.c    3.4     2002/10/17      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -2390,15 +2390,16 @@ register struct attack *mattk;
                goto assess_dmg;
            case AD_STON: /* cockatrice */
            {
-               int protector =
-                   mattk->aatyp == AT_TENT ? 0 :
-                   mattk->aatyp == AT_KICK ? W_ARMF : W_ARMG;
-               if (!resists_ston(mtmp) &&
-                   (mattk->aatyp != AT_WEAP || !MON_WEP(mtmp)) &&
-                   mattk->aatyp != AT_GAZE && mattk->aatyp != AT_EXPL &&
-                   mattk->aatyp != AT_MAGC &&
-                   !(mtmp->misc_worn_check & protector)) {
-                   if(poly_when_stoned(mtmp->data)) {
+               long protector = attk_protection(mattk->aatyp),
+                    wornitems = mtmp->misc_worn_check;
+
+               /* wielded weapon gives same protection as gloves here */
+               if (MON_WEP(mtmp) != 0) wornitems |= W_ARMG;
+
+               if (!resists_ston(mtmp) && (protector == 0L ||
+                       (protector != ~0L &&
+                           (wornitems & protector) != protector))) {
+                   if (poly_when_stoned(mtmp->data)) {
                        mon_to_stone(mtmp);
                        return (1);
                    }
index 63fd5ac2c7c84eb6e283a6fd7c0fffbed59ac53c..017e11ebdb2a74a496c119a6f6fcc2f4a2a69ebe 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)uhitm.c    3.4     2002/09/08      */
+/*     SCCS Id: @(#)uhitm.c    3.4     2002/10/17      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -2020,21 +2020,26 @@ uchar aatyp;
            exercise(A_STR, FALSE);
            break;
          case AD_STON:
-           if(mhit) {
-             /* mhit does not mean you physically hit; it just means the
-                attack was successful */
-             if ((aatyp == AT_KICK && !uarmf) ||
-                   ((aatyp == AT_WEAP || aatyp == AT_CLAW || aatyp == AT_MAGC
-                               || aatyp == AT_TUCH) && !uwep && !uarmg) ||
-                   aatyp == AT_BITE || aatyp == AT_STNG || aatyp == AT_BUTT ||
-                   aatyp == AT_TENT || aatyp == AT_HUGS || aatyp == AT_ENGL) {
-               if (!Stone_resistance &&
-                   !(poly_when_stoned(youmonst.data) && polymon(PM_STONE_GOLEM))) {
+           if (mhit) {         /* successful attack */
+               long protector = attk_protection(aatyp);
+
+               /* hero using monsters' AT_MAGC attack is hitting hand to
+                  hand rather than casting a spell */
+               if (aatyp == AT_MAGC) protector = W_ARMG;
+
+               if (protector == 0L ||          /* no protection */
+                       (protector == W_ARMG && !uarmg && !uwep) ||
+                       (protector == W_ARMF && !uarmf) ||
+                       (protector == W_ARMH && !uarmh) ||
+                       (protector == (W_ARMC|W_ARMG) && (!uarmc || !uarmg))) {
+                   if (!Stone_resistance &&
+                           !(poly_when_stoned(youmonst.data) &&
+                               polymon(PM_STONE_GOLEM))) {
                        You("turn to stone...");
                        done_in_by(mon);
                        return 2;
+                   }
                }
-             }
            }
            break;
          case AD_RUST: