• New Horizons on Maelstrom
    Maelstrom New Horizons


    Visit our website www.piratehorizons.com to quickly find download links for the newest versions of our New Horizons mods Beyond New Horizons and Maelstrom New Horizons!

Need Help Make citizens use differents voices depending nations

Benouyt

HoO Team Member
Provisional
Hello,

I get some fun to mod sound in TEHO since few times, i understood many stuff how it work and already replaced every merchants, barmen, etc... voices by modding PROGRAM files and .ini.

But there is something i would like to do: I would like to get citizen speak differents languages following nations. I tried many many stuff, helped by some old mod files of potc but i cant seems to get it work.

I know i need to change "chr.greeting" and "npchar.greeting" of citizens in lAI_utilities and i tried many formules to do it but i cant get it to work.
I have already set everything in .ini file (eng_male_citizens, fra_male_citizen, etc...) but i just need to know the good formules to put in the PROGRAM files then.

If someone could help me that would be great !

Thanks.
 
If TEHO is structured the same as CT/COAS, the following should work:
Code:
switch (npchar.nation)
{
    case "England":
        npchar.greeting = "name-of-English-sound-file";
        break;
    case "France":
        npchar.greeting = "name-of-French-sound-file";
        break;
}

You can add the rest of the nations from here. Note that you don't need the extension of the file, just the filename.

Also note that "char" is not a global variable, and won't work where "char" is not set to be "npchar" or "pchar". Best to use "npchar" (for NPC) and "pchar" (for player character) in your script to be safe.
 
Last edited:
Yes i tried that, but seemingly town citizen use "chr.greeting" and not "npchar.greeting" so when i put formules with npchar.greeting it just crash on "chr.greeting". And if i replace npchar with "chr" in formules, then the sound just go mute.
 
Have a look in the function you are trying to add your code to. What is "chr" set to? (i.e. chr = ? or makeref(chr,?))

If there is no "chr" defined, don't use "chr" in your script, as an undeclared variable will stop the compiler from running (i.e. "crash" the game).
 
Can you paste me your code (or the whole function your code resides in)?
 
Here is some of the lines

