E void FDECL(monflee, (struct monst *, int, BOOLEAN_P, BOOLEAN_P));
E void FDECL(mon_yells, (struct monst *, const char *));
E int FDECL(dochug, (struct monst *));
+E boolean FDECL(m_digweapon_check, (struct monst *, XCHAR_P, XCHAR_P));
E int FDECL(m_move, (struct monst *, int));
E void FDECL(dissolve_bars, (int, int));
E boolean FDECL(closed_door, (int, int));
}
if (!m_in_out_region(mtmp, nix, niy))
return 1;
- if (((IS_ROCK(levl[nix][niy].typ) && may_dig(nix, niy))
- || closed_door(nix, niy))
- && mtmp->weapon_check != NO_WEAPON_WANTED
- && tunnels(mtmp->data) && needspick(mtmp->data)) {
- if (closed_door(nix, niy)) {
- if (!(mw_tmp = MON_WEP(mtmp)) || !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))
- mtmp->weapon_check = NEED_AXE;
- } else if (!(mw_tmp = MON_WEP(mtmp)) || !is_pick(mw_tmp)) {
- mtmp->weapon_check = NEED_PICK_AXE;
- }
- if (mtmp->weapon_check >= NEED_PICK_AXE && mon_wield_item(mtmp))
- return 0;
- }
+ if (m_digweapon_check(mtmp, nix,niy))
+ return 0;
+
/* insert a worm_move() if worms ever begin to eat things */
wasseen = canseemon(mtmp);
remove_monster(omx, omy);
return FALSE;
}
+boolean
+m_digweapon_check(mtmp, nix, niy)
+struct monst *mtmp;
+xchar nix,niy;
+{
+ boolean can_tunnel = 0;
+ struct obj *mw_tmp;
+
+ if (!Is_rogue_level(&u.uz))
+ can_tunnel = tunnels(mtmp->data);
+
+ if (can_tunnel && needspick(mtmp->data)
+ && mtmp->weapon_check != NO_WEAPON_WANTED
+ && ((IS_ROCK(levl[nix][niy].typ) && may_dig(nix, niy))
+ || closed_door(nix, niy))) {
+ if (closed_door(nix, niy)) {
+ if (!(mw_tmp = MON_WEP(mtmp))
+ || !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))
+ mtmp->weapon_check = NEED_AXE;
+ } else if (!(mw_tmp = MON_WEP(mtmp)) || !is_pick(mw_tmp)) {
+ mtmp->weapon_check = NEED_PICK_AXE;
+ }
+ if (mtmp->weapon_check >= NEED_PICK_AXE && mon_wield_item(mtmp))
+ return TRUE;
+ }
+ return FALSE;
+}
+
/* Return values:
* 0: did not move, but can still attack and do other stuff.
* 1: moved, possibly can attack.
if (mmoved == 1 && (u.ux != nix || u.uy != niy) && itsstuck(mtmp))
return 3;
- if (mmoved == 1 && can_tunnel && needspick(ptr)
- && ((IS_ROCK(levl[nix][niy].typ) && may_dig(nix, niy))
- || closed_door(nix, niy))) {
- if (closed_door(nix, niy)) {
- if (!(mw_tmp = MON_WEP(mtmp)) || !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))
- mtmp->weapon_check = NEED_AXE;
- } else if (!(mw_tmp = MON_WEP(mtmp)) || !is_pick(mw_tmp)) {
- mtmp->weapon_check = NEED_PICK_AXE;
- }
- if (mtmp->weapon_check >= NEED_PICK_AXE && mon_wield_item(mtmp))
- return 3;
- }
+ if (mmoved == 1 && m_digweapon_check(mtmp, nix,niy))
+ return 3;
+
/* If ALLOW_U is set, either it's trying to attack you, or it
* thinks it is. In either case, attack this spot in preference to
* all others.