Home > Tutorials > Creating a Custom Merchant for The Player’s Camp – Part 2

Creating a Custom Merchant for The Player’s Camp – Part 2

Continuing on with our tutorial series to create a new NPC merchant for our player’s camp, we take a look at conversations and how to add them to our creature that we created last time.

First we will look at conversations in general, then we will apply some basic conversation to our NPC.  We will also look briefly at how to add a storage chest next to our creature to give the camp a little flavor.

Before We Begin

Before we get started on this next part, I want to bring up an issue that we need to address.  If you haven’t read the article Beware the Dangers of module_core then please go read that. It is a short read.

As a result of what we learned there, I want to be sure we fix our module to be safe before we move on. Open your module properties, and for the Script property, click the 3 dots and choose “(none)” in the list. There, now w’ere safe and can move on.

The other thing I wanted to touch on briefly, is that many of you have been asking how you can adapt this code to place Placeables like chests, and how you can spawn multiple items.  I’m only going to talk about this quickly because in the last part of this tutorial we will actually be building up a small camp for our merchant.  But for those of you who want to mess around with it now, the following script should spawn the merchant and place a generic crate nearby.

#include “wrappers_h”
void main()
{
// The first thing we want to do, before anything, is look around and see
// if we have already spawned this merchant
object oPlayer = GetMainControlled();
DisplayFloatyMessage(oPlayer, “tut_merchant_spawn”, FLOATY_MESSAGE, 16777215, 20.0);
object oMerchant = UT_GetNearestObjectByTag(oPlayer, “jwv_t_creature1”);
if (!IsObjectValid(oMerchant))
{
// If we get to this code, it means the merchant has not been placed yet
// So let’s do that

// get an object pointer to the party camp area
object oArea = GetObjectByTag(“cam100ar_camp_plains”);
// create a location for where our merchant NPC will be placed
location lMerchantLocation = Location(oArea, Vector(166.61, 124.77, -1.33), 85.4);
// Spawn the NPC
CreateObject(OBJECT_TYPE_CREATURE, R”jwv_t_creature1.utc”, lMerchantLocation);

//Now lets create a location for our crate
location lCrate1Location = Location(oArea, Vector(167.27, 122.54, -1.27), 110.75);
// and spawn the crate
CreateObject(OBJECT_TYPE_PLACEABLE, R”genip_crate_wd_large_stat.utp”, lCrate1Location);
}
}

Ok now let’s move on with today’s material!

So Just What Is a Conversation?

Moving beyond the obvious, a conversation in Dragon Age is a series of branching dialog options.  You assign dialog to both the player and NPCs involved in the conversation.  Since the player can be given multiple choices of what to say, the dialog naturally branches out, like a tree, into many different paths.

Conversations can be simple back and forth dialog exchanges, but they can also be much more.  Individual nodes in a conversation can run scripts, access plot flags, and otherwise work in a dynamic manner adding more choice to the player’s actions.

Conversations are edited in the toolset’s conversation editor.

A Quick Look at the Conversation Editor

I’m not going to provide a comprehensive overview of the conversation in here.  I feel that the best way to learn is by doing, so we will cover most of this when we actually use it to create our conversations.  I do however want to give a quick overview of the editor and how to use it for our purposes.

Take a look above at what a basic conversation looks like in the editor.  For now, ignore the color coding.  Instead just look it over and get a feel for how it is laid out.  Notice how you have a hierarchy, branching its way out as you go down.  You can click on the image to see it in full size.

To help clarify the branching nature, take a look at this image which is the same conversation, except I have collapsed the lines of dialog  beyond our initial greetings.

Understanding the branching nature of the conversations may come easy to some of you, and harder to others.  Take the time you need to fully understand it, as it is important.  It will also become more clear as we work through this.

Now let us take a look at the color coding.  You’ll not this is a rather colorful conversation!  So what do all the colors mean?  Well they are there to make it easier to understand how the conversation is branching.  The blue text is the PC’s text, and the Red text is the NPC text.  In all the NPC text you will see it is preceeded by [[OWNER]].  Since in a conversation you could have multiple NPC speakers, this identifies which NPC is speaking that line of text.  [[OWNER]] means the NPC who owns the conversation, and in a conversation like ours where there is only one NPC they will all be spoken by the owner.

