Dynamically Adding An Item To A Vendor?

Post » Sat Feb 19, 2011 1:43 am

I want to add an item to a vendor through a quest script at a particular point, then remove it. As far as I can tell there is a disconnect between a merchants sell list and what is in their merchant container. Modifying the merchant container in game (adding or removing items) does not change what the merchant sells. In addition, using the additem/removeitem function behaves in the same way. What can I do to remedy this situation? Below is the quest script and some additional notes.

scn HermDialogQuestSCRIPTfloat fQuestDelayTimeshort addeditemsshort gotwinebegin gamemodeif Player.GetInCell BravilSewerHouse == 1 && GetStageDone HermDialogQuest 10 != 1        set fQuestDelayTime to 0.01        if GetTalkedToPCParam HermRef == 1                SetStage HermDialogQuest 10                set fQuestDelayTime to 0        endifendifif getStage HermDialogQuest == 11 && addeditems == 0         LonelySuitorBogrumChest.additem HermGideonWine, 1        SilverhomeGilgondorinChest.additem HermGideonWine, 1        MessageBox "Items added" //for playtesting        set addeditems to 1endifif player.GetItemCount HermGideonWine == 1 && gotwine == 0        LonelySuitorBogrumChest.removeitem HermGideonWine, 1        SilverhomeGilgondorinChest.removeitem HermGideonWine, 1        SetStage HermDialogQuest 12        MessageBox "Items removed" //for playtesting        set gotwine to 1endifend


Please note that SilverhomeGilgondorinChest and LonelySuitorBogrumChest ARE Persistent Reference IDs. All other pieces of this script are functional and have been tested.
User avatar
Alina loves Alexandra
 
Posts: 3456
Joined: Mon Jan 01, 2007 7:55 pm

Post » Sat Feb 19, 2011 4:34 am

Since a merchant sells his own inventory (except for equipped items) you can try bypassing the container and add/remove the items directly referring to the NPC. I'm not sure when the container and inventory get merged to produce the "for sale" list, but since you're not supposed to be able to access the containers in game, it would make sense that their content is assumed static.
User avatar
Mashystar
 
Posts: 3460
Joined: Mon Jul 16, 2007 6:35 am

Post » Sat Feb 19, 2011 7:38 am

Since a merchant sells his own inventory (except for equipped items) you can try bypassing the container and add/remove the items directly referring to the NPC. I'm not sure when the container and inventory get merged to produce the "for sale" list, but since you're not supposed to be able to access the containers in game, it would make sense that their content is assumed static.


I was certain it would work, but sadly no.
User avatar
Beulah Bell
 
Posts: 3372
Joined: Thu Nov 23, 2006 7:08 pm

Post » Sat Feb 19, 2011 6:15 am

I was certain it would work, but sadly no.

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.
User avatar
Melanie
 
Posts: 3448
Joined: Tue Dec 26, 2006 4:54 pm

Post » Sat Feb 19, 2011 4:03 am

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.


You found the problem! :celebration: I didn't know about the non zero price bit! Thank you very much.
User avatar
Cathrine Jack
 
Posts: 3329
Joined: Sat Dec 02, 2006 1:29 am


Return to IV - Oblivion