Quest Generation (Domains)

Announcements, support questions, and discussion for Quest Machine.
dlevel
Posts: 183
Joined: Wed Nov 16, 2016 6:17 pm

Quest Generation (Domains)

Post by dlevel »

Hello!

I'm trying to create some generated quest functionality in my game, and especially when the player is inside the dungeons. What I cannot understand after following the step by step documentation guide, is that I see the Quest Domains in 2D are marked easily, in 3D is the same method? I just create an empty object and selecting the area which is the Domain in a collider?? Also my dungeons are runtime generated, should I just save the domain in a prefab and spawn it after the dungeon is created? Is my workflow thinking correct?
User avatar
Tony Li
Posts: 22143
Joined: Thu Jul 18, 2013 1:27 pm

Re: Quest Generation (Domains)

Post by Tony Li »

Yes, that's all correct. 3D works the same as 2D. Your domain needs a trigger collider and a QuestDomain component with a DomainType asset assigned to it. Make sure the layers are set up to detect QuestEntities in the trigger collider. Prefabs are fine. You'll also want to assign the domain to one or more quest givers.
dlevel
Posts: 183
Joined: Wed Nov 16, 2016 6:17 pm

Re: Quest Generation (Domains)

Post by dlevel »

figured it out :)
dlevel
Posts: 183
Joined: Wed Nov 16, 2016 6:17 pm

Re: Quest Generation (Domains)

Post by dlevel »

One little issue I have is getting the domain in the Quest Giver after it instantiates (domain is on scene, the NPC prefab is not). If you have a small script to plug in the NPC to get the Domain or can guide me to make one would be nice. Thank you.
User avatar
Tony Li
Posts: 22143
Joined: Thu Jul 18, 2013 1:27 pm

Re: Quest Generation (Domains)

Post by Tony Li »

Hi,

Add this script to your quest giver, and assign DomainType assets. It will find corresponding QuestDomains in Start. You can call its AddMyDomains() method manually if the QuestDomains aren't ready yet in Start.

FindQuestGiverDomains.cs

Code: Select all

using UnityEngine;
using PixelCrushers.QuestMachine;
using System.Collections.Generic;

[RequireComponent(typeof(QuestGeneratorEntity))]
public class FindQuestGiverDomains : MonoBehaviour
{
    public List<DomainType> domainTypes;

    void Start()
    {
        AddMyDomains();
    }

    public void AddMyDomains()
    {
        var generator = GetComponent<QuestGeneratorEntity>();
        var domains = new List<QuestDomain>(generator.domains);
        foreach (var domain in FindObjectsOfType<QuestDomain>())
        {
            var wantThisDomain = domainTypes.Contains(domain.domainType);
            var alreadyHaveThisDomain = domains.Find(x => x.domainType == domain.domainType) != null;
            if (wantThisDomain && !alreadyHaveThisDomain)
            {
                domains.Add(domain);
            }
        }
        generator.domains = domains.ToArray();
    }
}
dlevel
Posts: 183
Joined: Wed Nov 16, 2016 6:17 pm

Re: Quest Generation (Domains)

Post by dlevel »

hmmm, can't get it to work, I put my domain type which is the same I have in the Domain that I have in the scene, I run it also manually, but still doesn't gets the domain gameobject in quest giver Domains. Thanks btw :)
User avatar
Tony Li
Posts: 22143
Joined: Thu Jul 18, 2013 1:27 pm

Re: Quest Generation (Domains)

Post by Tony Li »

Are you sure the QuestDomains are in place before the script runs its AddMyDomains() method?

Also, make sure you're using the exact same DomainType asset in the QuestDomain and this script, not two separate assets that have the same name.

As a test to get an idea of how it works, you can open the Demo scene and clear the Knight's domains list. Add the script and assign the Field and Forest DomainTypes. When you play, the script should add the domains to the Knight's domains list. should
dlevel
Posts: 183
Joined: Wed Nov 16, 2016 6:17 pm

Re: Quest Generation (Domains)

Post by dlevel »

I tried it on the knight, same results :) (the photo is on runtime)

https://ibb.co/C7yPh4x
User avatar
Tony Li
Posts: 22143
Joined: Thu Jul 18, 2013 1:27 pm

Re: Quest Generation (Domains)

Post by Tony Li »

Set the Quest Generator Entity's Domains > Size to zero, or add a null check in the script's loop.
dlevel
Posts: 183
Joined: Wed Nov 16, 2016 6:17 pm

Re: Quest Generation (Domains)

Post by dlevel »

same, stays on 0
Post Reply