PDA

View Full Version : Some issue with dialog.tlk and dialogf.tlk


Januszka
10-09-2006, 04:02 PM
Hello.
Hi, I am just testing some editions I made for kotor2 spanish dialog files and I have some question.

Ok. I think I should first tell what I intended to do and stuff.
Spanish version of the game only came with a tlk file: dialog.tlk, but spanish do change when saying an adjective to a male/female character.
Eg. The Exile, in spanish is "El Exiliado" (male) or "La exiliada" (female).
Thing is, in my site we created a dialogf.tlk and modified the original dialog.tlk to make this look ok (original dialog.tlk was a bit messy... there were many moments where being a woman they called you exiliadO and the other way around too. And I have to say, spanish players got were really angry with this issue. So I decided to try and fix it.

Ok. Now it seems we almost fixed it. But even having set a dialogf.tlk it still uses dialog.tlk. Now the question is: when does the game (kotor2) *EXACTLY* use the dialogf.tlk? Is it possible that it still uses the dialog.tlk even when the exile is female? Can it be possible that it uses the dialog.tlk when you're not using him/her (eg when you have to play with atton alone), and then is it going to use dialogf.tlk when playing only with mira?

Thanks :)

tk102
10-10-2006, 12:19 PM
It is my understanding that it is up to the .dlg files to deliberately determine the gender of the Player Character using conditional scripts and then specify the appropriate CExoLocString gender within the dialog text. Because you say the dialog.tlk file is still being used, it sounds like the .dlg files did not have the feminine branches implemented. I hope I'm wrong about that assumption, otherwise that would mean a lot more work would be necessary to modify the plethora of DLG files in the game.

Here's some documentation regarding this:
GFF file format (http://nwn.bioware.com/developers/Bioware_Aurora_GFF_Format.pdf) (sections 2.2 and 4.6)
Localized Strings (http://nwn.bioware.com/developers/Bioware_Aurora_LocalizedStrings_Format.pdf)

Note: This above all theoretical to me; I have not seen a non-English KotOR or TSL set of game fields to know exactly how it is implemented or not. Perhaps someone with a non-English version of the game who is familiar with DLG files could comment. :)

stoffe
10-10-2006, 02:14 PM
It is my understanding that it is up to the .dlg files to deliberately determine the gender of the Player Character using conditional scripts and then specify the appropriate CExoLocString gender within the dialog text.

I'm not so sure about that, unless I misunderstand what you mean. I may be wrong, but as far as I understand it the dialogf.tlk is corresponding to the LanguageID+1 substring ID within an ExoLocString which is used to specify the feminine forms. I don't think that has anything to do with specifically creating separate dialog branches and giving them their own unique StrRef in the text ExoLocString.

If you needed separate StrRefs for the text there wouldn't be any need for a dialogf.tlk file at all, since you could just put all the strings in the dialog.tlk file. Since the dialog.tlk and dialogf.tlk files must contain the same strings at the same StrRef you can't single out the gender-unique strings just by using the StrRef.

In general I'm as confused about this as the original poster however, since either my own native language nor english have these differences, and I'm not good enough at a language using distinct feminine sentence structure to have played a game in any of those languages. I have seen, while modding other games, that such languages tend to have one masculine and one feminine variant of all text strings, which I assume is for the same reason as why the bioware games have two dialog*.tlk files for such languages, and why the ExoLocString supports two substrings for each language ID.

But I have no idea what determines when the game picks which genus string. With some patience it could be determined by testing, however, if you take a specific string with different text for the masculine and feminine strings, and then try to use it in a variety of situations and see what the game picks.

All this is just wild guesses and conjecture on my part though, from what I have observed while modding various games, so take it with a huge grain of salt. :)

tk102
10-10-2006, 03:08 PM
In the English version of KotOR and TSL, unmodified .dlg files have no CExoLocSubStrings within the CExoLocStrings. These CExoLocSubStrings contain a StringID which is the LanguageID*2+Gender, as stoffe mentioned. In DLGEditor, the Mode: Language Settings menu item will only change the StringID if the StrRef for the CExoLocString is set to -1. I made the assumption that if the StrRef was something other than -1, then it there would be no CExoLocSubStrings to change. Perhaps I should rethink that.

You see, the reason I assumed you would need separate dialog branches is because I had no idea what other mechanism the game would use to distinguish using one SubString from another. But if you needed to go that extreme, then as you say, it wouldn't be any different than just using a different StringRef to begin with. Perhaps there is a hidden aspect in the game engine that silently calls the GetGender function on the main PC?

