Custom Flat & Model Activation

Discuss modding questions and implementation details.
Post Reply
User avatar
BadLuckBurt
Posts: 557
Joined: Sun Nov 05, 2017 8:30 pm

Custom Flat & Model Activation

Post by BadLuckBurt » 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:

Code: Select all

using UnityEngine;
using DaggerfallWorkshop.Game;
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:

Code: Select all

private static void ExampleActivation(RaycastHit hit) {
//Your code here
}
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:

Code: Select all

//For flats
PlayerActivate.RegisterCustomActivation(mod, 211, 20, ExampleActivation);
//For models
PlayerActivate.RegisterCustomActivation(mod, 41005, ExampleActivation);
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.
Daggerfall Unity on UESP: https://en.uesp.net/w/index.php?title=T ... fall_Unity
Daggerfall Unity on Nexus Mods: https://www.nexusmods.com/daggerfallunity
My github repositories with mostly DFU related stuff: https://github.com/BadLuckBurt

Asesino
Posts: 44
Joined: Fri Aug 16, 2019 3:14 am

Re: Custom Flat & Model Activation

Post by Asesino » Wed Apr 22, 2020 6:48 pm

Hi @BadLuckBurt,
I just tried this out and it worked without a hitch! I added crates to it and was able to trigger them. I was thinking about creating a mod that puts loot into crates, bookshelves, weapon racks, etc. in dungeons so that they are more useful than just eye candy.

This turned that effort much easier!

Thank you so much for this.

a

User avatar
BadLuckBurt
Posts: 557
Joined: Sun Nov 05, 2017 8:30 pm

Re: Custom Flat & Model Activation

Post by BadLuckBurt » Wed Apr 22, 2020 7:30 pm

Asesino wrote:
Wed Apr 22, 2020 6:48 pm
Hi @BadLuckBurt,
I just tried this out and it worked without a hitch! I added crates to it and was able to trigger them. I was thinking about creating a mod that puts loot into crates, bookshelves, weapon racks, etc. in dungeons so that they are more useful than just eye candy.

This turned that effort much easier!

Thank you so much for this.

a
You're welcome but model activation was already implemented by Hazelnut some time ago. I just extended it to flats and unified the code a bit. In any case, good to hear that it was so easy for you to use, hopefully more people will follow :D

Looking forward to what you're going to do with this!
Daggerfall Unity on UESP: https://en.uesp.net/w/index.php?title=T ... fall_Unity
Daggerfall Unity on Nexus Mods: https://www.nexusmods.com/daggerfallunity
My github repositories with mostly DFU related stuff: https://github.com/BadLuckBurt

Asesino
Posts: 44
Joined: Fri Aug 16, 2019 3:14 am

Re: Custom Flat & Model Activation

Post by Asesino » Wed Apr 22, 2020 8:35 pm

BadLuckBurt wrote:
Wed Apr 22, 2020 7:30 pm
Asesino wrote:
Wed Apr 22, 2020 6:48 pm
Hi @BadLuckBurt,
I just tried this out and it worked without a hitch! I added crates to it and was able to trigger them. I was thinking about creating a mod that puts loot into crates, bookshelves, weapon racks, etc. in dungeons so that they are more useful than just eye candy.

This turned that effort much easier!

Thank you so much for this.

a
You're welcome but model activation was already implemented by Hazelnut some time ago. I just extended it to flats and unified the code a bit. In any case, good to hear that it was so easy for you to use, hopefully more people will follow :D

Looking forward to what you're going to do with this!
Ah, I was not aware of that. Thank you both; everytime I log in, there is something new to play with!

Keep up the excellent work!
a

Post Reply