Custom Flat & Model Activation
Posted: Mon Apr 20, 2020 7:54 am
This is a quick tutorial for modders on how to add custom activation to flats and models which will become available in the next release.
PREREQUISITES
1. Load the UnityEngine and DaggerfallWorkshop.Game namespaces in your mod, you can achieve this by adding the following lines at the top of your mod class file:
2. The model ID(s) and / or the texture archive - record combinations that you want to attach custom activation to. You can find these using Daggerfall Modeling (https://www.dfworkshop.net/downloads/da ... modelling/) and Daggerfall Imaging (https://www.dfworkshop.net/downloads/da ... l-imaging/).
3. Your mod class will need methods that handle the custom activation, they need to be set up as follows:
When you have this in place and know what models / flats you want to attach the custom activation to, the next step is to add a call to PlayerActivate.RegisterCustomActivation like this:
I recommend you add the calls to RegisterCustomActivation in the init method of your mod.
LOAD PRIORITY
The RegisterCustomActivation method adheres to the load order priority for mods and will log any failed registration to the output_log so check there if you have trouble getting your activations registered.
Look for the following line: 'Denied custom activation registration from <Mod1> for <ObjectName> | <Mod2> has higher load priority'
This will tell you what mod is interfering with your registration.
I have put up a demo version that showcases the functionality through a mod: https://github.com/BadLuckBurt/dfu-cust ... o/releases. To try this showcase, go to the Daggerfall region and search for 'Custom' on the travel map, it's a tiny dungeon that consists of 1 room with various objects you can activate.
The source.zip on the release page contains the entire mod, the master branch on Github already contains code for the next stage: custom dialog buttons but until that is merged, it won't be compatible with the main DFU release.
PREREQUISITES
1. Load the UnityEngine and DaggerfallWorkshop.Game namespaces in your mod, you can achieve this by adding the following lines at the top of your mod class file:
Code: Select all
using UnityEngine;
using DaggerfallWorkshop.Game;
3. Your mod class will need methods that handle the custom activation, they need to be set up as follows:
Code: Select all
private static void ExampleActivation(RaycastHit hit) {
//Your code here
}
Code: Select all
//For flats
PlayerActivate.RegisterCustomActivation(mod, 211, 20, ExampleActivation);
//For models
PlayerActivate.RegisterCustomActivation(mod, 41005, ExampleActivation);
LOAD PRIORITY
The RegisterCustomActivation method adheres to the load order priority for mods and will log any failed registration to the output_log so check there if you have trouble getting your activations registered.
Look for the following line: 'Denied custom activation registration from <Mod1> for <ObjectName> | <Mod2> has higher load priority'
This will tell you what mod is interfering with your registration.
I have put up a demo version that showcases the functionality through a mod: https://github.com/BadLuckBurt/dfu-cust ... o/releases. To try this showcase, go to the Daggerfall region and search for 'Custom' on the travel map, it's a tiny dungeon that consists of 1 room with various objects you can activate.
The source.zip on the release page contains the entire mod, the master branch on Github already contains code for the next stage: custom dialog buttons but until that is merged, it won't be compatible with the main DFU release.