Edit: the preceding paragraph above just shows off my ignorance...

But of course when all else fails, RTFM. :xp: :D

Here is a quote from Bioware's LocalizedStrings document:

Procedure to Fetch LocString Text
...
1. Get the user's Language ID from the talk table and determine the gender to display (eg., gender of the player character who is speaking in a conversation).
2. Try to find an embedded string in the LocString that matches the user's language ID and the current gender. Use that string if found, and indicate success.
3. If there is no embedded string that matches the above criteria, get the StrRef of the LocString and try to fetch the text of that StrRef from the talk table, using the current gender. If the talk table contains the desired text, return that text and indicate success.

How does KotOR and TSL determine the gender in #1? A silent call to GetGender(OBJECT_SELF) during the start of the dialog? And according to this, it only checks based on the person talking, not the main PC in all cases. So you would have to use gender-checking conditionals such as a call to GetGlobalBoolean("000_PLAYER_GENDER") to avoid the Exiliado/Exiliado faux pas.

Januszka
10-10-2006, 03:58 PM
How does KotOR and TSL determine the gender in #1? A silent call to GetGender(OBJECT_SELF) during the start of the dialog? And according to this, it only checks based on the person talking, not the main PC in all cases. So you would have to use gender-checking conditionals such as a call to GetGlobalBoolean("000_PLAYER_GENDER") to avoid the Exiliado/Exiliado faux pas.


Is there any way to do so? Or do I need to be a modding ninja to do so? Cause that would be pretty nice indeed! *REALLY NICE* actually :D

stoffe
10-10-2006, 04:56 PM
I made the assumption that if the StrRef was something other than -1, then it there would be no CExoLocSubStrings to change. Perhaps I should rethink that.

That's probably correct. I'd be very surprised if there were any ExoLocString substrings in any of the standard game resources, since it would make localization exponentially more complicated. I'd imagine the reason they store all game strings in dialog.tlk is that all you need to do to localize the game would be to replace the dialog.tlk file, and any VO sound files, and you have another language version of the game. Thus the modules and BIF content would not require any changes. ExoLocString substrings are only meant for mods, to allow them to be self-contained, AFAIK.




How does KotOR and TSL determine the gender in #1? A silent call to GetGender(OBJECT_SELF) during the start of the dialog? And according to this, it only checks based on the person talking, not the main PC in all cases. So you would have to use gender-checking conditionals such as a call to GetGlobalBoolean("000_PLAYER_GENDER") to avoid the Exiliado/Exiliado faux pas.

It would probably be the equivalent of GetGender(GetPCSpeaker()) then, if it uses the object that is the target of an ActionStartConversation action (OBJECT_SELF is the NPC that runs the dialog). This is usually the main character in KotOR, but doesn't necessarily have to be. (And the main character does not have to be the Exile at all times.)


Is there any way to do so? Or do I need to be a modding ninja to do so? Cause that would be pretty nice indeed! *REALLY NICE* actually :D

As far as I understand it would require you to modify the DLG files in question to make the text change depending on the gender of the Exile if the Exile is not in the conversation. Are you going to change the voiceover sounds as well, or just the text? If it's just the text there are two ways of doing it that I can think of:
Make a separate dialog node for each entry/reply which needs to be different depending on the gender of the absent Exile, and put a gender check conditional script on the the "male" variant like below, and then link the entry/reply to the same reply/entry node the original was linked to:int StartingConditional() {
return GetGlobalBoolean("000_PLAYER_GENDER");
} (Or use one of the standard c_ismale or c_isfemale scripts that come with the game that does the same check.)


Replace the part of the text that needs to change with a custom token, and then use a script run by the dialog to set the text this token should contain depending on the gender of the Exile. As an example, if the text of a node is set as "Where is the <CUSTOM100>?", you could have a script set on that node like:
int StartingConditional() {
if (GetGlobalBoolean("000_PLAYER_GENDER")) {
SetCustomToken(100, "handsome Exile");
}
else {
SetCustomToken(100, "beautiful Exile");
}
return TRUE;
}

...which would make the text display as "Where is the handsome Exile?" if the Exile is male, or "Where is the beautiful Exile?" if she is female, when the dialog is run. This approach only works if you don't change the voiceover, of course.


Either would be a fair amount of work if it needs to be done in many dialog files.

Januszka
10-10-2006, 06:57 PM
Ooof sounds quite difficult for me. Isnt there just a way to make the game use dialog.tlk for male main character and dialogf.tlk for female main character, no matter who's talking?

