Modding System

Play with Mods


Introduction

A mod for Daggerfall Unity has .dfmod extension and it can include different varieties of assets, including scripts. This make them a powerful tool as mods can interact directly with the core game and affects game behaviour, as well as add new features on top of the solid base provided by Unity and DTFU.

Mods benefit of an integrated replacement framework which provide artists a code-free platform for graphic improvements of the original Daggerfall; this avoid any incompatibility and make use of the load order to smoothly handle duplicates. Certain assets, such as textures, sounds and music and even new quest files, can also be imported directly from folders on disk as loose files.

Finally, several mods created for the dos game are still functional with Daggerfall Unity since the original assets are accessed; other mods may be not compatible or simply obsolete.

Installation

Mods can be placed inside StreamingAssets/Mods or any subfolder inside this one. Loose files are placed inside other specific folders inside StreamingAssets; always refers to ReadMe and developers for any additional indication.

StreamingAssets folder is located inside DaggerfallUnity_Data on Windows and Linux, while on Mac is found by right-clicking the player and selecting “show package contents”; the folder is inside Contents\Resources\Data;

Configuration

The load order defines the orders in which mods are executed; if two (or more) mods contain the same asset, the one in the lower position will be used. If multiple mods provides the same features, the load order may help to prevent incompatibilities but you should always referes to mod developers.

More advanced mods may provide support for user settings, as well as presets with predefined values for all or some options. Settings are configurable from an in game UI; additionally new presets can be automatically created from current settings to be shared with the community or simply to store and retrieve a configuration locally.

Note: when upgrading, local settings are reverted to default values if incompatible with the new version.

Share presets

The presets creator window has a button labelled Export. When you click on it the selected preset is exported to %PersistentDataPath%/Mods/ExportedPresets/%ModFileName% (i.e.  C:/Users/ExampleUserName/AppData/Local/Daggerfall Workshop/Daggerfall Unity/Mods/ExportedPresets/ExampleModName/ExamplePresetName.json).

Presets can be imported from StreamingAssets/Presets/%ModFileName%/ (or %ModRoot%/Assets/Presets/%ModFileName%/ from a mod). For example StreamingAssets/Presets/ExampleMod/ExamplePreset.json.

Released Mods

 

Develop new Mods


Scripting

Daggerfall Unity supports real-time injection of C# code; this allow modders to develop scripts for the Unity Engine and benefit of all the possibilities offered by this combination. A mod can change the game behaviour and create endless possible gameplay revisions and enhancement, as well as importing new assets to create something entirely new.

A mod for Daggerfall Unity consists of a package with .dfmod extension. This is a Unity AssetBundle with C# text files, compiled when the game starts, and game assets which can be retrieved at run time. The typical mod behaviour is to subscribe to some of the many events provided to add new features to the game, or alter it with the implementation of interfaces and callbacks. A standard integration with settings and saves is provided, while a message layer can be used to locate and communicate with other mods and implement compatibility patches only when required.

It is suggested to start reading Mod features and attempt to run the proposed tutorial examples to learn the basics of modding for Daggerfall Unity. Then the API Documentation can be used to retrieve more advanced informations and examples for specific features.

Feel free to propose your contributions for these documentations with a PR at github.com/Interkarma/daggerfall-unity and github.com/TheLacus/daggerfall-unity-docs.

Import Assets

When mods aim to swap meshes, textures and other resources, a common issue is that asset usage is often a core part of the game which is not or should not be accessible to mods; additionally multiple mods with similar purposes can create a variety of incompatibilities. The Asset-Injection framework answers with a single implementation within the core game, while mods are given the role of providers. Specifically there are two ways for a mod to provide asset contributions:

  • Asset Bundle: a single optimized package created with the Unity Editor; allows improved optimization and customization and can be added or removed individually with a load order.
  • Loose Files: raw assets imported directly from disk with default format; easier for the mod developer at the cost of missing features, but also harder to manage for the user.

Note: There is a button labeled Extract Text in game which allows to export C# scripts as text files for security concerns. To solve a misconception raised on forums, it is needed to clarify tha this doesn’t mean that is possible to re-import extracted assets as loose files. An asset bundle is not a simple compressed archive, but rather a container for text and binary assets processed to a suitable format for target platform. In some cases, it is however possible to override a specific assets by placing a replacement in a lower position of the load order.

Main Assets

Additional Resources

Additional resources usable in game can also be provided via loose files.

Write Quests

Quests for Daggerfall Unity are written in a simple scripting language, based on Donald Tipton’s TEMPLATE v1.11, which is compiled Just In Time and so can be written and tested even while the game is running. A quest debugger is also available to test the script and immediately find the target locations.

Localization

Most of the text used for the UI is drawn directly on background images, which can be replaced with the framework presented above. Other strings that were hardcoded in classic Daggerfall are being gradually moved to csv files, which is also how mods can be provided in different languages. At this time support for localization is not complete and will be improved after the stable release.

Extensions

Daggerfall Unity modding system can be used to create frameworks that can expose to mod developers more features in addition to the core mod support. This is a list of some of the most intriguing tools created by the community.