monster gazes at you */
| 1665 | |
| 1666 | /* monster gazes at you */ |
| 1667 | int |
| 1668 | gazemu(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 |
no test coverage detected