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

Function study_book

src/spell.c:465–641  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

463}
464
465RESTORE_WARNING_FORMAT_NONLITERAL
466
467int
468study_book(struct obj *spellbook)
469{
470 int booktype = spellbook->otyp, i;
471 boolean confused = (Confusion != 0);
472 boolean too_hard = FALSE;
473
474 /* attempting to read dull book may make hero fall asleep */
475 if (!confused && !Sleep_resistance
476 && objdescr_is(spellbook, "dull")) {
477 const char *eyes;
478 int dullbook = rnd(25) - ACURR(A_WIS);
479
480 /* adjust chance if hero stayed awake, got interrupted, retries */
481 if (svc.context.spbook.delay && spellbook == svc.context.spbook.book)
482 dullbook -= rnd(objects[booktype].oc_level);
483
484 if (dullbook > 0) {
485 eyes = body_part(EYE);
486 if (eyecount(gy.youmonst.data) > 1)
487 eyes = makeplural(eyes);
488 pline("This book is so dull that you can't keep your %s open.",
489 eyes);
490 dullbook += rnd(2 * objects[booktype].oc_level);
491 fall_asleep(-dullbook, TRUE);
492 return 1;
493 }
494 }
495
496 if (svc.context.spbook.delay && !confused
497 && spellbook == svc.context.spbook.book
498 /* handle the sequence: start reading, get interrupted, have
499 svc.context.spbook.book become erased somehow, resume reading it */
500 && booktype != SPE_BLANK_PAPER) {
501 You("continue your efforts to %s.",
502 (booktype == SPE_NOVEL) ? "read the novel"
503 : "memorize the spell");
504 } else {
505 /* KMH -- Simplified this code */
506 if (booktype == SPE_BLANK_PAPER) {
507 pline("This spellbook is all blank.");
508 makeknown(booktype);
509 return 1;
510 }
511
512 /* 3.6 tribute */
513 if (booktype == SPE_NOVEL) {
514 /* Obtain current Terry Pratchett book title */
515 const char *tribtitle = noveltitle(&spellbook->novelidx);
516
517 if (read_tribute("books", tribtitle, 0, (char *) 0, 0,
518 spellbook->o_id)) {
519 if (!u.uconduct.literate++)
520 livelog_printf(LL_CONDUCT,
521 "became literate by reading %s",
522 tribtitle);

Callers 1

doreadFunction · 0.85

Calls 15

objdescr_isFunction · 0.85
rndFunction · 0.85
body_partFunction · 0.85
makepluralFunction · 0.85
fall_asleepFunction · 0.85
YouFunction · 0.85
noveltitleFunction · 0.85
read_tributeFunction · 0.85
livelog_printfFunction · 0.85
check_unpaidFunction · 0.85
record_achievementFunction · 0.85
more_experiencedFunction · 0.85

Tested by

no test coverage detected