]> granicus.if.org Git - nethack/commitdiff
Unify ad_acid
authorPasi Kallinen <paxed@alt.org>
Mon, 30 Nov 2020 18:19:49 +0000 (20:19 +0200)
committerPasi Kallinen <paxed@alt.org>
Fri, 4 Dec 2020 07:30:15 +0000 (09:30 +0200)
include/extern.h
src/mhitm.c
src/mhitu.c
src/uhitm.c

index c899cdc1803d807d60c9f8bd2626790e42bcffd6..7d9907babb2c3be8cf7164bf86f8b9029ea8848d 100644 (file)
@@ -2763,6 +2763,7 @@ E void FDECL(mhitm_ad_drli, (struct monst *, struct attack *, struct monst *, st
 E void FDECL(mhitm_ad_fire, (struct monst *, struct attack *, struct monst *, struct mhitm_data *));
 E void FDECL(mhitm_ad_cold, (struct monst *, struct attack *, struct monst *, struct mhitm_data *));
 E void FDECL(mhitm_ad_elec, (struct monst *, struct attack *, struct monst *, struct mhitm_data *));
+E void FDECL(mhitm_ad_acid, (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 f0f95fda8c3a2852975806217ca15bc195890a5d..f5e15a5333cf0c0886863af494aadc558c6403ac 100644 (file)
@@ -1031,23 +1031,9 @@ int dieroll;
             return mhm.hitflags;
         break;
     case AD_ACID:
-        if (magr->mcan) {
-            mhm.damage = 0;
-            break;
-        }
-        if (resists_acid(mdef)) {
-            if (g.vis && canseemon(mdef))
-                pline("%s is covered in %s, but it seems harmless.",
-                      Monnam(mdef), hliquid("acid"));
-            mhm.damage = 0;
-        } else if (g.vis && canseemon(mdef)) {
-            pline("%s is covered in %s!", Monnam(mdef), hliquid("acid"));
-            pline("It burns %s!", mon_nam(mdef));
-        }
-        if (!rn2(30))
-            erode_armor(mdef, ERODE_CORRODE);
-        if (!rn2(6))
-            acid_damage(MON_WEP(mdef));
+        mhitm_ad_acid(magr, mattk, mdef, &mhm);
+        if (mhm.done)
+            return mhm.hitflags;
         break;
     case AD_RUST:
         mhitm_ad_rust(magr, mattk, mdef, &mhm);
index 3b146cd20c4105ad3d9041241a16ecd264f7169a..1e45dadcced57bd505b82427c48ce89c87396b77 100644 (file)
@@ -1550,18 +1550,9 @@ register struct attack *mattk;
         }
         break;
     case AD_ACID:
-        hitmsg(mtmp, mattk);
-        if (!mtmp->mcan && !rn2(3))
-            if (Acid_resistance) {
-                pline("You're covered in %s, but it seems harmless.",
-                      hliquid("acid"));
-                mhm.damage = 0;
-            } else {
-                pline("You're covered in %s!  It burns!", hliquid("acid"));
-                exercise(A_STR, FALSE);
-            }
-        else
-            mhm.damage = 0;
+        mhitm_ad_acid(mtmp, mattk, &g.youmonst, &mhm);
+        if (mhm.done)
+            return mhm.hitflags;
         break;
     case AD_SLOW:
         hitmsg(mtmp, mattk);
index 2d78004ed3541e46a4e32697fc7d0837b747f6a8..330342f7ef0cde410c52ea6fdd283fe55715a250 100644 (file)
@@ -2213,6 +2213,55 @@ struct mhitm_data *mhm;
     }
 }
 
+void
+mhitm_ad_acid(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 (resists_acid(mdef))
+            mhm->damage = 0;
+    } else if (mdef == &g.youmonst) {
+        /* mhitu */
+        hitmsg(magr, mattk);
+        if (!magr->mcan && !rn2(3))
+            if (Acid_resistance) {
+                pline("You're covered in %s, but it seems harmless.",
+                      hliquid("acid"));
+                mhm->damage = 0;
+            } else {
+                pline("You're covered in %s!  It burns!", hliquid("acid"));
+                exercise(A_STR, FALSE);
+            }
+        else
+            mhm->damage = 0;
+    } else {
+        /* mhitm */
+        if (magr->mcan) {
+            mhm->damage = 0;
+            return;
+        }
+        if (resists_acid(mdef)) {
+            if (g.vis && canseemon(mdef))
+                pline("%s is covered in %s, but it seems harmless.",
+                      Monnam(mdef), hliquid("acid"));
+            mhm->damage = 0;
+        } else if (g.vis && canseemon(mdef)) {
+            pline("%s is covered in %s!", Monnam(mdef), hliquid("acid"));
+            pline("It burns %s!", mon_nam(mdef));
+        }
+        if (!rn2(30))
+            erode_armor(mdef, ERODE_CORRODE);
+        if (!rn2(6))
+            acid_damage(MON_WEP(mdef));
+    }
+}
+
 
 /* Template for monster hits monster for AD_FOO.
    - replace "break" with return
@@ -2329,8 +2378,9 @@ int specialdmg; /* blessed and/or silver bonus against various things */
             return mhm.hitflags;
         break;
     case AD_ACID:
-        if (resists_acid(mdef))
-            mhm.damage = 0;
+        mhitm_ad_acid(&g.youmonst, mattk, mdef, &mhm);
+        if (mhm.done)
+            return mhm.hitflags;
         break;
     case AD_STON:
         if (!munstone(mdef, TRUE))