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

Function mon_givit

src/mon.c:1777–1824  ·  view source on GitHub ↗

Maybe give an intrinsic to monster from eating corpse that confers it. */

Source from the content-addressed store, hash-verified

1775
1776/* Maybe give an intrinsic to monster from eating corpse that confers it. */
1777void
1778mon_givit(struct monst *mtmp, struct permonst *ptr)
1779{
1780 int prop = corpse_intrinsic(ptr);
1781 boolean vis = canseemon(mtmp);
1782
1783 if (DEADMONSTER(mtmp))
1784 return;
1785
1786 if (ptr == &mons[PM_STALKER]) {
1787 /*
1788 * Invisible stalker isn't flagged as conferring invisibility
1789 * so prop is 0. For hero, eating a stalker corpse confers
1790 * temporary invisibility if hero is visible. When already
1791 * invisible, if confers permanent invisibility and also
1792 * permanent see invisible. For monsters, only permanent
1793 * invisibility is possible; temporary invisibility and see
1794 * invisible aren't implemented for them.
1795 *
1796 * A monster being invisible gains no benefit against other
1797 * monsters, and an invisible pet when hero can't see invisible
1798 * is a nuisance at best, so this is probably detrimental.
1799 * Players will just have to live with it if they want to be
1800 * able to have pets gain intrinsics from eating corpses.
1801 */
1802 if (!mtmp->perminvis || mtmp->invis_blkd) {
1803 char mtmpbuf[BUFSZ];
1804
1805 Strcpy(mtmpbuf, Monnam(mtmp));
1806 mon_set_minvis(mtmp, FALSE);
1807 if (vis)
1808 pline_mon(mtmp, "%s %s.", mtmpbuf,
1809 !canspotmon(mtmp) ? "vanishes"
1810 : mtmp->invis_blkd ? "seems to flicker"
1811 : "becomes invisible");
1812 }
1813 mtmp->mstun = 1; /* no timeout but will eventually wear off */
1814 return;
1815 }
1816
1817 if (prop == 0)
1818 return; /* no intrinsic from this corpse */
1819
1820 if (!should_givit(prop, ptr))
1821 return; /* failed die roll */
1822
1823 mon_give_prop(mtmp, prop);
1824}
1825
1826void
1827mpickgold(struct monst *mtmp)

Callers 2

mdamagemFunction · 0.85
m_consume_objFunction · 0.85

Calls 7

corpse_intrinsicFunction · 0.85
canseemonFunction · 0.85
MonnamFunction · 0.85
mon_set_minvisFunction · 0.85
pline_monFunction · 0.85
should_givitFunction · 0.85
mon_give_propFunction · 0.85

Tested by

no test coverage detected