OBLIVION
OblivionScriptOptimization by Hrmn
Oblivion » Gameplay Effects and Changes
Added: 08/09/2007 - 08:51AM
Updated: 08/01/2012 - 08:14PM

1,579 Endorsements

1.0 Latest version

44,096 Unique D/Ls

66,714 Total D/Ls

186,538 Total Views

Uploaded by hrmn

Description

Last updated at 20:14, 8 Jan 2012 Uploaded at 8:51, 8 Sep 2007

The goal of this mod is to give a better performance by optimizing the scripts found in the game. Every frame, hunderds sometimes thousands of scripts run in the background, processing these requires alot of cpu processing power. The scripts which are part of the game have been written for readability and not optimization, which unfortunately causes them to run slower than possible. Readability offers no benefits ingame so this mod aims to improve upon the optimization of the scripts so that their execution costs less processing time, which leads to a higher performance. Functionally the scripts remain exactly the same, so there is no downside.

You can find the official discussion on the mod here: http://www.bethsoft.com/bgsforums/index.php?showtopic=753010
=============================
How much will this improve my performance?
=============================
For most computers running Oblivion, the video card is usually the weakest link. And the weakest link is what determines the framerate. However, during the loading of new areas, when the game needs to process many AI packages or when lots of mods are running in the background, the cpu will often be the weakest link temporarily. Because this mod reduces the load of scripts on the cpu, this bottleneck will be hit less often, and with less severity.
For most computers this mod will increase the overall framerate in Oblivion slightly, but the main gains in performance are not in the framerate. The main performance gains that can be expected from using this mod are that the game experience will feel smoother because sudden cpu bottlenecks will be far less noticeable, and these bottlenecks are experienced in game by the game randomly stuttering and by longer load times. By installing this mod the effects of these on your game will diminish causing a smoother game experience, especially if you run lots of mods or if your cpu isn't that good compared to your video card.
The overall fps improvements on my pc were over longer durations found to be between 0.3-0.4 in benchmarks. But these improvements are mainly there where my fps would otherwise suddenly drop.
Although a slight change in performance, it can be quite noticeable, and this mod has absolutely no drawbacks because the scripts do exactly the same, there is no loss in quality anywhere, just an improvement in performance.

=============================
Warning
=============================
First, the warning, you should load the mod first, not second, absolutely first, there is no mod which should ever be loaded before it, not the unofficial oblivion patch, not anything (except esms which cannot be loaded after the esp). Each script optimized only gives a very small bonus in performance, and that small bonus is less important then any other thing that could be altering the scripts, bugfixes for example are way more important.(note that im talking about esps here, you cant load this before a esm). By loading the mod first, any changes this mod makes in scripts get overwritten which means that no conflicts can occur.

=============================
Explanation
=============================
Some might not believe that rewriting scripts can cause it to drain less cpu power. So an explanation of how it is done follows here, some scripting experience is required to understand it though. The following is an example from a script, before and after optimization.

Before:

if timer <= 0 && getstage MQ15 == 58 && OrtheRef.getdead == 0
set timer to 5
sayTo player MQ15EldamilWarning
endif

if timer <= 0 && getstage MQ15 == 66 && getdistance player < 1000
if suicide == 0
set timer to sayTo player MQ15EldamilWarning
set suicide to 1
endif
endif

if suicide == 1 && getstage MQ15 == 66 && timer <= 0
setstage MQ15 67
endif


Before the optimalization, this script would always check 9 things in the if statements, no matter what happens. These are:
timer <= 0
getstage MQ15 == 58
OrtheRef.getdead == 0
timer <= 0
getstage MQ15 == 66
getdistance player < 1000
suicide == 1
getstage MQ15 == 66
timer <= 0

As you can see there are quite a few duplicate checks, and some checks would not always have to be executed.
After the optimization, the following is used:

if timer <= 0
if getstage MQ15 == 58
if OrtheRef.getdead == 0
set timer to 5
sayTo player MQ15EldamilWarning
endif
elseif getstage MQ15 == 66
if getdistance player < 1000
if suicide == 0
set timer to sayTo player MQ15EldamilWarning
set suicide to 1
elseif suicide == 1
setstage MQ15 67
endif
endif
endif
endif


After the optimization, the script does not always check for all the options, because that's not needed. In certain circumstances, the game will check for only one thing, and only if it finds a certain answer will it continue. Lets take a look at the posibilitys:

option 1: timer > 0
only 1 question is needed here 8 questions less
option 2: timer <= 0 getstage mq15 == 58 ortheref.getdead == 1
3 questions needed 6 questions less
option 3: timer <= 0 getstage mq15 == 58 ortheref.getdead == 0
3 questions needed 6 questions less
option 4: timer <= 0 getstage mq15 != 58 getstage mq15 == 66 getdistance player >= 1000
4 questions needed 5 questions less
option 5: timer <= 0 getstage mq15 != 58 getstage mq15 == 66 getdistance player < 1000 suicide == 0
5 questions needed 5 questions less (original needs 10 here)
option 6: timer <= 0 getstage mq15 != 58 getstage mq15 == 66 getdistance player < 1000 suicide == 1
5 questions needed 5 questions less (original needs 10 here)
option 7: timer <= 0 getstage mq15 != 58 getstage mq15 != 66
3 questions needed 6 questions less

You can see that it doesnt which option it is it takes less questions/checks to find out if the conditions are met for specific things. Scripters will notice that the script will do exactly the same, no matter what the variables are, but with less checks. And a check will always take more cpu power than no check.
Interestingly enough, "timer <= 0' is almost always false, so the other checks would only be needed every few seconds, instead of once every frame, in the old script, every check was done every frame, now only one check has to be done every frame.
Some of the checks are also easier to perform, "if timer <= 0" is a simple variable check and takes almost no time, "getdistance player < 1000" however involves a calculation and takes some more performance. By hiding heavier checks behind easier checks, performance is increased, especially if the easy checks are almost never passed.

Note that statements such as "if timer <= 0 && getstage MQ15 == 66 && getdistance player < 1000" would in most programming languages execute the first check first, and ignore the others if the first was false. But extensive testing shows that the Oblivion engine controls all 3 statements no matter what. By nesting the statements, this problem is solved. See also the discussion here http://www.bethsoft.com/bgsforums/index.php?showtopic=753010 for more information.


=============================
Install
=============================
Just extract into your oblivion/data folder, use obmm or something similar to load it first, activate it and you're done.