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

Function ucatchgem

src/mthrowu.c:505–529  ·  view source on GitHub ↗

hero catches gem thrown by mon iff poly'd into unicorn; might drop it */

Source from the content-addressed store, hash-verified

503
504/* hero catches gem thrown by mon iff poly'd into unicorn; might drop it */
505staticfn boolean
506ucatchgem(
507 struct obj *gem, /* caller has verified gem->oclass */
508 struct monst *mon)
509{
510 /* won't catch rock or gray stone; catch (then drop) worthless glass */
511 if (gem->otyp <= LAST_GLASS_GEM && is_unicorn(gy.youmonst.data)) {
512 char *gem_xname = xname(gem),
513 *mon_s_name = s_suffix(mon_nam(mon));
514
515 if (gem->otyp >= FIRST_GLASS_GEM) {
516 You("catch the %s.", gem_xname);
517 You("are not interested in %s junk.", mon_s_name);
518 makeknown(gem->otyp);
519 dropy(gem);
520 } else {
521 You("accept %s gift in the spirit in which it was intended.",
522 mon_s_name);
523 (void) hold_another_object(gem, "You catch, but drop, %s.",
524 gem_xname, "You catch:");
525 }
526 return TRUE;
527 }
528 return FALSE;
529}
530
531/* hero may catch thrown obj. it is added to inventory, if possible */
532staticfn boolean

Callers 1

mthrowu.cFile · 0.85

Calls 6

xnameFunction · 0.85
s_suffixFunction · 0.85
mon_namFunction · 0.85
YouFunction · 0.85
dropyFunction · 0.85
hold_another_objectFunction · 0.85

Tested by

no test coverage detected