Results 1 to 12 of 12

Thread: Better solution to finding cave exit?

  1. #1
    Join Date
    Jun 2015
    Posts
    29
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default Better solution to finding cave exit?

    I'm currently working on a troll fighting script, and one procedure I have is to exit the troll cave. Right now I'm locating the top of the barrels near the exit, and doing a messy mouse move with coordinates for where the exit should be. Is there a more elegant and reliable solution that anyone can think of? (If you're testing this I used DirectX for the colors, it seems to work on all machines)

    Note: This is for the troll cave north of Burthorpe.

    Simba Code:
    procedure exitCave();
      var
        x, y, i : Integer;
        cavePoint : TPoint;
        bucketArray : TPointArray;
        bucket2Array : T2DPointArray;
    begin
        minimap.clickCompass(false);
        mainScreen.setAngle(MS_ANGLE_HIGH);
        findColorsSpiralTolerance(x, y, bucketArray, 7105611, mainScreen.getBounds(), 3, colorSetting(2, 16.51, 0.38));
        if (length(bucketArray) < 1) then
        begin
          writeLn('Failed to find bucket, make debug here');
          terminatescript;
        end;

        bucket2Array := bucketArray.toATPA(15, 15);
        bucket2Array.filterBetween(1, 30);
        bucket2Array.sortBySize(true);
        if (length(bucket2Array) < 1) then
          writeLn('Failed to find bucket 2D, make debug here');
          terminatescript;

        smartimage.debugATPA(bucket2Array);

        for (i := 0) to high(bucket2Array) do
        begin
          cavePoint.create(bucket2Array[0].getMiddle().x - 60, bucket2Array[0].getMiddle().y + 50);
          mouse(cavePoint, MOUSE_MOVE, MOUSE_HUMAN);
          if (isMouseOverText(['nter'])) then
          begin  // mouseover found, click and exit
            fastClick(MOUSE_LEFT);
            smartImage.clear();
            wait(5000);
            minimap.clickCompass(false);
            mainScreen.setAngle(MS_ANGLE_HIGH);
            exit;
          end
        end;

        begin
          writeLn('Could not locate cave entrance, make debug here');
          terminatescript;
        end;

    end;
    Last edited by geek borgel; 06-27-2015 at 09:53 PM.

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

    Default

    Simba Code:
    if (length(bucketArray) > 1) then
    Something seems off here...

    Also I have no idea what this cave is, so a picture would help.

  3. #3
    Join Date
    Jun 2015
    Posts
    29
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    oops I'm testing the code now so there are probably a few minor bugs, fixed it though thanks!

  4. #4
    Join Date
    Mar 2014
    Posts
    205
    Mentioned
    4 Post(s)
    Quoted
    116 Post(s)

    Default

    Can you post a picture of the area you're in when trying to find the cave entrance? I don't know which area this is.

  5. #5
    Join Date
    Dec 2011
    Posts
    2,147
    Mentioned
    221 Post(s)
    Quoted
    1068 Post(s)

    Default

    This area I assume:



    The barrel top is a good unique color. I would probably use the iron rails of the tracks - that color seems to stick out nicely as well, and the tracks lead directly and centrally into the cave exit, making it more convenient to work with, especially with changed camera angles. The click area of the cave entrance starts right at the end of the tracks in that screenshot. If there are any similar colors, some quick filtering, as you've done in your snippet, should take care of this.

    Sometimes a method will feel messy, but as long as it gets the job done, there's nothing further to be worried about! If it works, it works.
    Last edited by Clarity; 06-27-2015 at 10:04 PM.

  6. #6
    Join Date
    Jun 2015
    Posts
    29
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    Area on map: http://imgur.com/IPhqluM
    cave with aca: http://imgur.com/SeRZ4DI

    Also clarity, the tracks and walls share many same colors it looked incredibly difficult to do it that way...unless i did a super long tpa?
    Last edited by geek borgel; 06-27-2015 at 10:07 PM.

  7. #7
    Join Date
    Dec 2011
    Posts
    2,147
    Mentioned
    221 Post(s)
    Quoted
    1068 Post(s)

    Default

    This seems like a totally fine and isolated TPA along the train tracks, all of those small overlaps can be filtered out, as the train track TPA is by far the biggest result.



    You can isolate the train track TPA using ATPA.sortBySize(). From there, you can calculate a number of click points you want from the highest Y point and central X point (of the bounds, not the TPA).

    Example of what I mean below: The green box represents the train track TPA that would result from searching and size filtering. The blue cross (highest Y and central X of the TPA bounding box) is already part of the exit click area, but you can take things further by creating an entire box from which a random click point will be chosen.



    Hope that helps Let me know if you have any more questions!
    Last edited by Clarity; 06-27-2015 at 10:24 PM.

  8. #8
    Join Date
    Jun 2015
    Posts
    29
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    How can I filter out the massive number of matches I'm getting from the wall?
    cavesnip1.PNG]
    best I can get:
    cavesnip2.PNG
    tracks changing colors:
    tracks.PNG

  9. #9
    Join Date
    Dec 2011
    Posts
    2,147
    Mentioned
    221 Post(s)
    Quoted
    1068 Post(s)

    Default

    Quote Originally Posted by geek borgel View Post
    How can I filter out the massive number of matches I'm getting from the wall?
    cavesnip1.PNG]
    best I can get:
    cavesnip2.PNG
    tracks changing colors:
    tracks.PNG
    I haven't been able to recreate the tracks changing colors like that, over a few logins. Strange. No matter, another method is possible without the need for an annoying color search!



    Step 1: There is a Burthorpe corporal standing still nearby the cave entrance. While he will usually be the closest NPC dot to your player, he might not be if a troll from the other cave wanders too close. You can create a modified search area close to your player to solve this.

    Simba Code:
    var
      searchBox: TBox;
    {...}
    searchBox := IntToBox(minimap.cx - 40, minimap.cy - 40, minimap.cx + 40, minimap.cy + 40);
    {...}

    Simba Code:
    var
      npcDots: TPointArray;
    {...}
    npcDots := minimap.getDots(MM_DOT_NPC, searchBox);
    {...}

    Step 2: Assuming the .getDots() successfully returns the corporal's position on the minimap as npcDots[0], you can now offset that point to where the cave exit is on the minimap.

    Simba Code:
    var
      caveMMPoint: TPoint;
    {...}
    caveMMPoint := npcDots[0].offset(point(someX, someY));
    {...}

    Step 3: Now, you can translate this offset point to the mainscreen.

    Simba Code:
    var
      caveMSPoint: TPoint;
    {...}
    caveMSPoint := minimap.pointToMainscreen(caveMMPoint);
    {...}

    Step 4: With a point now somewhere close to the cave exit, you can create a clickbox easily, that will always encompass the click area for the cave exit. A color search will not be necessary then, unless you want to for a failsafe (an interface could block the cave, with the minimap dot still being visible, for instance).

    Simba Code:
    var
      clickBox: TBox;
    {...}
    clickBox := IntToBox(caveMSPoint.X - someX, caveMSPoint.Y - someY, caveMSPoint.X + someX, caveMSPoint.Y + someY);
    {...}

    You will need to do some trial and error to determine the best someX and someY for your box and minimap offsetting.

    That should work pretty well! There are many different ways to go about object interaction, and your barrel method might work fine instead of this. Like I said, don't worry about it if something feels messy if it's working 100% of the time.
    Last edited by Clarity; 06-27-2015 at 11:16 PM.

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

    Default

    Mine is shorter!
    Quote Originally Posted by Clarity View Post
    Simba Code:
    searchBox := [0,0,0,0]; searchBox.offset(minimap.getCenterPoint()); searchBox.expand(40);
    searchBox := IntToBox(minimap.cx - 40, minimap.cy - 40, minimap.cx + 40, minimap.cy + 40);
    On topic: OP, couldn't you face south so that the actual cave opening is visible?

  11. #11
    Join Date
    Jun 2015
    Posts
    29
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    Thanks! Those are great ideas and I'm definitely saving them to use Got it working now! Now on to the identifying and fighting part!

  12. #12
    Join Date
    Sep 2014
    Posts
    447
    Mentioned
    10 Post(s)
    Quoted
    203 Post(s)

    Default

    God damn, I love you evilcitrus haha.

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
  •