Code:
            for(i=0; i<iCitizQty; i++)//ìåùàíå-áþðãåðû + ïîñåòèòåëè öåðêâè
            {
                if (loc.type == "church") iSex = MAN;
                else iSex = rand(WOMAN);
                sType = "citizen";
                iChar = NPC_GeneratePhantomCharacter("citizen", iNation, iSex, 2);
                chr = &characters[iChar];
                SetNPCModelUniq(chr, sType, iSex);
                chr.City = Colonies[iColony].id;
                chr.CityType = "citizen";
                LAi_SetLoginTime(chr, 6.0, 21.99);
                if (loc.type == "church" && chr.sex == "man")
                {
                    LAi_SetSitType(chr);
                    PlaceCharacter(chr, "sit", "random_free");
                    chr.dialog.filename = "Enc_Walker.c";
                    chr.greeting = "citizen_male";
                    chr.nonTable = true;
                }
                else
                {
                    LAi_SetCitizenType(chr);
                    PlaceCharacter(chr, "goto", "random_free");
                }
                if (sti(Colonies[iColony].HeroOwn) == true) LAi_group_MoveCharacter(chr, LAI_GROUP_PLAYER_OWN);
                else LAi_group_MoveCharacter(chr, slai_group);
                chr.dialog.currentnode = "first time";
                if(chr.sex == "man")
                {
                    chr.dialog.filename = "Population\Townman.c";
                    chr.greeting = "citizen_male";
                    
                    if (rand(6) > 4 && !CheckAttribute(pchar, "questTemp.Sharlie.Lock") && loc.type != "church" && chr.City != "Panama") //ïàññàæèðñêèé ãåíåðàòîð patch-5
                    {
                        chr.quest.passenger = "true";
                        chr.talker = rand(3);
                    }
                }
                else
                {
                    chr.dialog.filename = "Population\Towngirl.c";
                    chr.greeting = "citizen_female";


This is some of things i need to change, those "chr.greetings" lines. :eek:
 
Okay, so this code makes it fairly simple for you to implement your changes.
Code:
chr = &characters[iChar];

This line sets "chr" to represent the NPC character that is just being created in the world by this function. If you use "chr" throughout the switch statement, like this...
Code:
switch (chr.nation)
{
   case "England":
       chr.greeting = "name-of-English-sound-file";
       break;
   case "France":
       chr.greeting = "name-of-French-sound-file";
       break;
}

...and place this code inside the "if" statements, where the "chr.greeting" lines are, you should have no problem getting it to work. If you still get no sound, this could be for two possible reasons:

1. The file name you gave to "chr.greeting" is wrong, or the file is not located in "RESOURCE/Sounds/Voice/[yourlanguage]".

2. "chr.nation" doesn't exist in TEHO, in which case you may want to try substituting "switch (chr.nation)" with "switch (iNation)" and the switch "cases" with numbers (0, 1, 2), and see if that makes it work:
Code:
case 1:

You'll just have to figure out which number corresponds to which nation, then.
 
Last edited:
Thanks you very much for your help, actually , im extremly bad. There was a little error in the files namings, that was the sounds wasnt played !!! But its when trying your second solutions that i discovered it, as english voices worked...

Then, it work, and thank you ! I have a last question: does there is a difference in game with using your first or second code solutions ? as the both work i was wondering what would be the difference.
 
I got one little problem who make runtime error:

Code:
if (chr.quest.last_theme == 0)
                    chr.greeting = "habitue";
                    else chr.greeting = "player"; 
}

i have this, and when i change it to
Code:
if (chr.quest.last_theme == 0)
                    switch(sti(chr.nation)) { case ENGLAND: chr.greeting = "eng_habitue"; break; case FRANCE: chr.greeting = "fra_habitue"; break; case SPAIN: chr.greeting = "spa_habitue"; break; case HOLLAND: chr.greeting = "hol_habitue"; break; case PIRATE: chr.greeting = "habitue"; break; }
                    else switch(sti(chr.nation)) { case ENGLAND: chr.greeting = "eng_gambler"; break; case FRANCE: chr.greeting = "fra_gambler"; break; case SPAIN: chr.greeting = "spa_gambler"; break; case HOLLAND: chr.greeting = "hol_gambler"; break; case PIRATE: chr.greeting = "player"; break; }
}

Any idea ? i got the same problem with "chr.greeting = "item_male" and "item_female".
 
Ah. In your first example you have an unmatched } at the end. If you removed that the code should work. Or the way you did it with braces around all conditions also works and makes it easier if you have to add lines to each condition.

I prefer the following indentation:

Code:
if (condition)
    statement;
else
    statement;

Hook
 
Thanks you very much for your help, actually , im extremly bad. There was a little error in the files namings, that was the sounds wasnt played !!! But its when trying your second solutions that i discovered it, as english voices worked...

That's why it always pays to triple-check. Human coding/programming mistakes are the most likely cause of game/software bugs. You're not bad; you're courageous. You're learning. ;) And you're welcome. :)

Then, it work, and thank you ! I have a last question: does there is a difference in game with using your first or second code solutions ? as the both work i was wondering what would be the difference.

The only difference would be that one is easier to use than the other. Both end up doing exactly the same thing.

One last thing I would advise is to break your switch statement into multiple, nested lines, like I've done above. This makes it easier for you or anyone else to read the code, and that is very important when it comes to finding the cause of bugs. It's important programmer's practice to visually format your code properly.

And yes, there cannot be an "else" without an "if" (and they need to be paired on an equal level), as you've found out yourself. :yes :doff
 
Last edited:
Thank you again ! its so much time i want to do this, i tought it would be impossible ! now im gonna try how it work '=(i replaced almost all ".greetings =" and dont got bug or crash yet !) If it work fine on long term i will maybe release that mod :)
 
Thank you again ! its so much time i want to do this, i tought it would be impossible ! now im gonna try how it work '=(i replaced almost all ".greetings =" and dont got bug or crash yet !) If it work fine on long term i will maybe release that mod :)
Just remember that anyone who is an expert was once a beginner. I have to remind myself of this on a regular basis.
 
Back
Top