Plarux Posted February 2, 2019 Share Posted February 2, 2019 Hello, I'm having trouble adding an item ( a key) to the leveled list of a vender (VL_Vendor_General_Drumin). My knowledge of papyrus is not good, so I cannot get the script to work properly. From research, I tried creating a quest that has a stage with a fragment - VL_Vendor_General_Drumlin.AddForm ( keyid, 1, 1). However, I'm not sure how to get properties of a script to work. When I try to add them to the script, the list of properties remains empty. If you could provide a sample script and maybe possible ways to add properties, I would be extremely thankful. It seems so simple, but I always run into issues when writing my own scripts. :sad: I appreciate any help! Plarux Link to comment Share on other sites More sharing options...
Plarux Posted February 3, 2019 Author Share Posted February 3, 2019 (edited) Here is the script that I came up with. I know it's wrong, but this was the best of my knowledge.All of the properties work, but the actual function does not. Also, I don't know which event to use in order to get this script to start.Since I'm using a quest, could it be a onSetStage 0 or something like that? UPDATE: Alright, I played around with it a bit more & figured it out. I used a leveled list containing the item. This script is connected to a quest that is startgame enabled & run once ticked.The quest has one stage - 0. When I tried to buy the key from Trudy, it doesn't appear in her inventory.I applied this script to an object and set extend to ObjectReference, it still didn't workAny suggestions? Edited February 3, 2019 by Plarux Link to comment Share on other sites More sharing options...
steve40 Posted February 3, 2019 Share Posted February 3, 2019 I don't think you can use AddItem (a function of ObjectReference script) on a LeveledItem (not a child of ObjectReference). LeveledItem only accepts AddForm(). Also, maybe use the OnQuestInit() event. Also, try removing CONST from the variable declarations. I could never get my head around the notion of having "constant variables", it's an oxymoron. It might be preventing you from modifying the formlist? I think CONST might also prevent the changes being saved in the savegame. Link to comment Share on other sites More sharing options...
Plarux Posted February 3, 2019 Author Share Posted February 3, 2019 (edited) I tried what you suggested steve40, but it still doesn't work.Do I need to wait for the vendor inventory to reset? UPDATE: Waiting didn't work. Edited February 3, 2019 by Plarux Link to comment Share on other sites More sharing options...
Plarux Posted February 3, 2019 Author Share Posted February 3, 2019 Unfortunately, I don't think you can add Keys to vendors. Using FO4Edit is easier to add items to vendor containers, which is their inventory. As long as your item is in a leveled list, it will show up in the vendor's inventory. The bypass for the key problem is to add a misc item to the vendor that looks like your key, then have a script replace the fake key with the real key (once you buy it and it's in the player inventory). There's a video on YouTube show how to do this in Skyrim, so I'm going to try that in Fallout 4. Here's the link to that video. Link to comment Share on other sites More sharing options...
steve40 Posted February 3, 2019 Share Posted February 3, 2019 I just want to confirm if you have tried adding the key directly using AddForm like this: ScriptName DLKeyInjectorScript extends Quest LeveledItem Property VL_Vendor_General_Drumlin auto Key Property DBKeyShack auto Event OnQuestInit() VL_Vendor_General_Drumlin.AddForm(DBKeyShack,1,1) EndEvent Link to comment Share on other sites More sharing options...
Plarux Posted February 3, 2019 Author Share Posted February 3, 2019 (edited) Yeah, it doesn't show up in her inventory for some reason. Since I can't add the key, I'm trying to add in a fake key the player buys from Trudy. After it is bought, a script will remove the fake key and add the real key to the player's inventory. However, all the scripts I've tried compile and don't function in game. Do you have any idea how to make a script that does this? I've tried OnContainerChanged and OnItemAdded for when the fake key is added, but the script doesn't do anything. I'm using Game.GetPlayer().AddItem & Game.GetPlayer().RemoveItem. Also, I tried a script that sets a quest stage after the item appears in the player's inventory and that stage does the removing/adding, still it doesn't work. ------- Thank you for the help! I just want to confirm if you have tried adding the key directly using AddForm like this: ScriptName DLKeyInjectorScript extends Quest LeveledItem Property VL_Vendor_General_Drumlin auto Key Property DBKeyShack auto Event OnQuestInit() VL_Vendor_General_Drumlin.AddForm(DBKeyShack,1,1) EndEvent Edited February 3, 2019 by Plarux Link to comment Share on other sites More sharing options...
steve40 Posted February 4, 2019 Share Posted February 4, 2019 If I can find the time, I'll do some tests to see if I keys can be added to vendor lists using a script. Cheers. Link to comment Share on other sites More sharing options...
MissingMeshTV Posted February 4, 2019 Share Posted February 4, 2019 @Plarux:You’re correct in that you can’t add keys to vendor inventories. Using a “fake” item that adds a key to the vendor inventory when the fake item is purchased is pretty much the only way, and is how I have always done it. I also set up a new vendor container (set to not respawn) and add my fake key item(s) to it as the only item(s), then link it to the vendor ref with a vendor container keyword (can’t recall the exact keyword offhand). No scripting or quest needed. This pretty much duplicates how vanilla Aspirational Vendor Containers are set up. Take a look at Daisy in Goodneighbor and how her Aspirational Container is set up and you’ll see what I mean. She has two containers linked to her ref: her basic vendor item container and the Aspirational Container that is linked to her ref with a keyword. It might be VendorContainer02…or something like that…I’m at work and am going only from memory. This might be another option for you. Link to comment Share on other sites More sharing options...
Plarux Posted February 4, 2019 Author Share Posted February 4, 2019 (edited) RedRocketTV, Thank you for the information. I'll take a look at Daisy to see exactly what you're talking about. However, what I'm stuck on is how to get the fake key/item to give the real key to the player when it is purchased. Would looking at Daisy shed some light on how to do this? I assume you meant to say "player inventory" when referring to using the "fake" item to add the key. @Plarux:You’re correct in that you can’t add keys to vendor inventories. Using a “fake” item that adds a key to the vendor inventory when the fake item is purchased is pretty much the only way, and is how I have always done it. I also set up a new vendor container (set to not respawn) and add my fake key item(s) to it as the only item(s), then link it to the vendor ref with a vendor container keyword (can’t recall the exact keyword offhand). No scripting or quest needed. This pretty much duplicates how vanilla Aspirational Vendor Containers are set up. Take a look at Daisy in Goodneighbor and how her Aspirational Container is set up and you’ll see what I mean. She has two containers linked to her ref: her basic vendor item container and the Aspirational Container that is linked to her ref with a keyword. It might be VendorContainer02…or something like that…I’m at work and am going only from memory. This might be another option for you. UPDATE: I assume this is what you're referring to with Daisy, but I pulled it up for Trudy. What I don't understand is what the ref "VendorAspirationDrumlinDiner" is there for. I open up VendorAspiration, but there's nothing in it. My guess is that scripts/quests add items into this container as the player progresses through the game? This is another way to add the key to the vendor's inventory, but how would I get the fake item to give the player the real key when it is purchased? Edited February 4, 2019 by Plarux Link to comment Share on other sites More sharing options...
Recommended Posts