Suggestion: Language translations in chat

Suggestions or Mechanical Requests for Classes, Feats, Races, Etc.

Moderators: Moderator, Quality Control, Developer, DM

Post Reply
User avatar
zhazz
Posts: 849
Joined: Sat Feb 08, 2020 7:12 am

Suggestion: Language translations in chat

Unread post by zhazz »

Ever since the language overhaul a little over a year ago we've had the translation be displayed in a System Message fashion. Thus allowing us to have it display in either the windows for General Chat, Combat Log, or both.

The downside to this is that having the translation appear in General Chat also spams all the other system messages there. Primarily players logging on and off.

Is it possible to change the display of translated language to the following?

Character knows the language
  • Display the translated message in General Chat
  • Display the non-translated message (gibberish) in Combat Log
Character does not know the language
  • Display the non-translated message (gibberish) in General Chat
This keeps the flow of roleplay and conversation, without breaking immersion from system messages. This regardless of the character knowing the language spoken or not. While still making both outcomes available for players looking for translations for naming purposes or teaching roleplay.
Adrian Baker - An innocent virtuoso (bio | journal)
Relyth Ravan'Thala - Bear of an Elf
Timothy Daleson - Paladin Wand Maker
Duncan Matsirani - A wanderer
User avatar
DaloLorn
Posts: 2467
Joined: Tue Mar 26, 2019 2:44 am
Location: Discord (@dalolorn)

Re: Suggestion: Language translations in chat

Unread post by DaloLorn »

This was something I initially mentioned I was toying with in a Discord or two... only to then silently drop it. In that context, I guess it's no wonder you haven't heard the outcome. :lol:

So: To the best of my knowledge, it can't be done due to technical limitations.

There are only three channels which we can control on a player-by-player basis:
  • Combat log, via the SendMessageToPC() method. Yellow text printed into the combat log by a zillion things throughout the server.
  • Server chat, via SendChatMessage() using the CHAT_MODE_SERVER constant as one of its parameters. This is currently used by language translation and party chat.
  • Tells, via SendChatMessage() using the CHAT_MODE_TELL constant. Sendings do this, and the new familiar stuff I did also forces your PC to send a tell whenever your familiar tries to do it.
CHAT_MODE_TALK, the mode used with what you called "General Chat", doesn't support targeted messages. If you try to supply a target, it will simply ignore it and do its own thing. Consequently, we'd have to rip out the entire chat system (frontend and backend) in order to make it work, which is... well beyond a reasonable amount of work for a minor change like that.
European player, UTC+1 (+2 during DST). Ex-fixer of random bits. Active in Discord.
Active characters:
  • Zeila Linepret
  • Ilhara Evrine
  • Linathyl Selmiyeritar
  • Belinda Ravenblood
  • Virin Swifteye
  • Gurzhuk
User avatar
zhazz
Posts: 849
Joined: Sat Feb 08, 2020 7:12 am

Re: Suggestion: Language translations in chat

Unread post by zhazz »

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 :D

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;
}

Adrian Baker - An innocent virtuoso (bio | journal)
Relyth Ravan'Thala - Bear of an Elf
Timothy Daleson - Paladin Wand Maker
Duncan Matsirani - A wanderer
User avatar
DaloLorn
Posts: 2467
Joined: Tue Mar 26, 2019 2:44 am
Location: Discord (@dalolorn)

Re: Suggestion: Language translations in chat

Unread post by DaloLorn »

Mmm, the key point is here:

Code: Select all

// oTarget - for CHAT_MODE_TELL and CHAT_MODE_SERVERMESSAGE, this is the person who is receiving the message.
It doesn't work for CHAT_MODE_TALK. (... I guess I never tested that, strictly speaking...)
European player, UTC+1 (+2 during DST). Ex-fixer of random bits. Active in Discord.
Active characters:
  • Zeila Linepret
  • Ilhara Evrine
  • Linathyl Selmiyeritar
  • Belinda Ravenblood
  • Virin Swifteye
  • Gurzhuk
User avatar
zhazz
Posts: 849
Joined: Sat Feb 08, 2020 7:12 am

Re: Suggestion: Language translations in chat

Unread post by zhazz »

Ahh. Okay. I get it now. The variable oTarget is only used for specific targets. If it is left without a value then the message is visible to everyone within range.

I suppose it does make sense to protect the inner workings of the messaging implementation. Though for a game clearly meant to be customized and modded by the community, it's just another point of frustration. :mrgreen:

Oh well. Maybe one day we will get a NWN2: Enhanced Edition, and this sort of nonsense will be fixed.
Adrian Baker - An innocent virtuoso (bio | journal)
Relyth Ravan'Thala - Bear of an Elf
Timothy Daleson - Paladin Wand Maker
Duncan Matsirani - A wanderer
Post Reply

Return to “Mechanics”