Making a quest start on load game

Post » Thu Jun 21, 2012 3:14 am

Hey guys. I've been having some trouble getting a custom quest to start when I load a saved game. My end objective is to use the quest to allow a script to run constantly (a method that was used a lot in Oblivion/Morrowind mods).


I've gotten the game to start the quest when I start a new game, but not when I load a saved game. To get to this point, I made the quest, checked the 'Start Game Enabled' box in the 'Quest Data' tab, then I created an index of 0 in the 'Quest Stages' tab. I checked the 'Start Up Stage' checkbox, and added a new, empty, Log Entry, to which I attached the papyrus fragment for my script.

Does anyone know what I'm missing to make the quest begin any time a game is loaded? Thanks for any help you can provide!
User avatar
maddison
 
Posts: 3498
Joined: Sat Mar 10, 2007 9:22 pm

Post » Wed Jun 20, 2012 4:57 pm

Does anyone know what I'm missing to make the quest begin any time a game is loaded? Thanks for any help you can provide!GetGameLoaded():
If your quest just isn't running to begin with: Could it be saved as already completed/not running? ~GetQuestRunning YourQUST might return a 0. If that's the case, you'd need to reset/start it from elsweyr or have its FormID changed so the engine will see it as brand new.

If you need GetGameLoaded() for code you need to run each time any save is loaded:
Spoiler
Forms added to LVLIs via http://www.creationkit.com/AddForm_-_LeveledItem don't persist in saves. This can be exploited using the below, jury rigged, GetGameLoaded() function:
Bool Function GetGameLoaded(LeveledItem akLeveledItem = None, Form apForm = None, ObjectReference akContainer = None)        akContainer.AddItem(akLeveledItem, 1, True)        If akContainer.GetItemCount(apForm)                akContainer.RemoveItem(apForm, akContainer.GetItemCount(apForm), True)                Return False        Else ; Will only return 'True' once per save load                akLeveledItem.AddForm(apForm, 1, 1)                Return True        EndIfEndFunction
...so...
       If GetGameLoaded(SomeBarrenLVLI, UnplayableTokenARMO, SomeContainerREF)
...will only return true once per ESS load. If ever Beth sets up AddForm() to persist, however, the function will cease to work. Chances are that SKSE will have a more permanent OnGameLoaded() event by then.
User avatar
Tom
 
Posts: 3463
Joined: Sun Aug 05, 2007 7:39 pm

Post » Wed Jun 20, 2012 5:31 pm

Forms added to LVLIs via http://www.creationkit.com/AddForm_-_LeveledItem don't persist in saves. This can be exploited using the below, jury rigged, GetGameLoaded() function:
Bool Function GetGameLoaded(LeveledItem akLeveledItem = None, Form apForm = None, ObjectReference akContainer = None)		akContainer.AddItem(akLeveledItem, 1, True)		If akContainer.GetItemCount(apForm)				akContainer.RemoveItem(apForm, akContainer.GetItemCount(apForm), True)				Return False		Else ; Will only return 'True' once per save load				akLeveledItem.AddForm(apForm, 1, 1)				Return True		EndIfEndFunction
...so...
	If GetGameLoaded(SomeBarrenLVLI, UnplayableTokenARMO, SomeContainerREF)
...will only return true once per ESS load. If ever Beth sets up AddForm() to persist, however, the function will cease to work. Chances are that SKSE will have a more permanent OnGameLoaded() event by then.

Thanks for the response! Unfortunately, I think you went a bit over my head here, haha. Are you saying I should edit the definition of the GetGameLoaded() function? If so, where is it defined? Also, this is the first thing I've seen regarding the AddForm() function.

EDIT: After looking at the function described, I think that while this could prove useful for later, it's not what I was attempting to do. I'm simply trying to get a quest to start when a game is loaded (unless quests are considered part of the leveled list?).

EDIT 2: How would I go about resetting it?
User avatar
Kitana Lucas
 
