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

Function freeinv_core

src/invent.c:1355–1399  ·  view source on GitHub ↗

* Adjust hero's attributes as if this object was being removed from the * hero's inventory. This should only be called from freeinv() and * where we are polymorphing an object already in the hero's inventory. * * Should think of a better name... */

Source from the content-addressed store, hash-verified

1353 * Should think of a better name...
1354 */
1355void
1356freeinv_core(struct obj *obj)
1357{
1358 if (obj->oclass == COIN_CLASS) {
1359 disp.botl = TRUE;
1360 return;
1361 } else if (obj->otyp == AMULET_OF_YENDOR) {
1362 if (!u.uhave.amulet)
1363 impossible("don't have amulet?");
1364 u.uhave.amulet = 0;
1365 } else if (obj->otyp == CANDELABRUM_OF_INVOCATION) {
1366 if (!u.uhave.menorah)
1367 impossible("don't have candelabrum?");
1368 u.uhave.menorah = 0;
1369 } else if (obj->otyp == BELL_OF_OPENING) {
1370 if (!u.uhave.bell)
1371 impossible("don't have silver bell?");
1372 u.uhave.bell = 0;
1373 } else if (obj->otyp == SPE_BOOK_OF_THE_DEAD) {
1374 if (!u.uhave.book)
1375 impossible("don't have the book?");
1376 u.uhave.book = 0;
1377 } else if (obj->oartifact) {
1378 if (is_quest_artifact(obj)) {
1379 if (!u.uhave.questart)
1380 impossible("don't have quest artifact?");
1381 u.uhave.questart = 0;
1382 }
1383 set_artifact_intrinsic(obj, 0, W_ART);
1384 }
1385
1386 if (obj->otyp == LOADSTONE) {
1387 curse(obj);
1388 } else if (confers_luck(obj)) {
1389 set_moreluck();
1390 disp.botl = TRUE;
1391 } else if (obj->otyp == FIGURINE && obj->timed) {
1392 (void) stop_timer(FIG_TRANSFORM, obj_to_any(obj));
1393 }
1394
1395 if (obj == svc.context.tin.tin) {
1396 svc.context.tin.tin = (struct obj *) 0;
1397 svc.context.tin.o_id = 0;
1398 }
1399}
1400
1401/* remove an object from the hero's inventory */
1402void

Callers 2

freeinvFunction · 0.85
poly_objFunction · 0.85

Calls 8

is_quest_artifactFunction · 0.85
set_artifact_intrinsicFunction · 0.85
curseFunction · 0.85
confers_luckFunction · 0.85
set_moreluckFunction · 0.85
stop_timerFunction · 0.85
obj_to_anyFunction · 0.85
impossibleFunction · 0.70

Tested by

no test coverage detected