PDA

View Full Version : Can NPCs speak in other languages?


Shendare
05-07-2009, 12:29 AM
Is there any built-in functionality for quest NPCs to speak in /say in languages other than common? Like a quest::sayLang(12, "Hey, $name! I'm speaking in Elder Elvish!"); ? Players who were fluent in the language would see it properly, but others nearby would see a garbled message just like players speaking in unfamiliar tongues.

Also, on a related note, I know in EQLive there was at least one quest where the NPC only responded when spoken to in the proper language (Elder Dragon, I think it was). Is there currently any way for a quest script in EVENT_SAY to determine what language the player was speaking when they spoke?

Thanks in advance!

- Shendare

joligario
05-07-2009, 06:45 AM
Not that I know of.. however, you can script a skill check. Something along the lines of this method:

if ($text=~/hail/i) {
if ($client->GetSkill(XX) > 50) {
quest::say("Your skill is above 50, so you can understand me.");
}
else {
quest::say("Gjoiwjf hoiaw oihaf 28? oi ahwue whiuhaw wewe=");
}
}

Shendare
05-07-2009, 09:49 AM
Thanks for the reply!

Yeah, when I couldn't find any built-in support for NPC languages after searching high and low, I had actually gone so far as to start putting together a full-on Perl-based speech scrambling system checking language skill and scrambling the text word by word based on (skill / 100) times word complexity based on each letter's frequency of use in English, ord() numeric hashes by each character for consistency instead of randomness, supporting different vocal sounds for different languages so each language would have its own distinct gibberish sound, etc. It was feeling pretty impressive!

Then I realized that if the NPC simply does a quest::say('Blah blah'), other players nearby who DO speak the language will get the scrambled message as well, even though it was only the player interacting with the NPC who didn't know the language (and vice-versa, those without the language could perfectly hear what the NPC said as long as someone else was talking to them).

So, I figured I'd use Client->Message, so that only the speaker got the language-based speech, but then everyone else around is going to be hearing a one-sided conversation, as though hearing someone talk on their cell phone. "Hail, NPC!" "What tasks?" "What Sword of Ultimate Power?"

So I thought maybe I could have the NPC check for all nearby players and do a skill check on each of them, sending a customized scrambled message to each one individually, but at that point I threw my hands up in the air and gave it up as a poor solution.

Even if I could manage to put it together somehow with the EntityList and Client classes and such, I'd basically be graduating from "a lot of work" to "completely reinventing the wheel on the Emu server's /say code" in order to do it, and it would probably take way too much server CPU power when you ended up with several dozen players interacting with NPCs, and just being near NPCs while others are interacting with them.

So, I came back to the forums hoping that either:

1) The functionality is already there, it's just not often used, so it isn't in the regular helpful tutorials and posts scattered around.

2) It's not there, but it shouldn't be too difficult to implement, and a Dev might be willing to look into it (related: is there any way to bribe a dev?).

But perhaps it would most likely end up being a third option.

3) Devs have their own tasks to work on. If you want the functionality added to the emulator then figure out SVN, check stuff out, and dig into the source code yourself to see what you can come up with.

The list ends up being in ascending order of how long it would likely end up taking to be able to get it working. LOL.

- Shendare

jellyini
05-07-2009, 10:41 AM
As I recall the frequency of the one-sided conversation was pretty high on live. i remember standing there wondering just what the heck was going on, and checked my chat log to see this or wingnut talking to themselves (like using /s when you mean to use/g or/t) or what. Sounds like your simplest bet.

J

Shendare
05-07-2009, 11:03 AM
Perhaps, but for the sake of real Norrathian flavour, I'll probably end up going with #3 if #2 doesn't work out.

If I get a definitive "There is no current way to do that" answer, I'll try posting in the Feature Request forum and see what response I receive.

Thanks for the input!

- Shendare

Dibalamin
05-07-2009, 11:03 AM
hehe, just add this

