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

Function canletgo

src/do.c:664–711  ·  view source on GitHub ↗

some common tests when trying to drop or throw items */

Source from the content-addressed store, hash-verified

662
663/* some common tests when trying to drop or throw items */
664boolean
665canletgo(struct obj *obj, const char *word)
666{
667 if (obj->owornmask & (W_ARMOR | W_ACCESSORY)) {
668 if (*word)
669 Norep("You cannot %s %s you are wearing.", word, something);
670 return FALSE;
671 }
672 if (obj == uwep && welded(uwep)) {
673 /* no weldmsg(), so uwep->bknown might become set silently
674 if word is "" */
675 if (*word) {
676 const char *hand = body_part(HAND);
677
678 if (bimanual(uwep))
679 hand = makeplural(hand);
680 Norep("You cannot %s %s welded to your %s.", word, something,
681 hand);
682 }
683 return FALSE;
684 }
685 if (obj->otyp == LOADSTONE && obj->cursed) {
686 /* getobj() kludge sets corpsenm to user's specified count
687 when refusing to split a stack of cursed loadstones */
688 if (*word) {
689 /* getobj() ignores a count for throwing since that is
690 implicitly forced to be 1; replicate its kludge... */
691 if (!strcmp(word, "throw") && obj->quan > 1L)
692 obj->corpsenm = 1;
693 pline("For some reason, you cannot %s%s the stone%s!", word,
694 obj->corpsenm ? " any of" : "", plur(obj->quan));
695 }
696 obj->corpsenm = 0; /* reset */
697 set_bknown(obj, 1);
698 return FALSE;
699 }
700 if (obj->otyp == LEASH && obj->leashmon != 0) {
701 if (*word)
702 pline_The("leash is tied around your %s.", body_part(HAND));
703 return FALSE;
704 }
705 if (obj->owornmask & W_SADDLE) {
706 if (*word)
707 You("cannot %s %s you are sitting on.", word, something);
708 return FALSE;
709 }
710 return TRUE;
711}
712
713staticfn int
714drop(struct obj *obj)

Callers 7

glibrFunction · 0.85
litterFunction · 0.85
dropFunction · 0.85
throw_objFunction · 0.85
drop_weaponFunction · 0.85
find_miscFunction · 0.85
use_miscFunction · 0.85

Calls 8

NorepFunction · 0.85
weldedFunction · 0.85
body_partFunction · 0.85
makepluralFunction · 0.85
set_bknownFunction · 0.85
pline_TheFunction · 0.85
YouFunction · 0.85
plineFunction · 0.70

Tested by

no test coverage detected