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

Function extract_from_minvent

src/worn.c:1376–1417  ·  view source on GitHub ↗

Remove an object from a monster's inventory. */

Source from the content-addressed store, hash-verified

1374
1375/* Remove an object from a monster's inventory. */
1376void
1377extract_from_minvent(
1378 struct monst *mon,
1379 struct obj *obj,
1380 boolean do_extrinsics, /* whether to call update_mon_extrinsics */
1381 boolean silently) /* doesn't affect all possible messages,
1382 * just update_mon_extrinsics's */
1383{
1384 long unwornmask = obj->owornmask;
1385
1386 /*
1387 * At its core this is just obj_extract_self(), but it also handles
1388 * any updates that need to happen if the gear is equipped or in
1389 * some other sort of state that needs handling.
1390 * Note that like obj_extract_self(), this leaves obj free.
1391 */
1392
1393 if (obj->where != OBJ_MINVENT) {
1394 impossible("extract_from_minvent called on object not in minvent");
1395 return;
1396 }
1397 /* handle gold dragon scales/scale-mail (lit when worn) before clearing
1398 obj->owornmask because artifact_light() expects that to be W_ARM */
1399 if ((unwornmask & W_ARM) != 0 && obj->lamplit && artifact_light(obj))
1400 end_burn(obj, FALSE);
1401
1402 obj_extract_self(obj);
1403 obj->owornmask = 0L;
1404 if (unwornmask) {
1405 if (!DEADMONSTER(mon) && do_extrinsics) {
1406 update_mon_extrinsics(mon, obj, FALSE, silently);
1407 }
1408 mon->misc_worn_check &= ~unwornmask;
1409 /* give monster a chance to wear other equipment on its next
1410 move instead of waiting until it picks something up */
1411 check_gear_next_turn(mon);
1412 }
1413 obj_no_longer_held(obj);
1414 if (unwornmask & W_WEP) {
1415 mwepgone(mon); /* unwields and sets weapon_check to NEED_WEAPON */
1416 }
1417}
1418
1419#undef w_blocks
1420

Callers 14

mdrop_objFunction · 0.85
mdrop_special_objsFunction · 0.85
steal_itFunction · 0.85
mhitm_ad_seduFunction · 0.85
m_lose_armorFunction · 0.85
loot_monFunction · 0.85
monstoneFunction · 0.85
discard_minventFunction · 0.85
erode_objFunction · 0.85
trapeffect_poly_trapFunction · 0.85
disintegrate_monFunction · 0.85
gelcube_digestsFunction · 0.85

Calls 8

artifact_lightFunction · 0.85
end_burnFunction · 0.85
obj_extract_selfFunction · 0.85
update_mon_extrinsicsFunction · 0.85
check_gear_next_turnFunction · 0.85
obj_no_longer_heldFunction · 0.85
mwepgoneFunction · 0.85
impossibleFunction · 0.70

Tested by

no test coverage detected