Jump to content

Help with script optimisaion please?


theimmersion

Recommended Posts

So i made a humongous script that runs very slow.

Its about 1000 lines in constant work.

It must check and calculate tons of things and apply many different things.

But it must respond quickly which it doesnt. Made a similar mod for Fallout and never had any issues with that.

But the papyrus script engine or what ever it is (not a programmer xD) is really a hard one to master.

So i was wondering.

If i would somehow be able to brake it down into multiple scripts i assume it would work faster but how about the performance?

Whats the difference between a code of around 1000 (not counting the declared variables) lines of ifs and elseifs and so on

in one or multiple scripts. The mod is done but its so slow its useless. -.-

Anyone want to land me a hand please about this?

 

Well, here it is.

http://www.nexusmods.com/skyrim/mods/64608/?

And heres the alpha build code:

  Reveal hidden contents

 

Edited by theimmersion
Link to comment
Share on other sites

Well, remove any Game.GetPlayer()s you may have and replace them with an Actor Property for the PC (PlayerREF). Cordone any less likely parts of the script behind Ifs. Put the If/ElseIfs in the order of most likely to happen (first) to least likely (last).
Link to comment
Share on other sites

Remove ANY CONVENIENCE FUNCTIONS. Functions like GetRef, GetAV, SetAV, GetActorRef. Replace them

With their full counterparts:

 

GetReference, GetActorValue, SetActorValue, GetReference as Actor

 

This is b/c each of those will call their counterparts, which in turn call the function, rather than directly. IE GetRef calls GetReference which does things, rather than just doing things.

Link to comment
Share on other sites

Im aiming at finishing it to 100% functional. Thats why im posting. To make sure i make a 100% working mod. But i also listen to wiser people. So i uploaded the source scripts. Next uploads will be with the source scripts.

Link to comment
Share on other sites

You are constantly calling for the values from the engine, so it's getting throttled you need to be caching the values locally that is the real bottle neck to your script, look for places where you are calling the same function over and over again, and instead cache that value to a local variable (e.g your GetEditorID(PlayerRef.GetRace()) if block).

 

That would be the first thing I would look for anyway. Papyrus' slowest point is the interface with the engine.

 

After that I would suggest thinking about what actually is needed in that update block, personally I think there is some parts in there that could be better placed elsewhere, look for other events you could hook into to reduce the volume of the code that runs when it doesn't particularly need to.

 

Doing those two things would be a great start in getting that script into a nice clean state!

Edited by Arocide
Link to comment
Share on other sites

Its calling it all the time because of changes to the race. If i transform into a vampire or werewolf, the editor and race block will detect it and apply different settings.

Unless there is a event for a race change that could send me the event and than recheck the race. Otherwise, it always checks the race.

It even needs constant animation registering.

It registered for the animations at initialization like keys but when i changed to a vampire, the registered animation were gone.

So even that needs a constant happening. Wish i had a big fat monitor for the whole code, id recode everything and compress as much as i can, but with the low overview of the code its very hard.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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