]> granicus.if.org Git - nethack/commitdiff
Unify ad_ston
authorPasi Kallinen <paxed@alt.org>
Tue, 1 Dec 2020 08:44:15 +0000 (10:44 +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 59982f23042b6e7a121450eff1937a42a02b79b6..4de281ec03eb0229d30bd2f85289cf93e4d5d2c5 100644 (file)
@@ -2786,6 +2786,7 @@ E void FDECL(mhitm_ad_pest, (struct monst *, struct attack *, struct monst *, st
 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 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 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 d7f9a6dbe438da3e5b089694596a318eb30d3a2b..236e4d83a011458e5cd8f321771d0fb49b80be4a 100644 (file)
@@ -1007,9 +1007,7 @@ int dieroll;
             return mhm.hitflags;
         break;
     case AD_STON:
-        if (magr->mcan)
-            break;
-        do_stone_mon(magr, mattk, mdef, &mhm);
+        mhitm_ad_ston(magr, mattk, mdef, &mhm);
         if (mhm.done)
             return mhm.hitflags;
         break;
index 5a3e69e42e869b32af80932b6207e5e55c2a6ce2..a08ce6ce74d847219a036fe24160e6e036e7a058 100644 (file)
@@ -1113,22 +1113,10 @@ register struct attack *mattk;
         }
         break;
     }
-    case AD_STON: /* cockatrice */
-        hitmsg(mtmp, mattk);
-        if (!rn2(3)) {
-            if (mtmp->mcan) {
-                if (!Deaf)
-                    You_hear("a cough from %s!", mon_nam(mtmp));
-            } else {
-                if (!Deaf)
-                    You_hear("%s hissing!", s_suffix(mon_nam(mtmp)));
-                if (!rn2(10)
-                    || (flags.moonphase == NEW_MOON && !have_lizard())) {
-                    if (do_stone_u(mtmp))
-                        return MM_HIT;
-                }
-            }
-        }
+    case AD_STON:
+        mhitm_ad_ston(mtmp, mattk, &g.youmonst, &mhm);
+        if (mhm.done)
+            return mhm.hitflags;
         break;
     case AD_STCK:
         mhitm_ad_stck(mtmp, mattk, &g.youmonst, &mhm);
index b377a5f355a033db95f56a272196340be6f3b008..e0d1d30d05df0dae9cfea87cbd7c335a7a41afdb 100644 (file)
@@ -3600,6 +3600,50 @@ struct mhitm_data *mhm;
     }
 }
 
+void
+mhitm_ad_ston(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 */
+        if (!munstone(mdef, TRUE))
+            minstapetrify(mdef, TRUE);
+        mhm->damage = 0;
+    } else if (mdef == &g.youmonst) {
+        /* mhitu */
+        hitmsg(magr, mattk);
+        if (!rn2(3)) {
+            if (magr->mcan) {
+                if (!Deaf)
+                    You_hear("a cough from %s!", mon_nam(magr));
+            } else {
+                if (!Deaf)
+                    You_hear("%s hissing!", s_suffix(mon_nam(magr)));
+                if (!rn2(10)
+                    || (flags.moonphase == NEW_MOON && !have_lizard())) {
+                    if (do_stone_u(magr)) {
+                        mhm->hitflags = MM_HIT;
+                        mhm->done = TRUE;
+                        return;
+                    }
+                }
+            }
+        }
+    } else {
+        /* mhitm */
+        if (magr->mcan)
+            return;
+        do_stone_mon(magr, 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
@@ -3704,9 +3748,9 @@ int specialdmg; /* blessed and/or silver bonus against various things */
             return mhm.hitflags;
         break;
     case AD_STON:
-        if (!munstone(mdef, TRUE))
-            minstapetrify(mdef, TRUE);
-        mhm.damage = 0;
+        mhitm_ad_ston(&g.youmonst, mattk, mdef, &mhm);
+        if (mhm.done)
+            return mhm.hitflags;
         break;
     case AD_SSEX:
     case AD_SEDU: