lesi123 Posted December 18, 2016 Author Share Posted December 18, 2016 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 More sharing options...
NexusComa Posted December 18, 2016 Share Posted December 18, 2016 "OnHit events without some kind of throttle for them (which using states solved)." I'm going to bet you never even tried the other approach. Link to comment Share on other sites More sharing options...
lesi123 Posted December 18, 2016 Author Share Posted December 18, 2016 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 More sharing options...
lesi123 Posted December 19, 2016 Author Share Posted December 19, 2016 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 More sharing options...
Masterofnet Posted December 19, 2016 Share Posted December 19, 2016 (edited) If you want real help with this script you need to post the full script. To be honest I find it hard to believe, if you are properly shutting down the OnHit Event using states, Papyrus is having problems keeping up. Edited December 19, 2016 by Masterofnet Link to comment Share on other sites More sharing options...
lesi123 Posted December 19, 2016 Author Share Posted December 19, 2016 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. Link to comment Share on other sites More sharing options...
Masterofnet Posted December 19, 2016 Share Posted December 19, 2016 (edited) 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 ReadyEvent OnHit GoToState ("Busy") if Blah == 1Function1()elseif Blah == 2Function2()elseGoToState("Ready")EndIf EndEventEndState Function1()if Foo == 1Bar1.cast(PlayerRef)elseif Foo == 2Bar2.cast(PlayerRef)endifGoToState("Ready")EndFunction Function2()if Doo == 1Dad1.cast(PlayerRef)elseif Doo == 2Dad2.cast(PlayerRef)endifGoToState("Ready")EndFunction State Busy; nothingEndState Edited December 19, 2016 by Masterofnet Link to comment Share on other sites More sharing options...
cdcooley Posted December 19, 2016 Share Posted December 19, 2016 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 More sharing options...
Masterofnet Posted December 19, 2016 Share Posted December 19, 2016 (edited) 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 December 19, 2016 by Masterofnet Link to comment Share on other sites More sharing options...
lofgren Posted December 19, 2016 Share Posted December 19, 2016 I am also curious why the event needs to be defined in the busy state as it would impact a script I am working on as well. I would have assumed the event should not be defined at all in the busy state. Link to comment Share on other sites More sharing options...
Recommended Posts