MCPcopy Create free account
hub / github.com/NetHack/NetHack / m_digweapon_check

Function m_digweapon_check

src/monmove.c:1107–1135  ·  view source on GitHub ↗

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 */

Source from the content-addressed store, hash-verified

1105/* have monster wield a pick-axe if it wants to dig and it has one;
1106 return True if it spends this move wielding one, False otherwise */
1107boolean
1108m_digweapon_check(
1109 struct monst *mtmp,
1110 coordxy nix, coordxy niy)
1111{
1112 boolean can_tunnel = FALSE;
1113 struct obj *mw_tmp = MON_WEP(mtmp);
1114
1115 if (!Is_rogue_level(&u.uz))
1116 can_tunnel = tunnels(mtmp->data);
1117
1118 if (can_tunnel && needspick(mtmp->data) && !mwelded(mw_tmp)
1119 && (may_dig(nix, niy) || closed_door(nix, niy))) {
1120 /* may_dig() is either IS_STWALL or IS_TREE */
1121 if (closed_door(nix, niy)) {
1122 if (!mw_tmp || !is_pick(mw_tmp) || !is_axe(mw_tmp))
1123 mtmp->weapon_check = NEED_PICK_OR_AXE;
1124 } else if (IS_TREE(levl[nix][niy].typ)) {
1125 if (!mw_tmp || !is_axe(mw_tmp))
1126 mtmp->weapon_check = NEED_AXE;
1127 } else if (IS_STWALL(levl[nix][niy].typ)) {
1128 if (!mw_tmp || !is_pick(mw_tmp))
1129 mtmp->weapon_check = NEED_PICK_AXE;
1130 }
1131 if (mtmp->weapon_check >= NEED_PICK_AXE && mon_wield_item(mtmp))
1132 return TRUE;
1133 }
1134 return FALSE;
1135}
1136
1137/* does leprechaun want to avoid the hero? */
1138staticfn boolean

Callers 2

dog_moveFunction · 0.85
m_moveFunction · 0.85

Calls 4

mweldedFunction · 0.85
may_digFunction · 0.85
closed_doorFunction · 0.85
mon_wield_itemFunction · 0.85

Tested by

no test coverage detected