Jump to content

[LE] Adding Items to a merchant via scripting


LittleBaron

Recommended Posts

So... in an attempt to avoid present and future mod conflicts, I try to add my content via a "start in GameMode" quest-script. After a full day and a half of head banging I managed to figure out the basics of the Papyrus scripting lingo, or so I think. The quest script is firing (my PC gets the intended message), all the properties below are fully linked up to existing items/objects and the script compiles successfully BUT when I visit the Markarth blacksmith, he's got nothin' I was hoping for. I also tried the mage vendor but that resulted in Nada also.

 

Any ideas or suggestions, oh great ones? Thank you in advance.

 

---------------------------------------------

Scriptname LB_SE_VendorAdd extends Quest

{Adds the SE Items to the blacksmith in Markarth.}

 

ObjectReference property chesty auto

Projectile property LBarrow auto

Weapon property LBdagger auto

Weapon property LBsword auto

Weapon property LBgsword auto

Weapon property LBbow auto

Weapon property LBwaxe auto

Weapon property LBbaxe auto

Weapon property LBstaff auto

Weapon property LBwhammer auto

 

Event OnInit()

 

chesty.additem(LBarrow,100,TRUE)

chesty.additem(LBdagger,1,TRUE)

chesty.additem(LBsword,1,TRUE)

chesty.additem(LBgsword,1,TRUE)

chesty.additem(LBbow,1,TRUE)

chesty.additem(LBwaxe,1,TRUE)

chesty.additem(LBbaxe,1,TRUE)

chesty.additem(LBwhammer,1,TRUE)

chesty.additem(LBstaff,1,TRUE)

Debug.MessageBox ("You have heard that the blacksmith in Markarth has a new collection of unique weapons")

 

EndEvent

-------------------------------------------------

xoxo

 

*EDIT* for those who go after me, in the script above 'projectile property' will not work. Use 'ammo property' instead.

Link to comment
Share on other sites

In the script's 'properties' I assigned 'chesty' to the merchant chest for the blacksmith in Markarth. Is there some other step I need to take? Not sure what you mean by 'initialized'.

 

and... thanks for replying!!

Link to comment
Share on other sites

In the script's 'properties' I assigned 'chesty' to the merchant chest for the blacksmith in Markarth. Is there some other step I need to take? Not sure what you mean by 'initialized'.

 

and... thanks for replying!!

 

That's what I meant, wanted to make sure "chesty" was assigned the appropriate object reference. When you enter a cell, all containers are filled at that time and their contents written to your save file. You may need to reset the interior or do a clean save and reload the mod to get the items to appear.

 

See here.

 

Might just try entering the following into the console:

pcb
resetinterior BlacksmithCellReferenceID

 

I don't know his cell ref id offhand, need to use instead of what I typed...oh, and don't be in his cell when typing that. Also, since this is added by a quest, might also have to do a startquest questrefid to refire the oninit block.

Link to comment
Share on other sites

OK. Thanks for the info about how merchant chest fill up, I didn't know that. I had however disabled/enabled my .esp after entering the area just in case, so I had checked that out already. But what you're telling me about how they fill means I would need to change my approach, anyway.

 

As an experiment I changed the container object from the merchant chest to the PC, and all the items showed up in my PC's inventory. So that part is working.

 

I may have chosen the wrong blacksmith merchant... there is a female orc also. I will look into that...

 

Thanks again.

 

LB

Link to comment
Share on other sites

That's odd, it looks like it should work. I can only think that you might have chosen the wrong chest ref, or--this is a long shot--your script is adding the items to the chest before the game is setting it up, so the game overwrites your items. I don't think the latter would actually happen, but I don't know how chests work all that well.
Link to comment
Share on other sites

You should check the wiki when you run into problems (in case another modder has already run into the issue).

 

Your problem is that the chest is set to "respawn". You are loading the game (I assume), the script adds the objects to the chest, but as soon as you talk to the merchant all his goods reset back to normal and your items disappear.

 

You basically have to add to merchant containers that don't respawn (which, unfortunately, means that adding via script to any merchants from the original game is basically useless... unless some extra scripting can take care of it be readding the items). This has caused me the most annoyance of anything so far.

 

And, in case you were planning on trying it, you can't add another merchant faction (with another container) to an existing merchant in the hopes they will sell your new items. Merchants will only sell from one faction container.

Link to comment
Share on other sites

Thank you very much. I did actually look all over the wiki, but was focused on possible scripting errors so I didn't think about how chests might work now. Ugh.

 

If I think of a work-around I will post it here.

 

*EDIT*

 

I added the items to the merchant herself. She equips the strongest item (the Battleaxe, in this case) and sells the rest (well, most of it). I was in Whiterun when the script fired and had not spoken with the female Markarth Blacksmith in recent memory, so I don't believe her personal inventory is subject to Respawn.

 

I will have to give her some custom weapon that's a bit stronger than mine, give the staff to Calcemo's mage assistant and find out why the arrows do not seem to find their way into the inventory yet.

Link to comment
Share on other sites

I kinda TL;DR the thread, but isn't it much easier to just add a second chest owned by the merchant, containing the new items? That way you won't have problems with the inventory respawning and the merchant won't equip the items. It also won't cause incompatibilities with mods that edit the same NPC.
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...