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

Function select_off

src/do_wear.c:2694–2821  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2692}
2693
2694staticfn
2695int
2696select_off(struct obj *otmp)
2697{
2698 struct obj *why;
2699 char buf[BUFSZ];
2700
2701 if (!otmp)
2702 return 0;
2703 *buf = '\0'; /* lint suppression */
2704
2705 /* special ring checks */
2706 if (otmp == uright || otmp == uleft) {
2707 struct obj glibdummy;
2708
2709 if (nolimbs(gy.youmonst.data)) {
2710 pline_The("ring is stuck.");
2711 return 0;
2712 }
2713 glibdummy = cg.zeroobj;
2714 why = 0; /* the item which prevents ring removal */
2715 if (welded(uwep) && ((otmp == RING_ON_PRIMARY) || bimanual(uwep))) {
2716 Sprintf(buf, "free a weapon %s", body_part(HAND));
2717 why = uwep;
2718 } else if (uarmg && (uarmg->cursed || Glib)) {
2719 Sprintf(buf, "take off your %s%s",
2720 Glib ? "slippery " : "", gloves_simple_name(uarmg));
2721 why = !Glib ? uarmg : &glibdummy;
2722 }
2723 if (why) {
2724 You("cannot %s to remove the ring.", buf);
2725 set_bknown(why, 1);
2726 return 0;
2727 }
2728 }
2729 /* special glove checks */
2730 if (otmp == uarmg) {
2731 if (welded(uwep)) {
2732 You("are unable to take off your %s while wielding that %s.",
2733 c_gloves, is_sword(uwep) ? c_sword : c_weapon);
2734 set_bknown(uwep, 1);
2735 return 0;
2736 } else if (Glib) {
2737 pline("%s %s are too slippery to take off.",
2738 uarmg->unpaid ? "The" : "Your", /* simplified Shk_Your() */
2739 gloves_simple_name(uarmg));
2740 return 0;
2741 }
2742 if (better_not_take_that_off(otmp))
2743 return 0;
2744 }
2745 /* special boot checks */
2746 if (otmp == uarmf) {
2747 if (u.utrap && u.utraptype == TT_BEARTRAP) {
2748 pline_The("bear trap prevents you from pulling your %s out.",
2749 body_part(FOOT));
2750 return 0;
2751 } else if (u.utrap && u.utraptype == TT_INFLOOR) {

Callers 2

armor_or_accessory_offFunction · 0.85
menu_remarmFunction · 0.85

Calls 15

pline_TheFunction · 0.85
weldedFunction · 0.85
body_partFunction · 0.85
gloves_simple_nameFunction · 0.85
YouFunction · 0.85
set_bknownFunction · 0.85
better_not_take_that_offFunction · 0.85
surfaceFunction · 0.85
makepluralFunction · 0.85
cloak_simple_nameFunction · 0.85
theFunction · 0.85
xnameFunction · 0.85

Tested by

no test coverage detected