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.
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.
~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:
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_lineNote: 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_lineImplementing this one should be easy, if a bit tedious. Coding in .d right from the beginning has its advantages...
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.
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_lineDoes it sound scary? No, not really. We had
SAY ~Hmm? No, I was thinking of - never mind.~ (to v5b.last)
, and now we are going to have
SAY ~Hmm? No, I was thinking of - never mind.~
IF ~~ + v5b.last
, that's it.
So, our dialogue looks like this now:
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:
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.)