There are two other colors here I want to point out.  The first is that orange background over the PC text near the bottom.  For some reason the conversations have character limits, and that background is indicating to us that the highlighted line has too many characters.  PC responses must be a maximum of 60 characters, and NPC responses can be up to 200 characters.

The last color is the grey text.  This is actually PC text, but it is what is called “linked” text.  If you look you will notice that both of those grey lines have duplicates that are in blue.  The grey lines are linked to the blue ones, so that if you choose the grey line in the conversation it jumps to the blue one.  The reason for this is that conversations with multiple branches and long dialog can often get very difficult to write.  This allows for various branches to split apart but also eventually join back together, guiding the PC in a certain direction.

Next let’s take a look at the top of the editor, where the toolbar is.  There are many buttons here.  If you mouseover each button it will give you a small tooltip.  For right now we only need to worry about two buttons.  These two pictured below:

If you hold your mouse over them, the first will say “Insert Line” and the second will say “Insert Line After”.  These are how we will add new lines of dialog as we build our conversation.  The first adds a new “child” branch, which basically means it will add text for the opposite speaker from the current line.  The second adds a new “sibling” branch which means it will add a new dialog choice at the current level.  This will always be for the PC.  This will make more sense as we build up our conversation.

Creating our Conversation

Ok, so now that we’ve had an introduction to the editor, let’s go ahead and start writing our conversation.  To begin with go ahead and create a new conversation resource, and both Module and Owner Module should be your module.

A new conversation will have just a Root node.  The root node contains no dialog. Instead it contains the global settings for the conversation.  Go ahead and click the Insert Line button (That was the first of the two buttons) to create our first node.  The NPC always speaks first, so this will be in red and start with [[OWNER]] automatically.  If you look down at the bottom half of the conversation editor, you will see that the Dialogue tab is selected.  The box right below that is where you enter the actual text for this node.  Using the screenshot from above, go ahead and enter the NPCs text.

Now we need to give our player some options to respond with.  Once again click the Insert Line button to create a new dialog node.  Notice how this one is indented under the previous, and is in blue.  This indicates that it is a player line.  Again, enter our first response “Greetings.  It is a pleasure to meet you.”  Normally you want to provide the player with a few choices of what to say, even if its just an illusion, so we’ll provide a couple alternatives here.

First we will take a moment though to illustrate the difference between the two buttons for adding lines.  Go ahead and click that first button, Insert Line again.  Notice what happens?  Instead of giving you another option for the player on the same level, it instead indents again and jumps back to the NPC text.  This is a Child node.  Now press CTRL-Z to undo then, then click that second button Insert Line After.  Note that this time it does not indent.  Instead it adds a new line at the same level as our current one, and it is still on the player’s text.  This is known as a Sibling node (think brothers and sisters versus children in a normal family).  This allows us to easily add alternate options for the player.

Using what you now know, and the screenshot above, go ahead and create every line of text except those two that are in grey.  This is what it should look like when you are done:

Now let’s talk about the linking.  In order to prevent us from having to write lots of duplicate dialog, the conversation editor lets us link text back around to other options.  We have two areas where we want to do this.  In our initial introduction, the PC has a few choices of what to say.  In one line, you can greet the merchant in response to her own greeting.  In another option you can get right to the point and ask “Where did you come from?”.  If the player is more polite and greets the merchant first, then after the greeting we want them to be able to ask that same question, “Where did you come from?”  Instead of duplicating that, and then having to duplicate everything below it, we will instead link to that existing branch of the conversation.  To do this, select the PC dialog option, “Where did you copy from?” and then copy it with EDIT -> COPY.  Then select the text we want this to come after, which is the NPC’s text “You are very polite.  I am glad I could catch up to you.”, and then choose EDIT->PASTE AS LINK.  You will see the dialog inserted as the grey text we saw earlier.  You now have a link.  We want to do the same thing with the dialog “Very well.  Let me see what you have.”, so go ahead and copy that line of dialog, then paste it as a link under the line that starts with “Rudeness does not become you.”

Now we have just one more thing to take care of, and that is fixing the line at the bottom that is too long.  Change it however you want.  I changed it to read “Are those supplies over there?  Let me see what you have.”

