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

Function eatcorpse

src/eat.c:1854–2018  ·  view source on GitHub ↗

called when a corpse is selected as food */

Source from the content-addressed store, hash-verified

1852
1853/* called when a corpse is selected as food */
1854staticfn int
1855eatcorpse(struct obj *otmp)
1856{
1857 int retcode = 0, tp = 0, mnum = otmp->corpsenm;
1858 long rotted = 0L;
1859 int ll_conduct = 0;
1860 boolean stoneable,
1861 slimeable = (mnum == PM_GREEN_SLIME && !Slimed && !Unchanging
1862 && !slimeproof(gy.youmonst.data)),
1863 glob = otmp->globby ? TRUE : FALSE;
1864
1865 assert(ismnum(mnum));
1866 stoneable = (flesh_petrifies(&mons[mnum]) && !Stone_resistance
1867 && !poly_when_stoned(gy.youmonst.data));
1868
1869 /* KMH, conduct */
1870 if (!vegan(&mons[mnum]))
1871 if (!u.uconduct.unvegan++) {
1872 livelog_printf(LL_CONDUCT,
1873 "consumed animal products for the first time, by eating %s",
1874 an(food_xname(otmp, FALSE)));
1875 ll_conduct++;
1876 }
1877 if (!vegetarian(&mons[mnum])) {
1878 if (!u.uconduct.unvegetarian && !ll_conduct)
1879 livelog_printf(LL_CONDUCT,
1880 "tasted meat for the first time, by eating %s",
1881 an(food_xname(otmp, FALSE)));
1882 violated_vegetarian();
1883 }
1884 if (!nonrotting_corpse(mnum)) {
1885 long age = peek_at_iced_corpse_age(otmp);
1886
1887 rotted = (svm.moves - age) / (10L + rn2(20));
1888 if (otmp->cursed)
1889 rotted += 2L;
1890 else if (otmp->blessed)
1891 rotted -= 2L;
1892 }
1893
1894 /* 5.0: globs don't become tainted, they shrink away */
1895 if (!glob && !stoneable && !slimeable && rotted > 5L) {
1896 boolean cannibal = maybe_cannibal(mnum, FALSE);
1897
1898 /* tp++; -- early return makes this unnecessary */
1899 pline("Ulch - that %s was tainted%s!",
1900 (mons[mnum].mlet == S_FUNGUS) ? "fungoid vegetation"
1901 : vegetarian(&mons[mnum]) ? "protoplasm"
1902 : "meat",
1903 cannibal ? ", you cannibal" : "");
1904 if (Sick_resistance) {
1905 pline("It doesn't seem at all sickening, though...");
1906 } else {
1907 long sick_time;
1908
1909 sick_time = (long) rn1(10, 10);
1910 /* make sure new ill doesn't result in improvement */
1911 if (Sick && (sick_time > Sick))

Callers 1

doeatFunction · 0.85

Calls 15

poly_when_stonedFunction · 0.85
livelog_printfFunction · 0.85
anFunction · 0.85
food_xnameFunction · 0.85
violated_vegetarianFunction · 0.85
peek_at_iced_corpse_ageFunction · 0.85
rn2Function · 0.85
maybe_cannibalFunction · 0.85
make_sickFunction · 0.85
corpse_xnameFunction · 0.85
useupFunction · 0.85
useupfFunction · 0.85

Tested by

no test coverage detected