MCPcopy Index your code
hub / github.com/NetHack/NetHack / initialspell

Function initialspell

src/spell.c:2339–2359  ·  view source on GitHub ↗

Learn a spell during creation of the initial inventory */

Source from the content-addressed store, hash-verified

2337
2338/* Learn a spell during creation of the initial inventory */
2339void
2340initialspell(struct obj *obj)
2341{
2342 int i, otyp = obj->otyp;
2343
2344 for (i = 0; i < MAXSPELL; i++)
2345 if (spellid(i) == NO_SPELL || spellid(i) == otyp)
2346 break;
2347
2348 if (i == MAXSPELL) {
2349 impossible("Too many spells memorized!");
2350 } else if (spellid(i) != NO_SPELL) {
2351 /* initial inventory shouldn't contain duplicate spellbooks */
2352 impossible("Spell %s already known.", OBJ_NAME(objects[otyp]));
2353 } else {
2354 svs.spl_book[i].sp_id = otyp;
2355 svs.spl_book[i].sp_lev = objects[otyp].oc_level;
2356 incrnknow(i, 0);
2357 }
2358 return;
2359}
2360
2361/* returns one of spe_Unknown, spe_Fresh, spe_GoingStale, spe_Forgotten */
2362int

Callers 1

ini_inv_use_objFunction · 0.85

Calls 1

impossibleFunction · 0.70

Tested by

no test coverage detected