In this tutorial, we'll make a quest in Unitycoding's RPG Kit using the Dialogue System's RPG Kit Support features. It assumes that you've already:
- Imported and configured RPG Kit.
- Imported the Dialogue System.
- Imported and configured the Dialogue System's RPG Kit Support package.
The script for the Tax Collector is:
- Tax Collector: (If quest is unassigned) "Collect taxes from the merchant."
- Player: "I'll return with the gold." (Activate the quest)
- Tax Collector: (If quest is active) "Do you have the gold?"
- Player: (If the player has 50 gold) "Here is the gold." (Remove 50 gold; finish the quest)
- Player: (If the player doesn't have 50 gold) "Not yet."
- Tax Collector: (If quest is over) "Thank you for helping the King."
- Player: "You're welcome."
- Merchant: Hello."
- Player: (If the quest is active) "I'm here to collect 50 gold for the King."
- Player: (If the quest is unassigned or done) "Bye."
Tutorial Steps
1. In your dialogue database, add a quest:
![Image](http://pixelcrushers.com/dialogue_system/images/rpgKitTutorial/quest.jpg)
2. Create the Tax Collector conversation:
![Image](http://pixelcrushers.com/dialogue_system/images/rpgKitTutorial/TaxCollectorConversation1.jpg)
In this conversation, set the Sequence, Conditions, and Script fields as shown below:
![Image](http://pixelcrushers.com/dialogue_system/images/rpgKitTutorial/TaxCollectorConversation2.jpg)
Notes:
- Use SetOverheadIcon() to change the Tax Collector's and Merchant's overhead icons.
- You can use the Lua wizard to get and set quest states.
- This example uses the new CurrentQuestState() and SetQuestState() Lua functions, but you can also set them manually: Quest["Taxes_for_the_King"].State = "active".
- You can't use the Lua wizard to add RPG Kit Lua functions such as PlayerHasItem() and PlayerRemoveItem(), so you will have to add those manually.
![Image](http://pixelcrushers.com/dialogue_system/images/rpgKitTutorial/merchantConversation1.jpg)
In this conversation, set the Sequence, Conditions, and Script fields as shown below:
![Image](http://pixelcrushers.com/dialogue_system/images/rpgKitTutorial/merchantConversation2.jpg)
4. Add the Tax Collector and Merchant NPCs to the scene. Add an Overhead Icon UI. Configure an RPG Kit Conversation Trigger to run the NPC's conversation:
![Image](http://pixelcrushers.com/dialogue_system/images/rpgKitTutorial/merchantGameObject.jpg)
They'll look similar to this in the game:
![Image](http://pixelcrushers.com/dialogue_system/images/rpgKitTutorial/taxCollectorGameView.jpg)
And conversations will look similar to this:
![Image](http://pixelcrushers.com/dialogue_system/images/rpgKitTutorial/dialogueUI.jpg)
Testing & Debugging
If you set the Dialogue Manager's Debug Level to Info, the Console view will give you information as you talk with NPCs:
![Image](http://pixelcrushers.com/dialogue_system/images/rpgKitTutorial/debugLevelInfo.jpg)
The screenshot above was taken after collecting gold from the Merchant. You can see:
- The RPG Kit Lua function PlayerAddItem("Gold", 50) gave 50 gold to the player.
- The sequencer command SetOverheadIcon(none, Merchant) turned off the Merchant's overhead icon.
- The sequencer command SetOverheadIcon(Exclamation, Tax Collector) changed the Tax Collector's overhead icon to the Exclamation icon.
You can test RPG Kit Lua functions by adding a Lua Console to the scene:
![Image](http://pixelcrushers.com/dialogue_system/images/rpgKitTutorial/luaConsoleTest.jpg)
If your quest isn't working, the Lua Console can help you figure out why.
You can also use the Lua Console to reset the quest so you can run it again:
![Image](http://pixelcrushers.com/dialogue_system/images/rpgKitTutorial/luaConsoleResetQuest.jpg)