If that new version of the mod doesn't introduce powerofthree's Papyrus Extender and PAPER as new dependencies, it'll be missing out on by far the most significant optimisations (the kinds that actually avoid substantial risks of the game's scripting engine overloading due to repeated OnHit() and/or OnMagicEffectApply() events).
Your optimizations are quite limited in scope. I've found some original Arcanum scripts that are really inefficient, but instead of rewriting the script you just remove some unnecessary lines. Is there a reason you take this conservative approach?
Can you name any scripts in particular you're thinking of there?
But basically, I try to mostly stick just to changes that I am 100% sure will not at all change how the scripts function in-game (apart from better performance), and will also work correctly when installed mid-playthrough.
It's definitely possible I might've missed some things though.
Yeah, so that's the kind of thing I didn't even really think about, because at first glance that would be something that would technically change the behaviour of the script. In the original, there's a 0.2 second cooldown on the effect, which is no longer the case in your version.
Now, the effect would only trigger in response to BowRelease events in the first place, and I doubt the player would ever be able to release their bow multiple times within a 0.2-second window, so I suppose in practice, it would work out the same way.
Well, the point of your mod is to optimize the scripts right? So, then why don't you optimize it as much as you can? The Sparkshot Repeater spell makes every other arrow fire a Lightning Bolt, my rewritten script does exactly that, nothing more. The 0.2 second cooldown in the original script serves no purpose, only bloating the script with too many int values and an extra event.
It's true that in practice it will barely make a difference. But, if you have 100 scripts running at the same time and all of the scripts are unoptimized you will start noticing script lag.
I was actually thinking of creating an optimization mod myself without the need for your PAPER plugin, but if you want I'd be down to work on a new version of this mod together?
Anything I spotted and was sure about, I optimised. Of course, I can't promise I'll always spot every tiny opportunity right away. I went through these scripts relatively quickly (especially in the case of mods that I don't actually even use myself, which is the case here).
Sure, I'd be happy to combine our optimisations together.
If you prefer to make a separate file yourself, of course that's also always fine. Getting rid of the PAPER requirement would likely mean you lose some of the actual bigger, more impactful optimisations though, not small micro-optimisations like we've been talking about here before.
12 comments
But basically, I try to mostly stick just to changes that I am 100% sure will not at all change how the scripts function in-game (apart from better performance), and will also work correctly when installed mid-playthrough.
It's definitely possible I might've missed some things though.
Take "sp_thundershoteffect.pcs" from the Sparkshot Repeater spell.
In your mod:
Scriptname SP_Thundershoteffect extends activemagiceffect
Spell Property Arrow Auto
Sound property release auto
keyword property bowkwd auto
Actor caster
int cando = 1
int property hardlimit auto
int property shotsleft auto
int shotsbegin
Event OnEffectStart(Actor akTarget, Actor akCaster)
shotsbegin = shotsleft
Caster = akcaster
RegisterForAnimationEvent(Caster, "BowRelease")
endEvent
Event OnAnimationEvent(ObjectReference akSource, string asEventName)
weapon bow = caster.GetEquippedWeapon()
if bow.haskeyword(bowkwd)
if cando == 1
cando = 0
registerforsingleupdate(0.2)
if shotsleft > 0
shotsleft = shotsleft - 1
else
shotsleft = shotsbegin
arrow.cast(caster)
release.play(caster)
endif
endif
endif
Endevent
Event onupdate()
cando = 1
endevent
Event OnEffectFinish(Actor akTarget, Actor akCaster)
unRegisterForAnimationEvent(Caster, "BowRelease")
endEvent
While I rewrote it as:
Scriptname SP_Thundershoteffect extends activemagiceffect
Spell Property arrow Auto
Sound property release auto
keyword property bowkwd auto
Actor caster
int shotcounter = 0
Event OnEffectStart(Actor akTarget, Actor akCaster)
Caster = akcaster
RegisterForAnimationEvent(Caster, "BowRelease")
endEvent
Event OnAnimationEvent(ObjectReference akSource, string asEventName)
weapon bow = caster.GetEquippedWeapon()
if bow.haskeyword(bowkwd)
if shotcounter == 1
arrow.cast(caster)
release.play(caster)
shotcounter -= 1
else
shotcounter += 1
endif
endif
Endevent
Event OnEffectFinish(Actor akTarget, Actor akCaster)
unRegisterForAnimationEvent(Caster, "BowRelease")
endEvent
There is no need for a "registerforsingleupdate" which waits for nothing, only slowing down the script.
Now, the effect would only trigger in response to BowRelease events in the first place, and I doubt the player would ever be able to release their bow multiple times within a 0.2-second window, so I suppose in practice, it would work out the same way.
It's true that in practice it will barely make a difference. But, if you have 100 scripts running at the same time and all of the scripts are unoptimized you will start noticing script lag.
I was actually thinking of creating an optimization mod myself without the need for your PAPER plugin, but if you want I'd be down to work on a new version of this mod together?
Sure, I'd be happy to combine our optimisations together.
If you prefer to make a separate file yourself, of course that's also always fine. Getting rid of the PAPER requirement would likely mean you lose some of the actual bigger, more impactful optimisations though, not small micro-optimisations like we've been talking about here before.