Kaspian
10-11-2006, 05:38 AM
You can backup your dialog.tlk and rename dialogf.tlk to dialog.tlk when playing as female, but that's not the right solution.

Januszka
10-11-2006, 08:14 AM
Well that'd be same than not using dialogf.tlk *at all*
So all the work I did for this fix would go to the trashbin, dont you think? ;)
So any idea on how to get the game check the gender with a GetGlobalBoolean("000_PLAYER_GENDER") instead of GetGender(OBJECT_SELF) ?
Do I have to edit all and every dlg files to do so? And how do I do it?

stoffe
10-11-2006, 08:44 AM
So any idea on how to get the game check the gender with a GetGlobalBoolean("000_PLAYER_GENDER") instead of GetGender(GetPCSpeaker()) ?

As far as I am aware you can't, that's just how the game engine works. It seems like it checks the gender of the one an NPC is speaking to.


Do I have to edit all and every dlg files to do so? And how do I do it?

If I understand it correctly you wouldn't need to edit all dialogs, just the ones referring to the Exile while the Exile is not the one the NPC is speaking to.

If this is the case you can use tk102's DLG Editor (http://www.starwarsknights.com/tools.php), find the entry nodes in the dialog tree that needs to be different either add an extra entry where the text needs to vary depending on gender and use a conditional script with a gender check to determine which dialog node is used. Or use custom tokens to substitute the text in the existing dialog node, as described earlier. Unless someone knows of a quicker and better way of doing it, of course. :)

If you do edit the dialogs, remember that the standard behavior of the DLG Editor is to save modified text as ExoLocString substrings within the DLG file. If you want to keep all your text changes to the dialog.tlk file you'll need to add your modified text as new entries in dialog.tlk and then put the StrRefs to your new entries in the DLG Editor, instead of typing in the text directly in it.

This sounds a lot more complicated than it really is when I'm explaining it. :) Have a look at one of the DLG files with the DLG Editor, and if you have any questions, ask and someone will probably know the answer. :)

I have attached a very quick example of a dialog file that demonstrates how both variants could be used you can have a look at with the DLG Editor:

Kaspian
10-11-2006, 08:55 AM
No I don't. Imagine installer, which would swap tlk files according to your choice.

* Play as male
* Play as female

I saw it in unofficial Czech translation. There were 4 choices.

* Revan was female, I play male
* Revan was female, I play female
* Revan was male, I play male
* Revan was male, I play female

Kaspian
10-12-2006, 04:08 AM
But even having set a dialogf.tlk it still uses dialog.tlk. Now the question is: when does the game (kotor2) *EXACTLY* use the dialogf.tlk? Is it possible that it still uses the dialog.tlk even when the exile is female? Can it be possible that it uses the dialog.tlk when you're not using him/her (eg when you have to play with atton alone), and then is it going to use dialogf.tlk when playing only with mira?I experimented with talktables tonight and forced the game (TSL) to use female version of dialog talktable. There is no dialogf in english version (ignored), so I had to duplicate dialog.tlk and rename it to dialogf. Next I changed the same entry in both files to contain different value (for testing purposes). Here comes the important part - both file's language had to be set to 4 (Spanish). It can be done with Stoffe's TlkEd (checked it (http://kaspian.fotopic.net/p35050126.html) with hex editor). From this point the game stopped ignoring dialogf. I tested it at 605DAN (Dantooine Courtyard) with one of the scavengers (Rulak?). Acquired response depended on main player character. Male got male's and female got female's response. I tried the same thing with Kreia in solo mode (and my PC as male) but NPC spoken to PC (male response) although he was really far away.

Please check your dialog's language ID.

Edit: If the ID is 4, try to set it to another value (1 for French worked too for me).

Januszka
10-12-2006, 07:35 AM
But did the NPC talk to kreia or to main character... I mean... was the main character in the group? cause I only had that problem in nar shadaa when you get kidnapped and mira talks to visquis.
Btw, both dialog.tlk and dialogf.tlk are set to spanish.

Kaspian
10-12-2006, 08:00 AM
The NPC talked to main character. I thought your female dialogs aren't working at all. OK that's great :) I would use Stoffe's solution in her post above.

stoffe
10-12-2006, 08:28 AM
Conversations are always started with the main character by default, regardless of which party member is controlled when the NPC is "clicked". As long as the Exile is in the game she is always the main character (GetFirstPC() in script).

