Called after polymorphing a monster, robbing it, etc.... Monsters * otherwise never unwield stuff on their own. Might print message. */
| 744 | * otherwise never unwield stuff on their own. Might print message. |
| 745 | */ |
| 746 | void |
| 747 | possibly_unwield(struct monst *mon, boolean polyspot) |
| 748 | { |
| 749 | struct obj *obj, *mw_tmp; |
| 750 | |
| 751 | if (!(mw_tmp = MON_WEP(mon))) |
| 752 | return; |
| 753 | for (obj = mon->minvent; obj; obj = obj->nobj) |
| 754 | if (obj == mw_tmp) |
| 755 | break; |
| 756 | if (!obj) { /* The weapon was stolen or destroyed */ |
| 757 | MON_NOWEP(mon); |
| 758 | mon->weapon_check = NEED_WEAPON; |
| 759 | return; |
| 760 | } |
| 761 | if (!attacktype(mon->data, AT_WEAP)) { |
| 762 | setmnotwielded(mon, mw_tmp); |
| 763 | mon->weapon_check = NO_WEAPON_WANTED; |
| 764 | /* if we're going to call distant_name(), do so before extract_self */ |
| 765 | if (cansee(mon->mx, mon->my)) { |
| 766 | pline_mon(mon, "%s drops %s.", Monnam(mon), distant_name(obj, doname)); |
| 767 | newsym(mon->mx, mon->my); |
| 768 | } |
| 769 | obj_extract_self(obj); |
| 770 | /* might be dropping object into water or lava */ |
| 771 | if (!flooreffects(obj, mon->mx, mon->my, "drop")) { |
| 772 | if (polyspot) |
| 773 | bypass_obj(obj); |
| 774 | place_object(obj, mon->mx, mon->my); |
| 775 | stackobj(obj); |
| 776 | } |
| 777 | return; |
| 778 | } |
| 779 | /* The remaining case where there is a change is where a monster |
| 780 | * is polymorphed into a stronger/weaker monster with a different |
| 781 | * choice of weapons. This has no parallel for players. It can |
| 782 | * be handled by waiting until mon_wield_item is actually called. |
| 783 | * Though the monster still wields the wrong weapon until then, |
| 784 | * this is OK since the player can't see it. (FIXME: Not okay since |
| 785 | * probing can reveal it.) |
| 786 | * Note that if there is no change, setting the check to NEED_WEAPON |
| 787 | * is harmless. |
| 788 | * Possible problem: big monster with big cursed weapon gets |
| 789 | * polymorphed into little monster. But it's not quite clear how to |
| 790 | * handle this anyway.... |
| 791 | */ |
| 792 | if (!(mwelded(mw_tmp) && mon->weapon_check == NO_WEAPON_WANTED)) |
| 793 | mon->weapon_check = NEED_WEAPON; |
| 794 | return; |
| 795 | } |
| 796 | |
| 797 | /* Let a monster try to wield a weapon, based on mon->weapon_check. |
| 798 | * Returns 1 if the monster took time to do it, 0 if it did not. |
no test coverage detected