NPC Quest Dialogue

Overview

The quest dialogue system allows you to setup quests for NPC’s and display different types of dialogue when different states are entered. This allows you to do things like have active quests from the start, give out quests on completing other quests or have NPC’s simply interact in some way.

You can see a demo/example of this package by using the “NPC Quest Dialogue Example” that is available when you create a new game.

Package Content

NPCdialogue - Mostly used to push the text that is displayed to the widget, there are a few other minor things it does to the player like locking their movement when they interact. Needs to be place on the User entity.

NPCwidget - Widget that the text will be rendered onto and will display the dialogue. Needs to be place on the User entity.

userNPCdialogue - Script folder that already have the above scripts/widget applied.

collectableScript - Can be added to pickups to make them disappear when you pick them up, these will also be tracked by the dialogue system. Can be placed on any mesh you want to use as a pickup.

NPCMissionScript - This is the main script that needs to be applied to a trigger that is on the NPC. More information on its usage can be found below. Needs to be place on ta Trigger entity.

ExampleNPCQuestGiver - An NPC who already has the NPCMissionScript setup on a trigger and a camera provided for the interaction. Other properties will need setting up to correctly make the quest work.

ExampleNPCParticipant - An NPC who can participate in the “Quest Givers” quest, but who doesn’t have their own quest to give out. Helpful to see how you can have other NPCs used in a quests.

objectiveScript - This script keeps the data saved from quests in tables and reports back to the NPCMissionScript. Effectively a way of storing and interrogating the states on quests and objectives.

userObjectiveLogic -Script folder with the above script already applied.

rewardItemScript - Can be used by an event on the NPCMissionScript to make something appear as a reward if you have completed a quest. Although it’s generic enough you could make an item appear on any interaction with the NPC which has an event attached.

RewardItem - A generic reward item with the rewardItemScript on, so you can just drag it into the level.

sendObjectiveComplete - Useful if you have something that you can interact with to complete an objective but isn’t a pickup. This will still send the id information that the colletableScript has, but won’t change the visible state of the entity.

resetObjectiveScript - This script can be set on an interactable object and will delete the save data for the quests on the specific user that interacts.

NPCGenericDialogue - A quick script that is very much cutdown, useful if you have an NPC that needs some flavour text when you greet them, but never has participation in quests.

Requirements/Prerequisites

Requires the following packages to be downloaded and installed correctly:

  • Prompts (Crayta)
  • Auto-Respawn (Crayta)
  • localHandler (AdamO)

Optional

  • Notifications

Setup

First, install the package by going to the Community tab and searching for “NPC Dialogue”. Don’t forget to install the prerequisites that are listed above.

If you look at the templates such as ExampleNPCQuestGiver then this will give you the general setup, but essentially you need to.

  1. Place any NPC from the Primitives or add a Camera and a Trigger as a child of that NPC if you want to DIY.
  2. Make sure the camera is facing the NPC in a suitable angle for when you interact with them.
  3. Add the NPCMissionScript to the Trigger.
  4. In the User add localHandlerScript, userNotifications, userPromptsView and userSpawn as prerequisites.
  5. Also add the userNPCDialogue and userObjectiveLogic from this package to the user.
  6. Read about what the properties do below, don’t forget to check out the example game!

Notes:

  • Don’t forget to add the “ids” to your NPCs, collectables etc. This is used to determine where you are in each quest. Each of these should be unique.
  • The collectableScript can be used on any entity that you want your player to interact with, useful for fetch quests. You can either template them or just drop them on an object.
  • The rewards script can be placed on an entity and will make it appear once the objectives for a quest are met. Useful if you want a trophy shelf of items as rewards for completion quests.

Script Properties

The properties that are on each script that either need or can be setup to make the quests work correctly.

collectableScript

  • Id - Add to an entity like a coin and then set the Id to a unique reference name.
  • Name - Set the Name to the name you want to see on any prompt.
  • Trigger - If you want to use a trigger on pickup instead of interacting then check this.

sendObjectiveComplete

  • Id - Add to an entity like another NPC or a trigger and then set the Id to a unique reference name.

rewardItemScript

  • Id - Add to an entity like a trophy and then set the Id to a unique reference name. It should only appear when you send an event like “Complete Quest Event” from the NPC.

