Main Campaign Modding- What we know (so far*)
*More specifically, what I know as of 1.0.81 on 7/27/2014

Because it would be handy to have this information in one place, I'm going to compile the information I have gathered so far about modding the Main Campaign.

First, the two rules that are pertinent to Main Campaign mods (and how to get around them)-
Click to reveal..

1) Only one mod can be active in a given playthrough at a time. If multiple mods are enabled at game start, then only the top one in the list will be active.

2) Mods by default cannot be swapped out mid-game. If you activate a mod and then load an unmodded save, the game loads as if the mod wasn't enabled.

Workarounds-
1- The solution to this is to just merge the different mods into one. This is only really doable if the mods aren't in a .pak form though, since .pak files don't like to merge easily (unless you unpak them with third party tools).

2- Getting a mod to be effective mid-game (or removing a mod midgame) takes a bit of save file editing.
A) Create a new game with 1 mod enabled. Save it as a new save file when you exit Character Creation.
B) Go to Documents/Larian Studios/Divinity Original Sin/Player Profiles/(Profile Name)/Savegames/(New Save name)/ and copy the meta.lsb there
C) Go to your old unmodded savegame folder and paste the meta.lsb you just copied, replacing it
D) Start up the game again and load your previously unmodded save. It should now have the mod effects. You may need to teleport to reach the map you were previously at, since it'll load in Cyseal regardless of where you were before.


Now on to modding the Main Campaign itself.
1. RootTemplates (for Characters and Items)
Click to reveal..

RootTemplates are an integral part of every single item and character within the game. If a RootTemplate for a Crate says that the Crate drops MegaBoss loot, then anything that uses that RootTemplate will drop the MegaBoss loot.

Basically, when it comes to modding the existing Main Campaign, you can either change the RootTemplate itself, or change the contents of whatever the RootTemplate is pointing to. This part will deal with the former.

At the top of the Editor you can see a button that says "Create and view templates" Clicking this brings up a list that contains every RootTemplate available for your Main-dependent mod. Be sure to click View -> Sidebar at the top as well.

For this example, I'll be showing how to change the Crate RootTemplate so that it contains MegaBoss loot.

In the Template list, search for "crate" at the top and click the "All" to the side. This should bring up a list of items with "Crate" in their name. The first entry, "Cont_Crate_A" is the one we want to change.

When you click that entry, you'll see information fill up the Sidebar to the right. When modifying an existing Template, the first thing to do is make sure that it gets saved to an appropriate location. In the Sidebar near the top there is an entry called "FileName" Click the entry there, and then the "..." button to the right to select the filepath.

A box opens that asks where you want to save it, with the default opening location pointing to Divinity " Original Sin/Data/Public/Main/RootTemplates/. We want to save it in a different location instead: Divinity - Original Sin/Data/Public/(Mod Name)/RootTemplates/. (Mod Name is the name of your mod followed by a bunch of numbers when you look in your Divinity folder). The filename can be anything you want.

Once you set the correct location, save *twice*. The first time you save, it will give you an error saying you don't have Developer rights. Subsequent saves work fine though, since the Editor is no longer trying to access a protected location.

Now you can get your changes to the RootTemplate to stick. To add MegaBoss loot to the Crate, just go to the "Inventory" entry. By default it contains the "Cont_Crate;" entry. You can just edit it so that it says "Cont_Crate; MegaBoss;" instead. Save again, and now any crate that uses this RootTemplate will drop MegaBoss loot (note: MegaBoss is the name of the specific TreasureTable that big bosses use; random names for inventories won't work).

The other entries in the RootTemplate can be modified in a similar way.


2. Stats- Changing existing stats for characters/items
Click to reveal..

As I mentioned in Part 1, I said that when it comes to modding existing items you can either change the RootTemplate, or change what the RootTemplate points to. The Stats folder for your mod (or the Main campaign, should your mod not have one) is where the content that the RootTemplates point to reside.

Unfortunately this part can't be done effectively without knowledge of what the pre-existing stat names/values are. These aren't really available in the Editor; the only way to know what a Stat/Equipment value contains is to look at the Main campaign Stats files yourself, which requires third party tools at the moment.

With that being said, first you need the correct folder setup for Stats within your mod. You need to have the following folders-
Code:
Data/Public/(Mod Name)/Stats/Generated/Data/
Data/Public/(Mod Name)/Stats/Generated/Links/
Data/Public/(Mod Name)/Stats/Generated/Structure/ (this may or may not need the contents of the Main campaign Structure folder in it)


In general, these two rules can be followed when modding anything concerning the Stats folder-
1) If the original Stats txt file has spaces between lines in it, your Stats.txt can safely have spaces in it.
2) If the original Stats txt file doesn't have spaces between the lines (SkillSet.txt for example), then your Stats txt file can't have spaces between the lines either.

