Jump to content

(trying to create) Quest with a time limit


Surjamte

Recommended Posts

So I saw this example script that could be used to make a timed quest and decided to try and make one.

 

The story is pretty simple. An npc has been poisoned and you need to find a cure within a certain amount of time. Otherwise (s)he'll die.

 

The script compiled nice and well, but whenever I fast travel and/or in-game the game crashes. So something is obviously wrong, but I have no idea what, because I suck at scripting.

 







Scriptname ASURG02TimedQuest extends Quest  

GlobalVariable Property GlobalDays auto ;initial days to complete
GlobalVariable Property GlobalTime auto ;counter for hours left
Quest Property TimedQuest auto ;the quest (I used two scripts on same quest while cause I modified a vanilla one)
int Property FailObjective auto ;objective that will fail when hours left reaches 0, it is the one to display the time left and will be refreshed
int Property FailStage auto ;stage to set the quest to, fail whole quest from it's fragment or whatever
 
Float endTime
 
Event OnInit()
	if (GlobalTime.GetValue()>0)
		;Debug.Notification("Starting countdown")
		GlobalTime.SetValue(GlobalDays.GetValue()*24)
		endTime = Utility.GetCurrentGameTime()+GlobalDays.GetValue()
		TimedQuest.UpdateCurrentInstanceGlobal(GlobalTime)
		RegisterForUpdateGameTime(0.10)
	EndIf
EndEvent
 
Event OnUpdateGameTime()
	if (!TimedQuest.IsRunning())
		UnregisterForUpdateGameTime()
	EndIf
	float step = Math.Ceiling((endTime - Utility.GetCurrentGameTime())*24) - GlobalTime.GetValue()
	if (step != 0)
		if (0-step > GlobalTime.GetValue()) ;avoid displaying less then 0
			step = 0 - GlobalTime.GetValue()
		EndIf
		if TimedQuest.ModObjectiveGlobal(step, GlobalTime, FailObjective, 0, false, false)
			GlobalTime.SetValue(0)
			TimedQuest.UpdateCurrentInstanceGlobal(GlobalTime)
			TimedQuest.SetStage(FailStage)
			UnregisterForUpdateGameTime()
		EndIf
	EndIf
EndEvent

I have no idea what I'm doing, but I really want this to work. So plz help me find out what's wrong. If you want to share any better way/script to create a timed quest that would work too. :smile:

 

Link to comment
Share on other sites

Not a problem, glad I could help! Good luck with your mod, if you need a tester for it when its done feel free to PM me! And also let me know when its done, I might review it on my upcoming YouTube series.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...