Author Topic: Writing dialogue in .d for REAL beginners  (Read 7009 times)

Offline Kulyok

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 6005
  • Gender: Female
  • The perfect moment is now.
Writing dialogue in .d for REAL beginners
« on: March 22, 2008, 06:58:19 AM »
If you're a modder, and you've already coded your first NPC, your first romance, or your tenth mod, you won't find anything useful here, I'm afraid.

But if you're just starting with your idea of an NPC mod, this is going to be useful.

Why am I writing this? Because I think that coding in .d is a really, really tedious and ungrateful work, which is why I think that every beginning NPC/romance/quest writer should know how to do it. And because it's That Simple.

It is easy, it will save time for you, and, if you are creating your mod with a help of a coder(or via "How to do this?" threads in IE Modding Help/Modding Q&A/your own forum), for others, too.

And if you've got your whole romance or NPC coded in perfect .d, finding a coder will be much easier - most of the work is already done.

So,

Talks with the PC: lovetalks, friend talks and more.

Let's take an example talk and code it. It's a romantic talk with Valygar.

Code: [Select]
A beautiful night.
- Indeed. (to v5b.1)
- But not the most romantic setting, is it? (to v5b.1)
- Take my hand, and let us walk together under the stars. (to v5b.1)
- Uh-huh. And a very quiet one. Damn, now I have to wipe my weapon again... (to v5b.1)

(v5b.1)
Shh. Can you hear it? An owl hooting - there!
Here it flies off! A magnificent bird.
- It shouldn't be here, right? (to v5b.2)
- Perhaps it is someone's messenger. (to v5b.2)
- Valygar, why are we discussing birds? (to v5b.3)

(v5b.2)
Owls are clever birds. It may be carrying messages... look, another one! A wizard must be living nearby.
- Valygar, I implore you: don't start about wizards. Not now. (to v5b.4)
- Or maybe they are courting. Just like we are. (to v5b.5)
- I wonder... (to v5b.last)

(v5b.3)
(Valygar looks at you in amazement, then laughs.)
Why indeed...  (to v5b.last)

(v5b.4)
Hmm? No, I was thinking of - never mind. (to v5b.last)

(v5b.5)
We are not, <CHARNAME>. We are... (to v5b.last)

(v5b.last)
You must be tired. Take my hand, and let's walk. Enough battles for today.

Rule 1: Every line should start with a tilde (~) and end with a tilde(~).

This is the most important rule ever. If you ever get an error during the mod's installation, it's probably this one.

Let's implement it.

Code: [Select]
~A beautiful night.~
- ~Indeed.~ (to v5b.1)
- ~But not the most romantic setting, is it?~ (to v5b.1)
- ~Take my hand, and let us walk together under the stars.~ (to v5b.1)
- ~Uh-huh. And a very quiet one. Damn, now I have to wipe my weapon again...~ (to v5b.1)

(v5b.1)
~Shh. Can you hear it? An owl hooting - there!~
~Here it flies off! A magnificent bird.~
- ~It shouldn't be here, right?~ (to v5b.2)
- ~Perhaps it is someone's messenger.~ (to v5b.2)
- ~Valygar, why are we discussing birds?~ (to v5b.3)

(v5b.2)
~Owls are clever birds. It may be carrying messages... look, another one! A wizard must be living nearby.~
- ~Valygar, I implore you: don't start about wizards. Not now.~ (to v5b.4)
- ~Or maybe they are courting. Just like we are.~ (to v5b.5)
- ~I wonder...~ (to v5b.last)

(v5b.3)
~(Valygar looks at you in amazement, then laughs.)~
~Why indeed...~  (to v5b.last)

(v5b.4)
~Hmm? No, I was thinking of - never mind.~ (to v5b.last)

(v5b.5)
~We are not, <CHARNAME>. We are...~ (to v5b.last)

(v5b.last)
~You must be tired. Take my hand, and let's walk. Enough battles for today.~

Rule 2: Every line NPC says should start with a SAY.
If NPC says several lines, all NPC lines after the one starting with SAY should start with an equals sign (=).

Easy enough? Let's see how it's going to look:

