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

Function drop

src/do.c:713–780  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

711}
712
713staticfn int
714drop(struct obj *obj)
715{
716 if (!obj)
717 return ECMD_FAIL;
718 if (!canletgo(obj, "drop"))
719 return ECMD_FAIL;
720 if (obj->otyp == CORPSE && better_not_try_to_drop_that(obj))
721 return ECMD_FAIL;
722 if (obj == uwep) {
723 if (welded(uwep)) {
724 weldmsg(obj);
725 return ECMD_FAIL;
726 }
727 setuwep((struct obj *) 0);
728 }
729 if (obj == uquiver) {
730 setuqwep((struct obj *) 0);
731 }
732 if (obj == uswapwep) {
733 setuswapwep((struct obj *) 0);
734 }
735
736 if (u.uswallow) {
737 /* barrier between you and the floor */
738 if (flags.verbose) {
739 char *onam_p, *mnam_p, monbuf[BUFSZ];
740
741 mnam_p = mon_nam(u.ustuck);
742 /* doname can call s_suffix, reusing its buffer */
743 if (digests(u.ustuck->data)) {
744 Sprintf(monbuf, "%s %s", s_suffix(mnam_p),
745 mbodypart(u.ustuck, STOMACH));
746 mnam_p = monbuf;
747 }
748 onam_p = is_unpaid(obj) ? yobjnam(obj, (char *) 0) : doname(obj);
749
750 You("drop %s into %s.", onam_p, mnam_p);
751 }
752 } else {
753 if ((obj->oclass == RING_CLASS || obj->otyp == MEAT_RING)
754 && IS_SINK(levl[u.ux][u.uy].typ)) {
755 dosinkring(obj);
756 return ECMD_TIME;
757 }
758 if (!can_reach_floor(TRUE)) {
759 /* we might be levitating due to #invoke Heart of Ahriman;
760 if so, levitation would end during call to freeinv()
761 and we want hitfloor() to happen before float_down() */
762 boolean levhack = finesse_ahriman(obj);
763
764 if (levhack)
765 ELevitation = W_ART; /* other than W_ARTI */
766 if (flags.verbose)
767 You("drop %s.", doname(obj));
768 freeinv(obj);
769 hitfloor(obj, TRUE);
770 if (levhack)

Callers 3

dodropFunction · 0.85
menudrop_splitFunction · 0.85
menu_dropFunction · 0.85

Calls 15

canletgoFunction · 0.85
weldedFunction · 0.85
weldmsgFunction · 0.85
setuwepFunction · 0.85
setuqwepFunction · 0.85
setuswapwepFunction · 0.85
mon_namFunction · 0.85
s_suffixFunction · 0.85
mbodypartFunction · 0.85
is_unpaidFunction · 0.85
yobjnamFunction · 0.85

Tested by

no test coverage detected