Jump to content

[LE] Multiple quest objectives on same stage


Recommended Posts

Hey all. Couldn't find any help with this anywhere, which is unusual because you'd think it'd be a fairly common question.

 

Anyway, I'm having trouble with getting a quest to advance past a certain stage where there are multiple objectives.

I'm working on a mod that adds several player homes, and there's a single quest involved where you have to find the keys to the front door of each house before gaining entry. The specific thing I can't figure out is how I mark the "key-finding" quest stage as completed once all the keys are found.

 

You can grab the keys in any order since they're all part of the same quest stage (though separate objectives, obviously). Marking each objective as complete works fine, separately. But is there a script or other solution I could use to mark that entire stage as complete and advance to the next one once all four keys are found?

 

I've added all the keys to a new FormList in hopes of figuring something out with that, but my modding capabilities and knowledge are very limited, so I'm not sure where to go from there, or if it's even necessary/efficient.

 

EDIT - Even more details for clarification:

Stage 20 is the stage I can't progress past.

Objectives 21, 22, 23, & 24 are "Find key 1", "Find key 2", etc.

Like I said, the individual objectives are marked as complete once I pick up the corresponding key, but once all are found, the quest isn't progressing past stage 20.

Edited by ninjamunky83
Link to comment
Share on other sites

Could you use a variable that is incremented each time you find a key and when it hits the required number sets the next stage?

I thought about that, but still have no idea how to go about it. Any suggestions?

Sorry, I'm REALLY new to this stuff.

Link to comment
Share on other sites

Look at the quests FreeformSarethiFarm where you need to collect 20 jazbey grapes or NN01 where you need 20 crimson nirnroots.

 

I think mainly you could put a script on the keys that would increase the count when it's container changes to the player's inventory. Look at OnContainerChange event.

Link to comment
Share on other sites

Thanks for your help so far. I've been trying everything to make this work for 9 hours straight now and STILL nothing, unfortunately. I might just have to come up with a different way to handle this stage.

 

 

Look at the quests FreeformSarethiFarm where you need to collect 20 jazbey grapes or NN01 where you need 20 crimson nirnroots.

The issue with these two quests is that the objective is to collect a certain amount of a generic item. With my quest, you have to collect 4 different unique items, which I think is what's complicating things. I did try looking through those quests and their objectives, stages, and scripts to see if I could apply anything to my quest, but it just brought up more questions and uncertainties. I really have no idea how Global Variables work.

 

My first solution was to put the defaultCounter script on one of the key aliases, (putting it on a quest just doesn't work) then adding the defaultcounterincrementonactivate script to that same key alias and the 3 others (tagging them all with the keyword "mhquestkeys" and having the counterincrement script point to it). No dice.

 

 

I think mainly you could put a script on the keys that would increase the count when it's container changes to the player's inventory. Look at OnContainerChange event.

 

As for the OnContainerChange Event, I don't think there's a default script that deals with that, which complicates things even further since I know literally nothing about writing my own scripts. I've been doing my research on how to use it, but I think I'm burned out and the information is just not sinking in (or maybe i'm just too dumb for this lmao).

 

I also tried to add the code

SetObjectiveDisplayed(21)
SetObjectiveDisplayed(22)
SetObjectiveDisplayed(23)
SetObjectiveDisplayed(24)
SetObjectiveCompleted(10)

if IsObjectiveCompleted(21) == 1
IsObjectiveCompleted(22) == 1
IsObjectiveCompleted(23) == 1
IsObjectiveCompleted(24) == 1
SetStage(100)
endif

to stage 20, but it won't even compile, saying

C:\Program Files (x86)\Steam\steamapps\common\Skyrim Special Edition\Data\Source\Scripts\temp\QF_MHKeyQuest_060780CF.psc(92,24): cannot initialize a globalvariable to 0
No output generated for QF_MHKeyQuest_060780CF, compilation failed.

I'm at my wits end here!

Edited by ninjamunky83
Link to comment
Share on other sites

I had something lying around that did similar so I adapted it. I did not test to see if it actually compiled or works as intended. This should go on a player alias record and it should work with a single objective with multiple targets.

 

 

Scriptname HouseKeyQuestPlayer extends ReferenceAlias  

FormList Property FilterList  Auto ;list of items being tracked for the quest
GlobalVariable Property HouseKeyCurrent Auto ;global variable record with initial value of 0
GlobalVariable Property HouseKeyTotal Auto ;global variable record with initial value of required amount to obtain
Int Property StageToStart Auto ;stage to be set when current stage objectives are met
Int Property ObjectiveToComplete Auto ;current objective to be completed

Float Count
Quest myQuest

Event OnInit()
    AddInventoryEventFilter(FilterList)
    myQuest = GetOwningQuest()
EndEvent

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
    If     myQuest.GetStageDone(0) == 1
        If     FilterList.HasForm(akBaseItem)
            Count += 1
            KeysCounted()
        EndIf
    EndIf
EndEvent

Event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)
    If     myQuest.GetStageDone(0) == 1
        If     FilterList.HasForm(akBaseItem)
            Count -= 1
            KeysCounted()
        EndIf
    EndIf
EndEvent

Function KeysCounted()
    HouseKeyCurrent.Value = Count
    UpdateCurrentInstanceGlobal(HouseKeyCurrent)
    If     Count >= HouseKeyTotal.GetValue()
        myQuest.SetObjectiveCompleted(ObjectiveToComplete)
        myQuest.SetStage(StageToStart)
    ElseIf Count < HouseKeyTotal.GetValue()
        myQuest.SetObjectiveDisplayed(ObjectiveToComplete,true,true)
    EndIf
EndFunction

For your objective display text you can do something like: Find the house keys (<Global=HouseKeyCurrent>/<Global=HouseKeyTotal>)

And it will display: Find the house keys (1/4)

 

 

 

Link to comment
Share on other sites

Okay, I attached that script to the quest alias for PlayerRef. Only got one error:

Starting 1 compile threads for 1 files...
Compiling "HouseKeyQuestPlayer"...
C:\Program Files (x86)\Steam\steamapps\common\Skyrim Special Edition\Data\Source\Scripts\temp\HouseKeyQuestPlayer.psc(37,4): UpdateCurrentInstanceGlobal is not a function or does not exist
No output generated for HouseKeyQuestPlayer, compilation failed.

Batch compile of 1 files finished. 0 succeeded, 1 failed.
Failed on HouseKeyQuestPlayer

I did of course rename my global variables to match your script too, but as you can see that's not the problem. Do I need to use the script extender for this function to work?

Edited by ninjamunky83
Link to comment
Share on other sites

I wondered why I had a quest script linked to the alias script. That function UpdateCurrentInstanceGlobal is on the Quest script. It would require creating a second script for the quest record itself that contained the custom function KeysCounted and any necessary properties / variables to go with it. Sorry about that. At least you figured out a solution.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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