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...

Dynamically Adding An Item To A Vendor


cosmo007
 Share

Recommended Posts

I have an item that is necessary for a particular quest that I want to add to two vendors' boxes when the player is at a certain stage and then remove the item when the player is at another stage. One of the vendors has a vendor box that is used by multiple vendors, the other vendor's box is unique to him. I "figured" that if I used the item ref and not the ID that it would only use one of the boxes. I am guessing this isn't true? because the script won't work.

Any advice would be great. If my script is awful go ahead and tell me.

Script:


scn HermathaDialogQuestSCRIPT


float fQuestDelayTime

short addeditems

short gotwine


begin gamemode

if Player.GetInCell BravilSewerHouse == 1 && GetStageDone HermathaDialogQuest 10 != 1

	set fQuestDelayTime to 0.01

	if GetTalkedToPCParam HermathaRef == 1

		SetStage HermathaDialogQuest 10

		set fQuestDelayTime to 0

	endif

endif


if getStage HermathaDialogQuest == 11 && addeditems == 0 

	LonelySuitorBogrumChest.additem HermGideonWine, 1

	SilverhomeGilgondorinChest.additem HermGideonWine, 1

	MessageBox "Items added" //for playtesting

	set addeditems to 1

endif


if player.GetItemCount HermGideonWine == 1 && gotwine == 0

	LonelySuitorBogrumChest.removeitem HermGideonWine, 1

	SilverhomeGilgondorinChest.removeitem HermGideonWine, 1

	SetStage HermathaDialogQuest 12

	MessageBox "Items removed" //for playtesting

	set gotwine to 1

endif


end

Edited by cosmo007
Link to comment
Share on other sites

I would think the chest needs to be referred to by it's persistent ref ID.

You might also want to consider creating a new chest unique to the first vendor or all the vendors that have access to that chest will gain access to that item.

Hmm when you say Ref ID do you mean Editor ID? Because in the code as it is, I am referring to the containers by their ref ID. Am I misunderstanding these terms?

Link to comment
Share on other sites

Any merchant container should be a persistent ref, ie; in your example, the chest (when you double click on it) should be showing as LonelySuitorBogrumChestRef, or something.

Okay well thats what I am doing. The persistent reference (like you said, when you double click on it, not the editor ID) is what I have written in the code. And if I use this persistent reference, it is as if I opened the chest in game and put an item in it? That item would not then be available through all the instances of the chest, correct?

Well this is the problem. When I add an item through the persistent reference it does not show in the merchant buy menu.

Link to comment
Share on other sites

Ok, I'm a little confused. XD

The code you posted in the first post does not include persistent ref ID's when you additem to the container. So if you've corrected that, perhaps repost what you have?

As for testing, are you sure you're at the right quest stage?

Link to comment
Share on other sites

Ok, I'm a little confused. XD

The code you posted in the first post does not include persistent ref ID's when you additem to the container. So if you've corrected that, perhaps repost what you have?

As for testing, are you sure you're at the right quest stage?

Lonely Suitor Lodge

Merchant: Brogrum GroGalash

has container ownership of ...

> Pers.RefID: LonelySuitorBogrumChest

>> Base Object: ChestVendorClothesLowerTwo

>>Count: 1

__________________________________________

Silver Home on the Water

Merchant: Gilgondorin

has container ownership of ...

> Pers.RefID: SilverhomeGilgondorinChest

>> Base Object: ChestVendorPublicanFood01

>> Base Object Count: 21

___________________________________________

I hope this clears up the confusion :lol:

Link to comment
Share on other sites

This is a quest script attached to my quest named HermathaDialogQuest. The first if-endif statement of the script runs fine.

I have placed the Wine item in the game world and the quest updates as orchestrated in the second part of the script. The only thing not working is adding to the merchant containers.

**EDIT**

I should note, although I do not think it matters, that the wine object is not considered a quest item

Edited by cosmo007
Link to comment
Share on other sites

Okay, so interesting update. I added this line:

HermsFoodStorageRef.additem HermGideonWine 1

Which is a persistent ref to a container accessible to the player and NOT a merchant container, and the items show up!

I am guessing that the problem stems from the merchant sell list not updating when an item is added. So is there a way to refresh the list? I looked through the functions on the wiki and I didn't see anything that seemed to do this...

Link to comment
Share on other sites

some other things worth of checking...

You can easily check whether item has been added to that chest by opening it. If the item is there and the merchant doesn't sell it still, then:

Is that container has an ownership assigned to that merchant? As vendors don't sell objects from containers which are other than their own.

Is this merchants sells such category the item belongs to? You can check this in merchant's AI settings windows.

Link to comment
Share on other sites

Hmm, try creating a new container unique to each merchant.

I am trying not to change any vanilla content so I did not follow this specific suggestion. However I did the next best thing.

HermsFoodStorageRef was set up with a merchant, Hermatha, who has 24/7 service offering of all items (clothes, spells, food, et cetera). After the item is added it is visible in the HermsFoodStorageRef container. Hermatha's sell list does not update though. Hermatha does not have "ownership", but this container is her assigned merchant container. Hermatha sells everything in container assigned to her through merchant container options, except the wine when it is added.

______________________________

@Trollf

some other things worth of checking...

You can easily check whether item has been added to that chest by opening it. If the item is there and the merchant doesn't sell it still, then:

Is that container has an ownership assigned to that merchant? As vendors don't sell objects from containers which are other than their own.

Is this merchants sells such category the item belongs to? You can check this in merchant's AI settings windows.

I did another test after reading your bit on container ownership (not merchant container assignment). It does not effect a merchants ability to sell items from a container, neither in a positive nor negative way. As for the other things you mentioned I double checked, and none of those options are set incorrectly.

_______________________________

As a player in game, I tried leaving an item in the container. Hermatha did not then sell said item. I think this conclusively proves that the sell list isn't updating. I tried zoning in an out and waiting to see if that would reset the sell list. No effect.

Link to comment
Share on other sites

I found the problem! It was rather stupid actually. See Gideon Wine is a custom item that I created, and for testing purposes I set it at a 0 price. Items with a 0 price are not sold by vendors so that was the issue. Now according to TheNiceOne over at TES Forums you still must add the item to the merchants inventory. The credit for the bit on adding to the inventory goes to Ghastley (also from TES Forums), who told me before TheNiceOne, but because I did not have the item at a nonzero price, it did not work.

Here is the link and TheNiceOne's post:

http://forums.bethsoft.com/index.php?/topic/1192808-dynamically-adding-an-item-to-a-vendor/page__gopid__17723571#entry17723571

Then you're doing something else wrong. My Real Sleep Extended mod dynamically add Bedrolls and Kaffe (Coffee drinks) to merchants the moment you activate a merchant. I add those directly to the merchant, not to his chest - and it works exactly as expected, the merchant has the amount I add for sale.

Are you sure the item you add are of a type that merchant will trade, and that the item has a non-zero price? If either is wrong, the item will not be visible for sale.

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...