Results 1 to 4 of 4

Thread: Tile Path Tool

  1. #1
    Join Date
    May 2012
    Location
    Glorious Nippon
    Posts
    1,011
    Mentioned
    50 Post(s)
    Quoted
    505 Post(s)

    Default Tile Path Tool

    I spent the last few hours making this tile path tool thingy
    I've never done anything with forms before, so there are probably lot's of problems with it. I just copied everything from Olly's TesseractTool.

    You will need this image. Save it as 'map.png' in your Simba folder.
    Then just run the script. Press the load button to load the map. Then hit the record button to record your path.
    The path will be printed as you make new points. When you close the window the path will also appear Simba's debug box.

    I only briefly tested it around Lumbridge, so who knows if it works anywhere else.
    It still needs a lot of work. Feel free to suggest improvements

    Simba Code:
    1. program pathThingy;
    2.  
    3. var
    4.   mainForm: TForm;
    5.   lbl: TLabel;
    6.   butt, mapButt: TSpeedButton;
    7.   sb: TScrollBox;
    8.   pnl: TPanel;
    9.   img, zoom: TImage;
    10.   memo: TMemo;
    11.   lastPoint: TPoint;
    12.   map: TMufasaBitmap;
    13.   mapw, maph: integer;
    14.   loadedMap: boolean := false;
    15.   path: TPointArray;
    16.  
    17. procedure debug(const str: string);
    18. begin
    19.   memo.getLines().add(str);
    20. end;
    21.  
    22. procedure debugPath();
    23. var
    24.   s: string;
    25.   i: integer;
    26. begin
    27.   s := s + 'path := [';
    28.   for i := 0 to high(path)-1 do
    29.     s := s + ('[' + toStr(path[i].x) + ', ' + toStr(path[i].y) + '], ');
    30.   s := s + ('[' + toStr(path[i].x) + ', ' + toStr(path[i].y) + ']');
    31.   s := s + '];';
    32.   debug(s);
    33. end;
    34.  
    35. procedure onImgClick(sender: TObject; button: TMouseButton; shift: TShiftState; x, y: integer); native;
    36. var
    37.   c: TCanvas;
    38.   w, h, xx, yy, px, py: integer;
    39.   box: TBox;
    40. begin
    41.   if (not butt.getDown) then exit();
    42.   c := img.getCanvas();
    43.   w := c.getWidth(); h := c.getHeight();
    44.  
    45.   xx := lastPoint.x;
    46.   yy := lastPoint.y;
    47.   case (xx mod 3) of
    48.     0: inc(xx);
    49.     2: dec(xx);
    50.   end;
    51.   case (yy mod 3) of
    52.     1: dec(yy);
    53.     2: inc(yy);
    54.   end;
    55.   box := [max(0, xx-1), max(0, yy-1), min(xx+1, w-1), min(yy+1, h-1)];
    56.   c.SetPixels(tpaFromBox(box), 255);
    57.   px := floor(xx/3) + 1391;
    58.   py := floor((h-yy)/3) + 2479;
    59.   appendTPA(path, [[px, py]]);
    60.   debugPath();
    61.   //incPath(px, py);
    62.   img.Repaint();
    63. end;
    64.  
    65. procedure onImgMouseMove(Sender: TObject; Shift: TShiftState; x, y: Integer); Native;
    66. var
    67.   c, zc: TCanvas;
    68.   w, h, xx, yy, px, py, col: integer;
    69.   box: TBox;
    70.   bmp: TMufasaBitmap;
    71.   tbmp: TBitmap;
    72. begin
    73.   if (not loadedMap) then exit();
    74.   lastPoint := [x, y];
    75.  
    76.   c := img.getCanvas();
    77.   w := c.getWidth(); h := c.getHeight();
    78.  
    79.   xx := x; yy := y;
    80.   case (xx mod 3) of
    81.     0: inc(xx);
    82.     2: dec(xx);
    83.   end;
    84.   case (yy mod 3) of
    85.     1: dec(yy);
    86.     2: inc(yy);
    87.   end;
    88.   col := c.GetPixel(xx, yy);
    89.   box := [max(0, xx-4), max(0, yy-4), min(xx+4, w-1), min(yy+4, h-1)];
    90.  
    91.   px := floor(xx/3) + 1391;
    92.   py := floor((h-yy)/3) + 2479;
    93.   lbl.setCaption('tile: [' + toStr(px) + ', ' + toStr(py) + ']');
    94.  
    95.   bmp.Init();
    96.   bmp := map.Copy(box.x1, box.y1, box.x2, box.y2);
    97.   bmp.StretchResize(90, 90);
    98.   tbmp := bmp.ToTBitmap();
    99.  
    100.   zoom.getPicture().clear();
    101.   zoom.getPicture().setBitmap(tbmp);
    102.   zoom.getCanvas().getBrush().setColor(col);
    103.   zoom.getCanvas().getPen().setColor(255);
    104.   zoom.getCanvas().rectangle(30, 30, 60, 60);
    105.  
    106.   zoom.Repaint();
    107.   bmp.Free();
    108.   tbmp.Free();
    109. end;
    110.  
    111. procedure loadMap();
    112. begin
    113.   map.Init();
    114.   map.LoadFromFile(appPath + 'map.png');
    115.   mapw := map.getWidth();
    116.   maph := map.getHeight();
    117. end;
    118.  
    119. procedure mapButton(sender: TObject); native;
    120. var
    121.   tbmp: TBitmap;
    122. begin
    123.   if loadedMap then exit();
    124.  
    125.   img.setWidth(mapw);
    126.   img.setHeight(maph);
    127.   img.getPicture().clear();
    128.  
    129.   tbmp := map.ToTBitmap();
    130.   img.getPicture().setBitmap(tbmp);
    131.   tbmp.Free();
    132.  
    133.   loadedMap := true;
    134. end;
    135.  
    136. procedure initForm(sender: TObject); native;
    137. begin
    138.   mainform.Init(nil);
    139.  
    140.   mainform.setCaption('formTest');
    141.   mainform.setWidth(800);
    142.   mainform.setHeight(600);
    143.   mainform.setLeft(200);
    144.   mainform.setTop(200);
    145.   mainform.getConstraints().setMinHeight(600);
    146.   mainform.getConstraints().setMinWidth(800);
    147.   mainform.setKeyPreview(true);
    148.   mainform.setDoubleBuffered(True);
    149.  
    150.   pnl.Init(mainform);
    151.   pnl.setParent(mainform);
    152.   pnl.setHeight(200);
    153.   pnl.setAlign(alBottom);
    154.  
    155.   butt.Init(mainform);
    156.   butt.setParent(pnl);
    157.   butt.setWidth(100);
    158.   butt.setAlign(alRight);
    159.   butt.setAllowAllUp(true);
    160.   butt.setGroupIndex(1);
    161.   butt.setCaption('record path');
    162.  
    163.   mapButt.Init(mainform);
    164.   mapButt.setParent(pnl);
    165.   mapButt.setWidth(100);
    166.   mapButt.setAlign(alRight);
    167.   mapButt.setCaption('load map');
    168.   mapButt.setOnClick(mapButton);
    169.  
    170.   sb.Init(mainform);
    171.   sb.setParent(mainform);
    172.   sb.setAlign(alClient);
    173.   sb.setBorderStyle(bsNone);
    174.  
    175.   img.Init(mainform);
    176.   img.setParent(sb);
    177.   img.setWidth(800);
    178.   img.setHeight(400);
    179.   img.setCursor(crCross);
    180.   img.setCenter(true);
    181.   img.setOnClick(onImgClick);
    182.   img.setOnMouseMove(onImgMouseMove);
    183.  
    184.   lbl.Init(mainform);
    185.   lbl.setParent(pnl);
    186.   lbl.setCaption('tile');
    187.   lbl.setAlign(alLeft);
    188.  
    189.   zoom.Init(mainform);
    190.   zoom.setParent(pnl);
    191.   zoom.setWidth(100);
    192.   zoom.setAlign(alLeft);
    193.   zoom.setCenter(true);
    194.  
    195.   memo.Init(mainform);
    196.   memo.setReadOnly(true);
    197.   memo.setParent(pnl);
    198.   memo.setHeight(100);
    199.   memo.setAlign(alBottom);
    200.   memo.setScrollBars(ssAutoVertical);
    201.  
    202.   try
    203.     mainform.ShowModal();
    204.   finally
    205.     mainform.Free();
    206.   end;
    207.  
    208. end;
    209.  
    210. procedure writePath();
    211. var
    212.   i: integer;
    213. begin
    214.   if (length(path) < 1) then exit();
    215.   write('path := [');
    216.   for i := 0 to high(path)-1 do
    217.     write('[', path[i].x, ', ', path[i].y, '], ');
    218.   write('[', path[i].x, ', ', path[i].y, ']');
    219.   writeln('];');
    220. end;
    221.  
    222. procedure freeMap();
    223. begin
    224.   if (map <> nil) then map.free;
    225.   writePath();
    226. end;
    227.  
    228. begin
    229.   addOnTerminate('freeMap');
    230.   clearDebug();
    231.   loadMap();
    232.   sync(initForm);
    233. end.

  2. #2
    Join Date
    Dec 2014
    Posts
    48
    Mentioned
    2 Post(s)
    Quoted
    28 Post(s)

    Default

    Im trying to learn reflection, and I used this tool to generate this path for my first script - so I can confirm that this tool definitely works in other areas. In about 4 hours, it only messed up once, with the debug message "Failed to find Tile {X = 3016, Y = 3450} on MM."

    One thing I noticed is that sometimes a point far away form the character's position is clicked on the minimap, followed by a very close point, causing the character to back-track a little.

    Other than that, it worked perfectly, +rep

  3. #3
    Join Date
    May 2012
    Location
    Glorious Nippon
    Posts
    1,011
    Mentioned
    50 Post(s)
    Quoted
    505 Post(s)

    Default

    Quote Originally Posted by meep152 View Post
    Im trying to learn reflection, and I used this tool to generate this path for my first script - so I can confirm that this tool definitely works in other areas. In about 4 hours, it only messed up once, with the debug message "Failed to find Tile {X = 3016, Y = 3450} on MM."

    One thing I noticed is that sometimes a point far away form the character's position is clicked on the minimap, followed by a very close point, causing the character to back-track a little.

    Other than that, it worked perfectly, +rep
    Thanks for trying it out!

    That has more to do with the walking method you're using. I've noticed that the reflection walking functions can be a bit wonky.

  4. #4
    Join Date
    Nov 2017
    Posts
    1
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks for sharing your file, it's very good, I'll prove it
    I like it live forex signals, it's like going on a roller coaster, amazing!!

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
  •