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

Function Amulet_off

src/do_wear.c:1089–1189  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1087}
1088
1089void
1090Amulet_off(void)
1091{
1092 struct obj *amul = uamul; /* for off_msg() after setworn(NULL,W_AMUL) */
1093 boolean mkn = FALSE, early_off_msg = FALSE;
1094
1095 svc.context.takeoff.mask &= ~W_AMUL;
1096
1097 switch (uamul->otyp) {
1098 case AMULET_OF_ESP:
1099 /* need to update ability before calling see_monsters() */
1100 setworn((struct obj *) 0, W_AMUL);
1101 off_msg(amul);
1102 early_off_msg = TRUE;
1103
1104 see_monsters();
1105 break;
1106 case AMULET_OF_LIFE_SAVING:
1107 case AMULET_VERSUS_POISON:
1108 case AMULET_OF_REFLECTION:
1109 case AMULET_OF_CHANGE:
1110 case AMULET_OF_UNCHANGING:
1111 case FAKE_AMULET_OF_YENDOR:
1112 break;
1113 case AMULET_OF_MAGICAL_BREATHING:
1114 /* amulet is currently still on; take it off before calling drown()
1115 and region_danger(); call off_msg() before specific messages */
1116 setworn((struct obj *) 0, W_AMUL);
1117 off_msg(amul); /* 'uamul' has been set to Null */
1118 early_off_msg = TRUE;
1119
1120 if (Underwater) {
1121 if (!cant_drown(gy.youmonst.data) && !Swimming) {
1122 You("suddenly inhale an unhealthy amount of %s!",
1123 hliquid("water"));
1124 mkn = TRUE; /* in case of life-saving */
1125 (void) drown();
1126 }
1127 }
1128 if (region_danger()) {
1129 /* "breathing": wouldn't get here otherwise */
1130 You("are breathing poison gas!");
1131 mkn = TRUE;
1132 }
1133 break;
1134 case AMULET_OF_STRANGULATION:
1135 setworn((struct obj *) 0, W_AMUL);
1136 off_msg(amul);
1137 early_off_msg = TRUE;
1138
1139 if (Strangled) {
1140 Strangled = 0L;
1141 disp.botl = TRUE;
1142 if (Breathless)
1143 Your("%s is no longer constricted!", body_part(NECK));
1144 else
1145 You("can breathe more easily!");
1146 mkn = TRUE;

Callers 4

remove_worn_itemFunction · 0.85
armor_or_accessory_offFunction · 0.85
do_takeoffFunction · 0.85
offer_real_amuletFunction · 0.85

Calls 13

setwornFunction · 0.85
off_msgFunction · 0.85
see_monstersFunction · 0.85
YouFunction · 0.85
hliquidFunction · 0.85
drownFunction · 0.85
region_dangerFunction · 0.85
YourFunction · 0.85
body_partFunction · 0.85
float_vs_flightFunction · 0.85
is_pool_or_lavaFunction · 0.85
spoteffectsFunction · 0.85

Tested by

no test coverage detected