The updated dialogue text timing script:

Normally I wouldn’t show something like this; but just for shits and giggles:

if (global.dialogue_selection == “old”)
{
   if (count == 0 && num_steps != 2) {num_steps = 2; text_length[1] = 12;
       text_length[2] = string_length(global.st0_dialogue_text[count]); byte_limit[1] = 180000; byte_limit[2] = 280000;
       byte_limit[3] = sinBassStreamGetLengthBytes(global.music); byte_limit[4] = 0; text_speed[1] = 3; text_speed[2] = 2;}
   else if (count == 1 && num_steps != 5) {num_steps = 5; text_length[1] = 55; text_length[2] = 76; text_length[3] = 83;
            text_length[4] = 102; text_length[5] = string_length(global.st0_dialogue_text[count]); byte_limit[1] = 750000;
            byte_limit[2] = 820000; byte_limit[3] = 1120000; byte_limit[4] = 1320000; byte_limit[5] = 1600000;
            byte_limit[6] = sinBassStreamGetLengthBytes(global.music); byte_limit[7] = 0; text_speed[1] = 3; text_speed[2] = 3;
            text_speed[3] = 3; text_speed[4] = 3; text_speed[5] = 3; text_step = 1;}
   else if (count == 2 && num_steps != 3) {num_steps = 3; text_length[1] = 10; text_length[2] = 32;
            text_length[3] = string_length(global.st0_dialogue_text[count]); byte_limit[1] = 100000; byte_limit[2] = 200000;
            byte_limit[3] = 600000; byte_limit[4] = sinBassStreamGetLengthBytes(global.music); byte_limit[5] = 0;
            text_speed[1] = 2; text_speed[2] = 4; text_speed[3] = 2; text_step = 1;}       
   else if (count == 3 && num_steps != 1) {num_steps = 1; text_length[1] = string_length(global.st0_dialogue_text[count]);
            byte_limit[1] = sinBassStreamGetLengthBytes(global.music); byte_limit[2] = 0; text_speed[1] = 3; text_step = 1;}                           
   //EC: stream length entered manually due to sinbass having an issue getting correct value
   else if (count == 4 && num_steps != 2) {num_steps = 2; text_length[1] = 37;
            text_length[2] = string_length(global.st0_dialogue_text[count]); byte_limit[1] = 450000; byte_limit[2] = 550000;
            byte_limit[3] = 1234688; byte_limit[4] = 0; text_speed[1] = 3; text_speed[2] = 4;
            text_step = 1;}                 
   else if (count == 5 && num_steps != 4) {num_steps = 4; text_length[1] = 14; text_length[2] = 50; text_length[3] = 69;
            text_length[4] = string_length(global.st0_dialogue_text[count]); byte_limit[1] = 235000; byte_limit[2] = 350000;
            byte_limit[3] = 850000; byte_limit[4] = 1100000; byte_limit[5] = 1294592;
            byte_limit[6] = 0; text_speed[1] = 4; text_speed[2] = 3; text_speed[3] = 2; text_speed[4] = 3; text_step = 1;}           
}   
else if (global.dialogue_selection == “jap”)
{
   if (count == 0 && num_steps != 2) {num_steps = 2; text_length[1] = 10;
       text_length[2] = string_length(global.st0_dialogue_text[count]); byte_limit[1] = 50000; byte_limit[2] = 115000;
       byte_limit[3] = sinBassStreamGetLengthBytes(global.music); byte_limit[4] = 0; text_speed[1] = 1; text_speed[2] = 2;}
   else if (count == 1 && num_steps != 4) {num_steps = 4; text_length[1] = 9; text_length[2] = 59; text_length[3] = 119;
            text_length[4] = string_length(global.st0_dialogue_text[count]); byte_limit[1] = 80000;
            byte_limit[2] = 120000; byte_limit[3] = 440000; byte_limit[4] = 810000;  
            byte_limit[5] = sinBassStreamGetLengthBytes(global.music); byte_limit[6] = 0; text_speed[1] = 4; text_speed[2] = 2;
            text_speed[3] = 2; text_speed[4] = 2; text_step = 1;}
   else if (count == 2 && num_steps != 5) {num_steps = 5; text_length[1] = 29; text_length[2] = 73; text_length[3] = 90;
            text_length[4] = 105; text_length[5] = string_length(global.st0_dialogue_text[count]); byte_limit[1] = 210000;
            byte_limit[2] = 280000; byte_limit[3] = 520000; byte_limit[4] = 630000; byte_limit[5] = 715000;
            byte_limit[6] = sinBassStreamGetLengthBytes(global.music); byte_limit[7] = 0; text_speed[1] = 3; text_speed[2] = 2;
            text_speed[3] = 1; text_speed[4] = 1; text_speed[5] = 2; text_step = 1;}       
   else if (count == 3 && num_steps != 3) {num_steps = 3; text_length[1] = 4; text_length[2] = 80;
            text_length[3] = string_length(global.st0_dialogue_text[count]); byte_limit[1] = 70000; byte_limit[2] = 145000;
            byte_limit[3] = 590000; byte_limit[4] = sinBassStreamGetLengthBytes(global.music); byte_limit[5] = 0;
            text_speed[1] = 5; text_speed[2] = 2; text_speed[3] = 4; text_step = 1;}    
   else if (count == 4 && num_steps != 4) {num_steps = 4; text_length[1] = 39; text_length[2] = 47; text_length[3] = 69;
            text_length[4] = string_length(global.st0_dialogue_text[count]); byte_limit[1] = 230000;
            byte_limit[2] = 285000; byte_limit[3] = 410000; byte_limit[4] = 620000;  
            byte_limit[5] = sinBassStreamGetLengthBytes(global.music); byte_limit[6] = 0; text_speed[1] = 3; text_speed[2] = 3;
            text_speed[3] = 3; text_speed[4] = 1; text_step = 1;}                       
   else if (count == 5 && num_steps != 3) {num_steps = 3; text_length[1] = 13; text_length[2] = 44;
            text_length[3] = string_length(global.st0_dialogue_text[count]); byte_limit[1] = 80000; byte_limit[2] = 200000;
            byte_limit[3] = 450000; byte_limit[4] = sinBassStreamGetLengthBytes(global.music); byte_limit[5] = 0;
            text_speed[1] = 2; text_speed[2] = 3; text_speed[3] = 2; text_step = 1;}          
}   
else
{
   if (count == 0 && num_steps != 3) {num_steps = 3; text_length[1] = 8; text_length[2] = 38;
       text_length[3] = string_length(global.st0_dialogue_text[count]); byte_limit[1] = 50000; byte_limit[2] = 80000;
       byte_limit[3] = 250000; byte_limit[4] = sinBassStreamGetLengthBytes(global.music); byte_limit[5] = 0;
       text_speed[1] = 4; text_speed[2] = 2; text_speed[3] = 2;}
   else if (count == 1 && text_length[1] != 3) {num_steps = 3; text_length[1] = 3; text_length[2] = 30;
            text_length[3] = string_length(global.st0_dialogue_text[count]); byte_limit[1] = 40000;
            byte_limit[2] = 80000; byte_limit[3] = 360000; byte_limit[4] = sinBassStreamGetLengthBytes(global.music);
            byte_limit[5] = 0; text_speed[1] = 4; text_speed[2] = 4; text_speed[3] = 4; text_step = 1;}
   else if (count == 2 && text_length[1] != 9) {num_steps = 3; text_length[1] = 9; text_length[2] = 25
            text_length[3] = string_length(global.st0_dialogue_text[count]); byte_limit[1] = 60000; byte_limit[2] = 90000;
            byte_limit[3] = 195000; byte_limit[4] = sinBassStreamGetLengthBytes(global.music); byte_limit[5] = 0;
            text_speed[1] = 2; text_speed[2] = 3; text_speed[3] = 3; text_step = 1;}            
   else if (count == 3 && num_steps != 2) {num_steps = 2; text_length[1] = 50;
       text_length[2] = string_length(global.st0_dialogue_text[count]); byte_limit[1] = 330000; byte_limit[2] = 380000;
       byte_limit[3] = sinBassStreamGetLengthBytes(global.music); byte_limit[4] = 0; text_speed[1] = 3; text_speed[2] = 3;
       text_step = 1;}
  else if (count == 4 && num_steps != 3) {num_steps = 3; text_length[1] = 24; text_length[2] = 50;
            text_length[3] = string_length(global.st0_dialogue_text[count]); byte_limit[1] = 120000; byte_limit[2] = 150000;
            byte_limit[3] = 305000; byte_limit[4] = sinBassStreamGetLengthBytes(global.music); byte_limit[5] = 0;
            text_speed[1] = 2; text_speed[2] = 2; text_speed[3] = 2; text_step = 1;}    
  else if (count == 5 && num_steps != 5) {num_steps = 5; text_length[1] = 3; text_length[2] = 14; text_length[3] = 44;
           text_length[4] = 65; text_length[5] = string_length(global.st0_dialogue_text[count]); byte_limit[1] = 20000;
           byte_limit[2] = 80000; byte_limit[3] = 240000; byte_limit[4] = 510000; byte_limit[5] = 650000;
           byte_limit[6] = sinBassStreamGetLengthBytes(global.music); byte_limit[7] = 0; text_speed[1] = 3; text_speed[2] = 5;
           text_speed[3] = 3; text_speed[4] = 3; text_speed[5] = 3; text_step = 1;}            
}            
 
