Vendor System #
The inventory can be combined with the AC_Vendor_Advanced to become a vendor. The vendor is based on a trade list, using categories to spawn items. You can tweak the sell and buy price multipliers for the vendor. Vendors have “Not interested” categories, a limited number of coins, and cannot buy if insufficient funds are available.
Vendor Logic #
Some vendor logic is set in the inventory component. The type should be vendor, and you can set the inventory name. In the vendor component, set a trade list. The item allocator component can restock or reset over time, but this may have a high-performance impact.
Trade List Data Table #
Set up trading details in the trade list data table, defining per item or category:
- Chance of the item spawning in the vendor’s inventory
- Restock amounts (random between min and max)
- Maximum inventory amounts
- Not interested lists
Trading with Vendors #
Both the player character and the vendor must have the vendor component to trade. The component uses a multiplier for selling and buying.
Buying Items #
When buying from a vendor, it checks if the player has enough resources. The required items vary depending on what is being bought, affected by item durability and vendor multipliers. If sufficient resources are available, the item is transferred from the vendor to the player’s inventory.
Selling Items #
Selling to a vendor uses similar functionality. It checks if the vendor has enough resources to buy the item and processes the transaction accordingly.
Tooltip #
The tooltip shows the amount of resource you can get by selling an item and the price of a stack from the vendor.