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

Function find_artifact

src/artifact.c:421–459  ·  view source on GitHub ↗

if an artifact hasn't already been designated 'found', do that now and generate a livelog event about finding it */

Source from the content-addressed store, hash-verified

419/* if an artifact hasn't already been designated 'found', do that now
420 and generate a livelog event about finding it */
421void
422find_artifact(struct obj *otmp)
423{
424 int a = otmp->oartifact;
425
426 if (a && !artiexist[a].found) {
427 const char *where;
428
429 found_artifact(a); /* artiexist[a].found = 1 */
430 /*
431 * Unlike costly_spot(), inside_shop() includes the "free spot"
432 * in front of the door. And it doesn't care whether or not
433 * there is a shopkeeper present.
434 *
435 * If hero sees a monster pick up a not-yet-found artifact, it
436 * will have its dknown flag set even if far away and will be
437 * described as 'found on the floor'. Similarly for dropping
438 * (possibly upon monster's death), dknown will be set and the
439 * artifact will be described as 'carried by a monster'.
440 * That's handled by caller: dog_invent(), mpickstuff(), or
441 * mdrop_obj() so that we get called before obj->where changes.
442 */
443 where = ((otmp->where == OBJ_FLOOR)
444 ? ((inside_shop(otmp->ox, otmp->oy) != NO_ROOM)
445 ? " in a shop"
446 : " on the floor")
447 /* artifacts aren't created in containers but could be
448 inside one if it comes from a bones level */
449 : (otmp->where == OBJ_CONTAINED) ? " in a container"
450 /* perhaps probing, or seeing monster wield artifact */
451 : (otmp->where == OBJ_MINVENT) ? " carried by a monster"
452 /* catchall: probably in inventory, picked up while
453 blind but now seen; there's no previous_where to
454 figure out how it got here */
455 : "");
456 livelog_printf(LL_ARTIFACT, "found %s%s",
457 bare_artifactname(otmp), where);
458 }
459}
460
461int
462nartifact_exist(void)

Callers 2

steal_itFunction · 0.85
xname_flagsFunction · 0.85

Calls 4

found_artifactFunction · 0.85
inside_shopFunction · 0.85
livelog_printfFunction · 0.85
bare_artifactnameFunction · 0.85

Tested by

no test coverage detected