So it's a limitation of the game engine itself. Hmm. Should have thought of that myself right away. NWN2 is like that most of the time
That being said, this page seems to indicate that it should be possible.
https://nwn2.fandom.com/wiki/On_Chat_Event
I might be missing something, since I don't know NWN2 scripting all that well. Looking at
the example, however, I think something like this should work.
Maybe I'm missing some crucial information, but this should work, right?
Code: Select all
int TranslateMessageAndSendIfRequired(object oSender, object oTarget, int nChannel, string sMessage)
{
// Allow the text to be spoken normally for objects other than
// PCs, and for any channel other than the standard 'talk' channel.
if (!GetIsPC(oSender) || nChannel != CHAT_MODE_TALK )
{
return TRUE;
}
// Check if sMessage is a language entry
// This is done by the assumption that messages sent through the language tool
// use the following syntax: "Language§§Message" e.g. "Elven§§I am a happy teapot".
boolean bIsLanguageEntry = FindSubString("sMessage, "§§") > 0;
// If not a language entry, then treat the message using the standard flow.
if (!bIsLanguageEntry)
return TRUE;
// Otherwise handle the language entry.
string sLanguage = SubString(sMessage, 0, FindSubString("sMessage, "§§"));
boolean bTargetUnderstandsLanguage = PCHasLanguage(oTarget, sLanguage);
string sTranslatedMessage = ConvertMessageToLanguage(sMessage, sLanguage); // Turn the message into Elven, Goblin, Orcish, etc
if (bTargetUnderstandsLanguage)
{
// Prefix the message so the PC knows what language is spoken.
string sReadableMessage = "(" + sLanguage + "): " + sMessage;
SendMessageToPC(oSender, sTranslatedMessage); // Display translated gibberish message in Combat Log.
SendChatMessage(oSender, oTarget, nChannel, sReadableMessage, FALSE); // Display understood message in regular chat.
return FALSE
}
// Otherwise the PC doesn't understand the language, and should receive gibberish
SendChatMessage(oSender, oTarget, nChannel, sTranslatedMessage, FALSE);
return FALSE;
}