And with that our conversation is written.  You may need to go through that a few times, or even mess around with your own dialog.  Play with it a bit and you will feel more comfortable.  Try to following the “paths” of conversations, and think about how it plays out in game.

Go ahead and save that, and now we need to get it applied to our NPC.

Applying the Conversation to our NPC

We’re nearly there.  We just need to somehow tell our creature that this new conversation belongs to them.  This is very easy.  First, make sure you have saved and exported the conversation.  Then open up the creature resource that you made in the last part of this tutorial.  On your creature you will see a conversation property.  Just click the 3 dots to open up a browser, and select the conversation you just made.  Save, check in and export your creature and you are done.

Finishing Up.

Go ahead and make sure everything is saved, checked in, and exported.  Recreate your module and manifest XML files, and clean up your export directories.  Then run the game and test our your new conversation.

You will notice it is, well, extremely bland.  This is a result of a few things, but mostly the lack of any actual voice acting.  The single player game rather spoils you in the regard.  It is also because we aren’t doing any camera work, and even gestures to animate the NPC at least a little bit.  We will address those issues in the final part of this tutorial when we polish everything up.

Categories: Tutorials
  1. newyears1978
    November 17, 2009 at 4:25 pm

    OH how close I was with my crate, just include it in the original if statement..DUH..so easy.

    Thanks for this tutorial, you’re the best. Following along now.

  2. Caladon
    November 17, 2009 at 5:07 pm

    Kind of silly I know but might want to mention that the buttons only show when you have a conversation open\viewed

  3. Newyears1978
    November 17, 2009 at 5:11 pm

    NEXT! =)

    • John Vanderbeck
      November 17, 2009 at 5:16 pm

      Newyears1978 :

      NEXT! =)

      Slave drivers.

      • Caladon
        November 17, 2009 at 5:53 pm

        Your own fault for making this understandable lol

  4. Caladon
    November 17, 2009 at 5:16 pm

    Yup }:-)

  5. newyears1978
    November 17, 2009 at 5:56 pm

    Haha =)

    For some reason my chest still doesn’t spawn…script compiles and all fine, NPC is there, but no crate..I must be making another stupid mistake..?

    #include “wrappers_h”
    void main()
    {
    // The first thing we want to do, before anything, is look around and see
    // if we have already spawned this merchant
    object oPlayer = GetMainControlled();
    DisplayFloatyMessage(oPlayer, “merchant”, FLOATY_MESSAGE, 16777215, 20.0);
    object oMerchant = UT_GetNearestObjectByTag(oPlayer, “jlp_npc_hoarder”);
    if (!IsObjectValid(oMerchant))
    {
    // If we get to this code, it means the merchant has not been placed yet
    // So let’s do that

    // get an object pointer to the party camp area
    object oArea = GetObjectByTag(“cam100ar_camp_plains”);
    // create a location for where our merchant NPC will be placed
    location lMerchantLocation = Location(oArea, Vector(134.270264, 111.795937, -0.781055), -142.727050781);
    // Spawn the NPC
    CreateObject(OBJECT_TYPE_CREATURE, R”jlp_npc_hoarder.utc”, lMerchantLocation);
    //Now lets create a location for our crate
    location lCrate1Location = Location(oArea, Vector(132.385178, 109.582336, -0.948085), -135.615631104);
    // and spawn the crate
    CreateObject(OBJECT_TYPE_PLACEABLE, R”genip_crate_wd_large_stat.utp”, lCrate1Location);
    }
    }

  6. Newyears1978
    November 17, 2009 at 6:05 pm

    Could it be because in my save game, I already have the NPC there, so the script is stopping. And if so how would I remedy this?

    • John Vanderbeck
      November 17, 2009 at 6:11 pm

      Yes that would be the problem. the chest will only spawn if the NPC isn’t already there. Also your new version of the NPC with the conversation probably won’t spawn either unless he or she is not there. You just need to go to a save game from before you spawned the merchant.

      • Newyears1978
        November 17, 2009 at 6:14 pm

        I deactivated the add-on, resaved, re-activated it, and wallah..worked.

        Learning, slowly, but surely =)

  7. newyears1978
    November 17, 2009 at 9:11 pm

    *chants* part 3, part 3! =)

    • John Vanderbeck
      November 17, 2009 at 9:59 pm

      I’m trying to get part 3 up tonight. I thought i’d have finished it by now, but i’m running into some troubles opening the merchant’s “store”. So I have to solve that bug first.

      • newyears1978
        November 17, 2009 at 10:43 pm

        Woops..well meanwhile I added my own voice over to my NPC and lipsyncing…

        I didn’t do a stage though as I don’t know how to put a stage in a prexisting area (not sure that you even can?)

  8. John Vanderbeck
    November 17, 2009 at 10:52 pm

    Ok part 3 isn’t going to get done tonight, i’m pretty certain. I’ve run into a huge snag that I need to figure out. My original plan for getting around the most ridiculous limitation that Bioware put into the toolset apparently isn’t working so I need to figure this out.

  9. John Vanderbeck
    November 18, 2009 at 1:33 am

    OK gang I FINALLY got my work around for our merchant resource to work. So tomorrow we can finish this up. The reason it isn’t so simple is because Bioware for some incredibly stupid reason, made it so that CreateObject() can NOT spawn merchant resources. There is no way to dynamically spawn a merchant. There are a few workarounds, but as i’m always talking about how important compatibility is, we need to go a certain direction i’ll cover in part 3 tomorrow.

    Maybe now I can get to sleep 🙂

    • newyears1978
      November 18, 2009 at 9:40 am

      So when I was told about 5 times on the forums you can’t create a merchant unless you make your own module..they were partially right =0

      • John Vanderbeck
        November 18, 2009 at 10:02 am

        People were saying you can’t do it because you can’t spawn one by a script. You need to think outside the box which is what we’ll be doing today 🙂

  10. newyears1978
    November 18, 2009 at 10:59 am

    Awesome, can’t wait!

  11. St4n4
    November 23, 2009 at 9:33 am

    Hi I cant get conversation part.
    “Once again click the Insert Line button to create a new dialog node.”
    When I click Insert Line button it gives me ” End dialogue” option I cant continue conversation

    • John Vanderbeck
      November 23, 2009 at 11:26 am

      @St4n4
      END DIALOG will always show on any new PC line to indicate that once the player chooses that line, the dialog will end. It will say that unless you add NPC dialog after it.

  12. St4n4
    November 23, 2009 at 4:05 pm

    Yes I found that, ty for answer.
    You have done an amazing job with this tutorial my friend.

  13. St4n4
    November 23, 2009 at 4:47 pm

    If you have time, could you post script without messages, or if anyone else know.
    Ty in advance.

  14. xenire
    November 28, 2009 at 3:08 pm

    I can’t seem to get the conversation to work. I’m unable to even initiate it. I tested some different conversations, but nothing seems to take effect.

    • xenire
      November 29, 2009 at 1:16 am

      I think it is having issues finding the conversation file for some reason. When I export I usually get the unable to find soundset error unless I export it twice, but even when it doesn’t give me the error I’m guessing it’s still not finding it. Anyone have any ideas? It seems like this shouldn’t be a hard problem to fix.

  15. December 13, 2009 at 3:41 pm

    Hi John,
    I didn’t know where to post this but your comments about spawning placeables helped me a lot so :
    I’m curently working on a mod to extent Lothering and so allow the PC to enter the mill. The tag of Lothering is lot100ar_lothering. So I made a custom indoor area for the mill with a door and a waypoint ( door variables PLC_AT_DEST_AREA_TAG = lot100ar_lothering
    PLC_AT_DEST_TAG = ext_mill_lot ), and I added a waypoint (ext_mill_lot) and a door outside the mill ( door variables PLC_AT_DEST_AREA_TAG = mill_interior
    PLC_AT_DEST_TAG = int_mill ). Thanks to the Lothering’s layout I could put the appropriate locations in the script for the mill’s door to spawn in the main game.

    That being said, I can actually enter my custom area but when I go out, I’m in the middle of nowhere in Lothering. In fact with a little debugging script, I manage to see that I’m in the center of the map : (0,0,0) …
    I tried everything, checked everything a thousand times, but nothing helped.

    Do you have any idea ?
    I need help please 🙂

  1. November 18, 2009 at 2:02 pm
  2. April 4, 2011 at 8:35 am

Leave a comment