mlheur Posted July 23, 2016 Share Posted July 23, 2016 (edited) I'm working on a mod to let player dump loot items on a vendor to sell on consignment. I've got pretty much everything working as I want except limiting the loot to stuff the vendor actually sells. In order to not clobber the existing vendor I dynamically add a new NPC (Consignment Agent) for each vendor once I've invested in them. The Consignment Agent is mostly just a container to use to hold the consignment items and sell a random number of items per day on the vendor's behalf. I use ShowGiftMenu() to dump items on the agent for sale, so that I can feed in a FormList to limit what items can be given. I can get from the vendor to his vendor factions, that part's easy. What I can't do is get from the faction to the form list the vendor uses to limit ShowBarterMenu() items. Simply putting the Consignment Agent in the same factions as the vendor doesn't help because ShowGiftMenu() doesn't honour these, and I don't want to use ShowBarterMenu() because I don't want to perform any financial transactions when dumping the loot, nor when taking back any unsold loot later on. I was really hoping the Faction script would have some more functions to support CK's faction vendor tab. Something like this: bool Faction.IsVendorEnabled() FormList Faction.GetVendorBuySellList() bool Faction.IsNotBuySell() bool Faction.OnlyBuysStolenItems() If I had these then I could obtain the filter(s) to use on ShowGiftMenu(). What I'm wondering is if there's some function that exists to check if a FormList belongs to a Faction's Vendor Buy/Sell List. I've read through the whole CK pages on Faction, FormList, ObjectReference, Actor, ActorBase and Form; but couldn't find anything that seems to check if a FormList IsIn() a Faction. I can see the VEND item under the FACT in the ESP, I just don't know how to get at it from script... I think I could achieve what I want by hard-coding each investable vendor and their associated VendorItems* FormList; or maybe creating a hard-coded map of vendor Factions to their FormLists, but that's not portable and would need compatibility patches for any mods that adds new Factions or FormLists. I haven't uploaded my mod yet because it's still in Alpha status, needs a bit more polish before I can move it to Beta, but it's far enough along that I can make it available if it would help get an answer. My last resort options, as I see them: see if I can add the GetVendorBuySellList to SKSE; or use the Barter menu and "refund" each item through OnItemAdded()/OnItemRemoved() as it's sold to the Consignment Agent. The first option is a little out of my league, and the second is a bad hack. Edited July 23, 2016 by mlheur Link to comment Share on other sites More sharing options...
IsharaMeradin Posted July 23, 2016 Share Posted July 23, 2016 Not sure if an NPC with ShowGiftMenu open behaves like a container with normal access menu open. If it does, you might want to consider this... A script on the NPC using OnItemAdded with checks to allow or return items depending upon whether or not the items are in the allowable lists. Here is an example for what I am talking about with a container. Perhaps you can adapt it for your situation (an NPC inventory is basically a container)http://www.creationkit.com/index.php?title=Complete_Example_Scripts#Script_a_container_that_only_accepts_certain_types_of_items Link to comment Share on other sites More sharing options...
mlheur Posted July 23, 2016 Author Share Posted July 23, 2016 Ha! So I started digging in SKSE, the function exists in the source code, and it exists in Faction.psc - it's just not documented on the CK Wiki. From PapyrusFaction.cpp registry->RegisterFunction( new NativeFunction0 <TESFaction, BGSListForm*>("GetBuySellList", "Faction", papyrusFaction::GetBuySellList, registry)); Link to comment Share on other sites More sharing options...
mlheur Posted July 24, 2016 Author Share Posted July 24, 2016 (edited) For anyone trying to use this in the future, the Faction.IsVendor() from skse 1.7.3 (release 48) is bugged for TESV.exe 1.9.32.0. As far as I can tell from skse source it should be running OK but checking all the Factions on Adrianne Avenicci it says the [CrimeFactionWhiterun "Whiterun" [FACT:000267EA]] IsVendor() is true and GetBuySellList() is none, and [WhiterunWarmaidensFaction "Whiterun Warmaiden's Faction" [FACT:00093B22]] IsVendor() is false and GetBuySellList() returns the correct [FormList < (00066333)>]. A better test for IsVendor(), until I can root out the issues with skse, is to call GetBuySellList() regardless and just test if it returns none.Current theory is that skse is assuming the wrong endianness in the DATA flags of the ESP. Looking at the dumps below, it seems GetVendorEndHour() is returning GetVendorStartHour() instead. I checked the code and it is indeed returning start hour, cut & paste error. I'll be contacting the skse team - I don't necessarily expect them to fix these after so long, but with the remastered edition coming out it might breathe some life into this. Here's a dump of whiterun crime faction [07/23/2016 - 10:26:55PM] Info: DumpFaction( akFaction=[[Faction < (000267EA)>]] ) [07/23/2016 - 10:26:55PM] Info: Name=[Whiterun] [07/23/2016 - 10:26:55PM] Info: IsVendor=[TRUE] [07/23/2016 - 10:26:55PM] Info: OnlyBuysStolenItems=[False] [07/23/2016 - 10:26:55PM] Info: GetVendorStartHour=[0] [07/23/2016 - 10:26:55PM] Info: GetVendorEndHour=[0] [07/23/2016 - 10:26:55PM] Info: GetVendorRadius=[0] [07/23/2016 - 10:26:55PM] Info: GetMerchantContainer=[None] [07/23/2016 - 10:26:55PM] Info: IsNotSellBuy=[False] [07/23/2016 - 10:26:55PM] Info: GetBuySellList=[None] and the warmaiden's faction [07/23/2016 - 10:26:59PM] Info: DumpFaction( akFaction=[[Faction < (000C6E40)>]] ) [07/23/2016 - 10:26:59PM] Info: Name=[Warmaidens] [07/23/2016 - 10:26:59PM] Info: IsVendor=[False] [07/23/2016 - 10:26:59PM] Info: OnlyBuysStolenItems=[False] [07/23/2016 - 10:26:59PM] Info: GetVendorStartHour=[6] [07/23/2016 - 10:26:59PM] Info: GetVendorEndHour=[6] [07/23/2016 - 10:26:59PM] Info: GetVendorRadius=[600] [07/23/2016 - 10:26:59PM] Info: GetMerchantContainer=[[ObjectReference < (0009CAFE)>]] [07/23/2016 - 10:26:59PM] Info: IsNotSellBuy=[False] [07/23/2016 - 10:26:59PM] Info: GetBuySellList=[[FormList < (00066333)>]] Edited July 24, 2016 by mlheur Link to comment Share on other sites More sharing options...
Recommended Posts