When the Exile is not in the party (T3/Atton/Mira solo adventures, G0T0's yacht, Dxun Tomb) the party member you choose to lead either expedition will become the new main character (who dialogs are started with, and whose gender will determine what gender strings are picked). This last part is the problem unless I've misunderstood it. When the Exile is not in the party, but is spoken of, the wrong gender strings are picked if the new main character's gender does not match that of the Exile, correct?

Januszka
10-12-2006, 10:05 AM
Eeeexactly, stoffe :)
The problem is *only* in these expeditions. Cause they dont have to be same gender (main character and leader of the party at that very moment).
So now i have this question: should i then find all those dialog files when main char is not in the party and change them? how do i do it then? Im now taking note of all the entries in the tlk where they talk about the jedi/exile by capturing screenshots. Can I with this find what dlg i should edit with this or do i have to just guess/scroll thru the dlg files to find which ones refer to those strings?

Januszka
10-12-2006, 10:39 AM
and another question: where are such dlg files? i dont see any in my kotor2 folder :(

Darth333
10-12-2006, 10:48 AM
Hola Janu! :waive1: It's good to see you on the boards!

One practical tool to search the entries you need to change is tk102's findrefs (http://www.starwarsknights.com/tools.php). I guess the best would be searching for the terms Exiliado/Exiliada.

If you want, this is something I could help you with if you send me the spanish .tlk tables.

Edit: findrefs allows you to extract the dlg files directly. You can also extract them with kotor tool (but don't edit them with KT: it is not fully compatible with Kotor 2 and your files will end up corrupted). The general banter .dlg files are located in the BIFs --> dialogs.bif --> Dialog and the module specific ones in the ERFs-->Modules under each module.

Januszka
10-12-2006, 11:54 AM
Wel the problem is not the part oof editing tlk files, already got a program for extracting and inserting tlk files into a txt. The problem resides on the parts you are not using main character, but atton, or mira or hanharr or whatever in a solo expedition. Then the game uses dialog.tlk or dialogf.tlk according to this person's gender, not yours :(

Im now thinking maybe a good idea would be to change all references to "el exiliado", la exiliada", el jedi/la jedi", el jeedai/la jeedai" into custom tokens and define them... But I have to think hw i should do that too hehe :)
But now off for a walk, ill keep on with these issues later :)

Kaspian
10-17-2006, 04:40 AM
It's possible to use custom tokens in talktables too. Replace the text in tlk with custom token defined in script.

¿Dónde está <CUSTOM4001>? (I don't know a word in Spanish, but this should be Where is Exile?)


//:: k_def_dialogue01
/*
Default On Dialogue Script
*/
//:: Created By: Preston Watamaniuk
//:: Copyright (c) 2002 Bioware Corp.

#include "k_inc_debug"
#include "k_inc_switch"

void main()
{
if (GetGlobalBoolean("000_PLAYER_GENDER") == FALSE) // Is main PC female?
{
SetCustomToken(4001, "la exiliada");
SetCustomToken(4002, "la jedi");
SetCustomToken(4003, "la jeedai");
}
else
{
SetCustomToken(4001, "el exiliado");
SetCustomToken(4002, "el jedi");
SetCustomToken(4003, "el jeedai");
}
ExecuteScript("k_ai_master", OBJECT_SELF, KOTOR_DEFAULT_EVENT_ON_DIALOGUE);
}
Please skip the next paragraph, if you know what to do with the code above.
Copy the code to any text editor, save as k_def_dialogue01.nss, compile and drop it to your Override folder. How to compile scripts? (http://www.lucasforums.com/showthread.php?t=143681)

I injected the script into k_def_dialogue01 so custom tokens are defined before every dialogue. I don't think it's the best solution but it worked fine.

There is also k_def_dialogue_s which differs in one line... SetKeepStealthInDialog(TRUE); As I understand it should keep character's stealth status in cutscenes. I would inject custom tokens definitions there as well.

stoffe
10-17-2006, 06:58 AM
Copy the code to any text editor, save as k_def_dialogue01.nss, compile and drop it to your Override folder.

If you use that approach, remember that some NPCs use the k_hen_dialogue01 OnDialog script as well, and that all party members have their own uniquely named k_hen_* OnDialog script (which unfortunately does not use k_ai_master, so you'll need to extract all the AI script include files in order to recompile them). You'd only need to change those if you are starting a conversation with another party member though that needs to use tokens. :)

Kaspian
10-17-2006, 09:06 AM
Thank you Stoffe, I'd never thought it is so complex. Will check it. Do you know if there is some other way how to define custom tokens throughout the entire game?

stoffe
10-17-2006, 10:40 AM
Thank you Stoffe, I'd never thought it is so complex. Will check it. Do you know if there is some other way how to define custom tokens throughout the entire game?

I don't think there is, everything except global variables, the quest journal, the party inventory and what's put in the party table and puppet table seems to be handled on a per module basis in the game. Custom tokens are no exception, if you transition to another area tokens previously set will not be preserved, since they are stored in the module.ifo files in the savegame as far as I am aware.

The safest and least hackish way of doing it is probably to set the tokens in a script in the dialog where they are needed. If you don't want to mess with the dialog files that need change, the way you proposed of altering the OnDialog AI scripts of the affected NPC is probably the second safest way.

* * *

If you want to set it throughout the entire game though... The most generic I can think of to ensure something is initialized everywhere would be to assign a global OnModuleLoad or OnClientEnter script to all modules in the game, and then put things into this script that you wish done whenever any module loads. In my game I have added an override-residing st_mod_onenter script to the Mod_OnClientEntr event (fires when the player enters a module) of all modules, where I do whatever initialization my other mods need.

There are only a handful of modules that already have their own OnClientEnter script assigned, so my st_mod_onenter script checks which module it is that is loading and uses ExecuteScript() to run those original script as well in the case of those modules, like:
void ST_RunOriginalScript() {
string sMod = GetModuleName();
string sScript = "";

if (sMod == "201TEL") sScript = "k_ptel201_enter";
else if (sMod == "202TEL") sScript = "k_ptel202_enter";
else if (sMod == "203TEL") sScript = "k_203tel_enter";
else if (sMod == "207TEL") sScript = "k_207tel_enter";
else if (sMod == "221TEL") sScript = "k_221tel_enter";
else if (sMod == "222TEL") sScript = "k_222tel_enter";

if (sScript != "") {
ExecuteScript(sScript, OBJECT_SELF);
}
}

It's worked fairly well so far, and if you use a mod-installer it's not too much work to make it modify the module.ifo file to assign the script in all the game's modules for you.

This might be a bit overkill if you only want to set a few custom tokens in a handful of areas when the Exile is not in the party though. ;)

Januszka
10-17-2006, 04:36 PM
Ugh. Now I'd wish I were a modder and udnerstand all this to make my version of the translation sooo cool :S

Kaspian
10-18-2006, 05:34 AM
Stoffe :thumbsup: thank you for the info. I don't want to mess with dialogs. I would rather add custom tokens to tlk and use your mod-installer to alter OnModuleLoad scripts of those few modules.

Januszka > You can be if you want :) Your localization is a good start. Do you need any help with it?

Januszka
11-03-2006, 02:00 PM
Oh, well, we finally decided to release the project together with a custom launcher.
It renames both tlk files according to what you're going to play. If you are going to play male, it renames dialogf.tlk to dialogf.temp, if you are going to play female, it renames dialog.tlk to dialog.temp and dialogf.tlk to dialog.tlk

We thought it'd be easier that way since we only have to release the tlk files + the launcher, not the tlk + dlg files and stuff.

And you only have to choose gender when you're going to play the game, not in the install :D

Well, it's not completely done yet, since we're trying to get the launcher not asking some libraries heh, but it'll be soon ;D

And now, thanks everyone :)

