]> granicus.if.org Git - nethack/commitdiff
Unify ad_samu
authorPasi Kallinen <paxed@alt.org>
Tue, 1 Dec 2020 09:28:41 +0000 (11:28 +0200)
committerPasi Kallinen <paxed@alt.org>
Fri, 4 Dec 2020 07:30:21 +0000 (09:30 +0200)
include/extern.h
src/mhitu.c
src/uhitm.c

index 97fdb46e359a636284fe92739eb4a6d0afb54ca8..914265912d1ce0be5d8e7165fdc87c00c9f7ac71 100644 (file)
@@ -2792,6 +2792,7 @@ E void FDECL(mhitm_ad_heal, (struct monst *, struct attack *, struct monst *, st
 E void FDECL(mhitm_ad_stun, (struct monst *, struct attack *, struct monst *, struct mhitm_data *));
 E void FDECL(mhitm_ad_legs, (struct monst *, struct attack *, struct monst *, struct mhitm_data *));
 E void FDECL(mhitm_ad_dgst, (struct monst *, struct attack *, struct monst *, struct mhitm_data *));
+E void FDECL(mhitm_ad_samu, (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 030c98ee955d0f7e4d69bd5a1b42920fe97972f6..d061dd9b1435d343a717140f4b4efedc1b9aa109 100644 (file)
@@ -1165,14 +1165,10 @@ register struct attack *mattk;
         break;
 
     case AD_SAMU:
-        hitmsg(mtmp, mattk);
-        /* when the Wizard or quest nemesis hits, there's a 1/20 chance
-           to steal a quest artifact (any, not just the one for the hero's
-           own role) or the Amulet or one of the invocation tools */
-        if (!rn2(20))
-            stealamulet(mtmp);
+        mhitm_ad_samu(mtmp, mattk, &g.youmonst, &mhm);
+        if (mhm.done)
+            return mhm.hitflags;
         break;
-
     case AD_TLPT:
         mhitm_ad_tlpt(mtmp, mattk, &g.youmonst, &mhm);
         if (mhm.done)
index 57bced509ccca337406acf9db3c5f480e0284b7a..59362b6bb18a36dc3b5df161ac73ade0cb3e5c56 100644 (file)
@@ -3959,6 +3959,33 @@ struct mhitm_data *mhm;
     }
 }
 
+void
+mhitm_ad_samu(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 */
+        hitmsg(magr, mattk);
+        /* when the Wizard or quest nemesis hits, there's a 1/20 chance
+           to steal a quest artifact (any, not just the one for the hero's
+           own role) or the Amulet or one of the invocation tools */
+        if (!rn2(20))
+            stealamulet(magr);
+    } else {
+        /* mhitm */
+        mhm->damage = 0;
+    }
+}
+
+
 /* Template for monster hits monster for AD_FOO.
    - replace "break" with return
    - replace "return" with mhm->done = TRUE