Talk:Reset - Quest

From the CreationKit Wiki
Jump to navigation Jump to search

On my custom quest, Quest.Reset() is working fine. Maybe it got fixed or it is only broken for standard quests? -- Jsquirrel

Quite strange then... it doesn't work for me. I'm using the CK version 1.5.24 and Skyrim is version 1.6.89.0.

This is the code I used to test:

Scriptname fg109TestQuestScript extends Quest

Event OnInit()
	Debug.Notification("Quest was initialized.")
	RegisterForSingleUpdate(10)
EndEvent

Event OnReset()
	Utility.Wait(1)
	Debug.Notification("Quest was reset.")
EndEvent

Event OnUpdate()
	Debug.Notification("Quest is updating.")
	if (Game.GetPlayer().IsSneaking())
		Stop()
		Utility.Wait(1)
		Start()
	else
		Reset()
	endif
EndEvent
Scriptname fg109TestMEScript extends ActiveMagicEffect

Quest Property fg109TestQuest Auto

Event OnEffectStart(Actor akTarget, Actor akCaster)
	Debug.Notification("Attempting to restart the quest.")
	if (akTarget.IsSneaking())
		fg109TestQuest.Stop()
		Utility.Wait(1)
		fg109TestQuest.Start()
	else
		fg109TestQuest.Reset()
	endif
EndEvent

Neither the Reset in the quest script nor the one in the magic effect script caused the message in either the OnInit block nor the message in the OnReset block to show up. The calls to Stop and Start did work in both scripts. Also, as noted in the OnReset notes, the message in the OnReset block is never shown, even when the quest is restarted successfully. --Fg109 15:39, 15 June 2012 (EDT)

Interesting. I'm using CK version 1.6.89.0 (current version from Steam) and game version 1.6.89.0.6 (also from Steam).

In my quest, an NPC hides a book in a chest at a certain time each day, if it is not already there (using a custom package). The player then gets asked by another NPC to find the book, advancing through a quest line that leads the player to eventually drop the book back on the table where it belongs. Dropping the book leads to this code being executed (much simplified version):

Event onContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)
  Quest q = self.GetOwningQuest()

  if ((akOldContainer == Game.GetPlayer()) && !akNewContainer && (q.GetStage() == 150))
    q.SetObjectiveCompleted(40)
    q.SetStage(0)
    q.Reset()
  endIf
endEvent

I am not using the OnReset event, though, and when I added OnReset()-Code it didn't fire for me either. But I can see in my quest log in-game that the quest has been reset and thus the diary can be hidden again. Note also that my quest does not complete while it is in the hide-find-return loop. It repeats until you catch the thief in the act, which is the only way to complete the quest. -- Jsquirrel

Maybe it's the SetStage(0) that's causing you to think the quest has been reset, when it actually hasn't. What happens if you take that out of the code? --Fg109 14:52, 21 June 2012 (EDT)
This doesn't work because OnReset() is not a member of the Quest script. So it will not respond to that event at all. Quest.Reset() does in fact do what it's supposed to, it just will not trigger an OnReset() event to tell you that. Arthmoor (talk) 2013-12-07T18:18:25 (EST)


Quest Aliases & Reset()[edit source]

I been having a problem where quest aliases are not refilled when restarting a quest via scripting. This code was a logical process:

Function ResetMod()
   Stop()
   Reset()
   Start()
EndFunction

Given that the aliases were filled fine first quest load even in a non-new game, spent forever trying different flags and stuff on the aliases to no avail. Then for some stupid reason I tried...

Function ResetMod()
   Reset()
   Stop()
   Start()
EndFunction

And the aliases were properly refilled. The lack of documentation surrounding reset is cheeky at best. But I am beginning to wonder if there is a point to Reset() at all. May it be better to Stop(), SetStage(0), Start(), and just say "screw it" to reset. Will Stop(), Start(), alone be enough of a reset?

--Darkconsole (talk) 2014-10-11T05:09:46 (EDT)

This is all I currently know about Reset(). Reset() will send a quest back to its [b]Startup stage[/b] and clears all aliases. What Reset does not do is refill them, and start the quest. Also Reset() will not run when Stop() has been called before it. This is why your second function worked as expected. --Terra Nova2 (talk) 2014-10-11T08:59:05 (EDT)