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 85

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

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 85

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 85

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
[C#] .map reader
Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: [C#] .map reader

  1. #1
    Junior Member
    Join Date
    Jun 2015
    Posts
    1

    [C#] .map reader

    Any idea to decrypt .map files? I want to start doing pathfinder from point to point

  2. #2
    Senior Member Lolrapa's Avatar
    Join Date
    Mar 2014
    Posts
    125
    Automap strucutre is really simple, is a two-dimensional matrix of bytes each byte indicates a tile type(wall, water, etc) and each tile type has a color. It must be a list of that colors for each byte in google somewhere.
    The height and the width of the matrix is the same for every file and I think it's the width and height of the minimap at full zoom out.
    Every file has a number, that allow you to order them in the right sequence.


    You'll have to make a general path with this method and then check for obstructions while walking, since some things may block your path and may not be desplayed in the minimap.
    There are two memory structures in tibia that allow you to check whether a tile is walkeable or not.

    I strongly recommend you to use dijkstra or a* algorithms to create the path

    Good luck!
    Just ask if you need any help!
    Last edited by Lolrapa; 06-01-2015 at 08:24 PM.

  3. #3
    Senior Member
    Join Date
    Jan 2012
    Posts
    417
    I tried to explain it (GlobalMap.lua file): https://github.com/Blequi/TibiaHardDrive

    I think it is detailed enough. Since it's coded in Lua, it is not a problem for the majority of Tibia related programmers

  4. #4
    Quote Originally Posted by Blequi View Post
    I tried to explain it (GlobalMap.lua file): https://github.com/Blequi/TibiaHardDrive

    I think it is detailed enough. Since it's coded in Lua, it is not a problem for the majority of Tibia related programmers
    I was trying to read the maps files some days ago and I got stuck with the 255 values on sqm's with fire/poison fields, because if you use a FF to block the way and then move away from that point, after some minutes it will still be marked as "Can not walk (255)", it will update the value only if you walk in that position again, so if you need to calculate a path to X position that was covered by fire fields, like on Yalahar dragon lords, it won't work, since the sqm's is blocked in the map file/memory.

    Do you know a way to "fix" this? Or am I doing something wrong?

  5. #5
    Senior Member
    Join Date
    Jan 2012
    Posts
    417
    There's nothing wrong with your thinking.

    I never built a cavebot, but the way I can think of is through local map (tiles around you). When you have an obstacle in a certain position, split the search area in 7x7 squares (for tiles available in the local map) and try to get closer to the goal location, repeating this process until you reach the desired location.

    The local map idea works because you can bypass fire (or energy, etc) fields if it's the only blocking item in the tile stack.

  6. #6
    Ye, I was just messing around with the map files, testing some pathfinders, then I faced this problem, was trying to create a path on all fenrock dragon lords, since the space to walk inside the cave is small, so this "split" thing wouldn't work that good I guess, since most of the ways are 3~4 sqm's and DL's aways trap all the sqm's, then I got stuck about that and how would be possible to "fix" it, but didn't try that much, I tought about update the visible area after walk X sqm's, but the path won't be found either, maybe I will take a look on that when I get free time.

  7. #7
    Senior Member
    Join Date
    Jan 2012
    Posts
    417
    Quote Originally Posted by Casky View Post
    so this "split" thing wouldn't work that good I guess, since most of the ways are 3~4 sqm's and DL's aways trap all the sqm's, then I got stuck
    well, if all the ways surrounding you are blocked, then there is no path and indeed, any pathfinder will fail to trace paths. You could see creatures or humans standing in sqm's as walkable in your pathfinder, when accounting for it in the local map, because if I'm not mistaken, they have a 99 id or something like that.

    I don't play Tibia in ages, but if I recall correctly, creatures are always non-blocking unless some fighting mode enabled.

  8. #8
    Senior Member Lolrapa's Avatar
    Join Date
    Mar 2014
    Posts
    125
    I'm pretty sure you cant walk through creatures in open pvp at least.
    There are three information sources you have at hand, maybe separated are inefficient or usless but together I'm sure it work 100%

    1) The can/can't walk info in map file.
    As you say this method fails when a tile is temporarily blocked and you leave the screen like that, but also can give us a good idea of what could be walkable.
    This method may show you a tile not walkable when it is.

    2) The color palette
    The colours of the map can give you an idea of whether a tile is or not walkeable, and will not change if there is fire or any other field or creature
    This method may show a tile walkeable when is not, since some stones or trees aren't shown in map.

    3)The local map
    The local map gives a detailed view of every tile and it's items since every item like fire, stones, etc has an id and the tile info is stored in the .data file you can easily check if you can walk or not over a tile using tile flags like BlockPathFinding or IsGround

    Remember that the more information we have the better. Just a little logic is needed to conect these three parts
    Last edited by Lolrapa; 06-03-2015 at 01:12 PM.

  9. #9
    Super Moderator klusbert's Avatar
    Join Date
    Dec 2007
    Posts
    1,201
    This is how I load whole tibiaMap into memory, verry elegant and fast.
    http://pastebin.com/fjh30vFn
    How to find battlelist address --> http://tpforums.org/forum/thread-8146.html
    Updating addresses --> http://tpforums.org/forum/thread-8625.html
    DataReader --> http://tpforums.org/forum/thread-10387.html

  10. #10
    Junior Member
    Join Date
    Oct 2010
    Posts
    21
    namespace WindowsFormsApplication1
    {
    public partial class Form1 : Form
    {
    public Form1()
    {
    InitializeComponent();
    }
    byte[,,] TibiaMap;
    private void button1_Click(object sender, EventArgs e)
    {
    string Path = Environment.GetFolderPath(Environment.SpecialFolde r.ApplicationData) + "\\Tibia\\Automap\\";
    int StartX = 31744;
    int StartY = 30976;
    int MaxHeight = 2048;
    int MaxWidth = 2048;
    TibiaMap = new byte[16, 2048, 2048];
    DirectoryInfo di = new DirectoryInfo(Path);
    for (int z = 0; z < 16; z++)
    {
    FileInfo[] mapFiles = di.GetFiles("1??1??" +
    z.ToString("00") +
    ".map");
    foreach (FileInfo inf in mapFiles)
    {

    Location RealLocation = MapFileNameToLocation(inf.Name);
    int ArrayX = RealLocation.X - StartX;
    int ArrayY = RealLocation.Y - StartY;


    byte[] ColorArray = new byte[65536];
    FileStream fs = new FileStream(inf.FullName, FileMode.Open);
    BufferedStream bs = new BufferedStream(fs);
    bs.Read(ColorArray, 0, 65536);
    int index = 0;
    for (int x = 0; x < 256; x++)
    {
    for (int y = 0; y < 256; y++)
    {
    TibiaMap[z, x + ArrayX,y + ArrayY] = ColorArray[index];
    index += 1;
    }
    }

    fs.Close();
    }
    }

    }
    private Location MapFileNameToLocation(string fileName)
    {
    Location l = new Location(0, 0, 0);
    if (fileName.Length == 12 || fileName.Length == 8)
    {
    l.X = Int32.Parse(fileName.Substring(0, 3)) * 256;
    l.Y = Int32.Parse(fileName.Substring(3, 3)) * 256;
    l.Z = Int32.Parse(fileName.Substring(6, 2));
    }
    return l;
    }
    }
    }

    -----------------------------------------------------------------------
    Declarate of Location? plz


    log:

    Error 1 'System.Windows.Forms.Form.Location' is a 'property' but is used like a 'type'
    Last edited by MaCrOs; 09-06-2015 at 08:50 AM. Reason: new inf

Tags for this Thread

Posting Permissions

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