/tg/ Station 13 - Modules - TypesVar Details - Proc Details

Trader

A mob that has some dialogue options with radials, allows for selling items and buying em'

Vars

currency_nameThe name of the currency that is used when buying or selling items
productsFormat; list(TYPEPATH = list(PRICE, QUANTITY)) Associated list of items the NPC sells with how much they cost and the quantity available before a restock This list is filled by Initialize(), if you want to change the starting products, modify initial_products()
say_phrasesAssociated list of defines matched with list of phrases; phrase to be said is dealt by return_trader_phrase()
sell_soundSound used when item sold/bought
wanted_itemsA list of wanted items that the trader would wish to buy, each typepath has a assigned value, quantity and additional flavor text

Procs

InitializeInitializes the products and item demands of the trader
apply_sell_price_modsModifies the 'base' price of a item based on certain variables
buy_itemGenerates a radial of the items the NPC sells and lets the user try to buy one Arguments:
check_menuChecks if the user is ok to use the radial
discussTalk about what items are being sold/wanted by the trader and in what quantity or lore
exchange_sold_itemsHandles modifying/deleting the items to ensure that a proper amount is converted into cash; put into it's own proc to make the children of this not override a 30+ line sell_item()
generate_cashCreates an item equal to the value set by the proc and puts it in the user's hands if possible Arguments:
initial_productsReturns a list of the starting price/quanity/fluff text about the product listings; products = initial(products) doesn't work so this exists mainly for restock_products()
initial_wantedsReturns a list of the starting price/quanity/fluff text about the wanted items; wanted_items = initial(wanted_items) doesn't work so this exists mainly for renew_item_demands()
interactSets up the radials for the user and calls procs related to the actions the user wants to take
renew_item_demandsSets quantity of all wanted_items to initial(quanity); this proc is currently not called anywhere on the base class of traders
restock_productsSets quantity of all products to initial(quanity); this proc is currently not called anywhere on the base class of traders
return_trader_phraseDepending on the passed parameter/override, returns a randomly picked string out of a list
sell_itemChecks if an item is in the list of wanted items and if it is after a Yes/No radial returns generate_cash with the value of the item for the NPC Arguments:
spend_buyer_offhand_moneyCalculates the value of money in the hand of the buyer and spends it if it's sufficient
trader_buys_whatDisplays to the user what the trader is willing to buy and how much until a restock happens
trader_sells_whatDisplays to the user what the trader is selling and how much is in stock
try_sellTries to call sell_item on one of the user's held items, if fail gives a chat message

Var Details

currency_name

The name of the currency that is used when buying or selling items

products

Format; list(TYPEPATH = list(PRICE, QUANTITY)) Associated list of items the NPC sells with how much they cost and the quantity available before a restock This list is filled by Initialize(), if you want to change the starting products, modify initial_products()

say_phrases

Associated list of defines matched with list of phrases; phrase to be said is dealt by return_trader_phrase()

sell_sound

Sound used when item sold/bought

wanted_items

A list of wanted items that the trader would wish to buy, each typepath has a assigned value, quantity and additional flavor text

CHILDREN OF TYPEPATHS INCLUDED IN WANTED_ITEMS WILL BE TREATED AS THE PARENT IF NO ENTRY EXISTS FOR THE CHILDREN

As an additional note; if you include multiple children of a typepath; the typepath with the most children should be placed after all other typepaths Bad; list(/obj/item/milk = list(100, 1, ""), /obj/item/milk/small = list(50, 2, "")) Good; list(/obj/item/milk/small = list(50, 2, ""), /obj/item/milk = list(100, 1, "")) This is mainly because sell_item() uses a istype(item_being_sold, item_in_entry) to determine what parent should the child be automatically considered as If /obj/item/milk/small/spooky was being sold; /obj/item/milk/small would be the first to check against rather than /obj/item/milk

Format; list(TYPEPATH = list(PRICE, QUANTITY, ADDITIONAL_DESCRIPTION)) Associated list of items able to be sold to the NPC with the money given for them. The price given should be the "base" price; any price manipulation based on variables should be done with apply_sell_price_mods() ADDITIONAL_DESCRIPTION is any additional text added to explain how the variables of the item effect the price; if it's stack based, it's final price depends how much is in the stack EX; /obj/item/stack/sheet/mineral/diamond = list(500, INFINITY, ", per 2000 cm3 sheet of diamond") This list is filled by Initialize(), if you want to change the starting wanted items, modify initial_wanteds()

Proc Details

Initialize

Initializes the products and item demands of the trader

apply_sell_price_mods

Modifies the 'base' price of a item based on certain variables

Arguments:

buy_item

Generates a radial of the items the NPC sells and lets the user try to buy one Arguments:

check_menu

Checks if the user is ok to use the radial

Checks if the user is not a mob or is incapacitated or not adjacent to the source of the radial, in those cases returns FALSE, otherwise returns TRUE Arguments:

discuss

Talk about what items are being sold/wanted by the trader and in what quantity or lore

exchange_sold_items

Handles modifying/deleting the items to ensure that a proper amount is converted into cash; put into it's own proc to make the children of this not override a 30+ line sell_item()

Arguments:

generate_cash

Creates an item equal to the value set by the proc and puts it in the user's hands if possible Arguments:

initial_products

Returns a list of the starting price/quanity/fluff text about the product listings; products = initial(products) doesn't work so this exists mainly for restock_products()

initial_wanteds

Returns a list of the starting price/quanity/fluff text about the wanted items; wanted_items = initial(wanted_items) doesn't work so this exists mainly for renew_item_demands()

interact

Sets up the radials for the user and calls procs related to the actions the user wants to take

renew_item_demands

Sets quantity of all wanted_items to initial(quanity); this proc is currently not called anywhere on the base class of traders

restock_products

Sets quantity of all products to initial(quanity); this proc is currently not called anywhere on the base class of traders

return_trader_phrase

Depending on the passed parameter/override, returns a randomly picked string out of a list

Do note when overriding this argument, you will need to ensure pick(the list) doesn't get supplied with a list of zero length Arguments:

sell_item

Checks if an item is in the list of wanted items and if it is after a Yes/No radial returns generate_cash with the value of the item for the NPC Arguments:

spend_buyer_offhand_money

Calculates the value of money in the hand of the buyer and spends it if it's sufficient

trader_buys_what

Displays to the user what the trader is willing to buy and how much until a restock happens

trader_sells_what

Displays to the user what the trader is selling and how much is in stock

try_sell

Tries to call sell_item on one of the user's held items, if fail gives a chat message

Gets both items in the user's hands, and then tries to call sell_item on them, if both fail, he gives a chat message Arguments: