the #rub command */
| 1782 | |
| 1783 | /* the #rub command */ |
| 1784 | int |
| 1785 | dorub(void) |
| 1786 | { |
| 1787 | struct obj *obj; |
| 1788 | |
| 1789 | if (nohands(gy.youmonst.data)) { |
| 1790 | You("aren't able to rub anything without hands."); |
| 1791 | return ECMD_OK; |
| 1792 | } |
| 1793 | obj = getobj("rub", rub_ok, GETOBJ_NOFLAGS); |
| 1794 | if (!obj) |
| 1795 | return ECMD_CANCEL; |
| 1796 | if (obj->oclass == GEM_CLASS || obj->oclass == FOOD_CLASS) { |
| 1797 | if (is_graystone(obj)) { |
| 1798 | return use_stone(obj); |
| 1799 | } else if (obj->otyp == LUMP_OF_ROYAL_JELLY) { |
| 1800 | return use_royal_jelly(&obj); |
| 1801 | } else { |
| 1802 | pline("Sorry, I don't know how to use that."); |
| 1803 | return ECMD_OK; |
| 1804 | } |
| 1805 | } |
| 1806 | if (obj != uwep) { |
| 1807 | if (wield_tool(obj, "rub")) { |
| 1808 | cmdq_add_ec(CQ_CANNED, dorub); |
| 1809 | cmdq_add_key(CQ_CANNED, obj->invlet); |
| 1810 | return ECMD_TIME; |
| 1811 | } |
| 1812 | return ECMD_OK; |
| 1813 | } |
| 1814 | |
| 1815 | /* now uwep is obj */ |
| 1816 | if (uwep->otyp == MAGIC_LAMP) { |
| 1817 | if (uwep->spe > 0 && !rn2(3)) { |
| 1818 | check_unpaid_usage(uwep, TRUE); /* unusual item use */ |
| 1819 | /* bones preparation: perform the lamp transformation |
| 1820 | before releasing the djinni in case the latter turns out |
| 1821 | to be fatal (a hostile djinni has no chance to attack yet, |
| 1822 | but an indebted one who grants a wish might bestow an |
| 1823 | artifact which blasts the hero with lethal results) */ |
| 1824 | uwep->otyp = OIL_LAMP; |
| 1825 | uwep->spe = 0; /* for safety */ |
| 1826 | uwep->age = rn1(500, 1000); |
| 1827 | if (uwep->lamplit) |
| 1828 | begin_burn(uwep, TRUE); |
| 1829 | djinni_from_bottle(uwep); |
| 1830 | makeknown(MAGIC_LAMP); |
| 1831 | update_inventory(); |
| 1832 | } else if (rn2(2)) { |
| 1833 | You("%s smoke.", !Blind ? "see a puff of" : "smell"); |
| 1834 | } else |
| 1835 | pline1(nothing_happens); |
| 1836 | } else if (obj->otyp == BRASS_LANTERN) { |
| 1837 | /* message from Adventure */ |
| 1838 | pline("Rubbing the electric lamp is not particularly rewarding."); |
| 1839 | pline("Anyway, nothing exciting happens."); |
| 1840 | } else |
| 1841 | pline1(nothing_happens); |
nothing calls this directly
no test coverage detected