Posts: 3421
Joined: Sat Aug 12, 2006 1:24 pm

Post » Wed Jun 20, 2012 10:57 pm

Thanks for the response! Unfortunately, I think you went a bit over my head here, haha. Are you saying I should edit the definition of the GetGameLoaded() function? If so, where is it defined?
Sorry, as I might have misunderstood (edited reply). If GetGameLoaded() is what you're after, it's not a native function, so you'd just copypasta the function into your quest script or whatever.
User avatar
Kira! :)))
 
Posts: 3496
Joined: Fri Mar 02, 2007 1:07 pm

Post » Thu Jun 21, 2012 1:42 am

Sorry, as I might have misunderstood (edited reply). If GetGameLoaded() is what you're after, it's not a native function, so you'd just copypasta the function into your quest script or whatever.

Gotcha. I also think I understand what you mean about resetting the quest now. Didn't realize at first you were talking about from the console. Checking it out now!

EDIT: Hey, what do you know, it was running and wouldn't even start over even upon resetting it. I apparently had to uncheck the .esp, make a new save, and recheck the .esp. I'm guessing it probably completed it when I was still editing it and then got messed up somehow since I've been using the same FormID for it. Thanks a lot for your help Justin!

EDIT2: Well, after some further investigation, it seems if I save the game and load it again, the quest is already running. I suppose I should have been even more detailed in my original problem, in that I'd like the quest to begin anew every time the game is loaded. Any ideas on that one?
User avatar
Trey Johnson
 
Posts: 3295
Joined: Thu Oct 11, 2007 7:00 pm

Post » Wed Jun 20, 2012 5:01 pm

No prob :) You could change the QUST's FormID with TESVSnip (just be sure to load/save w/ CK afterward) and it would be seen as a different form by TESV.exe. To wipe the quest each save load, use a GetGameLoaded() check and Reset() when true, hinging the rest of the code on 'Else'.

Note: If ever that stops working after a patch, it'll mean AddForm() persists.
User avatar
Samantha Wood
 
Posts: 3286
Joined: Sun Oct 15, 2006 5:03 am

Post » Thu Jun 21, 2012 1:34 am

No prob :smile: You could change the QUST's FormID with TESVSnip (just be sure to load/save w/ CK afterward) and it would be seen as a different form by TESV.exe. To wipe the quest each save load, use a GetGameLoaded() check and Reset() when true, hinging the rest of the code on 'Else'.

Note: If ever that stops working after a patch, it'll mean AddForm() persists.

Thanks a lot for all of your help. I found an even better solution I think than using the GetGameLoaded() function, since like you said it could stop working in the future. I simply have a "While 1" at the beginning of the script, encompassing the entirety of the code. I found if I check the "Complete Quest" box in quest stage with this script, it remains running without completing any time a game is loaded.
User avatar
CORY
 
Posts: 3335
Joined: Sat Oct 13, 2007 9:54 pm

Post » Wed Jun 20, 2012 9:36 pm

A while loop is bound to be overkill and will iterate as quickly as it can from all I've seen. If you post the script, there's bound to be a way you can pull it off using events rather than keeping it in a loop.
User avatar
Robert Devlin
 
Posts: 3521
Joined: Mon Jul 23, 2007 2:19 pm

Post » Wed Jun 20, 2012 4:05 pm

Ooh, I like the levelled list hack... Where did you get it JustinOther?
User avatar
Shannon Marie Jones
 
Posts: 3391
Joined: Sun Nov 12, 2006 3:19 pm

Post » Wed Jun 20, 2012 5:42 pm

Ooh, I like the levelled list hack... Where did you get it JustinOther?
I wrote it for Bag of Holding so I could make sure the maintenance code ran when it should, but not when it shouldn't. The idea to use http://www.creationkit.com/AddForm_-_LeveledItem was Cipscis'.
User avatar
Izzy Coleman
 
Posts: 3336
Joined: Tue Jun 20, 2006 3:34 am


Return to V - Skyrim