LID919 Posted December 20, 2013 Posted December 20, 2013 I've recently started doing a little bit of modding for my own personal use, but decided I wanted to share one mod I have created here on the nexus, after some polishing. I have been making a "Staff of Magnus improved" mod, but with a difference. I am trying to set things up so that when the player receives the staff, it is the Vanilla staff of Magnus, but an atronarch forge recipe is added to the player's inventory when they first pick it up, and later (after following that recipe) when an improved staff of Magnus is added to the player's inventory, to add another note with a new recipe. How might I go about writing the script to do this? To recap, the script needs to add an item to the player's inventory when a different item is added to the inventory for the first time.
taleden Posted December 20, 2013 Posted December 20, 2013 (edited) Make a (start game enabled, run once) quest with a reference alias force-filled to PlayerRef. Add a script to the alias which defines OnItemAdded(), and in that event, check if the added form (first argument) is the vanilla staff. If so, then AddItem() your recipe. Edit: After adding the recipe, either stop the quest or set a property so that you avoid adding the recipe a second time if the player drops the staff and picks it up again. Edited December 20, 2013 by taleden
LID919 Posted December 20, 2013 Author Posted December 20, 2013 (edited) I've been trying to do as you said, but I've been having trouble (sorry, I've not done scripting in Skyrim before, and it is very different from Oblivion scripting). I made the quest, added the reference to the player, but got stuck on writing the papyrus script. Every time I've gotten various errors. I tried looking into papyrus documentation, but still couldn't figure out how to proceed. Would you mind showing me an example of how this sort of script should look? Thanks. Edited December 20, 2013 by LID919
taleden Posted December 20, 2013 Posted December 20, 2013 Script MyAliasScript Extends ReferenceAlias Weapon Property MG07StaffofMagnus Auto Form Property MyRecipe Auto Bool bRecipeAdded = False Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) If (bRecipeAdded == False) && (akBaseItem == MG07StaffofMagnus) bRecipeAdded = True Self.AddItem(MyRecipe, 1, False) EndIf EndEventI think that should work, just change MyAliasScript to something more unique for your mod, and change MyRecipe to whatever you called your recipe item, and optionally also change Form (on the MyRecipe property) to whatever type of item it is (I've never worked with recipes -- are they Books? MiscObjects?). Also don't forget to populate those properties in the CK after saving the script, or they'll evaluate as None and it won't work. There are some things you could do to improve this, like using a script state instead of the Bool variable, but this way is probably easier to understand when you're starting out.
LID919 Posted December 20, 2013 Author Posted December 20, 2013 I set up the quest, added the script (it compiled fine) and tried it out in game. It didnt work, so I checked the quests with the console command "sqt". I didn't see it on that list, so I looked up the quest via the "help" command (it was there, so the data is in place) and tried both, "setstage" and "startquest" to no avail. Any idea what I am doing wrong? Thanks for all the help.
taleden Posted December 21, 2013 Posted December 21, 2013 Hard to say. A few things to check:the quest should be start game enabled, but it doesn't need any stages or objectives or anything elsethe reference alias should "allow reserved" and be force-filled to PlayerRefthe script should attach to the reference alias (not the quest itself)click "properties" on the script and make sure both of them are filled correctlyIf that all fails, you could post the .esp as an attachment here (is that allowed?), or post it somewhere anyway, and I'll take a look.
LID919 Posted December 21, 2013 Author Posted December 21, 2013 (edited) I can't attach .esp files as attachments to posts, but I put it in Google Drive at this link: EDIT: Link Closed I edited the script a bit, trying to change things around to get it working, but couldn't get it to work. The quest name is MagnusReforgeQST, and the item is MagnusRecipe01 (I hope to do this with recipe 02 as well once this is sorted) Edited December 21, 2013 by LID919
myztikrice Posted December 21, 2013 Posted December 21, 2013 Can't you set picking up the item to start a quest or something? Having a running quest that checks every single additem event seems messy
LID919 Posted December 21, 2013 Author Posted December 21, 2013 After reopening this today, I decided on a different method to solve the problem. I added a script to the staff itself so that when it was equipped for the first time, the player would "notice" the recipe inscribed on the staff, and "write it down". It worked like a charm, and the finished mod is now on the nexus here: http://www.nexusmods.com/skyrim/mods/49045/? Thank you for putting up with my questions this whole time as I explored the scripting system.
taleden Posted December 22, 2013 Posted December 22, 2013 Sorry I didn't have a chance to look at your esp yesterday, had to finish my holiday shopping. I can see how the script on the item itself would be easier to set up, but it does create a compatibility risk if any other mod edits the same base item. There are also some scripts (like weapon racks, at least until the next USKP release) that react poorly to items which have attached scripts, which is why I suggested the alternative approach using just the alias on the player. myztikrice's comment about OnItemAdded is true, but you can solve that problem using AddInventoryEventFilter.
Recommended Posts