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

Function force_learn_spell

src/spell.c:2390–2413  ·  view source on GitHub ↗

learn or refresh spell otyp, if feasible; return casting letter or '\0' */

Source from the content-addressed store, hash-verified

2388
2389/* learn or refresh spell otyp, if feasible; return casting letter or '\0' */
2390char
2391force_learn_spell(short otyp)
2392{
2393 int i;
2394
2395 if (otyp == SPE_BLANK_PAPER || otyp == SPE_BOOK_OF_THE_DEAD
2396 || known_spell(otyp) == spe_Fresh)
2397 return '\0';
2398
2399 for (i = 0; i < MAXSPELL; i++)
2400 if (spellid(i) == NO_SPELL || spellid(i) == otyp)
2401 break;
2402 if (i == MAXSPELL) {
2403 impossible("Too many spells memorized");
2404 return '\0';
2405 }
2406 /* for a going-stale or forgotten spell the sp_id and sp_lev assignments
2407 are redundant but harmless; for an unknown spell, they're essential */
2408 svs.spl_book[i].sp_id = otyp;
2409 svs.spl_book[i].sp_lev = objects[otyp].oc_level;
2410 incrnknow(i, 0); /* set spl_book[i].sp_know to KEEN; unlike when learning
2411 * a spell by reading its book, we don't need to add 1 */
2412 return spellet(i);
2413}
2414
2415/* number of spells hero knows */
2416int

Callers 1

give_spellFunction · 0.85

Calls 2

known_spellFunction · 0.85
impossibleFunction · 0.70

Tested by

no test coverage detected