]> granicus.if.org Git - nethack/commitdiff
More unpolyable unifying
authorPasi Kallinen <paxed@alt.org>
Tue, 17 Nov 2020 16:00:40 +0000 (18:00 +0200)
committerPasi Kallinen <paxed@alt.org>
Tue, 17 Nov 2020 16:00:43 +0000 (18:00 +0200)
... and fix the potion dipping case.

include/extern.h
src/potion.c
src/zap.c

index 7b4600174cd9c4ad25bab2c338b18dcda89af46d..843cb73ebaf58ee83ac0125c10c170df6265109b 100644 (file)
@@ -3154,6 +3154,7 @@ E int FDECL(unturn_dead, (struct monst *));
 E void NDECL(unturn_you);
 E void FDECL(cancel_item, (struct obj *));
 E boolean FDECL(drain_item, (struct obj *, BOOLEAN_P));
+E boolean FDECL(obj_unpolyable, (struct obj *));
 E struct obj *FDECL(poly_obj, (struct obj *, int));
 E boolean FDECL(obj_resists, (struct obj *, int, int));
 E boolean FDECL(obj_shudders, (struct obj *));
index a0e2256ed659c6a5de5fe858b3bea11988741d2a..34ff6de8e9cf6d78b5920faede89ecbd52f7d2b0 100644 (file)
@@ -1977,11 +1977,7 @@ dodip()
             goto poof;
     } else if (obj->otyp == POT_POLYMORPH || potion->otyp == POT_POLYMORPH) {
         /* some objects can't be polymorphed */
-        if (obj->otyp == potion->otyp /* both POT_POLY */
-            || unpolyable(obj)
-            || obj == uball || obj == uskin
-            || obj_resists(obj->otyp == POT_POLYMORPH ? potion : obj,
-                           5, 95)) {
+        if (obj_unpolyable(obj->otyp == POT_POLYMORPH ? potion : obj)) {
             pline1(nothing_happens);
         } else {
             short save_otyp = obj->otyp;
index b8fd955ae3b73b405e16da7d7cb81371ee9b6d97..edb4943d2a2af0d7b2f887fcaac55783a10585b9 100644 (file)
--- a/src/zap.c
+++ b/src/zap.c
@@ -1476,6 +1476,16 @@ struct obj *obj;
     delobj(obj);
 }
 
+/* Returns TRUE if obj resists polymorphing */
+boolean
+obj_unpolyable(obj)
+struct obj *obj;
+{
+    return (unpolyable(obj)
+            || obj == uball || obj == uskin
+            || obj_resists(obj, 5, 95));
+}
+
 /* classes of items whose current charge count carries over across polymorph
  */
 static const char charged_objs[] = { WAND_CLASS, WEAPON_CLASS, ARMOR_CLASS,
@@ -1964,7 +1974,7 @@ struct obj *obj, *otmp;
         switch (otmp->otyp) {
         case WAN_POLYMORPH:
         case SPE_POLYMORPH:
-            if (unpolyable(obj) || obj_resists(obj, 5, 95)) {
+            if (obj_unpolyable(obj)) {
                 res = 0;
                 break;
             }