Jump to content

[LE] Adding custom items to existing merchants


Recommended Posts

I realize this is an old thread and moderators may hate me but I'm certain there are people who still want an answer. I've always created a chest for a vendor then gave the vendor ownership and then they would sell the items in the chest. You just have to make sure the chest doesn't respawn.

Link to comment
Share on other sites

  • 1 year later...

Cut to 13 months later, and I'm one of the people still looking for an answer to this question with a mod.
Complete with going out of my way to make this thing as compatible as humanly possible with other mods. LOL

There are only two threads I've found that come close to answering this for me. This one, and one that was last active 4 years earlier than this one (Simplest way to add a pack of spell tomes to the merchant lists). I'm trying to add about 12 Spells in a mod to make runes useful for a larger stretch of the game: basic Rune Marks for early game, and powered up Rune Circles for later game.

The "Rune Strength Variants" mod is already on the Main site, but it only adds the spells and books to the game. I need to get my books in the hands of merchants, and I need to hand-place some copies physically in the game. Since I'm having trouble with the render window, I thought merchants would be the easier obstacle to overcome, but I don't know anything about coding.

 

I was hoping newer methods may have been discovered since Skyrim SE came out, but that seems stupidly unlikely, and is a testament to how little I know about modding. :wink: I guess I'm not quite understanding how leveled lists work, or how to make a quest trigger in such a way as to not interfere with anything else, especially if people end up having to update my mod sometime in the future.

 

That other thread also mentioned that Master-Level spell tomes might also be special cases, which may need separate quests to get THEM to work out. So now I'm worried about that too. Although, I'd be happy just to just let people buy the master tomes whenever they hit level 90 in the corresponding school of magic, without having to full-on unlock them with the Master quests. I mean, they'll still cost a metric-ton of magicka to use either way, so why not, right? lol

 

- For now I'm really tired, and will have to tackle this another day.

Edited by 1wolffan
Link to comment
Share on other sites

As far as adding spell tomes to merchants, you can utilize this function that I made for my Mining For Mages mod.

 

 

Function AddFormToLeveledList(LeveledItem LItem,Form ItemToAdd,Int Level,Int Quantity)
    Bool DoAdd = true
    Int ix = 0
    While ix < LItem.GetNumForms()
        If LItem.GetNthForm(ix) == ItemToAdd
            ;already present in Leveled Item list
            ;do not add & get out of leveled item list
            DoAdd = false
            ix = LItem.GetNumForms()
        EndIf
        ix += 1 ;go to next item in form list
    EndWhile
    If DoAdd == true
        LItem.AddForm(ItemToAdd,Level,Quantity)
    EndIf
EndFunction

Use it like this:

AddFormToLeveledList(LItemSpellTomes00Spells,            abim_SpellTomeElectromining as form,1,1)

You will need properties for whatever leveled lists you wish to use as well as for your spell tomes.

 

 

It should be noted that in some cases if you add the tome to more than one list, it could end up with multiple copies at any given merchant. Also, adding to the correct leveled lists will automatically put them into the pool of tomes to be spawned out in the wild.

 

Easiest way to utilize this is to create a start game enabled quest record. Add a script to the quest record. Add this function to the script. Add your properties. Add the OnInit event and call the function from there as needed. If you are concerned about another mod possibly erasing your changes by running Revert on the list, then add a player alias with a script. Use the OnPlayerLoadGame event to re-run everything.

 

You are welcome to look at my Mining For Mages mod to see how it is set up, you'll have to extract the script source files from the BSA tho.

Edited by IsharaMeradin
Link to comment
Share on other sites

Thank you. I'm hoping I find the right list for it to be in merchant pools, and possibly found in dungeon chests too. That would make life easier for me for sure. lol It's gonna take me a few days for me to be in the mood to get back to it, but I'm never discouraged for too long. ;)

 

It's not that I'm worried about people reverting anything. It's more that I'm worried if I set it to only fire on start game, that it won't update and put everything back in the lists after an update. Unless people do a clean install, which is just a couple extra steps that some people would rather avoid. Since it won't be a huge script, would it be a low enough impact to just set it for when ever someone loads a save file?

Link to comment
Share on other sites

That is what the OnPlayerLoadGame event is for, run stuff when a save file is loaded. But you'll still need it to run at game start for the player's first session with a character.

 

