Saerileth Posted April 5, 2013 Share Posted April 5, 2013 Hi all, I'm very new to Papyrus and wanted to ask if someone could help me out here. I'm trying to make an activator that, when activated, scans the players journal for certain quest stages and enables certain other (initially disabled) objects within the same cell, based on what it found. So, for example, if the player completed the quest to fetch the dragon stone, the activator would enable the dragon stone replica I placed in my player home, etc. What would be the easiest way to achieve this? The replicas themselves should be activators, so I can attach some script that displays a message when the player tries to pick them up, and I'm guessing they'd have to be linked to the main activator. I'm looking for something that could easily be extended with additional quest/replica pairs, since I'm aiming to cover most unique quest items in the game. Also, there might be a performance issue if the script goes through the entire list of covered quests every single time it's activated, but I don't know of any other way to do it. I hope I'm explaining this comprehensively and someone can give me a few pointers. Cheers,Saerileth Link to comment Share on other sites More sharing options...
Daedthr Posted April 5, 2013 Share Posted April 5, 2013 Wait, are you looking for a script that simply enables something when a quest stage is completed or do you know the script already and just want to know how to implement it so it is efficient and usable in the context you outlined? I don't know how you might get this to work for most unique items in the game without doing each one individually, but to enable an object when a quest stage is completed you could use something along the lines of: If (questName.GetStageDone (XX)) ObjectReference.EnableEndIf Hopefully that'll work, may have got something wrong though. Link to comment Share on other sites More sharing options...
Saerileth Posted April 5, 2013 Author Share Posted April 5, 2013 This is my very first Papyrus script, but I have programmed in a variety of "real" object oriented languages. So I know in principle what I want to do, but I have no idea how to do it in Papyrus. I figured it's easier to attach the script checking the quest stage to the replicas themselves, that way I only need to write one script and can match the quest name / stage requirements to the individual references via properties. This is the script attached to the items I'd like to enable: Scriptname Saeri_ReplicaScript extends ObjectReference Quest Property triggerQuest Auto Int Property triggerStage Auto Function Display() If (triggerQuest.GetStage() >= triggerStage) Enable() EndIf EndFunction Now I need a script that calls Display() on each replica item every time someone activates the trigger. But I don't know how the "main" script would get hold of the proper references to call Display. Is there some way to iterate over a list of linked refs? Link to comment Share on other sites More sharing options...
Saerileth Posted April 5, 2013 Author Share Posted April 5, 2013 (edited) Nevermind, I just noticed I can add arrays of properties, and select the references in the editor window. The script attached to the main activator (a journal on a desk) is as follows: Scriptname Saeri_JournalScript extends ObjectReference Saeri_ReplicaScript[] Property replicas Auto Event OnActivate(ObjectReference akActionRef) int i = 0 While i < replicas.Length replicas[i].Display() i = i + 1 EndWhile EndEvent Haven't tested this yet, though. Edit: tested, and it works. Thanks for the help, Daedthr! Now I'm looking for a script that does something similar, only it's attached to a container and enables/disables the replicas based on what's placed in the container. The idea is to allow the player to fill up shelves with alchemy ingredients, for example, without having to place them all ingame, since Skyrim's physics engine is a pain in the *** when it comes to that. Note that I'm not looking for dynamic placement (like the bookshelves), that would be over the top right now. Just something a bit more realistic than finding a player home all stocked and ready to move in. Edited April 5, 2013 by Saerileth Link to comment Share on other sites More sharing options...
Saerileth Posted April 6, 2013 Author Share Posted April 6, 2013 (edited) Ok, for some reason the above scripts only work as long as there is only one replica. The Dragonstone gets enabled just fine, the Windcaller Horn and the Dragon Skull never show up (even though I meet the quest stage requirements). I tried tracing some of the calls, and it seems the horn and skull Disply() functions are both called with the dragonstone's quest requirements (MQ103, stage 190), even though I set different values in their properties. Also, there is an error that Enable() could not be called, because "no native object bound to the script object, or object is of incorrect type". What am I missing? :( Edit: debug.trace is telling me that my replicas array has length 1, and it's only element is the Dragonstone. But I added four more references to the list in the properties dialogue. How is this possible? Edited April 6, 2013 by Saerileth Link to comment Share on other sites More sharing options...
Saerileth Posted April 6, 2013 Author Share Posted April 6, 2013 Anyone, please? I'm at my wits end. I'm beginning to think that the creation kit is not saving my changes at all, because even after I removed the Dragonstone from the replicas property, the script claims array length to be one, and proceeds to enable the Dragonstone, to which it no longer holds a reference! Link to comment Share on other sites More sharing options...
Recommended Posts