Code: [Select]
SAY ~A beautiful night.~
- ~Indeed.~ (to v5b.1)
- ~But not the most romantic setting, is it?~ (to v5b.1)
- ~Take my hand, and let us walk together under the stars.~ (to v5b.1)
- ~Uh-huh. And a very quiet one. Damn, now I have to wipe my weapon again...~ (to v5b.1)

(v5b.1)
SAY ~Shh. Can you hear it? An owl hooting - there!~
= ~Here it flies off! A magnificent bird.~
- ~It shouldn't be here, right?~ (to v5b.2)
- ~Perhaps it is someone's messenger.~ (to v5b.2)
- ~Valygar, why are we discussing birds?~ (to v5b.3)

(v5b.2)
SAY ~Owls are clever birds. It may be carrying messages... look, another one! A wizard must be living nearby.~
- ~Valygar, I implore you: don't start about wizards. Not now.~ (to v5b.4)
- ~Or maybe they are courting. Just like we are.~ (to v5b.5)
- ~I wonder...~ (to v5b.last)

(v5b.3)
SAY ~(Valygar looks at you in amazement, then laughs.)~
= ~Why indeed...~  (to v5b.last)

(v5b.4)
SAY ~Hmm? No, I was thinking of - never mind.~ (to v5b.last)

(v5b.5)
SAY ~We are not, <CHARNAME>. We are...~ (to v5b.last)

(v5b.last)
SAY ~You must be tired. Take my hand, and let's walk. Enough battles for today.~

Rule 3: PC replies should look this way: ++ ~Reply~ + NPC_answers_this_line

Note: if a line only works under a special condition(PC is an elf, for example), the form changes to
+ ~condition~ + ~Reply~ + NPC_answers_this_line, as in
+ ~Race(Player1,ELF)~ + ~Reply~ + NPC_answers_this_line


Implementing this one should be easy, if a bit tedious. Coding in .d right from the beginning has its advantages...

Code: [Select]
SAY ~A beautiful night.~
++ ~Indeed.~ + v5b.1
++ ~But not the most romantic setting, is it?~ + v5b.1
++ ~Take my hand, and let us walk together under the stars.~ + v5b.1
++ ~Uh-huh. And a very quiet one. Damn, now I have to wipe my weapon again...~ + v5b.1

(v5b.1)
SAY ~Shh. Can you hear it? An owl hooting - there!~
= ~Here it flies off! A magnificent bird.~
++ ~It shouldn't be here, right?~ + v5b.2
++ ~Perhaps it is someone's messenger.~ + v5b.2
++ ~Valygar, why are we discussing birds?~ + v5b.3

(v5b.2)
SAY ~Owls are clever birds. It may be carrying messages... look, another one! A wizard must be living nearby.~
++ ~Valygar, I implore you: don't start about wizards. Not now.~ + v5b.4
++ ~Or maybe they are courting. Just like we are.~ + v5b.5
++ ~I wonder...~ + v5b.last

(v5b.3)
SAY ~(Valygar looks at you in amazement, then laughs.)~
= ~Why indeed...~  (to v5b.last)

(v5b.4)
SAY ~Hmm? No, I was thinking of - never mind.~ (to v5b.last)

(v5b.5)
SAY ~We are not, <CHARNAME>. We are...~ (to v5b.last)

(v5b.last)
SAY ~You must be tired. Take my hand, and let's walk. Enough battles for today.~

Rule 4: every block should have a unique name: IF ~~ block_name

"Unique" part is important, or you will get errors during the installation.

Easy? Easy.

Code: [Select]
IF ~~ v5b
SAY ~A beautiful night.~
++ ~Indeed.~ + v5b.1
++ ~But not the most romantic setting, is it?~ + v5b.1
++ ~Take my hand, and let us walk together under the stars.~ + v5b.1
++ ~Uh-huh. And a very quiet one. Damn, now I have to wipe my weapon again...~ + v5b.1

IF ~~ v5b.1
SAY ~Shh. Can you hear it? An owl hooting - there!~
= ~Here it flies off! A magnificent bird.~
++ ~It shouldn't be here, right?~ + v5b.2
++ ~Perhaps it is someone's messenger.~ + v5b.2
++ ~Valygar, why are we discussing birds?~ + v5b.3

IF ~~ v5b.2
SAY ~Owls are clever birds. It may be carrying messages... look, another one! A wizard must be living nearby.~
++ ~Valygar, I implore you: don't start about wizards. Not now.~ + v5b.4
++ ~Or maybe they are courting. Just like we are.~ + v5b.5
++ ~I wonder...~ + v5b.last

