Jump to content

[LE] Throttling OnHit scripts


lesi123

Recommended Posts

Thank you guys for your responses, they are very insightful and much appreciated!

 

Cdcooly is correct in that my scripts are already written, I am just in the optimization process now and was getting insane stack dumps from my mod's OnHit events without some kind of throttle for them (which using states solved). While it stinks that some valid OnHit events won't fire because the script is currently busy, it's completely unnoticeable in gameplay and prevents heavy fights from overloading Papyrus. I'd rather not destroy a save game by accident! :X

Link to comment
Share on other sites

  • Replies 67
  • Created
  • Last Reply

Top Posters In This Topic

I actually had tried the flagging method on one of my OnHit scripts when I first began rewritting them after looking through some older threads here on Nexus forums. However, Papyrus was still stack dumping with my mod alone on vanilla Skyrim so I began looking into other ways to prevent the OnHit from firing if it was already running.

 

Don't get me wrong, it was running fine during normal combat with a few npcs or a single dragon, but once I started some stress testing and spawned in multiple dragons/npcs that were attacking me and everything around me, my log would fill up with stack dumps after 30 seconds of combat.That's when I looked into states and came across the site I linked in the first post and gave that a shot. It worked, but I wanted to be sure how I had everything organized in the script was correct.

Link to comment
Share on other sites

After doing some more stress testing, I’ve run into another issue with throttling. As of now, dragons are my favorite NPC to test OnHit scripts with since they spit out so many and I’m able to get a rough idea of how much it takes to make Papyrus overload.

 

Deadly Dragons is one of my favorite mods and so I’ve been using that to help test. However, after spawning a single Sun Dragon from DD, I get stack dumps less than a minute after combat begins. I disabled every other mod in my load order except for official DLC, USLEEP, SkyUI, MfgConsole, Deadly Dragons, and Bleed Them Dry(my mod) and it’s the same situation of stack dumps shortly after combat starts. I’m assuming that even though my script may be in the Busy state, the script is still requesting to run even though it would return nearly instantly since the Busy state has no code in it. My character is just getting pummeled too fast with OnHit events from stuff during the fight with the Sun Dragon for Papyrus to keep up, regardless of states.

 

As of now, I’m using a quest to add or remove the OnHit script from the player depending on an option selected in the MCM. Would it be wise to make an stronger throttle option that starts and stops the quest in some sort of interval to allow Papyrus to catch up? Such as starting the quest, waiting X seconds, stopping the quest for X seconds, starting the quest again, waiting X seconds, etc.

 

I have no idea how resource intensive it is on the system to start and stop quests though or if there is a better method. This seems to be a very situational issue but I’m hoping to find a way to work with it since I really like Deadly Dragons.

Link to comment
Share on other sites

This is how I would do it. You were actually firing the OnHit event in your busy state.
As you can see I am keeping the event shut down until after the conditions or functions have fired. This could have also been contributing to the problem.
State Ready
Event OnHit
GoToState ("Busy")
if Blah == 1
Function1()
elseif Blah == 2
Function2()
else
GoToState("Ready")
EndIf
EndEvent
EndState

 

Function1()
if Foo == 1
Bar1.cast(PlayerRef)
elseif Foo == 2
Bar2.cast(PlayerRef)
endif
GoToState("Ready")
EndFunction
Function2()
if Doo == 1
Dad1.cast(PlayerRef)
elseif Doo == 2
Dad2.cast(PlayerRef)
endif
GoToState("Ready")
EndFunction

 

State Busy
; nothing
EndState
Edited by Masterofnet
Link to comment
Share on other sites

The state system will block calls if they are set up right. The event defined in the Busy state needs its body to be completely empty (except for possibly a comment) to trigger the optimization though.

 

Do post the whole script and this time use the code box (represented with the blue <> symbol in the toolbar buttons) or explicitly wrapping it in the [ code ] [ /code ] tags so formatting is preserved.

Link to comment
Share on other sites

The state system will block calls if they are set up right. The event defined in the Busy state needs its body to be completely empty (except for possibly a comment) to trigger the optimization though.

 

Why would you place an event in the Busy State?

 

 

Sure thing. As soon as I get home from work I'll post what I have written and maybe someone can spot something I missed.

 

Would you please simply try the script the way I did it and see if it works (before you post the full script) ?

Edited by Masterofnet
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...