Jump to content

Cant use RegisterforSingleUpdate on quest script? help?


Recommended Posts

I hope the comments will help you understand what's going on in the script:

Scriptname SomeQuestScript Extends Quest

;This is the quest that you want to restart
Quest Property TheOtherQuest Auto
;This is the base object that will be placed in the world to check for the distance of the player
Static Property xMarker Auto

;this stores the reference of the marker
ObjectReference TrackingMarkerRef
;this stores the reference of the player
ObjectReference PlayerRef
;this is the distance that the player needs to move before the quest gets restarted
Float Radius = 10000.0

;When the quest starts the references of the marker and the player
;are stored in the local variables which can be accesed from the functions and events.
Event OnQuestInit()
	PlayerRef = Game.GetPlayer()
	;Place at me places an xMarker in the world and returns its reference, which is stored in the variable.
	TrackingMarkerRef = PlayerRef.PlaceAtMe(xMarker)
	;Call the function that moves the marker to the position of the player and listens for a new "greater than" event
	UpdateMarker()
EndEvent

; When the player reaches the distance the marker is moved to the player and it listens for a new "greater than event" (UpdateMarker)
; Then it restarts the quest (RestartQuest)
Event OnDistanceGreaterThan(ObjectReference akObj1, ObjectReference akObj2, float afDistance)
	If akObj1 == PlayerRef && akObj2 == TrackingMarkerRef && afDistance > Radius
		UpdateMarker()
		RestartQuest()
	EndIf
EndEvent

Function UpdateMarker()
	;Move the marker where the player is now
	TrackingMarkerRef.MoveTo(PlayerRef)
	;Call the OnDistanceGreaterThan event when the distance between the player and the marker
	;is greater than the given radius (10000 or whatever is set in the variable named Radius)
	RegisterForDistanceGreaterThanEvent(PlayerRef, TrackingMarkerRef, Radius)
EndFunction

Function RestartQuest()
	;Stop the other quest
	TheOtherQuest.Stop()
	;wait while the other quest stops
	Int i = 0
	while !TheOtherQuest.IsStopped() && i < 50
		Utility.Wait(0.1)
		i += 1
	endWhile
	;start the other quest
	TheOtherQuest.Start()
EndFunction
Edited by DieFeM
Link to comment
Share on other sites

That make sense Rasikko, thanks mate :)

 

Thankyou DieFeM! ahh so thats how you use the Xmarker haha, no wonder it wasnt working for me.

 

So i plugged the new script in and tested in game and now im getting the debug and quest resert when moving away from the marker. Yes! But, unfortunately, still the aliases dont seem to be refilling and the aliases that are filled when the quest first starts seem to empty after the reset too.

 

Just to confirm, should i be reseting the quest that contains the aliases, or should i be reseting the quest that contains the OnHit Event? or both?

Link to comment
Share on other sites

  On 6/4/2019 at 1:53 PM, SandMouseAnarchy said:

 

Just to confirm, should i be reseting the quest that contains the aliases, or should i be reseting the quest that contains the OnHit Event? or both?

The quest that contain the ref collection alias of the trees, so it is filled with other trees in the new current player area (I guess you need to check: Closest to [Player]). Maybe you'll need to change some setting in the aliases or the quest data tab:

https://www.creationkit.com/index.php?title=Quest_Alias_Tab&redirect=no

Edited by DieFeM
Link to comment
Share on other sites

I was having a chat about quest aliases with another modder, and he mentioned the quest reset function, you maybe get the collection alias filled with new tree references by calling TheOtherQuest.Reset() before or after TheOtherQuest.Start(), I'm not sure how it behaves, but its worth a try.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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