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

Function amulet

src/wizard.c:60–103  ·  view source on GitHub ↗

If you've found the Amulet, make the Wizard appear after some time */ Also, give hints about portal locations, if amulet is worn/wielded -dlc */

Source from the content-addressed store, hash-verified

58/* If you've found the Amulet, make the Wizard appear after some time */
59/* Also, give hints about portal locations, if amulet is worn/wielded -dlc */
60void
61amulet(void)
62{
63 struct monst *mtmp;
64 struct trap *ttmp;
65 struct obj *amu;
66
67#if 0 /* caller takes care of this check */
68 if (!u.uhave.amulet)
69 return;
70#endif
71 if ((((amu = uamul) != 0 && amu->otyp == AMULET_OF_YENDOR)
72 || ((amu = uwep) != 0 && amu->otyp == AMULET_OF_YENDOR))
73 && !rn2(15)) {
74 for (ttmp = gf.ftrap; ttmp; ttmp = ttmp->ntrap) {
75 if (ttmp->ttyp == MAGIC_PORTAL) {
76 int du = distu(ttmp->tx, ttmp->ty);
77 if (du <= 9)
78 pline("%s hot!", Tobjnam(amu, "feel"));
79 else if (du <= 64)
80 pline("%s very warm.", Tobjnam(amu, "feel"));
81 else if (du <= 144)
82 pline("%s warm.", Tobjnam(amu, "feel"));
83 /* else, the amulet feels normal */
84 break;
85 }
86 }
87 }
88
89 if (!svc.context.no_of_wizards)
90 return;
91 /* find Wizard, and wake him if necessary */
92 for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
93 if (DEADMONSTER(mtmp))
94 continue;
95 if (mtmp->iswiz && mtmp->msleeping && !rn2(40)) {
96 mtmp->msleeping = 0;
97 if (!m_next2u(mtmp))
98 You(
99 "get the creepy feeling that somebody noticed your taking the Amulet.");
100 return;
101 }
102 }
103}
104
105int
106mon_has_amulet(struct monst *mtmp)

Callers 1

allmain.cFile · 0.85

Calls 4

rn2Function · 0.85
TobjnamFunction · 0.85
YouFunction · 0.85
plineFunction · 0.70

Tested by

no test coverage detected