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

Function costly_alteration

src/mkobj.c:751–826  ·  view source on GitHub ↗

possibly bill for an object which the player has just modified */

Source from the content-addressed store, hash-verified

749
750/* possibly bill for an object which the player has just modified */
751void
752costly_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);

Callers 15

chweponFunction · 0.85
H2Opotion_dipFunction · 0.85
potion_dipFunction · 0.85
obj_no_longer_heldFunction · 0.85
breakchestlockFunction · 0.85
dog_eatFunction · 0.85
touchfoodFunction · 0.85
costly_tinFunction · 0.85
erode_objFunction · 0.85
trapeffect_anti_magicFunction · 0.85
cancel_itemFunction · 0.85
drain_itemFunction · 0.85

Calls 10

get_obj_locationFunction · 0.85
costly_spotFunction · 0.85
in_roomsFunction · 0.85
billableFunction · 0.85
set_bknownFunction · 0.85
verbalizeFunction · 0.85
simpleonamesFunction · 0.85
bill_dummy_objectFunction · 0.85
stolen_valueFunction · 0.85
impossibleFunction · 0.70

Tested by

no test coverage detected