Difference between revisions of "Part 4: adding the skillbook to a vendor"

From Divinity Engine Wiki
Jump to: navigation, search
m
Line 19: Line 19:
 
Vendors are NPC characters that buy or sell items. In order to assign our skillbook to a vendor npc, we will need to do a couple of things:
 
Vendors are NPC characters that buy or sell items. In order to assign our skillbook to a vendor npc, we will need to do a couple of things:
 
# Create a treasure table
 
# Create a treasure table
# Create a vendor
+
# Create a vendor and set the trade treasure of the vendor
# Add the treasure table to the vendor
+
# Add a dialog to the vendor
  
 
<br />
 
<br />
Line 40: Line 40:
  
 
<br />
 
<br />
=== Step 2: Creating a vendor ===
+
=== Step 2: Creating a vendor and setting the trade treasure ===
 +
For our vendor, we copy the GameMaster_Trader_Skill_NOTUSED root template in the root template panel.
 +
 
 +
Make sure to set the mod (project) of the new root template and give it a new name. I named my new root template MyTrader_WaterBolt.
 +
 
 +
We also need to set the "Trade Treasure" property of the template. When the "Edit Treasure" dialog editor is open, remove the "TraderSkill" treasure table and add the treasure table we created in step 1 (ST_SkillbookWaterBolt in my case).
 +
 
 +
Then we press create, optionally move the root template to a different folder in the root template panel, and hit save.
  
 
<br />
 
<br />
=== Step 3: Adding the treasure table to the vendor ===
+
=== Step 3: Adding a dialog to the vendor ===
 +
Although our vendor is all set up to trade with, the player can not yet initiate conversation. To do this, we first need to add a dialog.
 +
 
 +
To do this, we first need to open the [[File:DialogEditor_Icon.png|32px]] [[Dialog editor]].
 +
 
 +
Second, we create a new empty dialg (Ctrl+N).
 +
 
 +
Third, we right click, hit "Add Node" and then "Greeting" to insert the greeting node of our dialog. When our greeting node is created, click it once and set the "End Node" property to true. Then, double click the greeting node and add a new text to the node. The text of my node is a simple "Hello there, traveler!".
 +
 
 +
To be able to use our dialog we also need to assign a speaker. This can be done in the top right of the dialog properties panel. Next to the "Speakers" dropdown, click "Edit".
 +
 
 +
Then, in the Edit Dialog Speakers window, add a new speaker and click "Edit" again.
 +
 
 +
In the Assign Speakers window, we search for the vendor's root template we created in step 2 (in my case it's MyTrader_WaterBolt), select it and assign it. Then hit "OK" twice.
 +
 
 +
Select the Greeting node again by single-clicking it and set the "Speaker" property to the speaker we just added.
 +
 
 +
Finally, save the dialog file. It needs to be in "Data\Mods\{YourProject}\Story\Dialogs" the directory or a subfolder. I named my dialog "DefaultGreeting".
 +
 
 +
Our dialog is now ready to be used. Select our trader's root template, find the "Default Dialog" property and set it to "DefaultGreeting" (or the name of your dialog if you chose to give it a different name).
 +
 
 +
If you create an instance of the trader npc you will now be able to trade with it and see that it sells your skillbook!
  
 
<br />
 
<br />

Revision as of 17:29, 18 September 2017

This article is part of a 4-part series on how to create, edit and use a new skill.

Part 1: creating a new skill
Part 2: creating a skill from existing
Part 3: creating and using a skillbook
Part 4: adding the skillbook to a vendor

The data used in this article was created in parts 1 & 2 of the series.


Description

Vendors are NPC characters that buy or sell items. In order to assign our skillbook to a vendor npc, we will need to do a couple of things:

  1. Create a treasure table
  2. Create a vendor and set the trade treasure of the vendor
  3. Add a dialog to the vendor


Setting up a vendor

Step 1: Creating a treasure table

CreateVendor Step1 CreateTreasureTable.png

Creating the treasure table stats entry

First, we will create a new treasure table to assign to our vendor. Treasure tables are item tables used to define random loot.


To create our treasure table, we:

  • Open the TreasureTable stats document in the StatsEditor Icon.png Stats editor (Create the document if it does not yet exist) (1).
  • Create a new treasure table, I named mine "ST_SkillbookWaterBolt", and then set the following fields (2):
    • DropCount (1,1): this defines the minumum and maximum amount of items generated from the treasure table.
    • ObjectCategory (I_SKILLBOOK_Air_WaterBolt): this is the name of our skillbook's stat object with "I_" prefixed to it.
    • Frequency (1): the likelyhood of SKILLBOOK_Air_WaterBolt being generated from the treasure table.
  • Save (3).


Step 2: Creating a vendor and setting the trade treasure

For our vendor, we copy the GameMaster_Trader_Skill_NOTUSED root template in the root template panel.

Make sure to set the mod (project) of the new root template and give it a new name. I named my new root template MyTrader_WaterBolt.

We also need to set the "Trade Treasure" property of the template. When the "Edit Treasure" dialog editor is open, remove the "TraderSkill" treasure table and add the treasure table we created in step 1 (ST_SkillbookWaterBolt in my case).

Then we press create, optionally move the root template to a different folder in the root template panel, and hit save.


Step 3: Adding a dialog to the vendor

Although our vendor is all set up to trade with, the player can not yet initiate conversation. To do this, we first need to add a dialog.

To do this, we first need to open the DialogEditor Icon.png Dialog editor.

Second, we create a new empty dialg (Ctrl+N).

Third, we right click, hit "Add Node" and then "Greeting" to insert the greeting node of our dialog. When our greeting node is created, click it once and set the "End Node" property to true. Then, double click the greeting node and add a new text to the node. The text of my node is a simple "Hello there, traveler!".

To be able to use our dialog we also need to assign a speaker. This can be done in the top right of the dialog properties panel. Next to the "Speakers" dropdown, click "Edit".

Then, in the Edit Dialog Speakers window, add a new speaker and click "Edit" again.

In the Assign Speakers window, we search for the vendor's root template we created in step 2 (in my case it's MyTrader_WaterBolt), select it and assign it. Then hit "OK" twice.

Select the Greeting node again by single-clicking it and set the "Speaker" property to the speaker we just added.

Finally, save the dialog file. It needs to be in "Data\Mods\{YourProject}\Story\Dialogs" the directory or a subfolder. I named my dialog "DefaultGreeting".

Our dialog is now ready to be used. Select our trader's root template, find the "Default Dialog" property and set it to "DefaultGreeting" (or the name of your dialog if you chose to give it a different name).

If you create an instance of the trader npc you will now be able to trade with it and see that it sells your skillbook!


Troubleshooting

Several things can cause a skillbook to not show up on a vendor's sell list:

  • The item was not generated out of that treasure table
    Items in treasure tables are randomly generated, if an item does not show up it might just be bad RNG!
  • Your skillbook stats entry does not have the correct root template id
  • The "Story Item" flag is checked in the skillbook properties