Jump to content

DOWNLOAD MODS

Are you looking for something shiny for your load order? We have many exclusive mods and resources you won't find anywhere else. Start your search now...

LEARN MODDING

Ready to try your hand at making your own mod creations? Visit the Enclave, the original ES/FO modding school, and learn the tricks of the trade from veteran modders...

JOIN THE ALLIANCE

Membership is free and registering unlocks image galleries, project hosting, live chat, unlimited downloads, & more...

[Help Request] Adding Items to a Merchant / Vendor Chest


Recommended Posts

Introduction: Greetings everyone.  I have an issue that I am hoping would prove a simple resolution to the more experienced script writers among you.  After searching, I have been unable to find the answer myself so here we are and I thank you in advance just for taking a look at my problem.

 

Issue/Goal: I wanted a way to add an item to what a merchant sells without changing/affecting the rest of what they sell.  Because I wanted to reduce the likelihood of mod conflict, I thought a script would be the best way to go.  I do not wish to add the item to any level lists as I think/believe this would result in other vendors possibly having the items as well as enemies.  And in my search for a solution, it would seem AddItem alone would not suffice due to the fact that a merchant's chest respawns/refreshes.

 

Problems With What I Found: I am still pretty novice at several aspects of this so despite finding what I believe to be the answer, I am not sure how to specifically get it to work (such as do I need to set up the aliases in the quest or is it defined in the script or both... if I have to set them up in the quest, which settings/checkboxes are used... where exactly do I tell the script to add my item to the chest).  The answer may be obvious, especially with what I found, but while I understand what I found much better than I  would have a few months ago, I'm still pretty green with scripting and quest making.

 

What I Found: Because of how the site looks when you're not a member (it doesn't show anyone's name and any code shown is smushed together without spaces so it has to be manually separated) I do not know who to credit for this (though it may have been Chesko) but this is basically what was said as an answer to someone else asking a similar question as what I am asking...

 

	scriptname _WL_VendorStock extends Quest
	ReferenceAlias property RiverwoodTraderChestAlias auto
	ReferenceAlias property CaravanAChestAlias auto
	ReferenceAlias property CaravanBChestAlias auto
	ReferenceAlias property CaravanCChestAlias auto
	ReferenceAlias property AvalAtheronChestAlias auto
	ReferenceAlias property BethethorsChestAlias auto
	ReferenceAlias property BirnaChestAlias auto
	ReferenceAlias property BrandChestAlias auto
	ReferenceAlias property PawnedPrawnChestAlias auto
	ReferenceAlias property WhiterunFraliaChestAlias auto
	ReferenceAlias property SolitudeBitsAndPiecesChestAlias auto
	ReferenceAlias property ArnleifChestAlias auto
	ReferenceAlias property GrayPineGoodsChestAlias auto
	ReferenceAlias property NiranyeChestAlias auto
	ObjectReference property RiverwoodTraderMerchantContainer auto
	ObjectReference property CaravanAChestREF auto
	ObjectReference property CaravanBChestREF auto
	ObjectReference property CaravanCChestREF auto
	ObjectReference property AvalAtheronChest auto
	ObjectReference property BethethorsMerchantChestRef auto
	ObjectReference property BirnaChest auto
	ObjectReference property BrandChest auto
	ObjectReference property PawnedPrawnChest auto
	ObjectReference property WhiterunFraliaChest auto
	ObjectReference property MerchantSolitudeBitsAndPiecesChestRef auto
	ObjectReference property ArnleifChest auto
	ObjectReference property GrayPineGoodsChest auto
	ObjectReference property NiranyeChest auto
	Event OnInit();Stock lantern items
	FillAllAliases()
	RegisterForSingleUpdateGameTime(24)
	endEvent
	Event OnUpdateGameTime();Restocks inventory for all merchants once per day
	ClearAllAliases()FillAllAliases()RegisterForSingleUpdateGameTime(24)
	endEvent
	Function ClearAllAliases();Clear all merchant chest aliases
	RiverwoodTraderChestAlias.Clear()
	CaravanAChestAlias.Clear()
	CaravanBChestAlias.Clear()
	CaravanCChestAlias.Clear()
	AvalAtheronChestAlias.Clear()
	BethethorsChestAlias.Clear()
	BirnaChestAlias.Clear()
	BrandChestAlias.Clear()
	PawnedPrawnChestAlias.Clear()
	WhiterunFraliaChestAlias.Clear()
	SolitudeBitsAndPiecesChestAlias.Clear()
	ArnleifChestAlias.Clear()
	GrayPineGoodsChestAlias.Clear()
	NiranyeChestAlias.Clear()
	endFunction
	Function FillAllAliases();Fill aliases to apply their inventories
	RiverwoodTraderChestAlias.ForceRefIfEmpty(RiverwoodTraderMerchantContainer)
	CaravanAChestAlias.ForceRefIfEmpty(CaravanAChestREF)
	CaravanBChestAlias.ForceRefIfEmpty(CaravanBChestREF)
	CaravanCChestAlias.ForceRefIfEmpty(CaravanCChestREF)
	AvalAtheronChestAlias.ForceRefIfEmpty(AvalAtheronChest)
	BethethorsChestAlias.ForceRefIfEmpty(BethethorsMerchantChestRef)
	BirnaChestAlias.ForceRefIfEmpty(BirnaChest)
	BrandChestAlias.ForceRefIfEmpty(BrandChest)
	PawnedPrawnChestAlias.ForceRefIfEmpty(PawnedPrawnChest)
	WhiterunFraliaChestAlias.ForceRefIfEmpty(WhiterunFraliaChest)
	SolitudeBitsAndPiecesChestAlias.ForceRefIfEmpty(MerchantSolitudeBitsAndPiecesChestRef)
	ArnleifChestAlias.ForceRefIfEmpty(ArnleifChest)
	GrayPineGoodsChestAlias.ForceRefIfEmpty(GrayPineGoodsChest)
	NiranyeChestAlias.ForceRefIfEmpty(NiranyeChest)
	endFunction
	

 

