Jump to content
MyDeadfireModAccount

ModHookScript vs. GlobalScriptCall impact on performance?

Recommended Posts

Hello this is my first post here. I've been modding this game for over a month now, mostly bumbling my way through it, looking through the exported files for examples of how things are implemented, and reading the few tutorials here.

 

The mod I'm doing has kind of turned out to become a massive overhaul of the game sort of mod and I have (estimated) over a hundred scripts in it for all sorts of things. I started out using ModHookScript because it is so simple to implement using IsInActiveScene condition but I had to include a few GlobalScriptCalls to get around looping and timing limitations. Still, 99% of my scripts are ModHookScript because they are so easy and accessible to write.

 

The problem now is, I'm wondering if using and relying on all these ModHookScripts to do the bulk of the script work will have a negative impact on game performance or if they are efficient at all if GlobalScriptCall can do the same thing without the game constantly running them each time a scene is entered.

 

Basically I'm not sure if a ModHookScript is still brought up and runned anyway, even if it had succeeded already, and will not succeed again, on entering a scene given "RunOnlyOnce" = false and "SucceedOnlyOnce" = true. If this is the case, then it seems like a waste of resources and a potential drag on game performance if I have dozens of "succeeded" scripts (that won't and shouldn't succeed again) still running each time the player transitions to a scene with ModHookScripts in it.

 

If my fear is correct then it seems like I need to change course and go with using only a few ModHookScripts that call GlobalScripts, where the bulk of the data is.

 

In my testing it is hard to tell if performance is impacted because I didn't think to or know to consider this aspect at the start. The game is running okay for me in testing but I'm afraid that other players playing with the mod will experience things like crashing if their computer can't handle it.

Share this post


Link to post
Share on other sites

The hooks will not continue to run after they have run or succeeded if they have RunOnlyOnce or SucceedOnlyOnce respectively. Of course, SucceedOnlyOnce hooks will be running on each scene transition until they succeed, which could potentially lead to slightly longer load times.  I would expect it to be pretty minimal, though (an IsInActiveScene call takes about 0.2-0.3 milliseconds on my machine).

Also, I don't know exactly how you're using the GlobalScripts, but to clarify, they won't call themselves.  They're intended to be re-usable or organized blocks of scripts you can call from different places; you do still need to call them from, for example, a ModScriptHook.

Share this post


Link to post
Share on other sites

Thankyou for the clarification. I'll keep using the ModHookScripts in that case.

 

And yeah, I am calling the GlobalScripts with ModHookScripts and using a called GlobalScript to call other GlobalScripts where necessary.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...