Ok, so against my better judgment, I tried some more. I took the scripts into Notepad++ so I could watch several scripts at once, something that the NWN EE toolset permits me to do it seems.
In your “dwarfconv” scripts it asks to check for the local int “pr_tongues”. From what I can see of of all the scripts, this isn’t set anywhere.
This is why when testing when just casting the Comprehend Languages you only get the dwarf speak visible. If you look at this code:
if (bHasDwarvenItem || bHasComprehend)
{
FloatingTextStringOnCreature(TMESSAGE_TEXT + sGreetingInDwarf + COLOR_END, oPC, FALSE);
}
This only displays (to my understanding) the sGreetingInDwarf and not the translation.
EDIT: What’s more odd is that when trying to read through the extensive pjr_chat_inc, I can’t see any function for translating back what the dwarf is saying. It should be something simple to just display what he says in common language, but I don’t know how to do that.
EDIT2: I might be on the verge of solving this. I’ll just be at it for an hour more…
EDIT3: I’m not sure I’ve been able to fix this fully, but it’s a step in the right direction, I believe.
Here’s the updated version of the “dwarfconv” script:
// Script: npc_dwarf_convo
#include "pjr_chat_inc" // Ensure you have necessary language translation includes
void main()
{
object oPC = GetFirstPC(); // Player character initiating conversation
object oNPC = OBJECT_SELF; // The NPC
string sDwarfPhrase = "'Welcome stranger'"; // NPC's Dwarven greeting
string sDwarfApology = "Sorry, I don't understand you."; // NPC's apology
// Check if PC has Dwarven language item or Comprehend Languages effect
int bHasDwarvenItem = FALSE;
object oItem = GetFirstItemInInventory(oPC);
while (GetIsObjectValid(oItem))
{
if (GetTag(oItem) == "hlslang_4") // If player has the Dwarven language item
{
bHasDwarvenItem = TRUE;
break;
}
oItem = GetNextItemInInventory(oPC);
}
int bHasComprehend = GetLocalInt(oPC, "pr_comprehend_4"); // Check if player has Comprehend Languages for Dwarven
int bHasTongues = GetLocalInt(oPC, "pr_tongues"); // Check if player has Tongues spell effect
// Process Dwarven phrases using your translation function
string sGreetingInDwarf = ProcessDwarf(sDwarfPhrase);
string sApologyInDwarf = ProcessDwarf(sDwarfApology);
// If player has comprehension, NPC greets in Dwarven; otherwise, NPC apologizes
if (bHasDwarvenItem || bHasComprehend)
{
FloatingTextStringOnCreature(TMESSAGE_TEXT + sGreetingInDwarf + COLOR_END, oPC, FALSE);
FloatingTextStringOnCreature(sDwarfPhrase + COLOR_END, oPC, FALSE);
// If player has Tongues, enable them to reply in Dwarven
if (bHasTongues)
{
SetLocalInt(oPC, "pr_language", 4); // Set player's current language to Dwarven
FloatingTextStringOnCreature(TMESSAGE_TEXT + "The NPC listens to your response in Dwarven." + COLOR_END, oPC, FALSE);
}
}
else
{
FloatingTextStringOnCreature(TMESSAGE_TEXT + sApologyInDwarf + COLOR_END, oPC, FALSE);
}
}
As per this script, the only thing that the dwarf says will be “Welcome stranger” since that’s the only thing here. I have no idea how to implement other random phrases at the moment. Still the “pr_tongues” isn’t set anywhere to my knowledge.
Here’s the updated version of “sp_comprehendlan” script:
// Comprehend Languages Spell Script
#include "pjr_chat_inc"
#include "x2_inc_switches"
// Duration of the "Comprehend Languages" effect in seconds
const float fDuration = 600.0; // Adjust as needed for desired duration
void ApplyLanguageComprehension(object oPC);
void RemoveLanguageComprehension(object oPC);
void main()
{
object oCaster = OBJECT_SELF;
// Apply comprehension of all languages
ApplyLanguageComprehension(oCaster);
// Set a delayed action to remove language comprehension when the duration expires
DelayCommand(fDuration, RemoveLanguageComprehension(oCaster));
// Inform the player
SendMessageToPC(oCaster, "You feel a surge of understanding for other languages.");
FloatingTextStringOnCreature("You are able to comprehend all languages for a limited time.", oCaster, FALSE);
}
void ApplyLanguageComprehension(object oPC)
{
object oItem;
int iLan;
// Cycle through items in inventory and check for language tags
for (oItem = GetFirstItemInInventory(oPC); GetIsObjectValid(oItem); oItem = GetNextItemInInventory(oPC))
{
string sTag = GetTag(oItem);
// Check if the item is a language item
if (GetStringLeft(sTag, 8) == "hlslang_")
{
iLan = GetLanguageNumber(sTag);
// Set language comprehension variables
SetLocalInt(oPC, "pr_comprehend_" + IntToString(iLan), TRUE);
}
else if(sTag == "ComprehendLanguages" || sTag == "Tongues")
{
int nLanguage = 1;
while (nLanguage <= 81)
{
SetLocalInt(oPC, "pr_comprehend_" + IntToString(nLanguage), TRUE);
nLanguage = nLanguage + 1;
}
}
}
}
void RemoveLanguageComprehension(object oPC)
{
object oItem;
int iLan;
// Cycle through items in inventory and remove comprehension variables
for (oItem = GetFirstItemInInventory(oPC); GetIsObjectValid(oItem); oItem = GetNextItemInInventory(oPC))
{
string sTag = GetTag(oItem);
if (GetStringLeft(sTag, 8) == "hlslang_")
{
iLan = GetLanguageNumber(sTag);
// Remove language comprehension variables
DeleteLocalInt(oPC, "pr_comprehend_" + IntToString(iLan));
}
}
// Inform the player
SendMessageToPC(oPC, "The effect of Comprehend Languages fades, and you lose the understanding of other languages.");
FloatingTextStringOnCreature("Your comprehension of languages has ended.", oPC, FALSE);
}
At the moment this works if you activate the dwarven widget (or what it’s called) or use the Comprehend Languages scroll/spell.
Now I leave this in more capable hands, someone else with much deeper understanding of scripting than my surface knowledge.