Modding

## Goals

The goals for the modding system is to allow users to do the following:

* Create small mods like adding new items, recipes, monsters, armor etc.
* Extend the existing campaign
* Create campaigns with levels and dungeons with unique quests and NPCs
* Add custom art and sounds
* Play through these mods alone or with friends
* Upload campaigns and mods that can be downloaded and played by the community through Steam workshop.

A major goal is to make modding easier and more intuitive then the modding in most other games. The editor is integrated with the game No programming experience required. The scripting is all through visual interfaces. Anyone can open the levels and dungeons in the main campaign and see how everything is done. Quick iteration is also important, their is no separate program and no need to create a build and then run the game to test. Testing a new mod is as easy as hitting play from editor mode (wait a few seconds) and then you are play testing your mod. The main campaign is built using the same editor that is in the game.

## What you can mod

* Create
	+ Campaigns
	+ Islands
	+ Dungeons
	+ Buildings through the builder system
	+ NPCs
	+ Quests
	+ Dialogue trees
	+ Combat behaviors
	+ AI brains
	+ Items
	+ Biomes
	+ Sound sets
	+ Patrol paths
	+ Attributes
	+ Charisma skills
	+ Spells
	+ Special effects
	+ Crafting recipes
	+ Class templates
	+ Loot tables
	+ Lakes and rivers
	+ Factions
	+ Fences
	+ Bridges
	+ Ambient sound areas
	+ Switches
	+ Area triggers
	+ Map markers
* Extend
	+ Extend existing campaigns using portals and modules
* Import
	+ Terrain texture sets
	+ Music, speech and sounds
	+ Item models
	+ Object models
	+ NPC and player models
	+ Animations
	+ Icons
	+ Armor and clothing skinned meshes
	+ Hairs and Facial hair
	+ Skin variations
	+ Face variations
	+ Fence models
	+ Bridge models
	+ Grass meshes
	+ Footstep sounds
	+ Custom skydomes that change according to the time of day

## What you can't mod

* User interface
* Core mechanics of health and stamina and how attributes work with health and stamina

## Modules

Modules are folders that can be created by users that can contain levels, dungeons, and all the databases used in modding. The main module is a special module that is shipped with the game. Any resources in the main module can be used by any other modules. Any changes to the main module cannot be uploaded to the steam workshop and will most likely be overwritten by a subsequent patch of the game. Modules created by the user will not be overwritten bu a game patch and can be uploaded to Steam. This is where all of the resources for your mod should be placed. Each module resides in a unique folder so multiple modules can be downloaded to a user's game without conflicting with each other. Each database in the game has a button used to select the module to get or put data in. In the image below the dialog is looking at resources in the main module. Press the carat next to main to select one of the other modules currently installed or one that you created.

## Importing assets

In order to be able to bring assets like meshes, sounds, materials, and animations into the game you will need to download Unity 2017.4.x. This is a free download.

The general workflow:

1. Create a 3D project in Unity 2017.4.x. You only have to do this once.
	1. https://docs.unity3d.com/2017.4/Documentation/Manual/UnityBasics.html
2. Import assets into Unity.
	1. https://docs.unity3d.com/2017.4/Documentation/Manual/AssetWorkflow.html
3. Assign those assets to an asset bundle. Then build the asset bundle.
	1. https://docs.unity3d.com/2017.4/Documentation/Manual/AssetBundlesIntro.html
	2. Make sure the asset bundle's compression is set to Chunk based compression (LZ4) otherwise it will not work in the game.
	3. The asset bundle browser can be useful for managing your asset bundles. It is a separate package on GitHub that has to be imported into your project. https://github.com/Unity-Technologies/AssetBundles-Browser
4. Copy the asset bundle and its .manifest into your module directory.
5. Open Isles of Adalar and edit an island or dungeon. From there you can create database objects (items, entities, sounds, environmental objects etc) that reference the assets contained in your asset bundle.
6. Now you can use those objects in the game.

   Once you create a new object in a database in the game you will see some properties one of which will be bundle asset.

In the bundle asset property the first edit box shows main. You would change this to your module by pressing ... next to the text and selecting the module you previously created. The middle edit box shows the asset bundle to get the asset from. Press ... to the right of the edit box and you will get a list of asset bundles in your module. Select the one that contains the asset you want. Then the final edit box shows the name of the asset. Press ... to the right of this edit box to select the asset within the asset bundle.

## Import animations

Isles of Adalar uses Unity's legacy animation system and non-root motion animation.

In order to get an entity with animations to work in Isles of Adalar a number of steps have to be taken in Unity to setup an animated mesh for use in isles of adalar.

1. Remove any Animator components from the prefab.
2. Select the fbx file(s) that contain the mesh and the animations. This could be all in one fbx file or in multiple fbx files. Click on the rig tab and switch the Animation type to Legacy. Make sure the Generation type is Store in Root (new). Make sure you do this for every fbx file that has an animation or a skinned mesh renderer in it for the model you want to use.
3. Add an Animation component to the prefab and drag all the animations from the fbx files into the Animation component
4. Then make sure it is assigned to an asset bundle, build the asset bundle, copy it to your module and then you should be able to set it up in Isles of Adalar.