possibly bill for an object which the player has just modified */
| 749 | |
| 750 | /* possibly bill for an object which the player has just modified */ |
| 751 | void |
| 752 | costly_alteration(struct obj *obj, int alter_type) |
| 753 | { |
| 754 | coordxy ox, oy; |
| 755 | char objroom; |
| 756 | boolean learn_bknown; |
| 757 | const char *those, *them; |
| 758 | struct monst *shkp = 0; |
| 759 | |
| 760 | if (alter_type < 0 || alter_type >= SIZE(alteration_verbs)) { |
| 761 | impossible("invalid alteration type (%d)", alter_type); |
| 762 | alter_type = 0; |
| 763 | } |
| 764 | |
| 765 | ox = oy = 0; /* lint suppression */ |
| 766 | objroom = '\0'; /* ditto */ |
| 767 | if (carried(obj) || obj->where == OBJ_FREE) { |
| 768 | /* OBJ_FREE catches obj_no_longer_held()'s transformation |
| 769 | of crysknife back into worm tooth; the object has been |
| 770 | removed from inventory but not necessarily placed at |
| 771 | its new location yet--the unpaid flag will still be set |
| 772 | if this item is owned by a shop */ |
| 773 | if (!obj->unpaid) |
| 774 | return; |
| 775 | } else { |
| 776 | /* this get_obj_location shouldn't fail, but if it does, |
| 777 | use hero's location */ |
| 778 | if (!get_obj_location(obj, &ox, &oy, CONTAINED_TOO)) |
| 779 | ox = u.ux, oy = u.uy; |
| 780 | if (!costly_spot(ox, oy)) |
| 781 | return; |
| 782 | objroom = *in_rooms(ox, oy, SHOPBASE); |
| 783 | /* if no shop cares about it, we're done */ |
| 784 | if (!billable(&shkp, obj, objroom, FALSE)) |
| 785 | return; |
| 786 | } |
| 787 | |
| 788 | if (obj->quan == 1L) |
| 789 | those = "that", them = "it"; |
| 790 | else |
| 791 | those = "those", them = "them"; |
| 792 | |
| 793 | /* when shopkeeper describes the object as being uncursed or unblessed |
| 794 | hero will know that it is now uncursed; will also make the feedback |
| 795 | from `I x' after bill_dummy_object() be more specific for this item */ |
| 796 | learn_bknown = (alter_type == COST_UNCURS || alter_type == COST_UNBLSS); |
| 797 | |
| 798 | switch (obj->where) { |
| 799 | case OBJ_FREE: /* obj_no_longer_held() */ |
| 800 | case OBJ_INVENT: |
| 801 | if (learn_bknown) |
| 802 | set_bknown(obj, 1); |
| 803 | if (shkp) { |
| 804 | SetVoice(shkp, 0, 80, 0); |
| 805 | } |
| 806 | verbalize("You %s %s %s, you pay for %s!", |
| 807 | alteration_verbs[alter_type], those, simpleonames(obj), |
| 808 | them); |
no test coverage detected