Jump to content

Looking to reduce edits to quests--can we do the following ?


Recommended Posts

Posted (edited)

I am just completing a mod I've been working on for a while. It makes a decent number of edits across multiple vanilla quests. The mod works very well as-is. But I'm looking for a better way.

The edits are generally simple and almost the same across these quests:
1) run a (my)  function in the vanilla quest script fragment--e.g. when stage 10 is achieved, and 
2) make slight edit to vanilla code in (normally) the same fragment.

Looking at my patching for my mod it seems to me it's only the property (for the quest where my function resides) that is causing the headache of patching with other popular quest mods.

Is there a way my mod can have a quest that listens for a stage being reached across multiple vanilla quests--and then to run my function ? My function call passes a parameter that indexes which vanilla quest it is being called from, so that would have to be possible in such a solution.

I've noticed possible solutions involving story manager-but doesn't that generally have substantial lag between stage being reached and my stuff being triggered ? E.g. a change of location. I would need something that runs very soon after the vanilla quest hits a given stage.

Is there a way to do this ? Is this an advisable strategy ?

Edited by csbx
Link to comment
Share on other sites

Untried, but I think it would work....

Whenever the quest starts/stop, or changes stage, the quest script's OnInit is called.  So, you can:

script MyCustomQuestEventScript extends Quest

event OnInit()
	if isRunning() && getStage() == 10
		doWhatYouNeedHere()
	endif
endevent

Just add this script to all the quests you are interested in.

Link to comment
Share on other sites

You can skip having a property for your quest.  Within the fragment you will need to setup something like this (example pulled from my Random Mining MCM mod where I did not want to add properties to the script)

abim_RM_MCM_QuestScript MCMScript = (Game.GetFormFromFile(0x00000D62,"Random Mining MCM.esp") as Quest) as abim_RM_MCM_QuestScript

Then call your external function as you are already doing.

Link to comment
Share on other sites

On 5/23/2024 at 5:45 PM, xkkmEl said:

Untried, but I think it would work....

Whenever the quest starts/stop, or changes stage, the quest script's OnInit is called.  So, you can:

script MyCustomQuestEventScript extends Quest

event OnInit()
	if isRunning() && getStage() == 10
		doWhatYouNeedHere()
	endif
endevent

Just add this script to all the quests you are interested in.

Thanks man. Yep - you're right. That would work. I'm squeamish about it because it means creating edits to 40+ vanilla quest scripts--which I think would be pretty ugly in the sense that those conflicts wouldn't show up as obvious conflicts for many (most) end-users. Ie. it's a miracle that people even notice form conflicts by cracking open sseedit. My mod sort of already does that (conflict ugliness) by editing those vanilla quest frags.

So where I'm at now is really no better in this regard.

I was aspiring to something more local--ie. in my quest03, I register 50 quest sniffing dogs that run only when one of those quests updates to stage 10 (e.g.). I'm getting the sense that skse does this, but that's a galaxy outside of my abilities.

Link to comment
Share on other sites

On 5/23/2024 at 7:34 PM, IsharaMeradin said:

You can skip having a property for your quest.  Within the fragment you will need to setup something like this (example pulled from my Random Mining MCM mod where I did not want to add properties to the script)

abim_RM_MCM_QuestScript MCMScript = (Game.GetFormFromFile(0x00000D62,"Random Mining MCM.esp") as Quest) as abim_RM_MCM_QuestScript

Then call your external function as you are already doing.

Ok - interesting. I'll have a look at that. Thanks a lot !

Link to comment
Share on other sites

On 5/23/2024 at 7:34 PM, IsharaMeradin said:

You can skip having a property for your quest.  Within the fragment you will need to setup something like this (example pulled from my Random Mining MCM mod where I did not want to add properties to the script)

abim_RM_MCM_QuestScript MCMScript = (Game.GetFormFromFile(0x00000D62,"Random Mining MCM.esp") as Quest) as abim_RM_MCM_QuestScript

Then call your external function as you are already doing.

Well damn--that was very easy to set up and the quest edit is gone (though script frag edit still there obv.). I have to ask: what's the downside to making the call in this way ? The speed of it isn't really important bc my function would only run at a certain stage of a vanilla quest; and once per those quests--it's not as if that happens very rapidly in normal gameplay. But any downside you know about ?

Link to comment
Share on other sites

Well, in the case of Skyrim scripts, casting likely involves a search through the list of attached scripts, looking for a match on the filename string.

Still, unless you are doing it in a tight loop called millions of times, you shouldn't worry.

In general, you should not worry about performance, until you see an actual performance problem.
Link to comment
Share on other sites

11 hours ago, csbx said:

I'm squeamish about it because it means creating edits to 40+ vanilla quest scripts--which I think would be pretty ugly in the sense that those conflicts wouldn't show up as obvious conflicts for many (most) end-users.

In what I was suggesting, you are not editing any existing quest scripts at all...

You'd just add your own scripts to the existing quests.  A quest can have any number of scripts attached, everyone of which will see the OnInit (and other) events, and each one will run its own code in parallel in response to those events.

You can combine this with Ishara's idea for adding a property... either as separate scripts (Ishara's property holder script, and my OnInit script), or in the same script, as fits your need.

My OnInit approach can replace any quest fragment edit you had in mind, so long as you are able to test all the conditions you need in script.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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