Jump to content

My script RegisterForSingleUpdateGameTime is not working, help is welcome


Recommended Posts

Hi everyone,

I would like a static, Farmhouse02Destroyed to be disable, one day after the College of Winterhold Quest is over.

Here is the script and obviously 

CollegeQuest is being set  to MG08

And Int for CompleteStage has been set to 100

 

Scriptname aaaDisableFarmhouse02DestroyedScript extends ObjectReference  

Quest Property CollegeQuest Auto  ; Assign the CollegeQuest quest in the CK
int Property CompleteStage = 100 Auto  ; Set this to the stage when the quest is finished

Event OnInit()
    RegisterForSingleUpdateGameTime(1.0)  ; Check once per in-game day
EndEvent

Event OnUpdateGameTime()
    if CollegeQuest.IsRunning()  ; Check if the quest has started
        if CollegeQuest.GetStageDone(CompleteStage)  
            Self.Disable()
        else
            RegisterForSingleUpdateGameTime(1.0)  ; Keep checking every in-game day
        endif
    else
        RegisterForSingleUpdateGameTime(1.0)  ; Keep waiting for the quest to start
    endif
EndEvent

 

I have attached the script to Farmhouse02Destroyed. It complies just fine but nothing happen in game...why?

Link to comment
Share on other sites

Three comments:

registerForSingleUpdateGameTime( 24.0) ; check once a day; it counts hours not days

if CollegeQuest.getStage() >= CompleteStage ; might be a safer test than GetStageDone()

Add trace statements (Debug.trace or Debug.messageBox) to check that your OnInit kicks in and the update loop is indeed running.

 

Otherwise, your code looks right to me.  It's probably a detail in how you are testing it, perhaps using a saved game that already has a faulty version of the script attached, or uninitialized properties (check in console using "prid farmhouseID" then "sv").

BTW, this will not wait 24 hors before disabling... it'll wait no more than 24 hours, but possibly only seconds.

 

Link to comment
Share on other sites

ok still not working...

change as you suggested:

registerForSingleUpdateGameTime( 24.0)

if CollegeQuest.getStage() >= CompleteStage 

 

here is what I have after the use of  the prid command and sv

Registered for game-time update every 0.98 hours

Script state = ""

::CollegeQuest_var = MG08 (0001F258)

::CompleteStage_var = 100

so it looks ok to me. 

PS I am testing this in a game when the quest is already finished...

any clues?

Link to comment
Share on other sites

MG08 in the base game does not have a stage 100.  It's final stage appears to be 200, but it also stops the quest.

So, don't test MG08.isRunning, and change CompleteStage to 200.

You'll need to start a new game, or insert code somewhere to fix the property value.  It will not autoupdate to the new CK value on a running save.

Do add a trace or messageBox to verify your update loop is indeed running....

EDIT: Leave CompleteStage to 100.  The greater-or-equal-to-100 test will work fine since there are no stage numbers between 50 and 200.

Edited by xkkmEl
Link to comment
Share on other sites

Here is the final script with the Debug.Trace 

Scriptname aaaDisableFarmhouse02DestroyedScript extends ObjectReference  

Quest Property CollegeQuest Auto  ; Assign the CollegeQuest quest in the CK
int Property CompleteStage >= 100 Auto  ; Set this to the stage when the quest is finished

Event OnInit()
    Debug.Trace("aaaDisableFarmhouse02DestroyedScript: OnInit() called. Registering for update.")
    RegisterForSingleUpdateGameTime(24.0)  ; Check once per in-game day
EndEvent

Event OnUpdateGameTime()
    Debug.Trace("aaaDisableFarmhouse02DestroyedScript: OnUpdateGameTime() called.")
    
    if CollegeQuest.IsRunning()  
        Debug.Trace("CollegeQuest is running. Current stage: " + CollegeQuest.getStage())

        if CollegeQuest.getStage() >= CompleteStage  
            Debug.Trace("Quest stage is " + CollegeQuest.getStage() + ", which is >= " + CompleteStage + ". Disabling object.")
            Self.Disable()
        else
            Debug.Trace("Quest stage is " + CollegeQuest.getStage() + ", not yet complete. Registering for another update in 1 in-game day.")
            RegisterForSingleUpdateGameTime(24.0)  
        endif
    else
        Debug.Trace("CollegeQuest is not running. Registering for another update in 1 in-game day.")
        RegisterForSingleUpdateGameTime(24.0)  
    endif
EndEvent

Edited by MasterAub
Link to comment
Share on other sites

As been stated - once a quest completes, it is no longer running.   And MG08 has 200 right after 50.   So while the quest is still running, its stage will NEVER be over 100.   And the moment it hits 200, the quest will be no longer running.   Which means that  CollegeQuest.IsRunning() being true AND its stage being >= 100  is impossible.     Just check quest for isCompleted()

And this entire game time checking is completely redundant.     

Why not just:

Scriptname aaaDisableFarmhouse02DestroyedScript extends ObjectReference

Quest Property CollegeQuest Auto

Event OnLoad()
  If isEnabled() && CollegeQuest.IsCompleted()
  	Self.Disable()
  EndIf
EndEvent

The first time after game needs to load this area after the quest is done, house will get disabled.

  • Like 1
Link to comment
Share on other sites

11 minutes ago, scorrp10 said:

As been stated - once a quest completes, it is no longer running.   And MG08 has 200 right after 50.   So while the quest is still running, its stage will NEVER be over 100.   And the moment it hits 200, the quest will be no longer running.   Which means that  CollegeQuest.IsRunning() being true AND its stage being >= 100  is impossible.     Just check quest for isCompleted()

And this entire game time checking is completely redundant.     

Why not just:

Scriptname aaaDisableFarmhouse02DestroyedScript extends ObjectReference

Quest Property CollegeQuest Auto

Event OnLoad()
  If isEnabled() && CollegeQuest.IsCompleted()
  	Self.Disable()
  EndIf
EndEvent

The first time after game needs to load this area after the quest is done, house will get disabled.

Seems way more simpler...I like simple...Thanks a thousand

Link to comment
Share on other sites

Oh, I just realized something - you actually want it happen 1 day after quest is completed.    And my version would cause it to get disabled next time player enters Winterhold area.    If you still want it to happen 1 game day after quest completion, then yes, it needs to be a little more complex.    Namely, there needs to be some way to retain the game time when MG08 quest has been completed.   Then, above function would need to check if on game day has elapsed since completion.

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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