Deprecated: The behavior of unparenthesized expressions containing both '.' and '+'/'-' will change in PHP 8: '+'/'-' will take a higher precedence in /home/iano/public_html/tpforums-vb5/forum/includes/class_core.php on line 5842

PHP Warning: Use of undefined constant MYSQL_NUM - assumed 'MYSQL_NUM' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_ASSOC - assumed 'MYSQL_ASSOC' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_BOTH - assumed 'MYSQL_BOTH' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 588

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 612

PHP Warning: Use of undefined constant misc - assumed 'misc' (this will throw an Error in a future version of PHP) in ..../global.php(29) : eval()'d code(6) : eval()'d code on line 1

PHP Warning: Use of undefined constant index - assumed 'index' (this will throw an Error in a future version of PHP) in ..../global.php(29) : eval()'d code(6) : eval()'d code on line 1

PHP Warning: Use of undefined constant misc - assumed 'misc' (this will throw an Error in a future version of PHP) in ..../includes/class_bootstrap.php(1422) : eval()'d code(4) : eval()'d code on line 1

PHP Warning: Use of undefined constant index - assumed 'index' (this will throw an Error in a future version of PHP) in ..../includes/class_bootstrap.php(1422) : eval()'d code(4) : eval()'d code on line 1

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6
Tibia Hard Drive
Results 1 to 4 of 4

Thread: Tibia Hard Drive

  1. #1
    Senior Member
    Join Date
    Jan 2012
    Posts
    417

    Tibia Hard Drive

    Tibia Hard Drive


    Description


    Tibia Hard Drive is a project meant to parse common files saved in the hard drive by the Tibia Client using Lua as programming language.

    Anyone with a toolset capable of running Lua code (compiler, interpreter, etc) can benefit from using this library and due the nature of Lua, you can call this library even from your host program in C, C++, C#, Java, etc running a Lua state.

    The files planned to be supported are: .map, .dat, .spr, .cfg and possibly others. For now, .map is the only one supported.

    Features



    • GlobalMap (.map):
      • Get location of the map (in x, y, z coordinates)
      • Left, Top, Right and Bottom locations of the map region in Tibian coordinates
      • Get rgb color at x, y as displayed by the Tibia Client's automap.
      • Get terrain cost at x, y
      • Get all the marks in the map
      • Save .bmp image of the map (probably Windows-only, not tested though)



    Planned Features


    • .dat:
      • Get info related to any object given its id
      • Get Items info
      • Get Outfits info
      • Get Effects info
      • Get Missiles info

    • .spr:
      • Save .bmp image of any player with an outfit, given its head, body, legs and feet colors.
      • Save .bmp image of any sprite
        • Item
        • Creature Outfit
        • Effect
        • Missile


    • .cfg:
      • Get all the info related to Tibia Client configuration, including Hotkeys, Classic Control, etc



    Examples


    GlobalMap class (.map)

    Rename "filename, bmpfilename" for your personal files where it appears


    • How to print all the marks on the map
      Code:
      local GlobalMap = require("GlobalMap")
          local map = GlobalMap()
      
          local filename = "FILENAME" -- ex: os.getenv("appdata") .. "\\Tibia\\Automap\\12812507.map"
      
          map:Open(filename)
      
          if (map:IsOpen()) then
              for _, mark in ipairs(map:Marks()) do
      
                  print(
                      ("{ x = %s, y = %s, type = %s, description = %q }"):format(mark.X, mark.Y, mark.Type, mark.Description)
                  )
      
              end
          else
              print("cannot open map")
          end
      
          map:Close()
    • How to save a .bmp image from the map:
      Code:
      local GlobalMap = require("GlobalMap")
          local map = GlobalMap()
      
          local filename = "FILENAME" -- ex: os.getenv("appdata") .. "\\Tibia\\Automap\\12812507.map"
          local bmpfilename = "USER_IMG.bmp" -- ex: os.getenv("userprofile") .. "\\venore.bmp"
      
          map:Open(filename)
      
          if (map:IsOpen()) then
              map:LoadColors()
              map:SaveImage(bmpfilename)
          else
              print("cannot open map")
          end
      
          map:Close()
    • How to print all the colors in the map and its respective Tibian locations:
      Code:
      local GlobalMap = require("GlobalMap")
          local map = GlobalMap()
      
          local filename = "FILENAME" -- ex: os.getenv("appdata") .. "\\Tibia\\Automap\\12812507.map"
      
          map:Open(filename)
      
          if (map:IsOpen()) then
      
           map:LoadColors()
      
              local left, top, right, bottom =
                  map:Left(), map:Top(), map:Right(), map:Bottom()
      
              local z = map:Z()
      
              local color = nil
      
              for x = left, right do
                  for y = top, bottom do
      
                    color = map:GetColor(x, y)
      
                      print(
                          ('(%05i, %05i, %02i) = { r = 0x%02X, g = 0x%02X, b = 0x%02X }')
                          :format(x, y, z, color.R, color.G, color.B)
                      )
                  end
              end
          else
            print("cannot open map")
          end
      
          map:Close()
    • How to print all the terrain costs in the map and its respective Tibian locations:
      Code:
      local GlobalMap = require("GlobalMap")
      
          local map = GlobalMap()
      
          local filename = "FILENAME" -- ex: os.getenv("appdata") .. "\\Tibia\\Automap\\12812507.map"
      
          map:Open(filename)
      
          if (map:IsOpen()) then
      
              map:LoadTerrainCosts()
      
              local left, top, right, bottom =
                  map:Left(), map:Top(), map:Right(), map:Bottom()
      
              local z = map:Z()
      
              for x = left, right do
                  for y = top, bottom do
                      print(
                          ("(%05i, %05i, %02i) = 0x%02X"):format(x, y, z, map:GetTerrainCost(x, y))
                      )
                  end
              end
      
          else
              print("cannot open map")
          end
      
          map:Close()


    Thanks




    Repository


    Last edited by Blequi; 07-07-2014 at 05:17 PM.

  2. #2
    Junior Member
    Join Date
    Jul 2013
    Posts
    15
    Simply amazing. Nice job

    Not to mention the great idea haha

  3. #3
    Senior Member
    Join Date
    Jan 2008
    Location
    Cambridge, England
    Posts
    725
    Pffffft. Idea thief!

    http://tpforums.org/forum/threads/6003-C-Map-Reader

    Jokes :P Nice work!

  4. #4
    Senior Member
    Join Date
    Jan 2012
    Posts
    417
    Quote Originally Posted by Maxy View Post
    Simply amazing. Nice job

    Not to mention the great idea haha
    Thank you

    Quote Originally Posted by XtrmJash View Post
    Pffffft. Idea thief!

    http://tpforums.org/forum/threads/6003-C-Map-Reader

    Jokes :P Nice work!
    I have to admit it is not the most original idea, but dealing with bytes in Lua isn't that straightforward. Also, I found very interesting to write the bitmap by its file format (it's is probably the fatest way to write it, but probably the less portable between OS versions).

    With this library, you can even code your pathfinder in Lua only, due my support to Terrain Costs (people around here calls it sqm speed)

Posting Permissions

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