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

Function remove_worn_item

src/steal.c:212–290  ·  view source on GitHub ↗

An object you're wearing has been taken off by a monster (theft or seduction). Also used if a worn item gets transformed (stone to flesh). */

Source from the content-addressed store, hash-verified

210/* An object you're wearing has been taken off by a monster (theft or
211 seduction). Also used if a worn item gets transformed (stone to flesh). */
212void
213remove_worn_item(
214 struct obj *obj,
215 boolean unchain_ball) /* whether to unpunish or just unwield */
216{
217 unsigned oldinuse;
218
219 if (donning(obj))
220 cancel_don();
221 if (!obj->owornmask)
222 return;
223
224 /*
225 * Losing worn gear might drop hero into water or lava or onto a
226 * location-changing trap or take away the ability to breathe in water.
227 * Marking it 'in_use' prevents emergency_disrobe() from dropping it
228 * and lava_effects() from destroying it; other cases impacting object
229 * location (or destruction) might still have issues.
230 *
231 * Note: if a hangup save occurs when 'in_use' is set, the item will
232 * be destroyed via useup() during restore. Maybe remove_worn_item()
233 * and emergency_disrobe() should switch to using obj->bypass instead
234 * but that would need a lot more cooperation by callers. It's a
235 * tradeoff between protecting the player against unintentional hangup
236 * and defending the game against deliberate hangup when player sees a
237 * message about something undesirable followed by --More--.
238 */
239 oldinuse = obj->in_use;
240 obj->in_use = 1;
241
242 if (obj->owornmask & W_ARMOR) {
243 if (obj == uskin) {
244 impossible("Removing embedded scales?");
245 skinback(TRUE); /* uarm = uskin; uskin = 0; */
246 }
247 if (obj == uarm)
248 (void) Armor_off();
249 else if (obj == uarmc)
250 (void) Cloak_off();
251 else if (obj == uarmf)
252 (void) Boots_off();
253 else if (obj == uarmg)
254 (void) Gloves_off();
255 else if (obj == uarmh)
256 (void) Helmet_off();
257 else if (obj == uarms)
258 (void) Shield_off();
259 else if (obj == uarmu)
260 (void) Shirt_off();
261 /* catchall -- should never happen */
262 else
263 setworn((struct obj *) 0, obj->owornmask & W_ARMOR);
264 } else if (obj->owornmask & W_AMUL) {
265 Amulet_off();
266 } else if (obj->owornmask & W_RING) {
267 Ring_gone(obj);
268 } else if (obj->owornmask & W_TOOL) {
269 Blindf_off(obj);

Callers 15

take_goldFunction · 0.85
worn_item_removalFunction · 0.85
stealFunction · 0.85
maybe_absorb_itemFunction · 0.85
dodrinkFunction · 0.85
wielding_corpseFunction · 0.85
Amulet_onFunction · 0.85
Blindf_onFunction · 0.85
stop_donningFunction · 0.85
armor_or_accessory_offFunction · 0.85
accessory_or_armor_onFunction · 0.85
use_saddleFunction · 0.85

Calls 15

donningFunction · 0.85
cancel_donFunction · 0.85
skinbackFunction · 0.85
Armor_offFunction · 0.85
Cloak_offFunction · 0.85
Boots_offFunction · 0.85
Gloves_offFunction · 0.85
Helmet_offFunction · 0.85
Shield_offFunction · 0.85
Shirt_offFunction · 0.85
setwornFunction · 0.85
Amulet_offFunction · 0.85

Tested by

no test coverage detected