Vendors
The vendor system has been setup similarly to the Loot Window system. It consists of 3 widgets:
- W_VendorWindow: This is the main Vendor window widget. It has an Event “InitVendorLoot” which will basically construct the widget according to the Items[] array. The array gets populated inside BP_Vendor according to the setup VendorItems[]. This event will also get called from BP_Vendor when the player interacts with the NPC through Event ActorOnClicked.
- W_VendorItem: This is the vendor item widget. For each item inside BP_Vendor, one of this widget will be constructed and added into W_VendorWindow through its “InitVendorLoot” event.
- W_VendorStacker: This is an altered copy of W_StackSplitter, adjusted in a way to work with buying different amounts of stackable items from a vendor.
Inspect these widgets - they are thoroughly commented out and will tell you what each event/function is for.
BP_Vendor Handles the Vendor Window
BP_Vendor has a variable VendorItems(map) which has a name (ItemID) and an integer (ItemAmountToSell). On BeginPlay, the function “SetupCurrentVendorItems” converts this map into CurrentVendorItems (S_ItemInfo array).
When interacted with (Event OnActorClicked RMB), the Vendor actor calls Function “AttemptShowVendorWindow”, which toggles W_VendorWindow then sets it up according to CurrentVendorItems[].