Making scripts efficient

Post » Fri May 17, 2013 2:15 am

Here is my script, currently. In short what it does is if out of combat, it applies a random set of shaders every 30 seconds to the actor, and if in combat a different set of random shaders + a corresponding damaging spell every 15 seconds. Every time it updates (30 or 15 seconds) it clears all the current shaders and spells. My question is how best do I accomplish this last part.

Here is the script:

Spoiler

As you can see in this script I have a big block of removespell for every possible spell she could have been given, and I assume the game tries to remove all of them even though most of them aren't there. Would it be more efficient to make it so each time there's an update the game tries to remove less spells, even if it ends up making the script longer.

In other words/tl;dr: Are shorter scripts not necessarily more efficient scripts?

User avatar
Alexandra walker
 
Posts: 3441
Joined: Wed Sep 13, 2006 2:50 am

Post » Fri May 17, 2013 2:00 am

Here is the alternative script. Is this more or less efficient than the last one?

Spoiler

Also, can I alleviate some of my problems by using script extender?

User avatar
Shannon Marie Jones
 
Posts: 3391
Joined: Sun Nov 12, 2006 3:19 pm

Post » Fri May 17, 2013 3:13 am

I would use Arrays of Spells and match the indices of spells in the array with your random numbers. That way you don't need all the if/else statements, you just generate the random number and use that as the index to remove/add a spell. It would make the script a lot shorter. When removing Spells you don't have to list them all either, just use the random number from before to remove them. Using arrays will also get rid of the large amount of Spell Properties (you fill the array(s) with the Spells in the Creation Kit).

User avatar
Hannah Barnard
 
Posts: 3421
Joined: Fri Feb 09, 2007 9:42 am


Return to V - Skyrim