And I know I have to make more changes and do other things (what exactly I don't know which is why I'm here) but here is what I changed so far...

	ScriptName _WL_VendorStock extends Quest
	ReferenceAlias property MerchantRiverwoodTraderChestAlias auto
	ReferenceAlias property MerchantWCollegeFaraldaChestAlias auto
	ReferenceAlias property MerchantWCollegeEnthirChestAlias auto
	ReferenceAlias property MerchantWhiterunBelethorsGoodsChestAlias auto
	ObjectReference property MerchantRiverwoodTraderChest auto
	ObjectReference property MerchantWCollegeFaraldaChest auto
	ObjectReference property MerchantWCollegeEnthirChest auto
	ObjectReference property MerchantWhiterunBelethorsGoodsChest auto
	Armor property Amulet auto
	Armor property Ring auto
	
	Event OnInit();Stock lantern items
	FillAllAliases()
	RegisterForSingleUpdateGameTime(24)
	endEvent
	Event OnUpdateGameTime();Restocks inventory for all merchants once per day
	ClearAllAliases()
	FillAllAliases()
	RegisterForSingleUpdateGameTime(24)
	end
	Event
	Function ClearAllAliases();Clear all merchant chest aliases
	MerchantRiverwoodTraderChestAlias.Clear()
	MerchantWCollegeFaraldaChestAlias.Clear()
	MerchantWCollegeEnthirChestAlias.Clear()
	MerchantWhiterunBelethorsGoodsChestAlias.Clear()
	endFunction
	Function FillAllAliases();Fill aliases to apply their inventories
	MerchantRiverwoodTraderChestAlias.ForceRefIfEmpty(MerchantRiverwoodTraderChest)
	MerchantWCollegeFaraldaChestAlias.ForceRefIfEmpty(MerchantWCollegeFaraldaChest)
	MerchantWCollegeEnthirChestAlias.ForceRefIfEmpty(MerchantWCollegeEnthirChest)
	MerchantWhiterunBelethorsGoodsChestAlias.ForceRefIfEmpty(MerchantWhiterunBelethorsGoodsChest)
	endFunction
	

 

Thank you all again for any help you can give.

Link to comment
Share on other sites

Here's an Update

So I tried to modify the method shown above to use Addform and LeveledItem Properties.  My Script compiles, and I see my Debug Notification fire off at least once, but still, my item is not being sold by any of the merchants that have the appropriate Leveled List.

 

Here is my current code:

 

LeveledItem property LItemSpellTomes00Destruction Auto

Book Property SpellBook Auto  


Event OnInit(); Distribute Item to Appropriate List
Utility.Wait(0.25)
Debug.Notification("Let's Get It!")
Utility.Wait(0.25)
FillAlLists()
RegisterForSingleUpdateGameTime(24)
endEvent

Event OnUpdateGameTime() ; Restocks inventory for all lists once per day
Utility.Wait(0.25)
ClearAlLists()
Utility.Wait(0.25)
FillAlLists()
RegisterForSingleUpdateGameTime(24)
endEvent

Function ClearAlLists() ; Clear all lists
Utility.Wait(0.25)
LItemSpellTomes00Destruction.Revert()
endFunction

Function FillAlLists();Fill lists with Book
Utility.Wait(0.25)
Debug.Notification("Let's Get It Again!")
Utility.Wait(0.25)
LItemSpellTomes00Destruction.AddForm(SpellBook, 1, 1)
endFunction

Edited by TheObstinateNoviceSmith
Link to comment
Share on other sites

Final update,

     Script was working, the problem was the LItems I was originally trying to use.  They were set to 100% (vanilla game setting) chance to not generate.  Also, it seems you can put any form into any LItem list as I was able to load an item with a WEAPON property into an LItem for Spells and it worked fine.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...