* Pick up of obj from the ground and add it to the hero's inventory. * Returns -1 if caller should break out of its loop, 0 if nothing picked * up, 1 if otherwise. */
| 1800 | * up, 1 if otherwise. |
| 1801 | */ |
| 1802 | int |
| 1803 | pickup_object( |
| 1804 | struct obj *obj, |
| 1805 | long count, /* if non-zero, pick up a subset of this amount */ |
| 1806 | boolean telekinesis) /* not picking it up directly by hand */ |
| 1807 | { |
| 1808 | int res; |
| 1809 | |
| 1810 | if (obj->quan < count) { |
| 1811 | impossible("pickup_object: count %ld > quan %ld?", count, obj->quan); |
| 1812 | return 0; |
| 1813 | } |
| 1814 | |
| 1815 | /* In case of auto-pickup, where we haven't had a chance |
| 1816 | to look at it yet; affects docall(SCR_SCARE_MONSTER). */ |
| 1817 | if (!Blind) |
| 1818 | observe_object(obj); |
| 1819 | |
| 1820 | if (obj == uchain) { /* do not pick up attached chain */ |
| 1821 | return 0; |
| 1822 | } else if (obj->where == OBJ_MINVENT && obj->owornmask != 0L |
| 1823 | && engulfing_u(obj->ocarry)) { |
| 1824 | You_cant("pick %s up.", ysimple_name(obj)); |
| 1825 | return 0; |
| 1826 | } else if (obj->oartifact && !touch_artifact(obj, &gy.youmonst)) { |
| 1827 | return 0; |
| 1828 | } else if (obj->otyp == CORPSE) { |
| 1829 | if (fatal_corpse_mistake(obj, telekinesis) |
| 1830 | || rider_corpse_revival(obj, telekinesis)) |
| 1831 | return -1; |
| 1832 | } else if (obj->otyp == SCR_SCARE_MONSTER) { |
| 1833 | int old_wt, new_wt; |
| 1834 | |
| 1835 | /* process a count before altering/deleting scrolls; |
| 1836 | tricky because being unable to lift full stack imposes an |
| 1837 | implicit count; unliftable ones should be treated as if |
| 1838 | the count excluded them so that they don't change state */ |
| 1839 | if ((count = carry_count(obj, (struct obj *) 0, |
| 1840 | count ? count : obj->quan, |
| 1841 | FALSE, &old_wt, &new_wt)) < 1L) |
| 1842 | return -1; /* couldn't even pick up 1, so effectively untouched */ |
| 1843 | /* all current callers handle a new object sanely when traversing |
| 1844 | a list; other half of a split will be left as-is and whatever |
| 1845 | already follows 'obj' will still be processed next */ |
| 1846 | if (count > 0L && count < obj->quan) |
| 1847 | obj = splitobj(obj, count); |
| 1848 | |
| 1849 | if (obj->blessed) { |
| 1850 | unbless(obj); |
| 1851 | } else if (!obj->spe && !obj->cursed) { |
| 1852 | obj->spe = 1; |
| 1853 | } else { |
| 1854 | pline_The("scroll%s %s to dust as you %s %s up.", plur(obj->quan), |
| 1855 | otense(obj, "turn"), telekinesis ? "raise" : "pick", |
| 1856 | (obj->quan == 1L) ? "it" : "them"); |
| 1857 | trycall(obj); |
| 1858 | useupf(obj, obj->quan); |
| 1859 | return 1; /* tried to pick something up and failed, but |
no test coverage detected