IF ~~ v5b.3
SAY ~(Valygar looks at you in amazement, then laughs.)~
= ~Why indeed...~  (to v5b.last)

IF ~~ v5b.4
SAY ~Hmm? No, I was thinking of - never mind.~ (to v5b.last)

IF ~~ v5b.5
SAY ~We are not, <CHARNAME>. We are...~ (to v5b.last)

IF ~~ v5b.last
SAY ~You must be tired. Take my hand, and let's walk. Enough battles for today.~

Rule 5: every block without PC replies should have either an ending, or an order to move to the next NPC line right under the NPC line.
An ending:
IF ~~ EXIT
An order to move to the next NPC line:
IF ~~ + name_of_the_next_NPC_line


Does it sound scary? No, not really. We had
Code: [Select]
SAY ~Hmm? No, I was thinking of - never mind.~ (to v5b.last), and now we are going to have
Code: [Select]
SAY ~Hmm? No, I was thinking of - never mind.~
IF ~~ + v5b.last
, that's it.

So, our dialogue looks like this now:

Code: [Select]
IF ~~ v5b
SAY ~A beautiful night.~
++ ~Indeed.~ + v5b.1
++ ~But not the most romantic setting, is it?~ + v5b.1
++ ~Take my hand, and let us walk together under the stars.~ + v5b.1
++ ~Uh-huh. And a very quiet one. Damn, now I have to wipe my weapon again...~ + v5b.1

IF ~~ v5b.1
SAY ~Shh. Can you hear it? An owl hooting - there!~
= ~Here it flies off! A magnificent bird.~
++ ~It shouldn't be here, right?~ + v5b.2
++ ~Perhaps it is someone's messenger.~ + v5b.2
++ ~Valygar, why are we discussing birds?~ + v5b.3

IF ~~ v5b.2
SAY ~Owls are clever birds. It may be carrying messages... look, another one! A wizard must be living nearby.~
++ ~Valygar, I implore you: don't start about wizards. Not now.~ + v5b.4
++ ~Or maybe they are courting. Just like we are.~ + v5b.5
++ ~I wonder...~ + v5b.last

IF ~~ v5b.3
SAY ~(Valygar looks at you in amazement, then laughs.)~
= ~Why indeed...~
IF ~~ + v5b.last

IF ~~ v5b.4
SAY ~Hmm? No, I was thinking of - never mind.~
IF ~~ + v5b.last

IF ~~ v5b.5
SAY ~We are not, <CHARNAME>. We are...~
IF ~~ + v5b.last

IF ~~ v5b.last
SAY ~You must be tired. Take my hand, and let's walk. Enough battles for today.~
IF ~~ EXIT

Rule 6, final: Every block, with replies or without, should have an END.

This one is just a quick copy and paste:

Code: [Select]
IF ~~ v5b
SAY ~A beautiful night.~
++ ~Indeed.~ + v5b.1
++ ~But not the most romantic setting, is it?~ + v5b.1
++ ~Take my hand, and let us walk together under the stars.~ + v5b.1
++ ~Uh-huh. And a very quiet one. Damn, now I have to wipe my weapon again...~ + v5b.1
END

IF ~~ v5b.1
SAY ~Shh. Can you hear it? An owl hooting - there!~
= ~Here it flies off! A magnificent bird.~
++ ~It shouldn't be here, right?~ + v5b.2
++ ~Perhaps it is someone's messenger.~ + v5b.2
++ ~Valygar, why are we discussing birds?~ + v5b.3
END

IF ~~ v5b.2
SAY ~Owls are clever birds. It may be carrying messages... look, another one! A wizard must be living nearby.~
++ ~Valygar, I implore you: don't start about wizards. Not now.~ + v5b.4
++ ~Or maybe they are courting. Just like we are.~ + v5b.5
++ ~I wonder...~ + v5b.last
END

IF ~~ v5b.3
SAY ~(Valygar looks at you in amazement, then laughs.)~
= ~Why indeed...~
IF ~~ + v5b.last
END

IF ~~ v5b.4
SAY ~Hmm? No, I was thinking of - never mind.~
IF ~~ + v5b.last
END

