… | |
… | |
826 | * buy item. |
826 | * buy item. |
827 | * |
827 | * |
828 | * Modified to fill available race: gold containers before dumping |
828 | * Modified to fill available race: gold containers before dumping |
829 | * remaining coins in character's inventory. |
829 | * remaining coins in character's inventory. |
830 | */ |
830 | */ |
831 | void |
831 | bool |
832 | sell_item (object *op, object *pl) |
832 | sell_item (object *op, object *pl) |
833 | { |
833 | { |
834 | sint64 amount = query_cost (op, pl, F_SELL | F_SHOP), extra_gain; |
834 | sint64 amount = query_cost (op, pl, F_SELL | F_SHOP), extra_gain; |
835 | |
835 | |
836 | if (pl == NULL || pl->type != PLAYER) |
836 | if (pl == NULL || pl->type != PLAYER) |
837 | { |
837 | { |
838 | LOG (llevDebug, "Object other than player tried to sell something.\n"); |
838 | LOG (llevDebug, "Object other than player tried to sell something.\n"); |
839 | return; |
839 | return false; |
840 | } |
840 | } |
841 | |
841 | |
842 | op->custom_name = 0; |
842 | op->custom_name = 0; |
843 | |
843 | |
844 | if (!amount) |
844 | if (!amount) |
845 | { |
845 | { |
846 | new_draw_info_format (NDI_UNIQUE, 0, pl, "We're not interested in %s.", query_name (op)); |
846 | new_draw_info_format (NDI_UNIQUE, 0, pl, "We're not interested in %s.", |
847 | |
847 | query_name (op)); |
848 | /* Even if the character doesn't get anything for it, it may still be |
848 | // elmex: change: the player now gets the item back if the shop is not |
849 | * worth something. If so, make it unpaid |
849 | // interested in it. |
850 | */ |
|
|
851 | if (op->value) |
|
|
852 | { |
|
|
853 | SET_FLAG (op, FLAG_UNPAID); |
|
|
854 | SET_FLAG (op, FLAG_PLAYER_SOLD); |
|
|
855 | } |
|
|
856 | |
|
|
857 | identify (op); |
|
|
858 | return; |
850 | return false; |
859 | } |
851 | } |
860 | |
852 | |
861 | /* We compare the price with the one for a player |
853 | /* We compare the price with the one for a player |
862 | * without bargaining skill. |
854 | * without bargaining skill. |
863 | * This determins the amount of exp (if any) gained for bargaining. |
855 | * This determins the amount of exp (if any) gained for bargaining. |
… | |
… | |
868 | if (extra_gain > 0) |
860 | if (extra_gain > 0) |
869 | change_exp (pl, extra_gain / 10, "bargaining", SK_EXP_NONE); |
861 | change_exp (pl, extra_gain / 10, "bargaining", SK_EXP_NONE); |
870 | |
862 | |
871 | pay_player (pl, amount); |
863 | pay_player (pl, amount); |
872 | |
864 | |
873 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You receive %s for %s.", query_cost_string (op, pl, F_SELL | F_SHOP), query_name (op)); |
865 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You receive %s for %s.", |
|
|
866 | query_cost_string (op, pl, F_SELL | F_SHOP), query_name (op)); |
874 | pl->play_sound (sound_find ("shop_sell")); |
867 | pl->play_sound (sound_find ("shop_sell")); |
875 | |
868 | |
876 | SET_FLAG (op, FLAG_UNPAID); |
869 | SET_FLAG (op, FLAG_UNPAID); |
877 | identify (op); |
870 | identify (op); |
|
|
871 | |
|
|
872 | return true; |
878 | } |
873 | } |
879 | |
874 | |
880 | /* returns a double that is the ratio of the price that a shop will offer for |
875 | /* returns a double that is the ratio of the price that a shop will offer for |
881 | * item based on the shops specialisation. Does not take account of greed, |
876 | * item based on the shops specialisation. Does not take account of greed, |
882 | * returned value is between SPECIALISATION_EFFECT and 1. |
877 | * returned value is between SPECIALISATION_EFFECT and 1. |