MCPcopy Index your code
hub / github.com/NetHack/NetHack / mpickobj

Function mpickobj

src/steal.c:617–685  ·  view source on GitHub ↗

Returns 1 if otmp is free'd, 0 otherwise. */

Source from the content-addressed store, hash-verified

615
616/* Returns 1 if otmp is free'd, 0 otherwise. */
617int
618mpickobj(struct monst *mtmp, struct obj *otmp)
619{
620 int freed_otmp;
621 boolean snuff_otmp = FALSE;
622
623 if (!otmp) {
624 impossible("monster (%s) taking or picking up nothing?",
625 pmname(mtmp->data, Mgender(mtmp)));
626 return 1;
627 } else if (otmp == uball || otmp == uchain) {
628 impossible("monster (%s) taking or picking up attached %s (%s)?",
629 pmname(mtmp->data, Mgender(mtmp)),
630 (otmp == uchain) ? "chain" : "ball", simpleonames(otmp));
631 return 0;
632 }
633 /* if monster is acquiring a thrown or kicked object, the throwing
634 or kicking code shouldn't continue to track and place it */
635 if (otmp == gt.thrownobj)
636 gt.thrownobj = 0;
637 else if (otmp == gk.kickedobj)
638 gk.kickedobj = 0;
639 /* an unpaid item can be on the floor; if a monster picks it up, take
640 it off the shop bill */
641 if (otmp->unpaid || (Has_contents(otmp) && count_unpaid(otmp->cobj))) {
642 subfrombill(otmp, find_objowner(otmp, otmp->ox, otmp->oy));
643 }
644 /* don't want hidden light source inside the monster; assumes that
645 engulfers won't have external inventories; whirly monsters cause
646 the light to be extinguished rather than letting it shine through */
647 if (obj_sheds_light(otmp) && attacktype(mtmp->data, AT_ENGL)) {
648 /* this is probably a burning object that you dropped or threw */
649 if (engulfing_u(mtmp) && !Blind)
650 pline("%s out.", Tobjnam(otmp, "go"));
651 snuff_otmp = TRUE;
652 }
653 /* for hero owned object on shop floor, mtmp is taking possession
654 and if it's eventually dropped in a shop, shk will claim it */
655 otmp->no_charge = 0;
656 /* some object handling is only done if mtmp isn't a pet */
657 if (!mtmp->mtame) {
658 /* if monst is unseen, some info hero knows about this object becomes
659 lost; continual pickup and drop by pets makes this too annoying if
660 it is applied to them; when engulfed (where monster can't be seen
661 because vision is disabled), or when held (or poly'd and holding)
662 while blind, behave as if the monster can be 'seen' by touch */
663 if (!canseemon(mtmp) && mtmp != u.ustuck)
664 unknow_object(otmp);
665 /* if otmp has flags set for how it left hero's inventory, change
666 those flags; if thrown, now stolen and autopickup might override
667 pickup_types and autopickup exceptions based on 'pickup_stolen'
668 rather than 'pickup_thrown'; if previously stolen, stays stolen;
669 if previously dropped, now forgotten and autopickup will operate
670 normally regardless of the setting for 'dropped_nopick' */
671 if (otmp->how_lost == LOST_THROWN)
672 otmp->how_lost = LOST_STOLEN;
673 else if (otmp->how_lost == LOST_DROPPED)
674 otmp->how_lost = LOST_NONE;

Callers 15

mk_mplayer_armorFunction · 0.85
mk_mplayerFunction · 0.85
stealarmFunction · 0.85
stealFunction · 0.85
stealamuletFunction · 0.85
maybe_absorb_itemFunction · 0.85
steal_itFunction · 0.85
put_saddle_on_monFunction · 0.85
dropzFunction · 0.85
tacticsFunction · 0.85
swallowitFunction · 0.85
throwitFunction · 0.85

Calls 15

pmnameFunction · 0.85
MgenderFunction · 0.85
simpleonamesFunction · 0.85
count_unpaidFunction · 0.85
subfrombillFunction · 0.85
find_objownerFunction · 0.85
obj_sheds_lightFunction · 0.85
attacktypeFunction · 0.85
TobjnamFunction · 0.85
canseemonFunction · 0.85
unknow_objectFunction · 0.85
carry_obj_effectsFunction · 0.85

Tested by

no test coverage detected