called by domonability() for #monster */
| 1774 | |
| 1775 | /* called by domonability() for #monster */ |
| 1776 | int |
| 1777 | dohide(void) |
| 1778 | { |
| 1779 | boolean ismimic = gy.youmonst.data->mlet == S_MIMIC, |
| 1780 | on_ceiling = is_clinger(gy.youmonst.data) || Flying; |
| 1781 | |
| 1782 | /* can't hide while being held (or holding) or while trapped |
| 1783 | (except for floor hiders [trapper or mimic] in pits) */ |
| 1784 | if (u.ustuck || (u.utrap && (u.utraptype != TT_PIT || on_ceiling))) { |
| 1785 | You_cant("hide while you're %s.", |
| 1786 | !u.ustuck ? "trapped" |
| 1787 | : u.uswallow ? (digests(u.ustuck->data) ? "swallowed" |
| 1788 | : "engulfed") |
| 1789 | : !sticks(gy.youmonst.data) ? "being held" |
| 1790 | : (humanoid(u.ustuck->data) ? "holding someone" |
| 1791 | : "holding that creature")); |
| 1792 | if (u.uundetected || (ismimic && U_AP_TYPE != M_AP_NOTHING)) { |
| 1793 | u.uundetected = 0; |
| 1794 | gy.youmonst.m_ap_type = M_AP_NOTHING; |
| 1795 | newsym(u.ux, u.uy); |
| 1796 | } |
| 1797 | return ECMD_OK; |
| 1798 | } |
| 1799 | /* note: hero-as-eel handling is incomplete but unnecessary; |
| 1800 | such critters aren't offered the option of hiding via #monster */ |
| 1801 | if (gy.youmonst.data->mlet == S_EEL && !is_pool(u.ux, u.uy)) { |
| 1802 | if (IS_FOUNTAIN(levl[u.ux][u.uy].typ)) |
| 1803 | pline_The("fountain is not deep enough to hide in."); |
| 1804 | else |
| 1805 | There("is no %s to hide in here.", hliquid("water")); |
| 1806 | u.uundetected = 0; |
| 1807 | return ECMD_OK; |
| 1808 | } |
| 1809 | if (hides_under(gy.youmonst.data)) { |
| 1810 | long ct = 0L; |
| 1811 | struct obj *otmp, *otop = svl.level.objects[u.ux][u.uy]; |
| 1812 | |
| 1813 | if (!otop) { |
| 1814 | There("is nothing to hide under here."); |
| 1815 | u.uundetected = 0; |
| 1816 | return ECMD_OK; |
| 1817 | } |
| 1818 | for (otmp = otop; |
| 1819 | otmp && otmp->otyp == CORPSE |
| 1820 | && touch_petrifies(&mons[otmp->corpsenm]); |
| 1821 | otmp = otmp->nexthere) |
| 1822 | ct += otmp->quan; |
| 1823 | /* otmp will be Null iff the entire pile consists of 'trice corpses */ |
| 1824 | if (!otmp && !Stone_resistance) { |
| 1825 | char kbuf[BUFSZ]; |
| 1826 | const char *corpse_name = cxname(otop); |
| 1827 | |
| 1828 | /* for the plural case, we'll say "cockatrice corpses" or |
| 1829 | "chickatrice corpses" depending on the top of the pile |
| 1830 | even if both types are present */ |
| 1831 | if (ct == 1) |
| 1832 | corpse_name = an(corpse_name); |
| 1833 | /* no need to check poly_when_stoned(); no hide-underers can |
no test coverage detected