That terrifying mess of code….. which probably made some of you folks eyeballs boil in your skull, is what is used to time the dialogue with the text (AND NO…. in game it is not so sloppily aligned; wordpress’ formatting is the cause of that)

Although it truly does look frightening, believe it or not it is actually VERY simple to use:

  • Count: how many separate sounds clips of dialogue we have for this conversation.
  • Num_steps: how many times in this bit of dialogue we will be changing the speed of the text, or having a pause in it. Consider each one of these as a group of text. So if num_steps = 2, this means we break the text into 2 sets; the first might be a slow one; the 2nd one might be quicker and start after a pause between the two of them.
  • Text_length: there is one of these for each num_step. So if there are 2 num_steps, we have text_length[1] and text_length[2]. These hold the amount of text for each of these groups of text. The last text_length always makes sure that ALL text is written when the sound dialogue clip is over (useful in cases where the user has a low end systems and might experience slow down in game, yet the audio is still going at 100%).
  • Byte_limit: we always have 2 more of these than we have num_steps; UNLESS we have 1 num_step; then we have 2 byte_limits. These basically indicate in BYTES at what point in the dialogue to start each group of text (see pic below for where I get this value from). The last one always has a value of 0; the one before the last always takes into account the full length in bytes of the dialogue sound clip.
  • Text_speed: how fast each group of text types; we have one for each step.
  • Text_step: this is used by the FUNCTION for the dialogue text; basically when text_steps is > num_steps, we know this bit of dialogue is done!