quest::emote("whispers softly to $name.);

and then on the next one put something like

quest::emote("motions for $name to lower his voice and resumes whispering.");

and then lastly

quest::emote("rolls her eys in disgust and whispers gruffly.");

AR PEE and problem solved, win win! That way they look less silly and it still fits.

realityincarnate
05-07-2009, 11:14 AM
If no one beats me to it, I'll take a look at this and try to get some functions in over the next day or two. It'll just depend on how much work interferes with life.

Shendare
05-07-2009, 11:29 AM
@Dibalamin ... :P

@realityincarnate...

That's awesome! You mean you're a coder looking into adding something like a quest::sayLang() and a $lang export indicating the languageid being spoken by the player?

- Shendare

realityincarnate
05-09-2009, 01:29 AM
I finally got a chance to work on the language stuff a bit. Here's what I've got at the moment, tell me if it seems like what you need:

quest::say() is modified to take an optional second parameter that determines the language spoken. So quest::say("I'm speaking elvish", 3) would indeed be said in elvish. The only downsides are that anything with a language given (even if it's a zero for common) uses the regular say channel, so it won't trigger quest journalling and it is subject to client filters.

The events SAY, AGGRO_SAY, and PROXIMITY_SAY all export a variable $langid that holds the number of the language spoken by the player.

The players language skill is accessable (and always has been) through the $client->GetLanguageSkill() function.

I'd like to do some more testing before I commit, but if everything works well and this is what you're looking for, I'll add it in tomorrow.

Shendare
05-09-2009, 01:45 AM
That's phenomenal! The hard work is so much appreciated!

So nearby players who don't speak the language will get a regular garbled "Soandso says in an unknown tongue, 'Abweioa ford julkani spevna.'", while those who do will see the original intended message?

- Shendare

realityincarnate
05-09-2009, 02:29 PM
That's correct, it will appear garbled based on the player's skill, just as if another player had spoken it.

The functions are now in the SVN source as of revision 488.

Shendare
05-10-2009, 12:44 AM
Bug Report: $langid always returns 0. We know it's exporting, at least, because it's returning 0 and not undef.

The speaking part is working flawlessly, however!

realityincarnate
05-10-2009, 08:29 AM
Could you give me an example of how you're using $langid? It seems to work fine for me, but my only tests have been simple things like

quest::say("Your language id is $langid");

and

if($langid == 3) {

type things.

Shendare
05-10-2009, 01:04 PM
I'm really sorry. It was just as I was drifting to sleep last night that I realized, "Bonehead! I didn't give him anything to go on beyond 'It's not working'!"

At any rate, this is my little test .pl file:

felwithea/Exterminator_Valern.pl

# Exterminator Valern, felwithea

sub EVENT_SAY
{
my $langName = (
!defined($langid) ? 'undefined' :
($langid < 0) ? 'undefined' :
($langid > 26) ? 'undefined' :
('Common Tongue', 'Barbarian' , 'Erudian' , 'Elvish' , 'Dark Elvish' , 'Dwarvish' , 'Troll' , 'Ogre' , 'Gnomish', # 00 - 08
'Halfling' , 'Thieves Cant', 'Old Erudian', 'Elder Elvish', 'Froglok' , 'Goblin' , 'Gnoll' , 'Combine Tongue', 'Elder Teir`dal', # 09 - 17
'Lizardman' , 'Orcish' , 'Faerie' , 'Dragon' , 'Elder Dragon', 'Dark Speech', 'Vah Shir', 'Unknown1' , 'Unknown2')[$langid]); # 18 - 26

quest::say("Hail, $name! You're speaking $langName ( $langid )!", 3);
}


And this is what I get:


Current Language is Elvish. (2)
You say, 'Hail, Exterminator Valern'
Exterminator Valern says, in Elvish, 'Hail, Palren! You're speaking Common Tongue ( 0 )!'
Current Language is Elder Elvish. (4)
You say, 'Hail, Exterminator Valern'
Exterminator Valern says, in Elvish, 'Hail, Palren! You're speaking Common Tongue ( 0 )!'
Current Language is Common Tongue. (1)
You say, 'Hail, Exterminator Valern'
Exterminator Valern says, in Elvish, 'Hail, Palren! You're speaking Common Tongue ( 0 )!'


I tried with both the SoF and Titanium client, in case it was an SoF packet thing. Sorry again for the lack of information earlier!

I can try downloading and compiling the most recent rev and trying again. I believe it was Rev488 that I compiled for this run.

- Shendare

Shendare
05-10-2009, 01:38 PM
Strangely, with Rev492 $langid is now returning 3.


Welcome to EverQuest!
You have entered Northern Felwithe.
You say, 'Hail, Exterminator Valern'
Exterminator Valern says, in Elvish, 'Hail, Palren! You're speaking Elvish ( 3 )!'
Current Language is Common Tongue. (1)
You say, 'Hail, Exterminator Valern'
Exterminator Valern says, in Elvish, 'Hail, Palren! You're speaking Elvish ( 3 )!'
Current Language is Elvish. (2)
You say, 'Hail, Exterminator Valern'
Exterminator Valern says, in Elvish, 'Hail, Palren! You're speaking Elvish ( 3 )!'
You say, '#reloadqst'
Clearing quest memory cache.
Current Language is Elder Elvish. (4)
You say, 'Hail, Exterminator Valern'
Exterminator Valern says, in Elvish, 'Hail, Palren! You're speaking Elvish ( 3 )!'


Changing the NPC's spoken language didn't change the $langid behavior, either.

realityincarnate
05-10-2009, 02:10 PM
I'm glad you included the full output like that. I don't know if I would have ever figured out what was going on without seeing the "Current Language is..." text.

So here's what I've found so far: if you change the language by right clicking on the main chat box and selecting a language, everything works fine. But if you use the /language command (which I forgot existed), it doesn't seem to actually change the language (even though it does update it in the select language box).

I'll try to figure out what's going on with /language; hopefully it'll be something simple and I'll be able to get a fix out tonight or tomorrow.

Shendare
05-10-2009, 02:25 PM
So I've been tripped up by an obscure problem with the /language command! Good catch!

I did some testing and it does appear that the /language command is not being received or processed on the server.

The client is acting as though it's working (it lists the changed value with /lang sans argument and even shows the correct language highlighted in the right-click menu), but the server never sees the change.

The server keeps acting as though you're speaking the old language, until you zone, at which time the server gets updated properly, and the NPC recognizes the new language.

realityincarnate
05-10-2009, 09:58 PM
I spent a little bit of time looking at the /language issue and, to be perfectly honest, I'm pretty confused.

The language number and skill is contained in the packet of each message sent, so that's where all the code currently grabs the language id from. For whatever reason, when you use /language it doesn't change the data that the client sends, but using the right click method does.

My first thought was that there was a "default" language value stored someplace on the server, and that /language was supposed to change that rather than updating the value sent in each packet. But the client doesn't seem to send anything different to the server when you use the command, so I don't know where it would get the information. The fact that it changes after zoning just makes it more confusing.

Anyway, with the weekend ending, I probably won't get to look at this again for a little bit, but I'd be interested to know if anyone has any idea what it's doing.

Shendare
05-10-2009, 10:16 PM
Ahh, if language changes are handled client-side, then it must be a client issue. Perhaps I'll just have to say good-bye to old /lang and start using the right-click menu. Thanks for looking into it!

trevius
05-10-2009, 10:28 PM
If language doesn't update until you zone, then it is probably because it is being added to the Player Profile, but not being handled properly by the server code before zoning. Using the /language command probably sends a packet that we aren't handling properly yet. Sounds like it should be changing a setting on the server end, but it isn't. This is just a guess, but the profile thing is most likely accurate.

realityincarnate
05-11-2009, 12:45 AM
The profile was my thought as well, but I couldn't track down how the data should be getting to the server in my (admittedly far from thorough) first attempts. The only packets I see being sent are ClientUpdate and FloatListThing. It doesn't seem to change any of the unknown values in ClientUpdate, and the floatlist is just a mess... I really hope it doesn't come to sifting through that.

Of course, I'm just using a zone modified to list and dump all incoming packets as my way of checking, so I could be missing something.

And actually, I'm not seeing the /language start working after zoning (using Titanium), now that I paid attention to it. Mine still sticks with whatever value was set by the right-click menu.

Shendare
05-11-2009, 01:32 AM
Oops, I must have goofed when I typed 'zoning' before. It updates after camping and logging back in, but not after zoning. Sorry!

As a reminder, another thing that may complicate tracking down the problem or detecting the packets is that the /lang command's language list doesn't number the languages by their langid, it renumbers the languages to keep them consecutive starting with 1 for the first language available to you, 2 for the second, 3 for the third, etc. It was meant to simplify things before the right-click menu was available.

realityincarnate
05-11-2009, 12:43 PM
I found a spot in the character .ini files where it stores the language setting for each window, and this seems to correspond to the /lang command values. It also explains why they switch after camping but not zoning.

Does anybody have a Live account that could check and see if /language actually works properly there? I'd hate to spend any more time just to eventually find out that it's a deprecated command that SOE left in. (I do remember it being a huge help back in the days when you otherwise had to just keep clicking until the language you wanted showed up)

BWStripes
05-15-2009, 06:56 AM
Just wanted to post that I noticed an NPC on live the other day speaking an unknown (to Drakkin) language. Turned out it was Dwarven.

BWStripes
05-16-2009, 09:35 AM
Oh, /language works - tested today

realityincarnate
05-16-2009, 10:13 PM
Ok, I feel really stupid that I didn't figure this out right away, but I think know the deal with /language now. Basically, it changes the language of anything coming out of the chat box but doesn't change the language of the hail command. I got these results a few minutes ago:

Current language is Erudian. (2)
You say, 'Hail, Ghul Rustem'
Ghul Rustem says, in Elvish, 'Hail, Candor! You're speaking Common Tongue (0)!'
You say, 'This time I type hail'
Ghul Rustem says, in Elvish, 'Hail, Candor! You're speaking Erudian (2)!'


There is a byte in the packet that tells if the message is from a hail command or not, but I can't think of anything particularly useful to do with that off the top of my head.

Oh, and thanks for checking, BWStripes.

Shendare
05-17-2009, 12:59 AM
Huh, so either the language code doesn't get transmitted properly with a hail, or things are somehow organized slightly differently for a hail.

Is it a completely different OpCode and struct for a hail as opposed to a regular /say message?