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

Function gazemu

src/mhitu.c:1667–1898  ·  view source on GitHub ↗

monster gazes at you */

Source from the content-addressed store, hash-verified

1665
1666/* monster gazes at you */
1667int
1668gazemu(struct monst *mtmp, struct attack *mattk)
1669{
1670 static const char *const reactions[] = {
1671 "confused", /* [0] */
1672 "stunned", /* [1] */
1673 "puzzled", "dazzled", /* [2,3] */
1674 "irritated", "inflamed", /* [4,5] */
1675 "tired", /* [6] */
1676 "dulled", /* [7] */
1677 };
1678 int react = -1;
1679 boolean is_medusa, reflectable,
1680 cancelled = (mtmp->mcan != 0), already = FALSE,
1681 mcanseeu = (canseemon(mtmp) && couldsee(mtmp->mx, mtmp->my)
1682 && mtmp->mcansee);
1683
1684 if (m_seenres(mtmp, cvt_adtyp_to_mseenres(mattk->adtyp)))
1685 return M_ATTK_MISS;
1686
1687 is_medusa = (mtmp->data == &mons[PM_MEDUSA]);
1688 reflectable = (Reflecting && couldsee(mtmp->mx, mtmp->my) && is_medusa);
1689 /* assumes that hero has to see monster's gaze in order to be
1690 affected, rather than monster just having to look at hero;
1691 Unaware: asleep or unconscious => not blind but won't see;
1692 when hallucinating, hero's brain doesn't register what
1693 it's seeing correctly so the gaze is usually ineffective
1694 [this could be taken a lot farther and select a gaze effect
1695 appropriate to what's currently being displayed, giving
1696 ordinary monsters a gaze attack when hero thinks he or she
1697 is facing a gazing creature, but let's not go that far...] */
1698 if ((Hallucination && rn2(4)) || (Unaware && !reflectable))
1699 cancelled = TRUE;
1700
1701 switch (mattk->adtyp) {
1702 case AD_STON:
1703 /* note: Medusa is the only monster with stoning gaze, so
1704 'is_medusa' will always be True here */
1705 if (cancelled || !mtmp->mcansee) {
1706 if (!canseemon(mtmp))
1707 break; /* silently */
1708 if (Unaware) { /* can't see attacker even though not blind */
1709 react = is_medusa ? 4 : 2; /* irritated or puzzled */
1710 break;
1711 }
1712 if (is_medusa && Hallucination && !rn2(3))
1713 pline("Someone seems overdue for a serpent cut.");
1714 else
1715 pline_mon(mtmp, "%s %s.", Monnam(mtmp),
1716 (is_medusa && mtmp->mcan && !react)
1717 ? "doesn't look all that ugly"
1718 : "gazes ineffectually");
1719 break;
1720 }
1721 if (reflectable) {
1722 /* hero has line of sight to Medusa and she's not blind */
1723 boolean useeit = canseemon(mtmp);
1724

Callers 2

m_respond_medusaFunction · 0.85
mattackuFunction · 0.85

Calls 15

canseemonFunction · 0.85
cvt_adtyp_to_mseenresFunction · 0.85
rn2Function · 0.85
pline_monFunction · 0.85
MonnamFunction · 0.85
ureflectsFunction · 0.85
s_suffixFunction · 0.85
mon_reflectsFunction · 0.85
killedFunction · 0.85
YouFunction · 0.85
mon_namFunction · 0.85
stop_occupationFunction · 0.85

Tested by

no test coverage detected