Returns 1 if otmp is free'd, 0 otherwise. */
| 615 | |
| 616 | /* Returns 1 if otmp is free'd, 0 otherwise. */ |
| 617 | int |
| 618 | mpickobj(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; |
no test coverage detected