[Tutorial] How to fix the vanishing merchant stock bug

Post a reply

Confirmation code
Enter the code exactly as it appears. All letters are case insensitive.
View more smilies
Smilies
:sn-1: :sn-2: :sn-3: :sn-4: :sn-5: :sn-6: :sn-7: :sn-8: :sn-9: :sn-10: :sn-11: :sn-12: :sn-13: :sn-14: :sn-15: :sn-16: :sn-17: :sn-18: :sn-19: :sn-20: :sn-21: :sn-22: :sn-23: :sn-24: :sn-25: :sn-26: :sn-27: :sn-28: :sn-29: :sn-30: :sn-31: :sn-32: :sn-33: :sn-34: :sn-35: :sn-36: :sn-37: :D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :arrow: :| :mrgreen: :geek: :ugeek:
View more smilies

BBCode is ON
[img] is ON
[url] is ON
Smilies are ON

Topic review

I accept the Privacy policy.

   
  • Saved at

Expand view Topic review: [Tutorial] How to fix the vanishing merchant stock bug

Re: How to fix the vanishing merchant stock bug

by Altbert » Wed Feb 01, 2023 6:56 pm

Never cared for followers, but long ago, at least a few years, I created a personal mod in which I could summon a merchant ghost with the appearance of Belethor, but it didn't feel right. The ghost always wandered off and I had to run after him.

Floating Island of Legends has a summonable Dwemer barrel (no, not BA's home), but it can only be used when near overencumbered (95% or more), based on current carrying capacity. Still have to add another condition: you can only summon the barrel when it's empty!

Since Floating Island is one of my largest mods since ever, I was struggling with compiling a loose file archive. Sure, I can create a BSA in the Creation Kit, but this may often include assets that are not really necessary (vanilla assets or assets from other masters). Also, when creating a BSA, the CK also skips assets I do want in my archive. So I took a new project on my hand in Visual Studio to use the <name>.achlist from the CK, which lists all the assets, and create a folder/file structure outside the Skyrim/Data folder, to use 7-Zip to create a loose file archive.

But I think I made the wrong choice! I use VB instead of C# to create the tools, because I thought it would be a bit more easy. Wrong choice! Working with VB was too long ago. Too late now as half of the tool has already been finished.

Re: How to fix the vanishing merchant stock bug

by Avrie » Wed Jan 25, 2023 12:22 pm

Interesting work around. I never noticed the bug, but I don't usually summon merchants. I do however use "Seluna and Sharleen Merchant Followers SE" one of the oldrim ports by ff7legend. So far I've never actually used them as followers. They hang in Whiterun and I just use them to empty my excess inventory. I wonder if they suffer from the same bug if I actually use them as followers?

https://www.nexusmods.com/skyrimspecial ... mods/45797 (Just a mod of convenience)

[Tutorial] How to fix the vanishing merchant stock bug

by Selene310187 » Sun Jan 22, 2023 3:43 pm

The vanishing merchant stock bug can occur with summonable merchants and merchant followers.

Sometimes these NPCs can loose their connection to their merchant chest. I experienced this during the development of SESM and the Dremora Merchant Tweak (old and deleted mod; I'm working on a rewrite with more features). Regarding the merchants of SESM, they couldn't access the chest containing the stock (leveled items, potions, armors, etc.) anymore after they became followers and the player entering another cell. If you reload a save and summon Dragonborn's Dremora Merchant, the merchant will not have any gold or items in his stock. Resummoning him solves the problem temporarily.

I solved both problems by implementing "invisible" middlemen. The middlemen are NPCs in a remote (interior) cell. They will trade with the player on behalf of the original merchants using the default merchant factions and without any follower factions. They are named after the original merchants so that the player will not notice the workaround ;).

Regarding the Dremora Merchant, I duplicated the NPC, the merchant faction and the merchant chest. Then I put the duplicated NPC (who is the middleman) and the duplicated chest into the remote cell. I replaced the merchant faction of the duplicated NPC with the duplicated merchant faction and let the duplicated faction point to the duplicated merchant chest. I also removed the gold from the chest as I add it to the middleman via script.

I modified the trading dialogue script fragment:
 

Code: Select all

Scriptname DLC2_TIF__0201EEAC Extends TopicInfo Hidden

Function Fragment_0(ObjectReference akSpeakerRef)
Actor akSpeaker = akSpeakerRef as Actor

(GetOwningQuest() as SESM_Dremora_Merchant_Tweak).Barter()
;akSpeaker.ShowBarterMenu()

EndFunction
I commented the ShowBarterMenu() part out and let the script fragment point to the custom Barter() function in the quest script (GetOwingQuest() part)


The original quest script with some additional annotations:
 

Code: Select all

Scriptname SESM_Dremora_Merchant_Tweak extends Quest  

SESMvariablesStorageScript property vars auto  
ObjectReference Property MerchantChest auto
Actor Property Middleman Auto

; used properties from SESMvariablesStorageScript:
; GlobalVariable Property MerchantGold Auto
; MiscObject Property gold Auto
; GlobalVariable Property MerchantRestock Auto


Function Barter()
MerchantChest.removeitem(vars.gold, MerchantChest.getitemcount(vars.gold))
Middleman.removeitem(vars.gold, Middleman.getitemcount(vars.gold))

If (vars.MerchantRestock.GetValueInt() == 2)
MerchantChest.reset()
endif

Middleman.additem(vars.gold, vars.MerchantGold.getvalueint())

Middleman.showbartermenu() 
EndFunction
You can ignore most of the script as only the last line of the custom Barter() function and the second and third properties are important.

The shortened version of the quest script:
 

Code: Select all

Scriptname SESM_Dremora_Merchant_Tweak extends Quest  


ObjectReference Property MerchantChest auto ; the duplicated merchant chest in the remote cell
Actor Property Middleman Auto ; the duplicated NPC in the remote cell

Function Barter()
Middleman.showbartermenu()
EndFunction
I attached he quest script to the quest DLC2Init which contains the dialogue of the Dremora Merchant.


The middleman will never leave the cell with his merchant chest and so he will never loose the connection to the chest and the stock.

Top