Automatic quests or quests on triggers

Announcements, support questions, and discussion for Quest Machine.
Post Reply
BigDaddio
Posts: 2
Joined: Tue Dec 05, 2017 6:49 pm

Automatic quests or quests on triggers

Post by BigDaddio »

I would like to assign a quest and have it active when a level is started, without a quest giver. Basically something like "Kill every damn thing in this level" I'd also like to add a quest on a unity trigger object. So when the player walks in a door they automatically get assigned a quest like "Steal the jewel from the idol" My game is all procedural. So the quests can be scripted, but only added on the event or thing being added. At the end of the level I want to count up the finished quests and assign points or such. Not turn them in to a quest giver. This is the thing I am having issue with, skipping the whole quest giver and acceptance etc.

I have to admit even though I have had this package for some time I am not that familiar with it... :oops:

If you can give me an idea how to get this started. I was thinking I'd build the quest using the quest builder,
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Automatic quests or quests on triggers

Post by Tony Li »

Hi,
BigDaddio wrote: Sat Apr 13, 2019 2:41 pmI would like to assign a quest and have it active when a level is started, without a quest giver. Basically something like "Kill every damn thing in this level"
There are two ways to do this:

1. Add the quest to the player's Quest Journal, and set it active. Example:

Code: Select all

questJournal.AddQuest(quest);
quest.SetState(QuestState.Active);
QuestMachineMessages.RefreshIndicators(quest);
Side note: If 'quest' is a hand-written quest asset in your project, don't add it directly. Clone it, and use the clone:

Code: Select all

var instance = quest.Clone();
questJournal.AddQuest(instance); //etc...
2. Or create an empty GameObject with a Quest Giver component. Add the quest to the Quest Giver's list. Also add a Timed Event component. Tick Activate On Start. Configure the OnTimeReached() event to call QuestGiver.GiveAllQuestsToQuester(player). In this case, the Quest Giver GameObject isn't an NPC, it's just a container that holds quests to give the player.
BigDaddio wrote: Sat Apr 13, 2019 2:41 pmI'd also like to add a quest on a unity trigger object. So when the player walks in a door they automatically get assigned a quest like "Steal the jewel from the idol"
Just like #2 above, except add a Trigger Event instead of a Timed Event.
BigDaddio wrote: Sat Apr 13, 2019 2:41 pmMy game is all procedural. So the quests can be scripted, but only added on the event or thing being added. At the end of the level I want to count up the finished quests and assign points or such.
That's no problem with Quest Machine. Since Quest Machine has an extensive API, I'm sure you'll have questions, so ask any time.
BigDaddio wrote: Sat Apr 13, 2019 2:41 pmI was thinking I'd build the quest using the quest builder
Here's the API: QuestBuilder.

Did you want to use Quest Machine's procedural quest generator? Or will you write your own code that builds quests using QuestBuilder? If you plan to write your own code, perhaps as part of the level generation process, then these are the general steps:

1. Create a player in the scene.
2. Add a Quest Journal component to the player.
3. Build a quest.
4. Call QuestMachine.RegisterQuestInstance(quest) to tell Quest Machine about the quest.
5. Use one of the methods above to add it to the player.
6. Repeat steps 3-5 for as many quests as you want.
BigDaddio
Posts: 2
Joined: Tue Dec 05, 2017 6:49 pm

Re: Automatic quests or quests on triggers

Post by BigDaddio »

Thanks so much. That works great.

The issue I have at the moment with generated quests, or in my case they are more like tasks or challenges. The issue I have is creating the areas. Since my game is pretty much procedural I'd have to create some code to define the areas or basically have areas predefined on the pieces I drop in. as opposed to creating an area on a prebuilt space I am going to have the triggers.
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Automatic quests or quests on triggers

Post by Tony Li »

If it's OK for your quest giver to know about all entities in the scene, then you can just create one huge trigger collider that encompasses the whole scene. Set it up as a quest domain, and assign it to the quest giver. That's certainly the easiest solution.

If you want the quest giver to only know about entities in certain areas -- for example, at most 20 units away -- you could build your quest giver with a 20-radius trigger collider and quest domain centered on it, like as a child GameObject.

I'm just tossing those out as ideas. If you want to provide more specifics, I might be able to suggest some other approaches.
Post Reply