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

Function deadbook

src/spell.c:230–339  ·  view source on GitHub ↗

special effects for the Book of the Dead; reading it while blind is allowed so that needs to be taken into account too */

Source from the content-addressed store, hash-verified

228/* special effects for the Book of the Dead; reading it while blind is
229 allowed so that needs to be taken into account too */
230staticfn void
231deadbook(struct obj *book2)
232{
233 struct monst *mtmp;
234 coord mm;
235
236 You("turn the pages of the Book of the Dead...");
237 makeknown(SPE_BOOK_OF_THE_DEAD);
238 observe_object(book2); /* in case blind now and hasn't been seen yet */
239 /* KMH -- Need ->known to avoid "_a_ Book of the Dead" */
240 book2->known = 1;
241 if (invocation_pos(u.ux, u.uy) && !On_stairs(u.ux, u.uy)) {
242 struct obj *otmp;
243 boolean arti1_primed = FALSE, arti2_primed = FALSE,
244 arti_cursed = FALSE;
245
246 if (book2->cursed) {
247 pline_The("%s!",
248 Blind ? "Book seems to be ignoring you"
249 : "runes appear scrambled. You can't read them");
250 return;
251 }
252
253 if (!u.uhave.bell || !u.uhave.menorah) {
254 pline("A chill runs down your %s.", body_part(SPINE));
255 if (!u.uhave.bell) {
256 Soundeffect(se_faint_chime, 30);
257 You_hear("a faint chime...");
258 }
259 if (!u.uhave.menorah)
260 pline("Vlad's doppelganger is amused.");
261 return;
262 }
263
264 for (otmp = gi.invent; otmp; otmp = otmp->nobj) {
265 if (otmp->otyp == CANDELABRUM_OF_INVOCATION && otmp->spe == 7
266 && otmp->lamplit) {
267 if (!otmp->cursed)
268 arti1_primed = TRUE;
269 else
270 arti_cursed = TRUE;
271 }
272 if (otmp->otyp == BELL_OF_OPENING
273 && (svm.moves - otmp->age) < 5L) { /* you rang it recently */
274 if (!otmp->cursed)
275 arti2_primed = TRUE;
276 else
277 arti_cursed = TRUE;
278 }
279 }
280
281 if (arti_cursed) {
282 pline_The("invocation fails!");
283 /* this used to say "your artifacts" but the invocation tools
284 are not artifacts */
285 pline("At least one of your relics is cursed...");
286 } else if (arti1_primed && arti2_primed) {
287 unsigned soon = (unsigned) d(2, 6); /* time til next intervene() */

Callers 1

learnFunction · 0.85

Calls 15

YouFunction · 0.85
observe_objectFunction · 0.85
invocation_posFunction · 0.85
On_stairsFunction · 0.85
pline_TheFunction · 0.85
body_partFunction · 0.85
You_hearFunction · 0.85
dFunction · 0.85
mkinvokeareaFunction · 0.85
record_achievementFunction · 0.85
rn2Function · 0.85
makemonFunction · 0.85

Tested by

no test coverage detected