Combine your SI and non-SI mods into one (OBSE, Patch v1.1, Other mods too)

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search

It is possible to make a single mod for both users with Shivering Isles and without. Likewise, it's possible to make a single mod for OBSE/non-OBSE users, Patch v1.2/v1.1 users, and even specific mods without creating a dependency (i.e., the user has Supreme Magicka installed or doesn't). Generally, if you needed multiple mods only because you needed multiple scripts you can combine them into one with these tests (more than scripts may be possible, I simply don't know and haven't tried--Haama 15:41, 12 January 2008 (EST)). This is an advanced script and assumes you know quite a bit about scripting already, so some of the smaller details are left out.

Each test has the same setup - When you need to tell what the player has installed, call up a Result Script (i.e., SetStage SITester 0). If the Installed variable on that quest script is true (1), then the player has installed it. Otherwise, it will be false (0). Use the returned Installed value to determine if you need to run a piece of script (or a separate script altogether).

Each test works a little bit differently, so they have been separated. For each, the test setup/coding is given first, then an explanation of how it works and finally how to use the test.


Tools used in this tutorial

Required


How to tell if the player is using OBSE[edit | edit source]

Test[edit | edit source]

Make sure you are using the Construction Set with OBSE loaded. Keep it loaded while you work on the mod! This test will ensure the player has the correct version of OBSE installed, if necessary.

First, create a quest (cobOBSETester in this case). Set it to Allow Repeated Stages and uncheck Start Game Enabled. Attach a script with these 3 variables to it

short Installed
short ReqVersion
short Version

Next create the stage (Stage 0, in this case) and add this Result script

set cobOBSETester.Installed to 0
set cobOBSETester.Version to GetOBSEVersion
if (cobOBSETester.Version >= cobOBSETester.ReqVersion)
	set cobOBSETester.Installed to 1
endif
;Reset variables
set cobOBSETester.Version to 0
set cobOBSETester.ReqVersion to 0

How it works[edit | edit source]

When Oblivion comes across a function it doesn't recognize, that function acts as a return. If the player doesn't have OBSE installed, the script stops at the second line and cobOBSETester.Installed remains at 0. This is followed by another test to make sure the player has a high enough version (ReqVersion) of OBSE installed, and if they do, sets Installed to 1.

Using the test[edit | edit source]

Each time you need to test for OBSE, use this snippet

set cobOBSETester.ReqVersion to 12
SetStage cobOBSETester 0
if (cobOBSETester.Installed)
	CopyAllEffectItems pPotion pSpell ;OBSE part of the script
	cobAlsEffectsDeterminerRef.Activate player, 1 ;or run a separate script
else
	set bRunSorter to 1 ;Non-OBSE part of the script
endif

Make sure OBSE functions are kept in the OBSE part of the script (or on another script), and that they will only run if Installed returns true.

How to tell if the player is using SI[edit | edit source]

Test[edit | edit source]

Make sure you have an Oblivion.esm with the Shivering Isles information and one without before you start. To do this, you need to make a copy of Oblivion.esm before you install Shivering Isles. If you have already installed Shivering Isles, you will need to uninstall Oblivion and reinstall again. While working on the mod, make sure the Shivering Isles version is named Oblivion.esm.

Set up the quest as before, but you only need the Installed variable. Here's the Result script

player.GetIsID SE02BoneArrow1
set cobSITester.Installed to 1

How it works[edit | edit source]

Whenever a script uses a FormID (Quest, Magic Effect, Items, etc.) that isn't loaded, Oblivion will ignore the entire script in-game. So, Installed must be set to 0 by the calling script first, then the test script will set Installed to 1 (if the player has SI installed).

Using the test[edit | edit source]

Each time you need to test for SI, use this snippet

set cobSITester.Installed to 0
SetStage cobSITester 0
if cobSITester.Installed
	cobSIEffects.Activate player, 1 ;Code if SI is installed - if you're using any EditorIDs from SI, make sure to keep them on a separate script
endif

Again, Oblivion will ignore the script if it includes a SI EditorID - so keep your SI EditorIDs on a separate script. If it needs to happen at that exact line of the script, you can use either a Persistent Object/Activator with an onActivate block, or a Result script. onActivate blocks have a nesting limit, and only 4-5 can be called from one another. Result scripts don't have a limit (or, at least it's >250), but are Non-reference scripts and have a very small characters limit.

To clear some confusion, the functions added by the version 1.2 patch do not require SI. Only the quests, textures, spells, items, etc. added to Oblivion.esm by SI require SI. It is unknown what happens when, for instance, a SI item is added to a leveled list and the player loads the mod without SI. However, scripts have been tested and they work.

How to tell if the player is using the v1.2 Patch[edit | edit source]

(I have not tested this one (I don't have a way to short of re-installing Oblivion), but extrapolating from the OBSE test...--Haama 14:31, 5 December 2007 (EST))

Test[edit | edit source]

Make sure you have a v1.2 Oblivion.esm and v1.1 Oblivion.esm before you start. To do this, you need to make a copy of Oblivion.esm before you upgrade or install Shivering Isles. If you have already installed the latest patch, you will need to uninstall Oblivion and reinstall again. While working on the mod, make sure you're using v1.2 (it's named Oblivion.esm).

Quest - just the 'Installed' variable again. Result script

set cobPatchTester.Installed to 0
GetPlayerInSEWorld
set cobPatchTester.Installed to 1

How it works[edit | edit source]

As with the OBSE tester, an unknown function acts as a return statement. If the player doesn't have the v1.2 patch installed, the script will stop on the second line and Installed will remain 0. Otherwise, it will be 1.

Using the test[edit | edit source]

Each time you need to test for v1.1, use this snippet

SetStage cobPatchTester 0
if (cobPatchTester .Installed)
	cobAlsEffectsDeterminerRef.Activate player, 1;v1.2 script, or you could have some code in this section
else
	set bRunSorter to 1;v1.1 part of the script
endif

Make sure v1.2 functions are kept in the v1.2 part of the script (or on another script), and that they will only run if Installed returns true.

How to tell if the player is using a particular Mod[edit | edit source]

This requires the OBSE v14 function IsModLoaded. A harder, less useful code can be used for pre-v14 OBSE, but it's not suggested. Make sure you tell users of your mod to not rename the other mod.

While you can change anything within your own mod, it's difficult to use anything from the other mod. You can't refer to any EditorIDs of the other mod in a script. (If you need to, you will need to make your mod dependent on the other mod). Instead, you will need to refer to the other mod in a text file and use RunBatchScript. RunBatchScript is very limited, and the lines in the text file will run as if they had been written in the console.

Reminders and notes[edit | edit source]

These techniques can be used to combine scripts. Any other combination (adding items from another mod to a leveled list, etc.) has been untested. Remember that it is possible to do many things through script:

  • Instead of dropping a SI item into a container, make a script that uses AddItem to add it to the container.
  • You can use GetInventoryObject and GetFirstRef to get the reference of nearly anything. Coordinate with the other modder so these items can be placed in common places (i.e., the player) so you can use the references.

When a script uses a EditorID (including spells, quests) of something that doesn't exist when Oblivion is loaded, the entire script will be ignored. Therefore, keep any SI and other mod EditorIDs in a separate script (persistent Activator or Result script would be good).

When a script uses a function that isn't recognized by Oblivion, it acts as a return. Make sure all of your OBSE and Patch v1.2 functions occur after the test.