Enabling an object after a quest.

Post » Fri Mar 11, 2016 10:45 am

Hello,



I need some help. I am trying to enable an object after a quest has been completed. In this case becoming the Thane of Winterhold.



I have this script:




Now the quest is favor257 and the complete stage is 20



So would I have to change it to the following?:





Then I select the object in the render window, click initially disabled then bring up the edit base, add the script.



Is this the correct way?

User avatar
Code Affinity
 
Posts: 3325
Joined: Wed Jun 13, 2007 11:11 am

Post » Thu Mar 10, 2016 9:17 pm

Nevermind.
User avatar
Rozlyn Robinson
 
Posts: 3528
Joined: Wed Jun 21, 2006 1:25 am

Post » Thu Mar 10, 2016 10:30 pm

Just the If statement isn't going to run unless you tell it to, though.


Your best bet would honestly be to edit the quest itself to add the enable call to that quest stage.
User avatar
stacy hamilton
 
Posts: 3354
Joined: Fri Aug 25, 2006 10:03 am

Post » Fri Mar 11, 2016 2:33 am

Sounds good, how do I do that?

User avatar
Heather Dawson
 
Posts: 3348
Joined: Sun Oct 15, 2006 4:14 pm

Post » Fri Mar 11, 2016 9:08 am


Well I've been thinking about it and while editing the quest itself is the most direct way and the best way as long as your mod is the only one running, it's not ideal if any other mod should try to edit the same quest.



So how immediate do you need the change to be registered by whatever it is you're doing? I'm thinking a less direct but more compatible method would be to check every few minutes, i.e. stick your original code inside an OnUpdate() block.



To check every five minutes, you'd need something like:



RegisterForSingleUpdate(300)

Event OnUpdate()
If favor257.IsStageDone(20)
yourRef.Enable()
Else
RegisterForSingleUpdate(300)
End If
End Event


You could also call RegisterForUpdate instead of RegisterForSingleUpdate but you'd have to make sure to call UnregisterForUpdate when your condition becomes true.

User avatar
Michelle Smith
 
Posts: 3417
Joined: Wed Nov 15, 2006 2:03 am

Post » Fri Mar 11, 2016 1:50 am

Nothing at all will ever happen if you attach the script to the object itself. While it's disabled, it can't run scripts.

You need a mechanism that triggers a piece of your own code, and lets you make the check from there. Look at the Story Manager and the various events that can start a "quest". Things like leveling up, changing location, etc. are all candidates. E.g. you could have a (very short) quest start when you enter a related interior. The quest just checks that the other stage was completed, and ends after enabling or not.

If there's a reward item, you could catch the event PlayerAddItem when the item is the quest reward, maybe?
User avatar
Hannah Barnard
 
Posts: 3421
Joined: Fri Feb 09, 2007 9:42 am

Post » Thu Mar 10, 2016 8:33 pm


What I'd do is use a quest with the script attached to a player alias and register for the update in an OnLoad block.

User avatar
El Khatiri
 
Posts: 3568
Joined: Sat Sep 01, 2007 2:43 am

Post » Thu Mar 10, 2016 8:43 pm


I like the sound of this. Compatibility would be a must.



Now, you say to put this on an Onupdate block. What is this? How does this work?

User avatar
Benjamin Holz
 
Posts: 3408
Joined: Fri Oct 19, 2007 9:34 pm

Post » Fri Mar 11, 2016 7:03 am


The OnUpdate block is just the code inside the OnUpdate event.



Make a new quest and set it to start game enabled. Add an alias to the quest and fill it with the player. Attach your script to that alias. Register for your updates inside an OnInit event on that script, and put your If/Else/etc. logic inside your OnUpdate event.



You can make the update interval anything you want, but I'd check as rarely as you're comfortable with. The Papyrus engine is stingy with processing time, and you don't want to waste resources that could be better allocated to other more time-sensitive scripts.

User avatar
Lisa
 
Posts: 3473
Joined: Thu Jul 13, 2006 3:57 am


Return to V - Skyrim