NPCDialogue

  • cameraTransition - Time in seconds to move between the player camera and the NPC camera.
  • interactionDelay - default is 0.2, but is the pause added between each time you press the interact button.

NPCMissionScript

  • camera - A camera that should be near the NPC and will focus on them as they talk.
  • owningNPC - You should assign the NPC this trigger belongs to here.
  • questName - The name for the quest that this NPC is going to give t your player.
  • questActiveAtStart - Should this NPC be able to give their quest at the start, or does it need to wait to be started.
  • trackingQuestName - Another quest name that needs to be completed to start this one.
  • questParticipationName - The quest that the NPC is participating in i.e. You have a quest setup to talk to this NPC and they need to react to it.
  • Name - A name for the NPC that will appear on the dialogue text.
  • participationText - Text that the NPC can announce if a quest is active but they are only in participation. Each element added will be treated like a new ‘page’ of dialogue.
  • questIdleText - Text that the NPC can announce prior to talking about their quest, mostly useful for NPCs that don’t have a quest on init. Each element added will be treated like a new ‘page’ of dialogue.
  • startingQuestText - Text that the NPC can announce on their quest starting. Each element added will be treated like a new ‘page’ of dialogue.
  • midQuestText - Text that the NPC can announce in-between their quest being complete. Each element added will be treated like a new ‘page’ of dialogue.
  • questCompleteText - Text that the NPC can announce on completion of their quest. Each element added will be treated like a new ‘page’ of dialogue.
  • postQuestText - Text that the NPC can announce after completion of their quest. Each element added will be treated like a new ‘page’ of dialogue.
  • emoteGeneric - Emote to be played if the NPC hasn’t yet given you a quest or doesn’t have a quest to give.
  • emoteInitialQuest - Emote to be played if the NPC has given you a quest.
  • emoteSuccess - Emote to be played if the NPC has rewarded your quest.
  • participationQuestEvent - Event that can be triggered by an NPC who is participating, can be used with sendObjectiveComplete script to say that this NPC was found on a quest.
  • InitialQuestEvent - Event that can be triggered on the initial quest being given. Can be used to make something appear for the player.
  • MidQuestEvent - Event that can be triggered mid-quest. Could be used to make something happen during a quest.
  • CompleteQuestEvent - Event that can be triggered at the end of the quest. Can be used to do something like setup the reward.
  • PostQuestEvent - Event that triggers once you talk to an NPC the second time after completing the quest.
  • FocusEvent - Event that triggers once you have completed a quest and are disengaging with the NPC. Could be used to trigger a switch in camera (for example.)
  • Objectives - An array of all the ids that make up the quest objectives. This might be pickups or other things like triggers that have ids that get set when you find them.
  • LinkedObjectives - An array of all the ids that make up anything that you need to have done to talk to an NPC that is participating in a quest but has things you need to do to activate their participation dialogue. e.g. quest is to pick up burgers then speak to this NPC. You would add the burger pickups to this array.
  • dialogueAutomatic - If you want this to automatically start when you walk into the trigger. If not you will need to set Interactable on your trigger.
  • interactMessage - Uses the prompts package to show an interact message.

NPCGenericDialogue

  • npcGenericText - Text that this NPC can say when you interact with them.
  • npcName - name of this NPC.
  • interactMsg - Message that is shown when you can interact with this NPC.

CollectableItem

A template example of a collectable item that can be found to meet quest requirements. A template isn’t a requirement but this is an example of how to set them up.

Reward Item

A template example of a reward item that can be made visible on completing requirements. A template isn’t a requirement but this is an example of how to set them up.

4 Likes

This is a cool package, Stuart! However, when I tried the burger quest in the example game I was unable to talk to the cook. It turned out this was because the linked objective array had an empty third element that caused the comparison of linkedAmount and the size of the linked objectives array to fail. Deleting the empty element got the quest working for me.

Ah, I thought I had updated that as I realised it was an issue. I will look at this again and see if I can resolve it.

I’ve tried republishing it as I did add this fix. I could improve that in the future as it’s hoping the index is correct; I would have to check each item myself to make sure it’s actually valid and track the amounts myself. Hopefully this will resolve the immediate issue.