Jump to content

[LE] Calling custom function from Vanilla Quest Stage


Recommended Posts

I have the following maintenance scripts (following the wiki guide) that set a Game Setting on every game load:

ScriptName LFMPC_QuestScript extends Quest

Quest Property TrinityRestored Auto
Quest Property DarknessReturns Auto

Event OnInit()
  SetValue()
EndEvent


Function SetValue()
  If DarknessReturns.IsCompleted()
    Game.SetGameSettingFloat(...) ; SKSE function
  ElseIf TrinityRestored.IsStageDone(57)
    Game.SetGameSettingFloat(...) ; SKSE function
  EndIf
EndFunction
ScriptName LFMPC_AliasScript extends ReferenceAlias

LFMPC_QuestScript Property QuestScript Auto

Event OnPlayerLoadGame()
  QuestScript.SetValue()
EndEvent

As you can see, the value depends on how much of the Thieves Guild questline the player has completed. This is all fine except for one thing: it requires the player to save and reload the game after completing the specified quest stages in order for the mod to take effect.

 

This is why I'd like to trigger the LFMPC_QuestScript.SetValue() function and display a Debug.Notification immediately when those stages are completed. I suppose I could do this by editing the TG quests directly, but I'd like to avoid doing that to keep my mod as compatible with other stuff as possible.

Link to comment
Share on other sites

You could add an OnLocationChange event to the player alias script. At least that way the player only needs to change locations. But you may need to have some conditions in place so it only calls your function when necessary and otherwise exits so as to waste as little processing time as possible.

 

You could register for single updates and keep registering as needed. I'd go with a longer time period as checking every few seconds is pointless for this task.

RegisterForSingleUpdate

OnUpdate

 

Otherwise, your option would be to edit the TG quest scripts directly as you've already stated.

Link to comment
Share on other sites

Create a magic effect on an ability spell, and have the script do your scripting work. For the ability spell set the condition for the magic effect to GetStageDone or GetStage and enter the quest and stage details.

 

The magic effect script will fire when those conditions are met. You don't have to do any script checks or polling yourself. The effect will fire roughly 1 second after the conditions are true.

Link to comment
Share on other sites

Thank you both for your replies, but I decided to avoid any polling approaches (explicit or implicit) and instead ended up editing the Quest Fragment scripts of the Thieves Guild quests. I guess it'll make my mod incompatible with any other mod that edits those same quests but oh well.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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