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

Function mon_give_prop

src/mon.c:1725–1774  ·  view source on GitHub ↗

give monster property prop */

Source from the content-addressed store, hash-verified

1723
1724/* give monster property prop */
1725void
1726mon_give_prop(struct monst *mtmp, int prop)
1727{
1728 const char *msg = NULL;
1729 unsigned short intrinsic = 0; /* MR_* constant */
1730
1731 /* Pets don't have all the fields that the hero does, so they can't get
1732 all the same intrinsics. If it happens to choose strength gain or
1733 teleport control or whatever, ignore it. */
1734 switch (prop) {
1735 case FIRE_RES:
1736 msg = "%s shivers slightly.";
1737 break;
1738 case COLD_RES:
1739 msg = "%s looks quite warm.";
1740 break;
1741 case SLEEP_RES:
1742 msg = "%s looks wide awake.";
1743 break;
1744 case DISINT_RES:
1745 msg = "%s looks very firm.";
1746 break;
1747 case SHOCK_RES:
1748 msg = "%s crackles with static electricity.";
1749 break;
1750 case POISON_RES:
1751 msg = "%s looks healthy.";
1752 break;
1753 default:
1754 return; /* can't give it */
1755 break;
1756 }
1757 intrinsic = res_to_mr(prop);
1758
1759 /* Don't give message if it already had this property intrinsically, but
1760 still do grant the intrinsic if it only had it from mresists.
1761 Do print the message if it only had this property extrinsically, which
1762 is why mon_resistancebits isn't used here. */
1763 if ((mtmp->data->mresists | mtmp->mintrinsics) & intrinsic)
1764 msg = (const char *) 0;
1765
1766 if (intrinsic)
1767 mtmp->mintrinsics |= intrinsic;
1768
1769 if (canseemon(mtmp) && msg) {
1770 DISABLE_WARNING_FORMAT_NONLITERAL
1771 pline_mon(mtmp, msg, Monnam(mtmp));
1772 RESTORE_WARNING_FORMAT_NONLITERAL
1773 }
1774}
1775
1776/* Maybe give an intrinsic to monster from eating corpse that confers it. */
1777void

Callers 2

mhitm_ad_cursFunction · 0.85
mon_givitFunction · 0.85

Calls 1

canseemonFunction · 0.85

Tested by

no test coverage detected