]> granicus.if.org Git - nethack/commitdiff
Unify ad_were
authorPasi Kallinen <paxed@alt.org>
Tue, 1 Dec 2020 08:51:19 +0000 (10:51 +0200)
committerPasi Kallinen <paxed@alt.org>
Fri, 4 Dec 2020 07:30:19 +0000 (09:30 +0200)
include/extern.h
src/mhitm.c
src/mhitu.c
src/uhitm.c

index 4de281ec03eb0229d30bd2f85289cf93e4d5d2c5..70d8298d95481af413bf6d9ebcf7b14c40befa66 100644 (file)
@@ -2787,6 +2787,7 @@ E void FDECL(mhitm_ad_deth, (struct monst *, struct attack *, struct monst *, st
 E void FDECL(mhitm_ad_halu, (struct monst *, struct attack *, struct monst *, struct mhitm_data *));
 E void FDECL(mhitm_ad_phys, (struct monst *, struct attack *, struct monst *, struct mhitm_data *));
 E void FDECL(mhitm_ad_ston, (struct monst *, struct attack *, struct monst *, struct mhitm_data *));
+E void FDECL(mhitm_ad_were, (struct monst *, struct attack *, struct monst *, struct mhitm_data *));
 E boolean FDECL(do_stone_u, (struct monst *));
 E void FDECL(do_stone_mon, (struct monst *, struct attack *, struct monst *, struct mhitm_data *));
 E int FDECL(damageum, (struct monst *, struct attack *, int));
index 236e4d83a011458e5cd8f321771d0fb49b80be4a..b743a2fe39820ad451e2eb0eaf27d8068bf2cc98 100644 (file)
@@ -964,6 +964,10 @@ int dieroll;
         }
         goto physical;
     case AD_WERE:
+        mhitm_ad_were(magr, mattk, mdef, &mhm);
+        if (mhm.done)
+            return mhm.hitflags;
+        break;
     case AD_HEAL:
     case AD_PHYS:
  physical:
index a08ce6ce74d847219a036fe24160e6e036e7a058..8000454e39bf7e5579b2d838c626bc5ce4158a01 100644 (file)
@@ -1129,14 +1129,9 @@ register struct attack *mattk;
             return mhm.hitflags;
         break;
     case AD_WERE:
-        hitmsg(mtmp, mattk);
-        if (uncancelled && !rn2(4) && u.ulycn == NON_PM
-            && !Protection_from_shape_changers && !defends(AD_WERE, uwep)) {
-            You_feel("feverish.");
-            exercise(A_CON, FALSE);
-            set_ulycn(monsndx(mdat));
-            retouch_equipment(2);
-        }
+        mhitm_ad_were(mtmp, mattk, &g.youmonst, &mhm);
+        if (mhm.done)
+            return mhm.hitflags;
         break;
     case AD_SGLD:
         mhitm_ad_sgld(mtmp, mattk, &g.youmonst, &mhm);
index e0d1d30d05df0dae9cfea87cbd7c335a7a41afdb..d4281ac2fc9fffa7d60bfec6bda2c6633cbaac87 100644 (file)
@@ -3644,6 +3644,42 @@ struct mhitm_data *mhm;
     }
 }
 
+void
+mhitm_ad_were(magr, mattk, mdef, mhm)
+struct monst *magr;
+struct attack *mattk;
+struct monst *mdef;
+struct mhitm_data *mhm;
+{
+    struct permonst *pa = magr->data;
+    struct permonst *pd = mdef->data;
+
+    if (magr == &g.youmonst) {
+        /* uhitm */
+        mhitm_ad_phys(&g.youmonst, mattk, mdef, mhm);
+        if (mhm->done)
+            return;
+    } else if (mdef == &g.youmonst) {
+        /* mhitu */
+        int armpro = magic_negation(mdef);
+        boolean uncancelled = !magr->mcan && (rn2(10) >= 3 * armpro);
+
+        hitmsg(magr, mattk);
+        if (uncancelled && !rn2(4) && u.ulycn == NON_PM
+            && !Protection_from_shape_changers && !defends(AD_WERE, uwep)) {
+            You_feel("feverish.");
+            exercise(A_CON, FALSE);
+            set_ulycn(monsndx(pa));
+            retouch_equipment(2);
+        }
+    } else {
+        /* mhitm */
+        mhitm_ad_phys(&g.youmonst, mattk, mdef, mhm);
+        if (mhm->done)
+            return;
+    }
+}
+
 /* Template for monster hits monster for AD_FOO.
    - replace "break" with return
    - replace "return" with mhm->done = TRUE
@@ -3719,7 +3755,11 @@ int specialdmg; /* blessed and/or silver bonus against various things */
         }
 #endif
         goto physical;
-    case AD_WERE: /* no special effect on monsters */
+    case AD_WERE:
+        mhitm_ad_were(&g.youmonst, mattk, mdef, &mhm);
+        if (mhm.done)
+            return mhm.hitflags;
+        break;
     case AD_HEAL: /* likewise */
     case AD_PHYS:
  physical: