MCPcopy Index your code
hub / github.com/NetHack/NetHack / dorub

Function dorub

src/apply.c:1784–1843  ·  view source on GitHub ↗

the #rub command */

Source from the content-addressed store, hash-verified

1782
1783/* the #rub command */
1784int
1785dorub(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);

Callers

nothing calls this directly

Calls 13

YouFunction · 0.85
getobjFunction · 0.85
use_stoneFunction · 0.85
use_royal_jellyFunction · 0.85
wield_toolFunction · 0.85
cmdq_add_ecFunction · 0.85
cmdq_add_keyFunction · 0.85
rn2Function · 0.85
check_unpaid_usageFunction · 0.85
begin_burnFunction · 0.85
djinni_from_bottleFunction · 0.85
update_inventoryFunction · 0.85

Tested by

no test coverage detected