Author Topic: .LTR File Format  (Read 2759 times)

Legacy_B_Harrison

  • Sr. Member
  • ****
  • Posts: 301
  • Karma: +0/-0
.LTR File Format
« Reply #15 on: September 08, 2010, 05:02:51 pm »


               Thanks guys.

I can at least confirm that the files are used by the game, because swapping around the files (by renaming them) changes the names generated for a race, and using an empty text file with the .ltr extension prevents names being generated for that race/gender/field.
               
               

               
            

Legacy_rafhot

  • Jr. Member
  • **
  • Posts: 58
  • Karma: +0/-0
.LTR File Format
« Reply #16 on: September 10, 2010, 05:57:23 am »


               hi Ben, im in need to remove the default names for my project too, i will help to discover how things work too
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
.LTR File Format
« Reply #17 on: October 21, 2010, 06:30:49 pm »


                  HEADER
    VALUE           SIZE/TYPE        DISCRIPTION 
   File Type            4 bytes            'LTR '      
   Version              4 bytes             currently 'V1.0'       
  NumOfLetters    1 byte               either 26(alpha only) or 28(alpha +( ' and -))
  

The entire rest of the file is made up of letter probability arrays. Each letter probability array is made up of a number of floats equal to the number of available letters given  in the header. Each float is 32 bits(4 bytes) long. in this post I am going to treat this Letter Porbability Array as a data type that I will call LPA. Each LPA will have a length of 4 bytes times the number of possiable letters. Most of the LTR files in the nwn BIF's use 28 this will make each LPA 112 bytes long.  Since the length can vary I am going to use LPA.Length in the equations for where each array is located. 

The floats in the LPA are all in the range of 0.0 to 1.0.  They are in incremental values for the chance of the letter repersented by the position in the array to occur. unfortunatly what the positions in the array represent is hard coded. The first 26 posistions of the array LPA
  • through LPA [25] repersent the Alpha letters (a - z), LPA[26] is the accent mark (') and LPA[27] is the hyphen (-).  basicly what the engine does with the LPA is roll a random number between 0 and 1, then cycles through the LPA untill it finds a Float that is bigger then the random number, Returning the postion in the array that has the first value larger then the random number generated.  Later it changes the position number int the ASCII code for what the position represents.

    The LTR file is made up of 3 arrays of LPA's. Each array has one more dimension then the one before it. 

    The first array is a single dinension  array starting at  LTR + 9  (Address posistion 9 in the zerro based addressed  LTR file ). If our array is defined as   

    LPA [] FirstArray =  new LPA[3];  

    then   FirstArray would be the inilized to the LPA at  (LTR+9) + (LPA.Length * i) 



    **Getting late  will continue later.   

     

               
               

               


                     Modifié par Lightfoot8, 28 octobre 2010 - 05:21 .