You could get away with a start game enabled quest with a player alias and put all code on the script assigned to the player alias. Would end up being something similar to this:

 

 

Book Property mySpellTome Auto
LeveledItem Property LItemSpellTomes00Spells  Auto
 
Event OnInit()
  AddFormToLeveledList(LItemSpellTomes00Spells, mySpellTome as form,1,1)
EndEvent
 
Event OnPlayerLoadGame()
  AddFormToLeveledList(LItemSpellTomes00Spells, mySpellTome as form,1,1)
EndEvent
 
Function AddFormToLeveledList(LeveledItem LItem,Form ItemToAdd,Int Level,Int Quantity)
    Bool DoAdd = true
    Int ix = 0
    While ix < LItem.GetNumForms()
        If LItem.GetNthForm(ix) == ItemToAdd
            ;already present in Leveled Item list
            ;do not add & get out of leveled item list
            DoAdd = false
            ix = LItem.GetNumForms()
        EndIf
        ix += 1 ;go to next item in form list
    EndWhile
    If DoAdd == true
        LItem.AddForm(ItemToAdd,Level,Quantity)
    EndIf
EndFunction

Link to comment
Share on other sites

In your quest code, which part is where I put all 12 books in, and which symbols do I keep them between. The only experience I've had with coding, is Flash Action Scripting, and a little bit of Javascript. So at least I know syntax is important. I'm just not familiar with Papyrus. While I'm asking, what are the lists called that I need to add things too? Obviously I want vendors to get things, but random loot in dungeons would be nice too.

 

Side-note... I thought of something. When I made all my tomes, I used a copy of the spell tomes already in the game for the regular runes, and only changed the name, the spell learned, and the value. When I have one of the books open in the Creation Kit, under Keywords is has VendorItemBook and VendorItemTome. Why doesn't that mean they are already part of those lists? *sigh*

Link to comment
Share on other sites

The leveled list which is the LeveledItem property is where the books will be added. I do not know which particular lists you will need to use. Look at existing books which appear at merchants, lying about as clutter and inside loot containers. See which leveled item lists are used there and add your tome to them. I use these leveled item lists with the following Editor ID names for my Mining For Mages mod: LItemSpellTomes00Spells; LItemSpellTomes00AllConjuration; LItemSpellTomes00AllSpells; LItemSpellTomes00Conjuration. It allows the spell books to appear in the game world and at merchants. However, some merchants use more than one of these lists and the tomes appear twice.

 

You just need to call the function for each book and leveled list pair, pass the leveled list into the LItem parameter, pass the book into the ItemToAdd parameter, pass the level you want the book to start appearing into the Level parameter and finally pass how many you want to appear into the Quantity parameter.

 

You could end up with something like:

AddFormToLeveledList(LItemSpellTomes00Spells, mySpellTome00 as form,1,1)

AddFormToLeveledList(LItemSpellTomes00Spells, mySpellTome01 as form,1,1)

;... etc

AddFormToLeveledList(LItemSpellTomes00Spells, mySpellTome11 as form,1,1)

 

Should you expect to add more spell tomes down the road, now is the time to make changes to the process so that that will be possible. Twelve books being added to one or more leveled lists is going to get a bit lengthy. Adding more at a later date is just going to make it longer and possibly confusing to maintain. If this is something you want to explore, let me know and we can look at it.

Link to comment
Share on other sites

I don't plan on adding more than the original 12 tomes I've made. If I get comfortable enough with the CK and custom spells, I might add a set of 3 healing runes, and maybe a sort-of super Rune Spell that just lays one of each elemental rune down in the same area, or something like that, but that's months down the line.

I'm not sure how we could change the process. Putting stuff in leveled lists seems to be the next required step. Unless there's a way to make my own list, then just have the merchants use that as well, or something like that. Perhaps we can try and sort something out there. But I think we're leaving the scope of this topic behind, so maybe we should switch to DMs? That would allow me to send code clips from my actual mod back and forth.

PS: You've been so patient with me, and my clueless-ness, that I've gone and added you to my "thanks' list in my Mod's description. Even if my brain stalls out a bit on this thing, you've already been quite helpful. Thank You!

Edited by 1wolffan
Link to comment
Share on other sites

  • Recently Browsing   0 members

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