Results 1 to 6 of 6

Thread: isMapOpen();

  1. #1
    Join Date
    Sep 2015
    Posts
    65
    Mentioned
    7 Post(s)
    Quoted
    20 Post(s)

    Default isMapOpen();

    I have recently been having some trouble with SPS where it would sometime click the map button while trying to click on a point. I found that it occurs fairly rarely but when it happened my bot would stop as there is no built in function in the SRL Include to exit the map (at least there was none that I could find).

    This is why I put together this guy:

    Simba Code:
    function isMapOpen(): boolean;
    var
      mapOpenDTM, x, y: integer;
    begin
      mapOpenDTM := DTMFromString('mrAAAAHic42BgYLBkZWAwhGI3KDZhhYiDcDtQzSQgroViEBsk1gPETUB8czkvA4eoDAMbvwgYg9gv9xozHF9mzLCpQ4SBiQETMCFhRgIYBgCeYw1g');
      result := false;
      if (findDTM(mapOpenDTM, x, y, getClientBounds())) then
      begin
        writeln('Map Is Open.');
        result := true;
      end else
        writeln('Map is not open.');
      freeDTM(mapOpenDTM);
    end;

    This function will let you know if the map is opened on the screen.

    I have gone further and wrote an override of the TSPSArea.walkPath function where you can implement the above function to use if the script accidentally clicks on the map while walking.

    Simba Code:
    function TSPSArea.walkPath(path: TPointArray; waitMoving: Boolean = True; shiftInterval: Integer = 500): boolean; override
    var
      p, lastPos, mmPoint: TPoint;
      t, fails, h, l, i, dx, dy, mapOpenDTM: integer;
      dtmTimer: TTimeMarker;
    begin
      mapOpenDTM := DTMFromString('mrAAAAHic42BgYLBkZWAwhGI3KDZhhYiDcDtQzSQgroViEBsk1gPETUB8czkvA4eoDAMbvwgYg9gv9xozHF9mzLCpQ4SBiQETMCFhRgIYBgCeYw1g');                  
      result := false;

      h := high(path);
      l := low(path);

      t := (getSystemTime() + randomRange(15000, 20000));

      repeat
        if (not isLoggedIn()) then
          exit(false);

        p := self.getPlayerPos();

        for i := h downto l do
          if (SPS_PosToMM(path[i], p, mmPoint)) then
          begin
            if (distance(minimap.getCenterPoint(), mmPoint) >= 10) then
            begin
              if (spsMultiMouse) then
                multiClick(mmPoint, 25, 3)
              else
                mouse(mmPoint, MOUSE_LEFT);

              if (minimap.isFlagPresent(2500 + random(500))) then
                minimap.waitFlag(10 + random(25));
            end;

            t := (getSystemTime() + randomRange(15000, 20000));

            result := (i = h) or (distance(path[i], path[h]) < 10);

            if (result) then
              break(2)
            else
              break();

          end;

        if (p.x = lastPos.x) and (p.y = lastPos.y) then
          inc(fails);
         
        lastPos := p;

        dtmTimer.start;
        if (findDTM(mapOpenDTM, dx, dy, getClientBounds())) then
        begin
          repeat
            writeln('Map Is Open. We will try to close it.');
            wait(randomrange(250, 750));
            moveMouse(dx, dy);
            fastClick(MOUSE_LEFT);
          until(not (findDTM(mapOpenDTM, dx, dy, getClientBounds())) or dtmTimer.getTime > 15000);
        end;        

      until (getSystemTime() > t) or (fails > 5);

      if waitMoving then
        if (minimap.isFlagPresent() or minimap.isPlayerMoving()) then
          minimap.waitPlayerMoving(shiftInterval);

      print(self.getName()+'.walkPath(): result = '+boolToStr(result));
      freeDTM(mapOpenDTM);
    end;

    I know that you could make is simpler by having that little section as its own procedure, but this is just something I quickly whipped up.

    I seemed to notice that this problem could be seen as human error, which I find kind of useful in making sure you dont get banned.
    Last edited by Shield; 11-09-2015 at 07:31 PM. Reason: Added Timer to SPS function.

  2. #2
    Join Date
    Aug 2014
    Location
    Australia
    Posts
    932
    Mentioned
    53 Post(s)
    Quoted
    495 Post(s)

    Default

    I tried repping you buuuuut...



    I've never had SPS click on the map button before, does this happen to you often? I also notice that the loop you use to close the map in the override function basically won't end unless the map is closed. What if something goes wrong and it never closes?



    New to scripting? Procedures & Functions for Beginners
    Do you use your computer at night? Just get f.lux

  3. #3
    Join Date
    Sep 2015
    Posts
    65
    Mentioned
    7 Post(s)
    Quoted
    20 Post(s)

    Default

    Quote Originally Posted by Incurable View Post
    I tried repping you buuuuut...



    I've never had SPS click on the map button before, does this happen to you often? I also notice that the loop you use to close the map in the override function basically won't end unless the map is closed. What if something goes wrong and it never closes?
    Ha ha. Thanks! It happens only when the next 'visible' point is close to the map button. I could always use a timer (which I totally forgot to add) but the DtM is fairly unique. The DtM is the exit button on the map, which I don't think is used anywhere else in the game (I could be wrong) but even if it is used somewhere else it would most likely be another exit button on some sort of other interface, therefore I can't see it ever finding the DTM without there being some sort of interface loaded.

    But I definitely should add a timer.

  4. #4
    Join Date
    Aug 2014
    Location
    Australia
    Posts
    932
    Mentioned
    53 Post(s)
    Quoted
    495 Post(s)

    Default

    Quote Originally Posted by Shield View Post
    But I definitely should add a timer.
    It's basically just a case of covering the "what if?" scenarios. It's probably never going to be necessary, but what if it was?



    New to scripting? Procedures & Functions for Beginners
    Do you use your computer at night? Just get f.lux

  5. #5
    Join Date
    Sep 2015
    Posts
    65
    Mentioned
    7 Post(s)
    Quoted
    20 Post(s)

    Default

    Quote Originally Posted by Incurable View Post
    It's basically just a case of covering the "what if?" scenarios. It's probably never going to be necessary, but what if it was?
    Yea man! Better to be safe than sorry. Plus it couldn't hurt to add another failsafe.

    I'll add one when I get to my computer.

  6. #6
    Join Date
    Dec 2011
    Posts
    59
    Mentioned
    1 Post(s)
    Quoted
    11 Post(s)

    Default

    Thanks, using this now and will see how it works out.

    Edit: Sometimes it will randomly say the map is open but it is not. I guess I will find a workaround. I adjusted the break timer to 10 seconds instead.

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
  •