]> granicus.if.org Git - nethack/commitdiff
m_digweapon_check()
authorPatR <rankin@nethack.org>
Thu, 4 Aug 2022 21:26:12 +0000 (14:26 -0700)
committerPatR <rankin@nethack.org>
Thu, 4 Aug 2022 21:26:12 +0000 (14:26 -0700)
Some streamlining that I left out of the recent commit for maybe
avoiding exclamation mark when a monster wields a tool or weapon
to dig or chop.

src/monmove.c

index 4b855997cba7e12f6f8c69a7e5b6e3581fc48269..d12bde9aaa66f2713f2e4ef3c324fb8d3d361da0 100644 (file)
@@ -867,10 +867,14 @@ should_displace(
     return FALSE;
 }
 
+/* have monster wield a pick-axe if it wants to dig and it has one;
+   return True if it spends this move wielding one, False otherwise */
 boolean
-m_digweapon_check(struct monst* mtmp, coordxy nix, coordxy niy)
+m_digweapon_check(
+    struct monst *mtmp,
+    coordxy nix, coordxy niy)
 {
-    boolean can_tunnel = 0;
+    boolean can_tunnel = FALSE;
     struct obj *mw_tmp = MON_WEP(mtmp);
 
     if (!Is_rogue_level(&u.uz))
@@ -880,15 +884,13 @@ m_digweapon_check(struct monst* mtmp, coordxy nix, coordxy niy)
         && (may_dig(nix, niy) || closed_door(nix, niy))) {
         /* may_dig() is either IS_STWALL or IS_TREE */
         if (closed_door(nix, niy)) {
-            if (!mw_tmp
-                || !is_pick(mw_tmp)
-                || !is_axe(mw_tmp))
+            if (!mw_tmp || !is_pick(mw_tmp) || !is_axe(mw_tmp))
                 mtmp->weapon_check = NEED_PICK_OR_AXE;
         } else if (IS_TREE(levl[nix][niy].typ)) {
-            if (!(mw_tmp = MON_WEP(mtmp)) || !is_axe(mw_tmp))
+            if (!mw_tmp || !is_axe(mw_tmp))
                 mtmp->weapon_check = NEED_AXE;
         } else if (IS_STWALL(levl[nix][niy].typ)) {
-            if (!(mw_tmp = MON_WEP(mtmp)) || !is_pick(mw_tmp))
+            if (!mw_tmp || !is_pick(mw_tmp))
                 mtmp->weapon_check = NEED_PICK_AXE;
         }
         if (mtmp->weapon_check >= NEED_PICK_AXE && mon_wield_item(mtmp))
@@ -1398,10 +1400,10 @@ m_move(register struct monst* mtmp, register int after)
     }
 
     if (mmoved != MMOVE_NOTHING) {
-        if (mmoved == MMOVE_MOVED && (u.ux != nix || u.uy != niy) && itsstuck(mtmp))
+        if (mmoved == MMOVE_MOVED && !u_at(nix, niy) && itsstuck(mtmp))
             return MMOVE_DONE;
 
-        if (mmoved == MMOVE_MOVED && m_digweapon_check(mtmp, nix,niy))
+        if (mmoved == MMOVE_MOVED && m_digweapon_check(mtmp, nix, niy))
             return MMOVE_DONE;
 
         /* If ALLOW_U is set, either it's trying to attack you, or it