Help with custom quest actions

Discuss modding questions and implementation details.
imsobadatnicknames
Posts: 371
Joined: Sun Jun 02, 2019 4:28 pm
Location: Colombia

Re: Help with custom quest actions

Post by imsobadatnicknames »

Thank you!
So, this script should be enough to initialize the mod and register the quest actions, right (i'll test it when I'm off work lol)? Or do I need to include anything else? Sorry, it's my first time doing this so I have a lot of dumb questions dskjdskjh

Code: Select all

using System;
using System.Collections.Generic;
using UnityEngine;
using DaggerfallConnect;
using DaggerfallConnect.Arena2;
using DaggerfallWorkshop.Game;
using DaggerfallWorkshop.Game.Questing;
using DaggerfallWorkshop.Game.Utility.ModSupport;
using DaggerfallWorkshop;
using DaggerfallWorkshop.Game.Utility.ModSupport.ModSettings;

namespace HealthAction
{
    public class HealthActionMod : MonoBehaviour
    {
        static Mod mod;	

        [Invoke(StateManager.StateTypes.Start, 0)]
        public static void Init(InitParams initParams)
        {
            mod = initParams.Mod;
            var go = new GameObject(mod.Title);

            GameManager.Instance.QuestMachine.RegisterAction(new WhenHealthLevel(null));
            GameManager.Instance.QuestMachine.RegisterAction(new WhenHealthLevelPercent(null));
        }