IF ~~ v5b.5
SAY ~We are not, <CHARNAME>. We are...~
IF ~~ + v5b.last
END

IF ~~ v5b.last
SAY ~You must be tired. Take my hand, and let's walk. Enough battles for today.~
IF ~~ EXIT
END

That's it! Coded.

Note that there is still one thing to do - setting the conditions for this lovetalk. To understand that, you'll have to read more on scripting in .baf, and how scripts work. If you want, you can start with:

1) A Beginner's Guide to NPC creation with WeiDU, and its expansion: How to make an NPC if you are a NOOB.

2) The road to banter - NPC-NPC dialogue, conditions, and more.

3) How to ensure your banters run when you want them to - that's scripting, quick and dirty.

(Or ask me or someone else to write another tutorial. AFTER you've coded your .d file, that is. :) )


Bottom line: rules to remember.

Rule 1: Every line should start with a tilde (~) and end with a tilde(~).
Rule 2: Every line NPC says should start with a SAY.
If NPC says several lines, all NPC lines after the one starting with SAY should start with an equals sign (=).
Rule 3: PC replies should look this way: ++ ~Reply~ + NPC_answers_this_line
Rule 4: every block should have a unique name: IF ~~ block_name
Rule 5: every block without PC replies should have either an ending, or an order to move to the next NPC line right under the NPC line.
An ending:
IF ~~ EXIT
An order to move to the next NPC line:
IF ~~ + name_of_the_next_NPC_line
Rule 6, final: Every block, with replies or without, should have an END.


(And, yes, when I saw Weidu readme and some of the more advanced tutorials for the first time, I panicked, too, especially after I saw the "Don't panic!" note. My first piece of .d code for Branwen romance was created via taking constant peeks at jastey's work - Ajantis romance, in that case. Do not be afraid to borrow code - just bring in your own ideas.)

Offline gertjanvh

  • Planewalker
  • *****
  • Posts: 95
  • Gender: Male
Re: Writing dialogue in .d for REAL beginners
« Reply #1 on: March 22, 2008, 07:16:15 AM »
ctrl - a
ctrl - c
ctrl - v

My gratitude is everlasting :)

Offline Rodman49

  • Excellence Incarnate
  • Planewalker
  • *****
  • Posts: 222
  • Gender: Male
  • Nietzschean
Re: Writing dialogue in .d for REAL beginners
« Reply #2 on: March 22, 2008, 02:51:06 PM »
Interesting how you write all the dialogue and then convert each line to code.  I always make a code template and then paste my dialogue into it . . . same effect, just interesting how you do yours . . .

Offline Kulyok

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 6005
  • Gender: Female
  • The perfect moment is now.
Re: Writing dialogue in .d for REAL beginners
« Reply #3 on: March 22, 2008, 03:01:24 PM »
I coded my dialogue straight in .d. I use step-by-step approach in this topic, as this is one of the simplest ways to explain the routine.

Offline magrat

  • Quiet
  • Planewalker
  • *****
  • Posts: 55
  • Gender: Female
    • FF
Re: Writing dialogue in .d for REAL beginners
« Reply #4 on: March 22, 2008, 03:34:39 PM »
Awesome.  I can now send you the RE encounter in a .d attempt!
"It is absurd to divide people into good and bad. People are either charming or tedious."
  - Oscar Wilde

Discovery,
Reclaiming,
Hopelessly Ever After

Offline Kulyok

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 6005
  • Gender: Female
  • The perfect moment is now.
Re: Writing dialogue in .d for REAL beginners
« Reply #5 on: June 23, 2008, 01:24:47 PM »
Topic split, and it's another good moment to remind everyone that it's NOT a good idea to PM tutorial authors, as some (or, to be honest, most) of them are no longer active. Use Modding Q&A forum instead.

As well, this topic is highly recommended.

Offline Kulyok

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 6005
  • Gender: Female
  • The perfect moment is now.
Re: Writing dialogue in .d for REAL beginners
« Reply #6 on: February 12, 2013, 04:39:03 AM »
And this topic at Gibberlings3 probably answers more than a few questions you might have:
http://forums.gibberlings3.net/index.php?showtopic=24982

 

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Name: Email:
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image
Type the letters shown in the picture:
What color are clouds?:
What is the fourth word in this sentence?: