• New Horizons on Maelstrom
    Maelstrom New Horizons


    Visit our website www.piratehorizons.com to quickly find download links for the newest versions of our New Horizons mods Beyond New Horizons and Maelstrom New Horizons!

trying to improve dialog writing

BathtubPirate

Privateer
Storm Modder
Hello y'all, I'm trying to use the momentum of passion for the game (both stock and NH) to improve my dialog writing. I've gotten some dialogs to work, others don't work. I think I understand most of the code, but until now I've always started by buidling my code on top of a copied dialog-file, so you might notice that in the whole preambel of the file. But writing it from scratch hasn't really worked for me.

Long story short, can you tell me what's causing the error in this short dialog structure I've been playing around with tonight?

//nclude "DIALOGS\Ramon Cabrera_dialog.h"
void ProcessDialogEvent()
{
ref NPChar;
aref Link, NextDiag;

DeleteAttribute(&Dialog,"Links");

makeref(NPChar,CharacterRef);
makearef(Link, Dialog.Links);
makearef(NextDiag, NPChar.Dialog);

ref PChar;
PChar = GetMainCharacter();


switch(Dialog.CurrentNode)
{
// -----------------------------------Äèàëîã ïåðâûé - ïåðâàÿ âñòðå÷à
case "First time":

Dialog.defAni = "dialog_stay1";
Dialog.defCam = "1";
Dialog.defSnd = "dialogs\0\017";
Dialog.defLinkAni = "dialog_1";
Dialog.defLinkCam = "1";
Dialog.defLinkSnd = "dialogs\woman\024";
Dialog.ani = "dialog_stay2";
Dialog.cam = "1";
Dialog.snd = "voice\THDI\THDI001";

dialog.text = DLG_TEXT[0];
link.l1 = DLG_TEXT[1];
link.l1.go = "shore_meetn1";
SetQuestHeader("castaway");
AddQuestrecord("castaway", "1");

break;

case "shore_meetn1":
d.Text = DLG_TEXT[2];
Link.l1 = DLG_TEXT[3];
Link.l1.go = "shore_meetn2";
Link.l2 = DLG_TEXT[4];
Link.l2.go = "exit_leave_shore";
break;

case "shore_meetn2":
d.Text = DLG_TEXT[5];
Link.l1 = DLG_TEXT[6];
Link.l1.go = "shore_meetn3";
break;

case "shore_meetn3":
d.Text = DLG_TEXT[7];
Link.l1 = DLG_TEXT[8];
Link.l1.go = "shore_meetn4";
break;

case "shore_meetn4":
d.Text = DLG_TEXT[9];
Link.l1 = DLG_TEXT[10];
Link.l1.go = "shore_meetn5";
Link.l2 = DLG_TEXT[11];
Link.l2.go = "exit_leave_shore";
break;

case "shore_meetn5":
d.Text = DLG_TEXT[12];
Link.l1 = DLG_TEXT[13];
Link.l1.go = "shore_meetn6";
break;

case "shore_meetn6":
d.Text = DLG_TEXT[14];
Link.l1 = DLG_TEXT[15];
Link.l1.go = "exit";
AddQuestrecord("castaway", "3");
break;

case "exit_leave_shore":
DialogExit();
NextDiag.CurrentNode = NextDiag.TempNode;
AddQuestrecord("castaway", "2");
CloseQuestHeader("castaway");
break;

case "exit":
DialogExit();
NextDiag.CurrentNode = NextDiag.TempNode;
break;
}
}
 
What's the error message you're getting? Or the error behaviour?

(At a first glance, I can't see anything wrong with this code -- other than that your 'case "exit"' dialogue exit doesn't have a closing for the opened QuestHeader "castaway".)
 
Last edited:
Hey, thanks, I couldn't spot an obvious error either, that's why I'm asking. It's a simple dialogue and it's frustrating it doesn't work...

What's the error message you're getting? Or the error behaviour?
The typical "I can't load dialogie file…"

other than that your 'case "exit"' dialogue exit doesn't have a closing for the opened QuestHeader "castaway".
It isn't supposed to. For now it's a straight dialogue which opens a quest entry at the beginning, ads a second text at the end and has two opportunities to close it before.

BTW, it's the whole "def" and "ani" stuff at the beginning of which I don't know what it means and left unchanged from the file I copied and then customized.
 
The typical "I can't load dialogie file…"
If it can't load it, then there's something wrong with the implementation.

Just to check: the dialogue texts you're referencing exist (e.g. "DLG_TEXT[15]")? You've added them to the game? I work mostly with Caribbean Tales (a later game in the series) and I haven't seen this method of referencing the text before. I'll have a look at some POTC dialogue files shortly.

BTW, it's the whole "def" and "ani" stuff at the beginning of which I don't know what it means and left unchanged from the file I copied and then customized.
These entries are for POTC's pop-over character image and voices in the dialogue. When you start a conversation with a person, you get that pop-up overlay with the animated character model in a portrait -- I'm pretty sure that's what these entries are for. :)
 
Okay, I see what's wrong:
//nclude "DIALOGS\Ramon Cabrera_dialog.h"
This needs to be:
Code:
#include "DIALOGS\Ramon Cabrera_dialog.h"
That's provided that "Ramon Cabrera_dialog.h" is the text file that contains your dialogue text for this dialogue.

The C header (.h) files contain the text for the dialogue.

At the start of this header text file, the number in square brackets is the total number of text lines to be spoken. (You can use the sideline line numbering in a text editor as reference to count them, but don't forget to reduce the total amount by one -- not counting the first line, which is a command and not a dialogue text line.)

Make sure that you have at least 15 dialogue text lines in there, so that your dialogue script is not referencing text that doesn't actually exist! ;)
 
Last edited:
That's provided that "Ramon Cabrera_dialog.h" is the text file that contains your dialogue text for this dialogue.

The C header (.h) files contain the text for the dialogue.

At the start of this header text file, the number in square brackets is the total number of text lines to be spoken. (You can use the sideline line numbering in a text editor as reference to count them, but don't forget to reduce the total amount by one -- not counting the first line, which is a command and not a text line.)
Thank you, I'll try that, but I'd like to say that every other dialogue file starts with //nclude (I'm testing this on a base game version of PotC, perhaps it's different in NH or CT?).

I know that the lines start with [0], meaning e.g. that the third line of text is [2]. But the .h file has also the number of lines on top of the file, and there the counting starts with 1.
 
Thank you, I'll try that, but I'd like to say that every other dialogue file starts with //nclude (I'm testing this on a base game version of PotC, perhaps it's different in NH or CT?).
This does not sound right. :no What text editor are you using?

But the .h file has also the number of lines on top of the file, and there the counting starts with 1.
If your dialogue text has 50 dialogue text lines, the text editor will show 51 at the last line (because it is counting the very first line in the file as well). Take away one, and you end up with the true number of total dialogue text lines: 50.
 
Hm, changing //nclude to #include hasn't done anything, and like I said, I was a bit sceptical because on that game, every file starts like that.

And there seems to be nothing wrong with the punctuation or line-counting in the .h file either… :rolleyes:
 
Just the normal Notepad I'm using. I've been to lazy to upgrade on a more comfortable editor...

That's what I meant with the lines, sorry. For clarification: The text file has 18 lines by now, and says string DLG_TEXT[18] at the top. I'm using the first 16 for now, and that's why the code I posted uses DLG_TEXT[0] to DLG_TEXT[15]. Seems to be correct.

UNLESS the dialog doesn't work because I've written those two more lines which are not included in the structure yet. But I can't really imagine that… Once I did a dialogue that worked perfectly, where I built all on top of a copied dialog file that still included parts of the structure for a completely different character (the one I copied it from).
 
UNLESS the dialog doesn't work because I've written those two more lines which are not included in the structure yet. But I can't really imagine that… Once I did a dialogue that worked perfectly, where I built all on top of a copied dialog file that still included parts of the structure for a completely different character (the one I copied it from).
As long as the total indicated at the top of the header file is not larger than the amount of lines you have in the file, or smaller than the highest line number you are referencing in the script file, this shouldn't pose a problem.

Does your header file exist for this new dialogue script file (named the same, just with a .h extension)?
 
Also make sure that your header file has the closing line of code at the very end:
Code:
};
 
Can you upload both files here? I'll have a careful look through them for you, if you like.
 
Dialog.defAni = "dialog_stay1";
Dialog.defCam = "1";
Dialog.defSnd = "dialogs\0\017";
Dialog.defLinkAni = "dialog_1";
Dialog.defLinkCam = "1";
Dialog.defLinkSnd = "dialogs\woman\024";
Dialog.ani = "dialog_stay2";
Dialog.cam = "1";
Dialog.snd = "voice\THDI\THDI001";
You could also try commenting these lines out for now, and try running the code without them:
Code:
//Dialog.defAni = "dialog_stay1";
//Dialog.defCam = "1";
//Dialog.defSnd = "dialogs\0\017";
//Dialog.defLinkAni = "dialog_1";
//Dialog.defLinkCam = "1";
//Dialog.defLinkSnd = "dialogs\woman\024";
//Dialog.ani = "dialog_stay2";
//Dialog.cam = "1";
//Dialog.snd = "voice\THDI\THDI001";
(Just in case something in them is the culprit -- though I find this unlikely.)
 
Sure. I've "simplified" the text down to placeholders, my draft was in german and it doesn't matter that much anyway.
 

Attachments

  • rc.zip
    1.1 KB · Views: 268
Okay, I don't see anything wrong with the text formatting and encoding either.

First, restore the #include for the .h file. This is a proper C programming convention -- it tells the interpreter/compiler to read the header file. I'm not sure why your copy of the game has this line commented out, but it certainly doesn't hurt to have it.

Then, a few suggestions you can try:

1. Simplify this line to omit the newline "\n"-s:
Code:
"first\nsecond\nthird!\nfourth...",

2. Comment out all "QuestHeader" and "Questrecord" lines -- just in case something's wrong with you use of these functions/commands.

I really can't think of anything else. It all seems fine otherwise, and should be working. Are you using any mods with your game?
 
Ok I found it. You have d.text in all cases except in "First time" where you have dialog.text.
I changed all to dialog.text and it works. Found this in the error log:

Code:
COMPILE ERROR - file: storyline\WoodesRogers\dialogs\Ramon Cabrera_dialog.c; line: 41
Undeclared identifier: d
 

Attachments

  • fixed.7z
    826 bytes · Views: 258
Ok I found it. You have d.text in all cases except in "First time" where you have dialog.text.
I changed all to dialog.text and it works.
I did notice this, but I've seen this mixed implementation in other dialog files, too, in POTC. I don't think the "d" was declared there either... Let me double-check... :nerbz
 
Thank you @Jack Rackham ! Strange... Is d.text something that doesn't work at all? Because I must have copied that from somewhere...

And thanks to @Cerez for all the effort too!

Btw, this is right now the attempt to make a quest, but in the very early stage of playing around and testing what I can do. It may lead somewhere interesting, but right now it's just me playing around a bit.
 
Back
Top