        void Awake()
        {
            InitMod();
            mod.IsReady = true;
        }

}
Released mods: https://www.nexusmods.com/users/5141135 ... files&BH=0
Daggerfall isn't the only ridiculously intrincate fantasy world simulator with the initials DF that I make mods for: http://www.bay12forums.com/smf/index.php?topic=177071.0

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

Re: Help with custom quest actions

Post by BadLuckBurt »

imsobadatnicknames wrote: Thu Aug 18, 2022 1:54 pm Thank you!
So, this script should be enough to initialize the mod and register the quest actions, right (i'll test it when I'm off work lol)? Or do I need to include anything else? Sorry, it's my first time doing this so I have a lot of dumb questions dskjdskjh
No worries, I think that should work. I'm not sure what the InitMod() call in Awake does but I don't think you need anything in Awake as long as those quest actions are registered from the Init.
DFU on UESP: https://en.uesp.net/w/index.php?title=T ... fall_Unity
DFU Nexus Mods: https://www.nexusmods.com/daggerfallunity
My github repositories with mostly DFU related stuff: https://github.com/BadLuckBurt

.

imsobadatnicknames
Posts: 371
Joined: Sun Jun 02, 2019 4:28 pm
Location: Colombia

Re: Help with custom quest actions

Post by imsobadatnicknames »

Is there anything else I need to do to get the mod initialization script to actually run? :(
I created a new script called HealthActionMod.cs in the Scripts folder in the editor, with the following code inside of it:

Code: Select all

using System;
using System.Collections.Generic;
using UnityEngine;
using DaggerfallConnect;
using DaggerfallConnect.Arena2;
using DaggerfallWorkshop.Game;
using DaggerfallWorkshop.Game.Questing;
using DaggerfallWorkshop.Game.Utility.ModSupport;
using DaggerfallWorkshop;
using DaggerfallWorkshop.Game.Utility.ModSupport.ModSettings;

namespace HealthActionMod
{
    public class HealthActionMod : MonoBehaviour
    {
        static Mod mod;	

        [Invoke(StateManager.StateTypes.Start, 0)]
        public static void Init(InitParams initParams)
        {
            mod = initParams.Mod;
            var go = new GameObject(mod.Title);
	    Debug.Log("Started setup of : " + mod.Title);

            GameManager.Instance.QuestMachine.RegisterAction(new WhenHealthLevel(null));
            GameManager.Instance.QuestMachine.RegisterAction(new WhenHealthLevelPercent(null));

	    mod.IsReady = true;
        }


}

}
But it's still not doing anything when I start the quest to test the action, and I don't see the "Started setup of : " line anywhere in the debug console, so I think this code isn't running
Released mods: https://www.nexusmods.com/users/5141135 ... files&BH=0
Daggerfall isn't the only ridiculously intrincate fantasy world simulator with the initials DF that I make mods for: http://www.bay12forums.com/smf/index.php?topic=177071.0

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

Re: Help with custom quest actions

Post by BadLuckBurt »

imsobadatnicknames wrote: Thu Aug 18, 2022 4:19 pm Is there anything else I need to do to get the mod initialization script to actually run? :(
I created a new script called HealthActionMod.cs in the Scripts folder in the editor, with the following code inside of it:

But it's still not doing anything when I start the quest to test the action, and I don't see the "Started setup of : " line anywhere in the debug console, so I think this code isn't running
I'm sorry, I keep forgetting that you probably haven't made a .dfmod yet. You need to put that script in a folder in the Assets/Game/Mods folder, for example Assets/Game/Mods/HealthLevel. Also move the two Quest Action scripts to that folder, you can have sub folders to organise the scripts.

Once that's done, in the top menu bar in the Unity Editor, there's an entry for Daggerfall Tools, choose Mod Builder from the list there. Click Create New Mod and save the .dfmod.json file in the same folder. Then just fill out the fields down to Description.

After that you need to actually add the files, you do this by navigating to your mod's folder in the Project Explorer, selecting the files on the right-hand side and then click the Add Selected Asset(s) button to add them. The .dfmod.json file isn't necessary to include, it's only used to build the mod.

When you've added all the files, click Build Mod at the bottom of the window (if you don't see this button, try to make the window taller).
DFU on UESP: https://en.uesp.net/w/index.php?title=T ... fall_Unity
DFU Nexus Mods: https://www.nexusmods.com/daggerfallunity
My github repositories with mostly DFU related stuff: https://github.com/BadLuckBurt

.

imsobadatnicknames
Posts: 371
Joined: Sun Jun 02, 2019 4:28 pm
Location: Colombia

Re: Help with custom quest actions

Post by imsobadatnicknames »

Ooooh okay. So I have to first package them into a .dfmod file before they actually get executed by the game? :p
I'll do it and see if it works.

EDIT: IT WORKED! Finally! Thank you so much for your help!
Released mods: https://www.nexusmods.com/users/5141135 ... files&BH=0
Daggerfall isn't the only ridiculously intrincate fantasy world simulator with the initials DF that I make mods for: http://www.bay12forums.com/smf/index.php?topic=177071.0

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

Re: Help with custom quest actions

Post by BadLuckBurt »

imsobadatnicknames wrote: Thu Aug 18, 2022 4:57 pm Ooooh okay. So I have to first package them into a .dfmod file before they actually get executed by the game? :p
I'll do it and see if it works.

EDIT: IT WORKED! Finally! Thank you so much for your help!
Yay, victory! :D

And yes, when C# scripts are involved you'll need to build a .dfmod so they get compiled. The quests themselves are just text files as far as DFU is concerned so it's happy to read those from disk. You can also include them in the .dfmod, that's totally fine.
DFU on UESP: https://en.uesp.net/w/index.php?title=T ... fall_Unity
DFU Nexus Mods: https://www.nexusmods.com/daggerfallunity
My github repositories with mostly DFU related stuff: https://github.com/BadLuckBurt

.

imsobadatnicknames
Posts: 371
Joined: Sun Jun 02, 2019 4:28 pm
Location: Colombia

Re: Help with custom quest actions

Post by imsobadatnicknames »

OOOh I didn't know that, thank you!
So. I got it working in game but it still isn't working quite as intended. It's only measuring the player's health at the moment the quest starts. If the player's health is over the defined value when the quest starts, but then becomes lower than it, the task remains active. Looks like I'm gonna have to look at how other quest actions that toggle on and off mid-quest work.
Released mods: https://www.nexusmods.com/users/5141135 ... files&BH=0
Daggerfall isn't the only ridiculously intrincate fantasy world simulator with the initials DF that I make mods for: http://www.bay12forums.com/smf/index.php?topic=177071.0

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

Re: Help with custom quest actions

Post by BadLuckBurt »

imsobadatnicknames wrote: Thu Aug 18, 2022 5:50 pm OOOh I didn't know that, thank you!
So. I got it working in game but it still isn't working quite as intended. It's only measuring the player's health at the moment the quest starts. If the player's health is over the defined value when the quest starts, but then becomes lower than it, the task remains active. Looks like I'm gonna have to look at how other quest actions that toggle on and off mid-quest work.
CheckTrigger evaluates until the condition is satisfied. You may need to add an action that checks the reverse, then that can arm a task and by checking whether one task is true and the other isn't or whatever combination you need, you can alter the execution of your quest.

If it needs to be a more real-time thing, you may need to start looking at that Update method I mentioned before, that can run indefinitely depending on the code you put in there. You can also complete the action from there by calling SetComplete() when your conditions are satisfied.

If the above doesn't help, you can upload a zip of the mod files here or make a repository on Github. Quest syntax and logic is a bit weird to get into so it might be easier to just set up some examples.
DFU on UESP: https://en.uesp.net/w/index.php?title=T ... fall_Unity
DFU Nexus Mods: https://www.nexusmods.com/daggerfallunity
My github repositories with mostly DFU related stuff: https://github.com/BadLuckBurt

.

imsobadatnicknames
Posts: 371
Joined: Sun Jun 02, 2019 4:28 pm
Location: Colombia

Re: Help with custom quest actions

Post by imsobadatnicknames »

Ooooh okay. I'm trying to do a quest that does something when the player's health goes under a certain value, so I could just create a quest action that's the opposite (trigger a task when the player's health is not equal or greater than a certain value) and use both in conjunction.
Released mods: https://www.nexusmods.com/users/5141135 ... files&BH=0
Daggerfall isn't the only ridiculously intrincate fantasy world simulator with the initials DF that I make mods for: http://www.bay12forums.com/smf/index.php?topic=177071.0

Post Reply