Jump to content

Recommended Posts

Posted

i want to enable an npc after a quest is done, but also if the quest is already done when the mod is enabled. i know this must be possible since it happens with the hearthfire housecarls but after scouring everything conceivably related to them, i couldn't find anything useful.

Posted

Checking if a quest is completed is as simple as putting in the line "GetStage()" on the quest. To know if Dragon Rising is done, you need to know that Dragon Rising's ID is MQ104. You also need to know it is considered completed only at stage 160. So you'd use "If ( MQ104.GetStage() == 160 )". If it's true, then the quest is completed, and it'll run the below code. If it's false, it's not completed, and it won't run the below code. Make a new quest with no name, just a descriptive ID. make sure its checkbox "Start game enabled" is checked. Save and exit that menu. THen, re-open it. Go to the quests tab and put in this script. You can change the names of the properties to the IDs of the things you're working with. That way, they'll auto-fill.

ScriptName X99_QuestCheck Extends Quest

ObjectReference Property NPCToEnable Auto
Quest Property QuestToChcek Auto
Int Property StageQuestIsDone Auto


Event OnInit()
     RegisterForSingleUpdate(1.0)
EndEvent

Event OnUpdate()
     If ( QuestToCheck.GetStage() == StageQuestIsDone )
          NPCToEnable.Enable()
          Stop()
     Else
          RegisterForSingleUpdate(5.0)
     EndIf
EndEvent

Change the script name to something you'll recognize. Fill in the properties, and as soon as the game runs the first time with this loaded, it'll check the quest for the correct stage, and it'll enable the NPC if it's the right stage. After it checks, it'll stop the quest so it's like it was never there. If you don't want to edit the original quest, then use this script instead. It'll do the same thing, but it'll keep running until the quest is completed.

Posted (edited)

thanks it compiled properly but in game it doesn't seem to be attached to the new quest i created to host it

do i have to name the script in a certain way or add some quest stages for it to work

Edited by axfvh
Posted

I'm not sure what you mean. The quest was made, and you made the script, but when you open the quest again, the script isn't attached? In that case, I'd see what happens if you try re-attach the script. I've never seen that happen. When you opened the quest and added the script again, did you click OK to exit the quest before saving or did you hit the upper right X? You must use OK or the CK will forget your changes (meaning it'll forget you tried attaching the script). Did you save the esp AFTER adding script?

 

Also, I screwed up in my previous post slightly. The script I posted was intended to be the second script, the one that runs until the quest is completed and enables the NPC when it is. The one that only runs once was supposed to be where that script is and it should have been:

 

 

ScriptName X99_QuestCheck Extends Quest

ObjectReference Property NPCToEnable Auto
Quest Property QuestToChcek Auto
Int Property StageQuestIsDone Auto

Event OnInit()
     If ( QuestToCheck.GetStage() == StageQuestIsDone )
          NPCToEnable.Enable()
     EndIf
     Stop()
EndEvent

 

 

Posted

well, i loaded the game with the esp enabled and used sqv command on the new quest, but it said no papyrus scripts attached

should i just add the second script along with the first one in the scripts tab for the quest?

Posted

Ah, I see. No, you wouldn't just add the script again. Reload the ESP and look to see if the script is attached. If it is, then something, somewhere is messing up. I'd add in "Debug.Notification("Script running")" on the line immediately after the enable bit. It might have to do with the fact that the script stops the quest, and that unlinks the quest's scripts.

Posted (edited)

so i replace the first script text with the new one using the same properties?

also if it matters at all i used something like

 If ( QuestToCheck.GetStage() == StageQuestIsDone ) OR ( QuestToCheck.GetStage() == StageQuestIsDone2 )


because there were two stages in that quest which might be interpreted as 'done'  
Edited by axfvh
  • Recently Browsing   0 members

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