Now say I want to modify the Source Hunters' stats when they begin a new game. Looking at their RootTemplate, it says that Player1 uses the MaleHero Stats and Player2 uses the FemaleHero Stats.

These stats are defined in the "Character.txt" of the Main campaigns" Stats/Generated/Data/ folder:
Code:
new entry "MaleHero"
type "Character"
using "_Hero"
data "Weight" "75000"

new entry "FemaleHero"
type "Character"
using "_Hero"
data "Weight" "55000"


Before I continue, I must point out that each of these lines has significance. Let's take the MaleHero for example-
Code:
new entry "MaleHero" 

The words "New entry" tells the Game that this is a new Stats entry. The words in the quotation marks afterwards ("MaleHero" is the name that the game and other files can refer to. Should two or more entries have the same name, then the last one loaded will have precedence.

Code:
type "Character" 

This tells the game that this Stat entry belongs to a Character. There are other " ypes" that a Stat entry can have, and each of those can contain certain values.

Code:
using "_Hero" 

This line is like the "import" statement of programming languages; it says that this Stat entry has the characteristics of whatever it's using (the _Hero entry) before it makes any changes.

An important thing to note is that the entry being used must be in the *same* txt file as whatever is using it. If your mod's entry has " sing "_Hero" " without defining it yourself, then the game will read that as an error and ignore it.

Code:
data "Weight" "75000" 

This line is how the Stats file can assign values to the different variables defined by its type. You can look at other entries to see what values can be changed using a data line.

If you wanted to make it so that both player characters had 10 to all stats, you would need to have your txt file look something like this:

Code:
new entry "_Hero"
type "Character"
data "Act" "1"
data "Act part" "1"
data "Act strength" "0"
data "Strength" "5"
data "Dexterity" "5"
data "Intelligence" "5"
data "Constitution" "5"
data "Speed" "5"
data "Perception" "5"
data "Armor" "0"
data "Reflexes" "0"
data "Vitality" "100"
data "APMaximum" "7"
data "APStart" "2"
data "APRecovery" "4"
data "Movement" "0"
data "Gain" "None"
data "Sight" "0"
data "Hearing" "0"
data "Initiative" "0"
data "FOV" "90"
data "Weight" "50000"
data "PiercingResistance" "0"
data "SlashingResistance" "0"
data "CrushingResistance" "0"
data "ShadowResistance" "0"
data "CriticalChance" "0"
data "MaxResistance" "200"
data "FireResistance" "0"
data "EarthResistance" "0"
data "WaterResistance" "0"
data "AirResistance" "0"
data "PoisonResistance" "0"
data "WarriorLore" "0"
data "RangerLore" "0"
data "SingleHanded" "0"
data "TwoHanded" "0"
data "Blackrock" "0"
data "Bow" "0"
data "Crossbow" "0"
data "Shield" "0"
data "ArmorMastery" "0"
data "BodyBuilding" "0"
data "Willpower" "0"
data "Sourcery" "0"
data "Telekinesis" "0"
data "FireSpecialist" "0"
data "WaterSpecialist" "0"
data "AirSpecialist" "0"
data "EarthSpecialist" "0"
data "Repair" "0"
data "Sneaking" "0"
data "PickPocket" "0"
data "LockPicking" "0"
data "Loremaster" "0"
data "Crafting" "0"
data "Barter" "0"
data "Charm" "0"
data "Intimidate" "0"
data "Reason" "0"
data "Charisma" "0"
data "Leadership" "0"
data "Luck" "0"
data "PathInfluence" "Lava,70;Fire,40;Electrified,40;BloodElectrified,40;CloudPoison,40;CloudStatic,40;Ooze,30"

new entry "FemaleHero"
type "Character"
using "_Hero"
data "Weight" "55000"
data "Strength" "10"
data "Dexterity" "10"
data "Intelligence" "10"
data "Constitution" "10"
data "Speed" "10"
data "Perception" "10"

new entry "MaleHero"
type "Character"
using "_Hero"
data "Weight" "75000"
data "Strength" "10"
data "Dexterity" "10"
data "Intelligence" "10"
data "Constitution" "10"
data "Speed" "10"
data "Perception" "10"



Changing SkillSets
Click to reveal..

Say you want your Wizard to start out with Lava Core instead of a simple Flare. SkillSets are what define what skills are available to a character.

Your mod's SkillSet.txt needs to be located in your mod's Stats/Generated/ folder. This is one of the files that can't tolerate empty line breaks, so don't separate any of your entries.

Looking at the Main SkillSet.txt, you can see that the Wizard uses the following skillset-
Code:
new skillset "Class_Wizard"
add skill "Projectile_FlareStart"
add skill "Target_TargetedOilSurface"
add skill "Projectile_PoisonDartStart"
add skill "Projectile_StaffOfMagus"


There's only two real lines of note-
Code:
new skillset "Class_Wizard" 

As like with the other entries of this type, this line tells the game that it is A) a SkillSet, and B) what name refers to it (can be used in RootTemplate entries).