Now, the final question: what would happen if someone goes and install some mod after the translation?
Thankies :)

Kaspian
11-06-2006, 03:02 AM
Oh, well, we finally decided to release the project together with a custom launcher.
Does your launcher back-up original dialog.tlk? It is always good to have it if you want to patch the game. I had some issues with altered talktable and downloaded UK patch.

Now, the final question: what would happen if someone goes and install some mod after the translation?
What will happen depends on mod's language and author. New text strings would be probably in English (injected into *.tlk or customized in *.dlg). Mod can also use existing strings in dialog.tlk so displayed text is in talktable's language. And finaly there are mods (for example some bug fixes) without need for text.

Januszka
11-22-2006, 06:41 PM
Does your launcher back-up original dialog.tlk? It is always good to have it if you want to patch the game. I had some issues with altered talktable and downloaded UK patch.


What will happen depends on mod's language and author. New text strings would be probably in English (injected into *.tlk or customized in *.dlg). Mod can also use existing strings in dialog.tlk so displayed text is in talktable's language. And finaly there are mods (for example some bug fixes) without need for text.

Well the installer of the patch (when it copies files to hd, before the launcher) does a backup of the dialog.tlk :)
The launcher renames dialog.rpgb and dialogf.rpgb to dialog.tlk according to what you start the game as (male/female)

ANd about mods. The mods that add texts to tlk files well these lines are added during the installation i guess? Well if the texts are customized in dlg files doesnt matter id guess, but i wanted to be sure.
Thanks! :)