This isn’t even showing the 4 objects used for dialogue, or the main function used to run all of this. There is good news though: using this format, I can quickly set up the text to sync with the dialogue regardless of what language it is, how long the text is, or any other little factors. It can be used over, and over again.

Why am I putting this up you ask? To show some of you EXACTLY what I had to go thru just to enable multi-language support and make sure that the text still synced. This is the hell I had to go thru for something that many of you (the fans) requested, and to keep the level of quality in this engine, HIGH!

……………. I better see mad presents under my tree this year for this one peoples!

This entry was posted in General. Bookmark the permalink.

5 Responses to The updated dialogue text timing script:

  1. Obamasplifs Jr. says:

    Nice to see some of your work, we appriciate your passion.

  2. Oliver says:

    Just looking at the code give me headache lol!

    I would indeed try to put the original voice acting when all the dialogue would be complete….But I dont think it is a high prioritie right now.

    Anyway I hope the development’s going well and that the next update will be full of surprise 🙂

  3. Gemini says:

    That sure is a ton of code just for one task! Good luck with the engine, it’s coming out really nice and all.

    RESPONSE: Thanks bro, and yeah it really is, although the function itself to run that bunch of code is pretty small! But then again you’ve seen the original code for SOTN’s dialogue, so you know what a mess it was too.

  4. Cool indentation, bro! lol, WordPress fucked the code

  5. Lordvanya says:

    Wow. That looks like it was indeed a hellish thing to cobble together. Great job, though.

    RESPONSE: Thanks bro! I actually figured out who you were right after I sent that last comment. You have used that SN before.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s