![]() |
Crossfire Server, Trunk
1.75.0
|
Go to the source code of this file.
Functions | |
int | can_pay (object *pl) |
Checks all unpaid items in op's inventory, adds up all the money they have, and checks that they can actually afford what they want to buy. More... | |
char * | cost_approx_str (const object *obj, object *who) |
Return a textual cost approximation in a newly-allocated string. More... | |
char * | cost_str (uint64_t cost) |
char * | cost_string_from_value (uint64_t cost, int largest_coin) |
Converts a price to number of coins. More... | |
int | pay_for_amount (uint64_t to_pay, object *pl) |
Takes the amount of money from the the player inventory and from it's various pouches using the pay_from_container() function. More... | |
int | pay_for_item (object *op, object *pl, uint64_t reduction) |
Player attemps to buy an item, if she has enough money then remove coins as needed from active containers. More... | |
uint64_t | price_approx (const object *obj, object *who) |
Adjust the value of the given item based on the player's skills. More... | |
uint64_t | query_money (const object *op) |
Determine the amount of money the given object contains, including what is inside containers. More... | |
void | sell_item (object *op, object *pl) |
Player is selling an item. More... | |
double | shop_approval (const mapstruct *map, const object *player) |
Return the approval ratio for a shop for a given player. More... | |
int | shop_describe (const object *op) |
Give the player a description of the shop on their current map. More... | |
int | shop_pay_unpaid (object *pl, object *op) |
Pay for each unpaid item carried by a player, including those inside containers. More... | |
uint64_t | shop_price_buy (const object *obj, object *who) |
Adjust the value of an item to be bought based on the player's bargaining skill and charisma. More... | |
uint64_t | shop_price_sell (const object *obj, object *who) |
Adjust the value of an item to be sold based on the player's bargaining skill and charisma. More... | |
int can_pay | ( | object * | pl | ) |
Checks all unpaid items in op's inventory, adds up all the money they have, and checks that they can actually afford what they want to buy.
Prints appropriate messages to the player.
pl | player trying to bug. |
1 | player could buy the items. |
0 | some items can't be bought. |
Definition at line 784 of file shop.cpp.
References buf, archetype::clone, coins, cost_str(), count_coins(), count_unpaid(), draw_ext_info, find_archetype(), object::inv, llevError, LOG(), make_list_like(), MAX_BUF, MSG_TYPE_SHOP, MSG_TYPE_SHOP_PAYMENT, object::name_pl, NDI_UNIQUE, NUM_COINS, unpaid_count::pl, PLAYER, query_money(), and object::type.
Referenced by cfapi_player_can_pay(), and shop_mat_type_move_on().
Return a textual cost approximation in a newly-allocated string.
obj | item to query the price of, must not be NULL. |
who | player asking for the price, must not be NULL. |
Definition at line 312 of file shop.cpp.
References buf, archetype::clone, cost_str(), find_next_coin(), find_skill_by_number(), get_typedata(), typedata::identifyskill, typedata::identifyskill2, LARGEST_COIN_GIVEN, MONEY, object::name, object::name_pl, price_approx(), real_money_value(), SK_BARGAINING, stringbuffer_append_printf(), stringbuffer_append_string(), stringbuffer_delete(), stringbuffer_finish(), stringbuffer_new(), object::type, and object::value.
Referenced by examine().
char* cost_str | ( | uint64_t | cost | ) |
Definition at line 308 of file shop.cpp.
References cost_string_from_value(), and LARGEST_COIN_GIVEN.
Referenced by can_pay(), cost_approx_str(), examine(), pick_up_object(), sell_item(), shop_describe(), and shop_pay_unpaid_callback().
char* cost_string_from_value | ( | uint64_t | cost, |
int | largest_coin | ||
) |
Converts a price to number of coins.
While cost is 64 bit, the number of any coin is still really limited to 32 bit (size of nrof field). If it turns out players have so much money that they have more than 2 billion platinum coins, there are certainly issues - the easiest fix at that time is to add a higher denomination (mithril piece with 10,000 silver or something)
cost | value to transform to currency. |
largest_coin | maximum coin to give the price into, should be between 0 and NUM_COINS - 1. |
Definition at line 220 of file shop.cpp.
References buf, archetype::clone, done, find_next_coin(), object::name, NUM_COINS, stringbuffer_append_printf(), stringbuffer_append_string(), stringbuffer_finish(), stringbuffer_new(), UINT32_MAX, and object::value.
Referenced by cfapi_cost_string_from_value(), and cost_str().
int pay_for_amount | ( | uint64_t | to_pay, |
object * | pl | ||
) |
Takes the amount of money from the the player inventory and from it's various pouches using the pay_from_container() function.
to_pay | amount to pay. |
pl | player paying. |
Definition at line 404 of file shop.cpp.
References CONTAINER, fix_object(), FLAG_APPLIED, FMT64U, FOR_INV_FINISH, FOR_INV_PREPARE, llevError, LOG(), pay_from_container(), QUERY_FLAG, and query_money().
Referenced by cfapi_object_pay_amount().
Player attemps to buy an item, if she has enough money then remove coins as needed from active containers.
Also handles bargaining experience.
op | object to buy. |
pl | player buying. |
reduction | positive or null price reduction, must be below the price of the item. |
Definition at line 444 of file shop.cpp.
References CONTAINER, FALSE, fix_object(), FLAG_APPLIED, FLAG_WAS_WIZ, FMT64U, FOR_INV_FINISH, FOR_INV_PREPARE, llevError, LOG(), pay_from_container(), QUERY_FLAG, query_money(), Settings::real_wiz, SET_FLAG, settings, and shop_price_buy().
Referenced by cfapi_object_pay_item(), and shop_pay_unpaid_callback().
Adjust the value of the given item based on the player's skills.
This function should only be used when calculating "you reckon" prices.
obj | item in question. Must not be NULL. |
who | player trying to judge the value of the item. Must not be NULL. |
Definition at line 71 of file shop.cpp.
References object::count, find_skill_by_number(), get_typedata(), typedata::identifyskill, typedata::identifyskill2, object::level, llevError, LOG(), object::name, price_base(), and object::type.
Referenced by cost_approx_str().
uint64_t query_money | ( | const object * | op | ) |
Determine the amount of money the given object contains, including what is inside containers.
op | Player or container object |
Definition at line 373 of file shop.cpp.
References CONTAINER, FLAG_APPLIED, FOR_INV_FINISH, FOR_INV_PREPARE, llevError, LOG(), MONEY, PLAYER, QUERY_FLAG, and object::type.
Referenced by can_pay(), cfapi_object_query_money(), pay_for_amount(), pay_for_item(), and shop_pay_unpaid_callback().
Player is selling an item.
Give money, print appropriate messages.
Will fill applied money containers before dumping remaining coins in character's inventory.
op | object to sell. |
pl | player. Shouldn't be NULL or non player. |
Definition at line 915 of file shop.cpp.
References change_exp(), archetype::clone, coins, compute_price_variation_with_bargaining(), CONTAINER, cost_str(), unpaid_count::count, CUSTOM_NAME_FIELD, draw_ext_info_format(), esrv_update_item(), EVENT_GSOLD, EVENT_SELLING, events_execute_global_event(), events_execute_object_event(), find_archetype(), FLAG_APPLIED, FLAG_UNPAID, FOR_INV_FINISH, FOR_INV_PREPARE, identify(), LARGEST_COIN_GIVEN, llevDebug, llevError, LOG(), MAX_BUF, MAX_SELL_EXTRA, MSG_TYPE_SHOP, MSG_TYPE_SHOP_SELL, NDI_UNIQUE, object::nrof, object_copy(), object_insert_in_ob(), object_new(), object_set_value(), unpaid_count::pl, PLAYER, unpaid_count::price, QUERY_FLAG, query_name(), SCRIPT_FIX_ALL, SET_FLAG, shop_price_sell(), SK_EXP_NONE, object::type, UPD_WEIGHT, object::value, and object::weight.
Referenced by drop_object().
Return the approval ratio for a shop for a given player.
This is based on both the race of the shopkeeper and the player.
map | Map with a shop |
player | Player in question |
Definition at line 1081 of file shop.cpp.
References NEUTRAL_RATIO, and mapstruct::shoprace.
Referenced by shop_describe(), shop_efficiency(), and shop_mat_type_move_on().
int shop_describe | ( | const object * | op | ) |
Give the player a description of the shop on their current map.
This is used for the bargaining skill.
op | Non-null player to describe the shop to |
Give the player a description of the shop on their current map.
op | who is examining the shop. |
Definition at line 1144 of file shop.cpp.
References cost_str(), draw_ext_info, draw_ext_info_format(), shopitems::index, make_list_like(), object::map, MAX_BUF, MSG_TYPE_SHOP, MSG_TYPE_SHOP_LISTING, MSG_TYPE_SHOP_MISC, shopitems::name, shopitems::name_pl, NDI_UNIQUE, PLAYER, shop_approval(), mapstruct::shopgreed, mapstruct::shopitems, mapstruct::shopmax, mapstruct::shopmin, mapstruct::shoprace, shopitems::strength, and object::type.
Referenced by do_skill().
Pay for each unpaid item carried by a player, including those inside containers.
It is a good idea to call can_pay() before using this function, because items are paid for here in no particular order.
pl | Player making purchase |
op | Container to examine, usually the same player object |
0 | Player still has unpaid items |
1 | Player paid for all unpaid items |
Pay for each unpaid item carried by a player, including those inside containers.
pl | player who is buying items. |
op | first potentially unpaid item. |
Definition at line 896 of file shop.cpp.
References unpaid_count::pl, shop_pay_unpaid_callback(), and unpaid_iter().
Referenced by shop_mat_type_move_on().
Adjust the value of an item to be bought based on the player's bargaining skill and charisma.
This should only be used if the player is in a shop.
obj | item in question. Must not be NULL. |
who | player trying to judge the value of the item. Must not be NULL. |
Definition at line 128 of file shop.cpp.
References object::arch, llevDebug, LOG(), archetype::name, NROF(), object_get_value(), object_value_set(), PLAYER, price_base(), shop_efficiency(), and object::type.
Referenced by count_unpaid_callback(), examine(), pay_for_item(), pick_up_object(), and shop_pay_unpaid_callback().
Adjust the value of an item to be sold based on the player's bargaining skill and charisma.
This should only be used if the player is in a shop.
obj | item in question. Must not be NULL. |
who | player trying to judge the value of the item. Must not be NULL. |
Definition at line 154 of file shop.cpp.
References object::arch, llevDebug, LOG(), object::map, archetype::name, NROF(), object_get_value(), PLAYER, price_base(), shop_efficiency(), shop_specialisation_ratio(), object::type, and value_limit().
Referenced by examine(), and sell_item().