+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 20

Thread: Tibia.dat Reader + .dat/.spr Structure and.spr reading code link

  1. #1

    Tibia.dat Reader + .dat/.spr Structure and.spr reading code link

    1) Tibia.dat Structure
    The first 4 bytes contains information for the dat version, I think this is used to see which structure to use (7.7+ or 7.6-). The next 2 bytes are item count, the next 2 bytes are outfit count, the next 2 bytes are effect count, and the next 2 bytes are distance count. The next byte starts the flags information for the first item (ID = 100), these flags are indicated by a value between &H0 and &H1F:
    • &H0 = ground tile
    • &H1 = on top
    • &H2 = walk through (doors etc.)
    • &H3 = walk through (arches etc.)
    • &H4 = container
    • &H5 = stackable
    • &H6 = ladder?
    • &H7 = usable
    • &H8 = rune
    • &H9 = writeable
    • &HA = readable
    • &HB = fluid container
    • &HC = splash
    • &HD = blocking
    • &HE = immoveable
    • &HF = blocks missile
    • &H10 = blocks monster movement
    • &H11 = equipable
    • &H12 = hangable (wall item)
    • &H13 = horizontal (wall item)
    • &H14 = vertical (wall item)
    • &H15 = rotateable
    • &H16 = light info
    • &H17 = unknown?
    • &H18 = floor change down?
    • &H19 = draw offset
    • &H1A = height
    • &H1B = draw with height offset for all parts (2x2) of the sprite,
    • &H1C = offset life-bar (for larger monsters)
    • &H1D = minimap color
    • &H1E = floor change?
    • &H1F = unknown?
    Certain flags are followed by a value, as shown below:
    • &H0 = ground tile is followed by a 2 byte value indicating the speed
    • &H9 = writeable is followed by a 2 byte value indicating the max text length
    • &HA = readable is followed by a 2 byte value indicating the max text length
    • &H16 = light info is followed by a 2 byte value indicating the light level then another 2 byte value indicating the light color
    • &H19 = draw offset is followed bye a 2 byte value indicating the x offset then another 2 byte value indicating the y offset
    • &H1A = height is followed by a 2 byte value indicating the draw height(?)
    • &H1D = minimap color is followed by a 2 byte value indicating the minimap color
    • &H1E = floor change? is followed by a 1 byte value indicating one of these values (86 - openable holes, 77 - can be used to go down, 76 - can be used to go up, 82 - stairs up, 79 - switch) then another 1 byte value that always returns 4
    The end of the flag values are indicated by a &HFF byte, then starts the objects information. The next byte is width, the next is height, if the width or height is greater than 1 you have to skip the next byte then the byte after it is blend frames if not then you don't skip the next byte because it is blend frames (i hope that made sense lol), the next is divx, the next is divy, the next is divz, then the next is animation length. The rest of the objects information depends on the number of sprites (width * height * blend frames * divx * divy * divz * animation length). You loop the number of sprites and in each loop you read 2 bytes to get a sprite ID for that object (the ID of the image the object uses in the .spr file). Then you go to the next object (101) and repeat the process.

    Here's a basic byte list including the header information and the information for the first object (100). [x] = byte count:
    Code :
    [4] - dat version
    [2] - item count
    [2] - outfit count
    [2] - effect count
    [2] - distance count
    [1] - ground tile
    [2] - speed = 0
    [1] - blocking
    [1] - immoveable
    [1] - blocks missiles
    [1] - light info
    [2] - light level = 3
    [2] - light color = 156
    [1] - width = 1
    [1] - height = 1
    [1] - blendframes = 1
    [1] - divx = 4
    [1] - divy = 4
    [1] - divz = 1
    [1] - animation length = 1
    [2] - sprite ID = 136
    [2] - sprite ID = 137
    [2] - sprite ID = 138
    [2] - sprite ID = 139
    [2] - sprite ID = 140
    [2] - sprite ID = 141
    [2] - sprite ID = 142
    [2] - sprite ID = 143
    [2] - sprite ID = 144
    [2] - sprite ID = 145
    [2] - sprite ID = 146
    [2] - sprite ID = 147
    [2] - sprite ID = 148
    [2] - sprite ID = 149
    [2] - sprite ID = 150
    [2] - sprite ID = 151


    2) .dat Reader

    After studying the .dat structure I was able to make a small, but working program to read the Tibia.dat file and allow you to get information for each object. The program is written in VB.Net and the sources are included.

    When you first start the program it will ask you to locate and open your Tibia.dat file. Once this is finished the program will load and the items, outfits, effects, and distance fields will be filled. In the above screenshot I've loaded the 8.40 .dat file. The current structure will work back to version 7.7x I believe. If you want to check the information of an object, place it's ID (ie. gold's ID is 3031) in the Client ID field and click 'Go'. The IDs start at 100, there are 9104 items so the max item ID is 9204, outfits are from 9205-9530, effects are from 9531-9597, and distances are from 9599-9640. If you put a value lower than 100 or higher than 9640 the program will crash because I didn't add any type of error handling. Everything should be self explanatory, equipable is also pickupable, the sprites dropdown box contains IDs of the sprites that the object uses from the .spr file.

    If you have any questions please feel free to ask.

    Download - http://jo3.knoxstudio.net/sources/dat reader.rar


    3) Tibia.spr Structure + link to code
    The first 4 bytes contain information for the sprite version(?), like in the .dat file I'm not sure what this information is used for, maybe so the client can make sure you're using the right sprite file(?). The next 2 bytes are the number of sprites in the file. Then starts each sprites information.

    Each sprite is offset by 4 and the sprites start 6 bytes from the beginning of the file, because of the sprite version and number of sprites. Also, the first sprite has an ID of 2 so you have to subtract 1 from each sprite ID to get to its offset. The equation used for this is (6 + (spriteID - 1) * 4). Now that we know this let's get back to the sprite information.

    From what I understand the first 3 bytes of each sprite is unnecessary when getting the sprite's pixel information, so just skip the first 3 bytes. The next 2 bytes are the size of the sprite, ie. if this returned 36 then the sprite would be 6x6 pixels. The next 2 bytes are the amount of transparent pixels until a colored pixel. Then the next 2 bytes are the amount of colored pixels until a transparent pixel. The next 3 bytes are the RGB value of the colored pixels and the amount depends on how many colored pixels were found. (ie. If 1 colored pixel was found then there would just be 3 bytes [r][g][b], if there were 2 colored pixels found then there would be 2 sets of 3 bytes [r][g][b][r][g][b].) The transparent/colored pixel information is read from left to right (starts at the top-left of the sprite and ends at the bottom-right).

    Here's the structure of the first sprite including the header information (spr version and number of sprites). [x] = number of bytes:
    Code :
    [4] - spr version = 1228754556
    [2] - number of sprites = 28729
    [3] - ?
    [2] - sprite size = 512
    [2] - transparent pixels = 397
    [2] - colored pixels = 4
    [3] - RGB value = [0][0][0]
    [3] - RGB value = [0][0][0]
    [3] - RGB value = [0][0][0]
    [3] - RGB value = [0][0][0]
    [2] - transparent pixels = 27
    [2] - colored pixels = 5
    [3] - RGB value = [0][0][0]
    [3] - RGB value = [12][84][17]
    [3] - RGB value = [18][145][21]
    [3] - RGB value = [8][88][12]
    [3] - RGB value = [0][0][0]
    [2] - transparent pixels = 3
    [2] - colored pixels = 1
    [3] - RGB value = [0][0][0]
    [2] - transparent pixels = 22
    [2] - colored pixels = 6
    [3] - RGB value = [0][0][0]
    [3] - RGB value = [16][98][28]
    [3] - RGB value = [17][199][21]
    [3] - RGB value = [21][169][28]
    [3] - RGB value = [9][104][15]
    [3] - RGB value = [0][0][0]
    [2] - transparent pixels = 2
    [2] - colored pixels = 4
    [3] - RGB value = [0][0][0]
    [3] - RGB value = [115][180][44]
    [3] - RGB value = [0][0][0]
    [3] - RGB value = [0][0][0]
    [2] - transparent pixels = 19
    [2] - colored pixels = 8
    [3] - RGB value = [0][0][0]
    [3] - RGB value = [157][8][13]
    [3] - RGB value = [235][30][31]
    [3] - RGB value = [8][174][17]
    [3] - RGB value = [13][105][26]
    [3] - RGB value = [157][8][13]
    [3] - RGB value = [237][27][35]
    [3] - RGB value = [0][0][0]
    [2] - transparent pixels = 1
    [2] - colored pixels = 4
    [3] - RGB value = [0][0][0]
    [3] - RGB value = [4][57][8]
    [3] - RGB value = [115][180][44]
    [3] - RGB value = [0][0][0]
    [2] - transparent pixels = 19
    [2] - colored pixels = 12
    [3] - RGB value = [0][0][0]
    [3] - RGB value = [6][62][10]
    [3] - RGB value = [6][60][10]
    [3] - RGB value = [12][152][17]
    [3] - RGB value = [13][97][26]
    [3] - RGB value = [6][62][10]
    [3] - RGB value = [6][62][10]
    [3] - RGB value = [1][40][5]
    [3] - RGB value = [0][0][0]
    [3] - RGB value = [4][69][9]
    [3] - RGB value = [33][169][45]
    [3] - RGB value = [0][0][0]
    [2] - transparent pixels = 21
    [2] - colored pixels = 11
    [3] - RGB value = [0][1][0]
    [3] - RGB value = [5][61][10]
    [3] - RGB value = [13][174][18]
    [3] - RGB value = [26][189][35]
    [3] - RGB value = [12][84][25]
    [3] - RGB value = [1][40][5]
    [3] - RGB value = [8][95][13]
    [3] - RGB value = [16][169][21]
    [3] - RGB value = [0][0][0]
    [3] - RGB value = [0][0][0]
    [3] - RGB value = [0][0][0]
    [2] - transparent pixels = 20
    [2] - colored pixels = 9
    [3] - RGB value = [0][0][0]
    [3] - RGB value = [0][1][0]
    [3] - RGB value = [7][55][12]
    [3] - RGB value = [25][188][32]
    [3] - RGB value = [19][234][23]
    [3] - RGB value = [22][132][29]
    [3] - RGB value = [7][61][10]
    [3] - RGB value = [6][61][10]
    [3] - RGB value = [0][0][0]
    [2] - transparent pixels = 1
    [2] - colored pixels = 5
    [3] - RGB value = [0][0][0]
    [3] - RGB value = [119][187][45]
    [3] - RGB value = [0][0][0]
    [3] - RGB value = [0][0][0]
    [3] - RGB value = [0][0][0]
    [2] - transparent pixels = 17
    [2] - colored pixels = 8
    [3] - RGB value = [0][0][0]
    [3] - RGB value = [0][0][0]
    [3] - RGB value = [6][42][8]
    [3] - RGB value = [15][148][20]
    [3] - RGB value = [18][231][23]
    [3] - RGB value = [19][184][23]
    [3] - RGB value = [16][86][22]
    [3] - RGB value = [0][0][0]
    [2] - transparent pixels = 1
    [2] - colored pixels = 6
    [3] - RGB value = [0][0][0]
    [3] - RGB value = [0][0][0]
    [3] - RGB value = [1][35][4]
    [3] - RGB value = [5][82][9]
    [3] - RGB value = [131][205][49]
    [3] - RGB value = [0][0][0]
    [2] - transparent pixels = 17
    [2] - colored pixels = 14
    [3] - RGB value = [0][0][0]
    [3] - RGB value = [115][180][44]
    [3] - RGB value = [1][9][3]
    [3] - RGB value = [15][103][20]
    [3] - RGB value = [17][224][22]
    [3] - RGB value = [30][192][38]
    [3] - RGB value = [20][105][27]
    [3] - RGB value = [0][0][0]
    [3] - RGB value = [0][0][0]
    [3] - RGB value = [1][22][4]
    [3] - RGB value = [15][145][19]
    [3] - RGB value = [0][0][0]
    [3] - RGB value = [1][37][4]
    [3] - RGB value = [0][0][0]
    [2] - transparent pixels = 18
    [2] - colored pixels = 14
    [3] - RGB value = [0][0][0]
    [3] - RGB value = [6][85][10]
    [3] - RGB value = [0][0][0]
    [3] - RGB value = [13][104][18]
    [3] - RGB value = [18][155][27]
    [3] - RGB value = [21][225][27]
    [3] - RGB value = [23][179][30]
    [3] - RGB value = [22][153][31]
    [3] - RGB value = [0][0][0]
    [3] - RGB value = [13][178][16]
    [3] - RGB value = [15][194][19]
    [3] - RGB value = [13][178][19]
    [3] - RGB value = [0][0][0]
    [3] - RGB value = [0][0][0]
    [2] - transparent pixels = 19
    [2] - colored pixels = 13
    [3] - RGB value = [0][0][0]
    [3] - RGB value = [4][63][9]
    [3] - RGB value = [0][0][0]
    [3] - RGB value = [13][82][18]
    [3] - RGB value = [19][205][26]
    [3] - RGB value = [19][206][26]
    [3] - RGB value = [14][190][20]
    [3] - RGB value = [18][151][24]
    [3] - RGB value = [17][143][22]
    [3] - RGB value = [8][101][12]
    [3] - RGB value = [14][197][21]
    [3] - RGB value = [0][0][0]
    [3] - RGB value = [0][0][0]
    [2] - transparent pixels = 20
    [2] - colored pixels = 12
    [3] - RGB value = [0][0][0]
    [3] - RGB value = [4][63][8]
    [3] - RGB value = [0][0][0]
    [3] - RGB value = [0][0][0]
    [3] - RGB value = [22][134][31]
    [3] - RGB value = [24][137][33]
    [3] - RGB value = [0][0][0]
    [3] - RGB value = [11][84][15]
    [3] - RGB value = [0][0][0]
    [3] - RGB value = [0][0][0]
    [3] - RGB value = [6][78][10]
    [3] - RGB value = [0][0][0]
    [2] - transparent pixels = 21
    [2] - colored pixels = 2
    [3] - RGB value = [0][0][0]
    [3] - RGB value = [0][0][0]
    [2] - transparent pixels = 1
    [2] - colored pixels = 2
    [3] - RGB value = [0][0][0]
    [3] - RGB value = [0][0][0]
    [2] - transparent pixels = 1
    [2] - colored pixels = 4
    [3] - RGB value = [0][0][0]
    [3] - RGB value = [0][0][0]
    [3] - RGB value = [0][0][0]
    [3] - RGB value = [0][0][0]

    You can view code on how to read sprite information for a spriteID from TibiaAPI (SpriteReader.cs - tibiaapi - Google Code). BTW, I'm an official developer of TibiaAPI. The project owner is the one who made the sprite reader code, but I went back and cleaned it up for him.

    Jo3
    Last edited by Joedamoe; 5th March 2009 at 21:55.

  2. #2
    Banned User
    Join Date
    Oct 2008
    Location
    Sweden / Hungary
    Posts
    2,415
    Really nice! Some people here are really geniuses This is really useful for those who want to make changes in the .dat file

  3. #3
    MUG --> Multi-Uses Guy Magich's Avatar
    Join Date
    Mar 2008
    Location
    SPAIN!!!
    Posts
    592
    really cool!
    Magich
    "Everybody has an artist inside. Let it out." by me xD
    "Last night I dreamed I ate a ten-pound marshmallow, and when I woke up the pillow was gone." by Tommy Cooper
    "DO NEVER EVER GIVE UP. IT IS THE WORST THING YOU CAN DO." also by me, I'm totally an artist :P

  4. #4
    Cleaned up version:

    Code :
            public static Image GetSpriteImage(string file, int spriteId)
            {
                const int maxSpriteID = 28722;
                const int minSpriteID = 2;
     
                if (spriteId < minSpriteID || spriteId > maxSpriteID)
                    throw new ArgumentOutOfRangeException(@"spriteId is out of range.");
     
                Bitmap bitmap = new Bitmap(32, 32);
     
                using (BinaryReader reader = new BinaryReader(File.OpenRead(file)))
                {
                    ushort currentPixel = 0;
                    long targetOffset;
     
                    reader.BaseStream.Seek(6 + (spriteId - 1) * 4, SeekOrigin.Begin);
                    reader.BaseStream.Seek(reader.ReadUInt32() + 3, SeekOrigin.Begin);
     
                    targetOffset = reader.BaseStream.Position + reader.ReadUInt16();
     
                    while (reader.BaseStream.Position < targetOffset)
                    {
                        ushort transparentPixels = reader.ReadUInt16();
                        ushort coloredPixels = reader.ReadUInt16();
                        currentPixel += transparentPixels;
                        for (int i = 0; i < coloredPixels; i++)
                        {
                            bitmap.SetPixel(currentPixel & 31, currentPixel >> 5,
                                Color.FromArgb(reader.ReadByte(), reader.ReadByte(), reader.ReadByte()));
                            currentPixel++;
                        }
                    }
                }
                return bitmap;
            }

    Code :
    Public Class Form1
        Dim dataArray As sType()
        Public maxID As Integer
     
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim id As Integer
            If Integer.TryParse(txtClientID.Text, id) AndAlso id >= 100 Then
                If id < dataArray.Length Then
                    Dim stype As sType = dataArray(id - 100)
                    cmbSprites.DataSource = stype.sprites
                    txtAlwaysOnTopOrder.Text = stype.alwaysOnTopOrder
                    txtAnimationLength.Text = stype.animationLength
                    txtBlendFrames.Text = stype.blendFrames
                    txtDivX.Text = stype.divX
                    txtDivY.Text = stype.divY
                    txtDivZ.Text = stype.divZ
                    txtDrawHeight.Text = stype.drawHeight
                    txtHeight.Text = stype.height
                    txtLightColor.Text = stype.lightColor
                    txtLightLevel.Text = stype.lightLevel
                    txtMinimapColor.Text = stype.minimapColor
                    txtNumSprites.Text = stype.numSprites
                    txtSpeed.Text = stype.speed
                    txtWidth.Text = stype.width
                    txtXOffset.Text = stype.xOffset
                    txtYOffset.Text = stype.yOffset
                    chkAlwaysOnTop.Checked = stype.alwaysOnTop
                    chkAlwaysUsed.Checked = stype.alwaysUsed
                    chkBlocking.Checked = stype.blocking
                    chkBlocksMissile.Checked = stype.blocksMissile
                    chkBlocksMonsterMovement.Checked = stype.blocksMonsterMovement
                    chkContainer.Checked = stype.container
                    chkEquipable.Checked = stype.equipable
                    chkFluidContainer.Checked = stype.fluidContainer
                    chkGround.Checked = stype.ground
                    chkHangable.Checked = stype.hangable
                    chkHorizontal.Checked = stype.horizontal
                    chkImmoveable.Checked = stype.immoveable
                    chkLadder.Checked = stype.ladder
                    chkReadable.Checked = stype.readable
                    chkRotateable.Checked = stype.rotateable
                    chkRune.Checked = stype.rune
                    chkSplash.Checked = stype.splash
                    chkStackable.Checked = stype.stackable
                    chkUsable.Checked = stype.useable
                    chkVertical.Checked = stype.vertical
                    chkWriteable.Checked = stype.writeable
                End If
            End If
        End Sub
     
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim FileName As String = vbNullString
            MessageBox.Show("Please locate and open your Tibia.dat file", ".dat Reader")
            With OpenFileDialog1
                .Filter = "Dat file (*.dat)|*.dat|" & "All files|*.*"
                If .ShowDialog = Windows.Forms.DialogResult.OK Then
                    FileName = .FileName
                Else
                    Application.Exit()
                End If
            End With
     
            Using reader As New IO.BinaryReader(IO.File.OpenRead(FileName))
                Dim datversion As Integer = reader.ReadUInt32()
                Dim items As Integer = reader.ReadUInt16()
                Dim outfits As Integer = reader.ReadUInt16()
                Dim effects As Integer = reader.ReadUInt16()
                Dim distance As Integer = reader.ReadUInt16()
     
                Dim maxID As Integer = items + outfits + effects + distance
                Dim ID As Integer = 100
     
                dataArray = Array.CreateInstance(GetType(sType), maxID - ID)
     
                Do While ID < maxID
                    Dim sType As sType
                    sType.id = ID
                    Do
                        Dim optbyte As Byte
                        optbyte = reader.ReadByte()
                        Select Case optbyte
                            Case &H0 'ground tile
                                sType.speed = reader.ReadUInt16()
                                sType.ground = True
                                sType.alwaysOnTopOrder = 0
                            Case &H1, &H2, &H3 'on top, walk through (doors etc.), walk through (arches etc.)
                                sType.alwaysOnTop = True
                                sType.alwaysOnTopOrder = optbyte
                            Case &H4 'container
                                sType.container = True
                            Case &H5 'stackable
                                sType.stackable = True
                            Case &H6 'ladder?
                                sType.alwaysUsed = True
                            Case &H7 'usable
                                sType.useable = True
                            Case &H8 'rune
                                sType.rune = True
                            Case &H9 'writeable
                                sType.writeable = True
                                reader.ReadUInt16() 'max text length
                            Case &HA 'readable
                                sType.readable = True
                                reader.ReadUInt16() 'max text length
                            Case &HB 'fluid container
                                sType.fluidContainer = True
                            Case &HC 'splash
                                sType.splash = True
                            Case &HD 'blocking
                                sType.blocking = True
                            Case &HE 'immoveable
                                sType.immoveable = True
                            Case &HF 'blocks missile
                                sType.blocksMissile = True
                            Case &H10 'blocks monster movement
                                sType.blocksMonsterMovement = True
                            Case &H11 'equipable
                                sType.equipable = True
                            Case &H12 'hangable (wall item)
                                sType.hangable = True
                            Case &H13 'horizontal (wall item)
                                sType.horizontal = True
                            Case &H14 'vertical (wall item)
                                sType.vertical = True
                            Case &H15 'rotateable
                                sType.rotateable = True
                            Case &H16 'light info
                                sType.lightLevel = reader.ReadUInt16()
                                sType.lightColor = reader.ReadUInt16()
                            Case &H17 'unknown?
     
                            Case &H18 'floor change down?
     
                            Case &H19 'draw offset
                                sType.xOffset = reader.ReadUInt16()
                                sType.yOffset = reader.ReadUInt16()
                            Case &H1A 'height
                                sType.drawHeight = reader.ReadUInt16()
                            Case &H1B 'draw with height offset for all parts (2x2) of the sprite
     
                            Case &H1C 'offset life-bar (for larger monsters)
     
                            Case &H1D 'minimap color
                                sType.minimapColor = reader.ReadUInt16()
                            Case &H1E 'floor change?
                                'fs.ReadByte() '86 -> openable holes, 77-> can be used to go down, 76 can be used to go up, 82 -> stairs up, 79 switch
                                'fs.ReadByte() 'always 4
                                reader.ReadUInt16()
                            Case &H1F 'unknown?
     
                            Case &HFF
                                Exit Do
                        End Select
                    Loop
     
                    sType.width = reader.ReadByte()
                    sType.height = reader.ReadByte()
                    If sType.width > 1 Or sType.height > 1 Then
                        reader.ReadByte()
                    End If
     
                    sType.blendFrames = reader.ReadByte()
                    sType.divX = reader.ReadByte()
                    sType.divY = reader.ReadByte()
                    sType.divZ = reader.ReadByte()
                    sType.animationLength = reader.ReadByte()
     
                    Dim numSpr As Integer = sType.width * sType.height
                    numSpr *= sType.blendFrames * sType.divX
                    numSpr *= sType.divY * sType.divZ
                    numSpr *= sType.animationLength
     
                    sType.numSprites = numSpr
     
                    sType.sprites = Array.CreateInstance(GetType(Integer), sType.numSprites)
                    For i As Integer = 0 To sType.numSprites - 1
                        sType.sprites(i) = reader.ReadUInt16()
                    Next
     
                    dataArray(ID - 100) = sType
                    ID += 1
                Loop
     
                txtItems.Text = items
                txtOutfits.Text = outfits
                txtEffects.Text = effects
                txtDistance.Text = distance
            End Using
        End Sub
     
        Private Structure sType
            Dim id As Integer
     
            Dim speed As Integer
            Dim ground As Boolean
            Dim alwaysOnTopOrder As Integer
            Dim alwaysOnTop As Boolean
            Dim container As Boolean
            Dim stackable As Boolean
            Dim ladder As Boolean
            Dim alwaysUsed As Boolean
            Dim useable As Boolean
            Dim rune As Boolean
            Dim writeable As Boolean
            Dim readable As Boolean
            Dim fluidContainer As Boolean
            Dim splash As Boolean
            Dim blocking As Boolean
            Dim immoveable As Boolean
            Dim blocksMissile As Boolean
            Dim blocksMonsterMovement As Boolean
            Dim equipable As Boolean
            Dim hangable As Boolean
            Dim horizontal As Boolean
            Dim vertical As Boolean
            Dim rotateable As Boolean
            Dim lightLevel As Integer
            Dim lightColor As Integer
            Dim xOffset As Integer
            Dim yOffset As Integer
            Dim drawHeight As Integer
            Dim minimapColor As Integer
            Dim width As Integer
            Dim height As Integer
            Dim blendFrames As Integer
            Dim divX As Integer
            Dim divY As Integer
            Dim divZ As Integer
            Dim animationLength As Integer
            Dim numSprites As Integer
     
            Dim sprites As Integer()
        End Structure
    End Class

  5. #5
    Thanks Thomac, any improvements to my coding is always welcome. :D

    Jo3

  6. #6
    UnderclassHero Aerox's Avatar
    Join Date
    Aug 2007
    Location
    Above you all
    Posts
    2,284
    Thanks for this,
    Listed on my VB.NET Thread.




    At the dead-end I begin To burn a bridge of innocence Satisfaction guaranteed
    A pillow-weight catastrophe


    I'm an asshole.

  7. #7
    Oi! Hello, got a question :S

    Is there anyway to save a new .dat file? or should i do it somehow alone XD?

  8. #8
    Thx a lot for this!
    Great job.

    btw, ur pic semce to be broken.

  9. #9
    I'm not sure that I can post on this topic (bit old), let's give a try.

    I was testing with PHP the binary-read of tibia.dat and it's not working very well... For example, I have on my items.xml:
    Code xml:
    <item id="100" name="void"/>
    <item id="101" name="earth"/>
    <item id="103" name="dirt"/>
    <item id="104" name="sand"/>
    <item id="106" name="grass"/>
    <item id="108" name="flowers"/>
    <item id="109" name="flowers"/>
    <item id="194" name="grass"/>
    <item id="231" name="sand"/>
    <item id="280" name="grass"/>
    <item id="293" name="grass"/>
    The first one, void, returns it's correctly spriteIds (136~151, like in byte list above). The second too, i thought - returns 7522 (an earth tile). 102, that doesn't have on my itens.xml, returns a flower. 103 dirt, 104 sand, 106 grass, 108 flowers... Then i jumped to itemid 2207 (sword ring) and it returns an array with spriteIds of a yellow wall :/ and some zeros on the array.

    I'm getting the spriteIds this way:
    Code php:
    $spr_count = array_product(unpack('C*', fread($fp, 5))) * $width * $height;
    $sprites = unpack("S*", fread($fp, 2 * $spr_count));
    I'm sure it's alright, worked well with the first ones.

    Is this structure same as 8.5 Tibia.dat one?

  10. #10
    Quote Originally Posted by NMagus View Post
    Is this structure same as 8.5 Tibia.dat one?
    I'm about 99% positive the DAT structure has changed in 8.5 since I posted this, which was 8.4x I believe. This would explain the problem you're having, but I don't know what the changes were so you'll have to hope someone else can help you, sorry.

+ Reply to Thread
Page 1 of 2 1 2 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts