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

Trader NPC Component

Manages the barks and the stocks of the traders Also manages the interactive radial menu

Vars

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()
radial_icons_cacheContains images of all radial icons
trader_dataContains information of a specific trader
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

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:
can_tradeReturns if the trader is conscious and its combat mode is disabled.
check_menuChecks if the customer 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 its 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:
on_attack_handIf our trader is alive, and the customer left clicks them with an empty hand without combat mode
open_npc_optionsGenerates a radial of the initial radials of the NPC Called via asynch, due to the sleep caused by show_radial_menu Arguments:
renew_item_demandsSets quantity of all wanted_items to initial(quanity); this proc is currently called during initialize
restock_productsSets quantity of all products to initial(quanity); this proc is currently called during initialize
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 customer what the trader is willing to buy and how much until a restock happens
trader_sells_whatDisplays to the customer what the trader is selling and how much is in stock
try_sellTries to call sell_item on one of the customer's held items, if fail gives a chat message

Var Details

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()

radial_icons_cache

Contains images of all radial icons

trader_data

Contains information of a specific trader

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, its final price depends how much is in the stack EX; /obj/item/stack/sheet/mineral/diamond = list(500, INFINITY, ", per 100 cm3 sheet of diamond") This list is filled by Initialize(), if you want to change the starting wanted items, modify initial_wanteds()

Proc Details

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:

can_trade

Returns if the trader is conscious and its combat mode is disabled.

check_menu

Checks if the customer is ok to use the radial

Checks if the customer 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 its 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:

on_attack_hand

If our trader is alive, and the customer left clicks them with an empty hand without combat mode

open_npc_options

Generates a radial of the initial radials of the NPC Called via asynch, due to the sleep caused by show_radial_menu Arguments:

renew_item_demands

Sets quantity of all wanted_items to initial(quanity); this proc is currently called during initialize

restock_products

Sets quantity of all products to initial(quanity); this proc is currently called during initialize

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 customer what the trader is willing to buy and how much until a restock happens

trader_sells_what

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

try_sell

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

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