Code:
add skill "Projectile_FlareStart" 

This line says what skill should be added to the skillset. The name in the parentheses is defined in the Stats/Generated/Data/SkillData.txt file (or your own mod's SkillData type Data entries). The skill name for Lava Core is Path_CreateLava, so to change Flare to Lava Core this is what the mod's SkillSet.txt would look like-

Code:
new skillset "Class_Wizard"
add skill "Path_CreateLava"
add skill "Target_TargetedOilSurface"
add skill "Projectile_PoisonDartStart"
add skill "Projectile_StaffOfMagus"


Note: Preset classes must have 4 skills, no matter what they are. Any more than 4 will be ignored by the game due to how Character Creation works.


Equipment entries
Click to reveal..

Say we want to change what equipment our default Wizard starts off with. The Equipment file belongs in your mod's Stats/Generated/Equipment.txt file.

First let's look at what the main game uses-
Code:
new equipment "Class_Wizard"
add equipmentgroup 
add equipment entry "WPN_Quarterstaff_Sourcehunter_Fire"
add equipmentgroup 
add equipment entry "POTION_Minor_Healing_Potion"
add equipmentgroup 
add equipment entry "POTION_Minor_Healing_Potion"
add equipmentgroup 
add equipment entry "SCROLL_Resurrect_1"
add equipmentgroup 
add equipment entry "SCROLL_Fireball_1"
add equipmentgroup 
add equipment entry "CONT_Backpack_A_SourceHunter"


This time there are three types of lines-
Code:
new equipment "Class_Wizard" 

This tells the game that this is an equipment entry and goes by the name "Class_Wizard" (RootTemplates can refer to this name)

Code:
add equipmentgroup

This is apparently necessary before each and every item, even for duplicates.

Code:
add equipment entry "WPN_Quarterstaff_Sourcehunter_Fire"

This line tells the game that the item named "WPN_Quarterstaff_Sourcehunter_Fire" from the Stats/Generated/Data folder belongs to this Equipment group.

Adding items is as simple as adding more lines. If I want to give my Wizard 10 Blood Stones at the start, I would have this-

Code:
new equipment "Class_Wizard"
add equipmentgroup 
add equipment entry "WPN_Quarterstaff_Sourcehunter_Fire"
add equipmentgroup 
add equipment entry "POTION_Minor_Healing_Potion"
add equipmentgroup 
add equipment entry "POTION_Minor_Healing_Potion"
add equipmentgroup 
add equipment entry "SCROLL_Resurrect_1"
add equipmentgroup 
add equipment entry "SCROLL_Fireball_1"
add equipmentgroup 
add equipment entry "CONT_Backpack_A_SourceHunter"
add equipmentgroup
add equipment entry "Quest_Stone_Blood_B"
add equipmentgroup
add equipment entry "Quest_Stone_Blood_B"
add equipmentgroup
add equipment entry "Quest_Stone_Blood_B"
add equipmentgroup
add equipment entry "Quest_Stone_Blood_B"
add equipmentgroup
add equipment entry "Quest_Stone_Blood_B"
add equipmentgroup
add equipment entry "Quest_Stone_Blood_B"
add equipmentgroup
add equipment entry "Quest_Stone_Blood_B"
add equipmentgroup
add equipment entry "Quest_Stone_Blood_B"
add equipmentgroup
add equipment entry "Quest_Stone_Blood_B"
add equipmentgroup
add equipment entry "Quest_Stone_Blood_B"



3. Adding new skills/items to the game
Click to reveal..

I'll be going over how to add a new Skill here. This includes introducing an item (Skillbook) that allows the Skill to be learned/used. This part uses knowledge from the above sections. The example I will be using is the custom Fire rain skill I added to the game in one of my other mods.

The first thing that all Skills need is a Stats/Generated/Data entry. Within a txt file within your mod's Stats/Generated/Data/ folder, you can copy/paste the pertinent information from the Main campaign's SkillData.txt file to use as a template to which you make changes.

This is the Skill entry I ended up with for my Fire Rain skill-
Code:
new entry "UNFAIR_Rain_Fire"
type "SkillData"
data "SkillType" "Rain"
data "Ability" "None"
data "Element" "Fire"
data "ActionPoints" "5"
data "Cooldown" "40"
data "ChargeDuration" "0"
data "Lifetime" "5"
data "SurfaceType" "Fire"
data "SurfaceLifetime" "12000"
data "SurfaceStatusChance" "100"
data "SkillProperties" "CreateSurface,2,5,Fire,100;TargetCreateSurface,1,5,Fire,100;Hasted,200,5"
data "TargetRadius" "15"
data "UseCharacterStats" "No"
data "UseWeaponDamage" "No"
data "AreaRadius" "15"
data "TotalSurfaceCells" "125"
data "SurfaceGrowStep" "5"
data "SurfaceGrowInterval" "150"
data "Icon" "Skill_Fire_Haste"
data "DisplayName" "UNFAIR_Rain_Fire_DisplayName"
data "Description" "UNFAIR_Rain_Fire_Description"
data "StatsDescription" "UNFAIR_Rain_Fire_StatsDescription"
data "FXScale" "100"
data "PrepareAnimationInit" "cast_long_start"
data "PrepareAnimationLoop" "cast_long_loop"
data "PrepareEffect" "FX_Skills_Fire_Summon_Prepare_A"
data "CastAnimation" "cast_long_cast"
data "CastTextEvent" "cast"
data "TargetEffect" "FX_GP_Target_Fire_A"
data "Magic Cost" "1"
data "RainEffect" "FX_Env_RainFire_A"
data "Atmosphere" "Rain"
data "ConsequencesStartTime" "1000"
data "Skillbook" "SKILLBOOK_UNFAIR_Rain_Fire"

new entry "UNFAIR_Rain_Fire_10"
type "SkillData"
using "UNFAIR_Rain_Fire"
data "Level" "10"


Now I won't be going over what every line does; it's just important to know that different skill types (Rain, Projectile, etc) make use of different parameters.

There are a few important lines though-
Code:
new entry "UNFAIR_Rain_Fire"
type "SkillData"

As before, this tells the game that this is a SkillData entry, as well as its name (UNFAIR_Rain_Fire).

Further down you see
Code:
new entry "UNFAIR_Rain_Fire_10"
type "SkillData"
using "UNFAIR_Rain_Fire"
data "Level" "10"

All skills have something similar; it tells the game which level the Skill is (important for determining how much your levels affect the skill effects), and the "data "Level" "10" " line says this Skill can be learned at Level 10.

Going back up a bit-
Code:
data "Element" "Fire"

This tells the game that it belongs to the Pyrokinetic school of magic. If this were set to a different value, it would go into a different skill school instead.

Code:
data "DisplayName" "UNFAIR_Rain_Fire_DisplayName"
data "Description" "UNFAIR_Rain_Fire_Description"
data "StatsDescription" "UNFAIR_Rain_Fire_StatsDescription"

These lines are important for getting the game to display the name and description for your custom skills.

Within the Editor, at the top there is the button that says TranslatedStringKey. If you enter that menu, a window pops up. Create a new file.

You will then need to enter a series of Key and Content pairs. For your skills, the Keys are what you put after the "DisplayName" "Description" and "StatsDescription" of your SkillData. My TranslatedStringKey file for my custom Fire rain skill looks something like this-
Code:
Key: UNFAIR_Rain_Fire_DisplayName
Content: Wild Fire Rain

Key: UNFAIR_Rain_Fire_Description
Content: Bring forth a fire rain that hastens friend and foe alike.

Key:UNFAIR_Rain_Fire_StatsDescription
Content: Radius: 15m<br>Duration:5 turns<br><br>Creates fire on terrain. Hastens all targets for 5 turns, and creates fire underneath each target at the start of their turn for 5 turns.


The TranslatedStringKey goes into your Mod's Data/Mods/(Mod Name)/Localization/ folder.

----

After creating the SkillData entry (and its Localization file), the next part is to create a Skillbook RootTemplate with which it can be used. Because it's a fire skill, I can create a new RootTemplate from any existing Fire Skillbook Template.

In the Editor, I go to the Template viewer and search the Books_Scrolls for "Skill_Fire" I right click the "Book_Skill_Fire_Haste" entry, and click "Create new from selected." In the box that comes up, I set the FilePath to my mod's RootTemplate folder, and set the Displayname and File Name to whatever I'm wanting. Then I finish its creation.

Selecting the new RootTemplate that was just created, you can set various values for it. But there's one other step to do beforehand, which is to create a Stats entry for this book itself.

In my mod's Stats/Generated/Data folder, I add these to a new (or old) txt file-
Code:
new entry "_Skillbooks"
type "Object"
data "ModifierType" "Item"
data "Act" "1"
data "UseAPCost" "6"
data "Value" "7"
data "Weight" "500"
data "Requirements" "Level 4"
data "InventoryTab" "Magical"

new entry "SKILLBOOK_UNFAIR_Rain_Fire"
type "Object"
using "_Skillbooks"
data "Act part" "10"
data "Requirements" "Level 10"


Now I can set the RootTemplate's Stats to "SKILLBOOK_UNFAIR_Rain_Fire" and set it's OnUse action to learn the "UNFAIR_Rain_Fire" skill (note- you might have to reload the Editor to get these options to show up, since it needs to load the new Stats files)

The last step in getting a fully functional Skillbook into the game is to create a txt file in the Stats/Generated/Links/ folder. The Links folder is how the game can link a Stats entry to a RootTemplate.

Here is my mod's Links file for the Fire Rain skill-
Code:
object itemstat "SKILLBOOK_UNFAIR_Rain_Fire","ea880242-8ee0-4719-b969-325b252049d3","",0,0,"SkillbookFire",1,1,8,0,8,20


There are really three important parts to this line-
Code:
object itemstat "SKILLBOOK_UNFAIR_Rain_Fire","ea880242-8ee0-4719-b969-325b252049d3"

This part is what links my Stat entry to the RootTemplate's GUID (that string of letters and numbers).

Code:
"SkillbookFire" 

This is what the game refers to as an "object category". It can be anything you want. This is what the game looks at when it's looking to add random items to something. For example, the Fire vendor will randomly add items with the object category "SkillbookFire" when its determining its inventory; this is what allows my custom item to show up in the game.

Code:
1,1,8,0,8,20

MinAmount | Max Amount | Priority | ??? | Min Level | Max Level |

The first two state how many can be stacked in your inventory I believe. I'm not sure about Priority (its 8 or 10 for skillbooks apparently). The Min Level and Max Level describe at what levels your item can be found. In my case, you can find the book starting at level 8. If you set this to 1, you would be able to purchase it from a vendor at the beginning of the game.


Edit:
After several attempts, I finally got this to copy/paste correctly. There's some sort of Encoding difference between the Word Processors I use and this forum.

If there are any unintelligible lines/characters remaining, please let me know so I can fix it.

Last edited by Rhidian; 28/07/14 03:07 AM.