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

From the Oblivion ConstructionSet Wiki
Revision as of 15:31, 5 December 2007 by imported>Haama (Created)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


Some 'How-to's on combining OBSE/non-OBSE, SI/non-SI, Patch v1.1/v1.2, and some other Mod/Not scripts. All are limited to scripts; that is, if you needed 2 mods only because you needed 2 different scripts, you can use this tutorial to combine them into one.

They all have 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 1, then the player has installed it; otherwise, it will return 0. I'll give the setup and then the explanation of how it works (sorry, just easier to do it that way). Since this is fairly advanced stuff, I've left out a lot of little steps.

This article is also up for discussion in the ESP vs. ESM --- Community Discussion thread on the Besthesda forums.

How to tell if the player is using OBSE

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

Now, how it works - 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, as set from another script) of OBSE installed, and if they do, sets Installed to 1.

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

set cobOBSETester.ReqVersion to 12
SetStage cobOBSETester 0
if (cobOBSETester.Installed)
	cobAlsEffectsDeterminerRef.Activate player, 1;OBSE script, or you could have some code in this section
else
	set bRunSorter to 1;Non-OBSE part of the script
endif

How to tell if the player is using SI

This one works a little differently. Set up the quest as before, but you only need the 'Installed' variable. Here's the Result script [code]player.GetIsID SE02BoneArrow1 set cobSITester.Installed to 1[/code] 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

How it works - Whenever a script uses a FormID that isn't loaded, Oblivion will ignore the entire script in-game. So, Installed must be set to 0 by the real script first, then the Test script will set Installed to 1 if the player has SI installed. This has been tested, and I'm sure that Oblivion will use the script once SI has been installed, even if the Test script attempted to run in an earlier save. There might be a better way to go around it - maybe

set cobSITester.Installed to 1
return
player.GetIsID SE02BoneArrow1

would be a bit faster, maybe there are other things to test (however, any FormID, whether Quest, Magic Effect, etc. will cause the script to basically fail to compile, so I'm not sure what test would be truly different).

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.

How to tell if the player is using the v1.2 Patch

(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))

Quest - just the 'Installed' variable. Result script

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

How it works - 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.

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

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

How to tell if the player is using a particular Mod

(Credit to Opaj for the idea) This one is a bit odd and requires more work. However, it gets rid of the need for dependcies and false-Mastering so it's worth it. This requires the latest OBSE.

Set up a quest (cobOtherModsTest in this case) with 'Start Game Enabled'. Attach this script to it

begin GameMode
if GetGameRestarted
	set Installed to -10
	RunBatchScript "TamrIngTest.txt"
endif
end

Create the text file mentioned above, and put it in the Oblivion directory (not Data, just Oblivion), open it, add the line

set cobOtherModsTest.Installed to TamrIngTest.Installed

How it works - RunBatchScript will run the line from the text file as if it were used in the console. If the mod is installed (and has the quest installed, more on that later) Installed will be set to TamrIngTest.Installed, if it isn't it will remain at -10.

Here's where it gets a bit weird - first, you need to make sure the quest variable in the second mod is set to a number other than -10. Hopefully there will be some Init variable that you could use. Second, it would help to have a quest too! If there isn't one, you could ask the author to include one.

Suggestions?

A better solution would be to use an item from the second mod and grab a non-zero value from it. However, EditorIDs can't be used from the console, so I'm not sure how to make this work. Another possibility would be globals, but I haven't tried them, and I don't think they would be any better.

General notes

This can only be used for scripting purposes. You still can't take an item from another mod/SI into a container in yours directly - you'd have to add the item via script.

Remember that 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).

Remember that 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.