]> granicus.if.org Git - nethack/commitdiff
Unify ad_halu
authorPasi Kallinen <paxed@alt.org>
Mon, 30 Nov 2020 21:28:13 +0000 (23:28 +0200)
committerPasi Kallinen <paxed@alt.org>
Fri, 4 Dec 2020 07:30:19 +0000 (09:30 +0200)
include/extern.h
src/mhitm.c
src/uhitm.c

index 6082a1537339678c47b6c576743dedc21b9ed3e9..4f4b9a2a3c87fa3a3f9e5265a80c89947c543df1 100644 (file)
@@ -2784,6 +2784,7 @@ E void FDECL(mhitm_ad_poly, (struct monst *, struct attack *, struct monst *, st
 E void FDECL(mhitm_ad_famn, (struct monst *, struct attack *, struct monst *, struct mhitm_data *));
 E void FDECL(mhitm_ad_pest, (struct monst *, struct attack *, struct monst *, struct mhitm_data *));
 E void FDECL(mhitm_ad_deth, (struct monst *, struct attack *, struct monst *, struct mhitm_data *));
+E void FDECL(mhitm_ad_halu, (struct monst *, struct attack *, struct monst *, struct mhitm_data *));
 E int FDECL(damageum, (struct monst *, struct attack *, int));
 E void FDECL(missum, (struct monst *, struct attack *, BOOLEAN_P));
 E int FDECL(passive, (struct monst *, struct obj *, BOOLEAN_P, int,
index 9d35199a692350e1cd2fcc2d4e40749b74d5d3dd..9c9e89bec7f726104c639cbc2e87b08880d7faed 100644 (file)
@@ -1107,14 +1107,9 @@ int dieroll;
             return mhm.hitflags;
         break;
     case AD_HALU:
-        if (!magr->mcan && haseyes(pd) && mdef->mcansee) {
-            if (g.vis && canseemon(mdef))
-                pline("%s looks %sconfused.", Monnam(mdef),
-                      mdef->mconf ? "more " : "");
-            mdef->mconf = 1;
-            mdef->mstrategy &= ~STRAT_WAITFORU;
-        }
-        mhm.damage = 0;
+        mhitm_ad_halu(magr, mattk, mdef, &mhm);
+        if (mhm.done)
+            return mhm.hitflags;
         break;
     case AD_CURS:
         mhitm_ad_curs(magr, mattk, mdef, &mhm);
index 4f5ead337065b030d7293416433da8e1f502658f..3213c8ff5a2dec2de1dbd473512b1afa240a2516 100644 (file)
@@ -3317,6 +3317,36 @@ struct mhitm_data *mhm;
     }
 }
 
+void
+mhitm_ad_halu(magr, mattk, mdef, mhm)
+struct monst *magr;
+struct attack *mattk;
+struct monst *mdef;
+struct mhitm_data *mhm;
+{
+    struct permonst *pd = mdef->data;
+
+    if (magr == &g.youmonst) {
+        /* uhitm */
+        mhm->damage = 0;
+    } else if (mdef == &g.youmonst) {
+        /* mhitu */
+        mhm->damage = 0;
+    } else {
+        /* mhitm */
+        int armpro = magic_negation(mdef);
+        boolean cancelled = magr->mcan || !(rn2(10) >= 3 * armpro);
+
+        if (!magr->mcan && haseyes(pd) && mdef->mcansee) {
+            if (g.vis && canseemon(mdef))
+                pline("%s looks %sconfused.", Monnam(mdef),
+                      mdef->mconf ? "more " : "");
+            mdef->mconf = 1;
+            mdef->mstrategy &= ~STRAT_WAITFORU;
+        }
+        mhm->damage = 0;
+    }
+}
 
 /* Template for monster hits monster for AD_FOO.
    - replace "break" with return