Results 1 to 22 of 22

Thread: Some fixes/replacements.

  1. #1
    Join Date
    Dec 2006
    Location
    Sydney, New South Wales, Australia
    Posts
    4,603
    Mentioned
    15 Post(s)
    Quoted
    42 Post(s)

    Default Some fixes/replacements.

    Hey guys,

    I was just browsing through the include when I saw a few things which I thought were a little iffy. So, I decided to fix them up (as shown below)

    • MultiMouse
      Location: /Core/AntiBan.simba
      Reason: Easily bannable as it spam clicks (only uses wait time from Mouse), as-well as having flawed logic if 'True' was passed to the 'red' argument.
      Simba Code:
      function MultiMouse(const X, Y, rX, rY: Integer; const Chance, maxClicks: Integer; const Red: Boolean): Boolean;
      var
        clickAmount, sleepTime, tmpInt: Integer;
        currPos: TPoint;
      begin
        // Initialisation
        Result := (not(Red));
        clickAmount := 0;
        sleepTime := 130;

        // Check if the mouse is already at the location.
        GetMousePos(currPos.X, currPos.Y);
        if(not((currPos.X = X) and (currPos.Y = Y))) then
          MMouse(X, Y, rX, rY);

        repeat
          ClickMouse2(mouse_Left);

          Result := (Red and DidRedClick);
          if(Red and Result) then
            Exit;

          if(Random(100) > Chance) then
            Break;

          clickAmount := clickAmount + 1;
          Sleep(sleepTime + RandomRange(-3, 3));

          // Gradually increase the wait time
          if(Random(6) = 0) then
          begin
            tmpInt := (clickAmount + 10) shr 1;
            sleepTime := sleepTime + RandomRange(tmpInt, tmpInt + Random(5));
          end;
        Until(clickAmount >= maxClicks);
      end;

      I ran several self tests to determine how a human actually handles spam clicking. I found that the interval between clicks gradually increases by a small amount (also, gradually increasing) every 4-8 clicks, so I decided to include it in. I also added the rX and rY arguments
    • CompassMovement:
      Location: /Core/AntiBan.simba
      Reason: Result is redundant.

      Change function -> procedure.
    • DidClick:
      Location: /Core/Mouse.simba
      Reason: Just removed some unnecessary clutter
      Simba Code:
      function DidClick(const Red: Boolean; const Time: Integer): Boolean;
      var
        currPos: TPoint;
        srchBox: TBox;
        exitTime: Cardinal;
        fR, fG: Byte;
      begin
        Result := False;
        GetMousePos(currPos.X, currPos.Y);
        srchBox := IntToBox(currPos.X - 15, currPos.Y - 15, currPos.X + 15, currPos.Y + 15);
        exitTime := GetTimeRunning + Time;
        while(exitTime > GetTimeRunning) do
        begin
          fR := CountColorTolerance(395675, srchBox.x1, srchBox.y1, srchBox.x2, srchBox.y2, 15);
          fG := CountColorTolerance(1695663, srchBox.x1, srchBox.y1, srchBox.x2, srchBox.y2, 15);
          if(Red and not(gG > 8)) then
            Result := (fR > 20) else
          if(not(fR > 5)) then
            Result := (fG > 35);
          if(Result) then
            Break;
        end;
      end;
    • InvFull:
      Location: /Core/Inventory.simba
      Reason: Shorter lines with minimal performance impact.

      Simba Code:
      function InvFull: Boolean;
      begin
        Result := InvCount = 28;
      end;
    • DropArray:
      Location: /Core/Inventory.simba
      Reason: There is a possible runtime error (out of range) in the current implementation. Also, removed unnecessary array randomisation (should be left up to the user/another method).
      Simba Code:
      procedure DropArray(const AInvSlots: TIntegerArray);
      var
        I, arrHi: Integer;
      begin
        arrHi := High(AInvSlots);
        for I := Low(AInvSlots) to arrHi do
          DropItem(AInvSlots[I]);
      end;
    • FindFlag2:
      Location: /Core/Flag.simba
      Reason: No need to waste precious CPU cycles copying and creating bitmaps from memory, changing Simba's focus window, etc, when we have Freeze and Unfreeze
      Simba Code:
      function FindFlag2(var X, Y: Integer): Boolean;
      var
        TPA: TPointArray;
        arrHi, I: Integer;
      begin
        Result := False;
        Freeze;
        FindColors(TPA, $10000, MMX1, MMY1, MMX2, MMY2);
        FilterPointsDist(TPA, 0, 75.5, (MMX2 - MMX1) shr 1, (MMY2 - MMY1) shr 1);
        arrHi := High(TPA);
        for I := 0 to arrHi do
          if((GetColor(TPA[I].X - 1, TPA[I].Y - 1) and GetColor(TPA[I].X, TPA[I].Y - 1)) = 6381921) then
          begin
            Result := True;
            X := TPA[I].X;
            Y := TPA[I].Y;
            Break;
          end;
        Unfreeze;
      end;
    • FindObjTPAMulti and FindObjTPA:
      Location: /Core/Object.simba
      Reason: Perhaps replace everything in FindObjTPA with one call to FindObjTPAMulti (or rename it to Ex), for consistency?
    • stats_Form:
      Location: /Core/GlobalStats.simba
      Reason: Cut all the crap and just use InputQuery/MessageBox.
    • GetColorsBox:
      Location: /Core/Color.simba
      Reason: Just added an 'and' to the conditional statement. Not really necessary, though.
      Simba Code:
      function GetColorsBox(x1, y1, x2, y2: Integer; ClearSameColors: Boolean): TIntegerArray;
      begin
        Result := GetColors(TPAFromBox(IntToBox(x1, y1, x2, y2)));
        if (ClearSameColors and (Length(Result) > 0)) then
          ClearSameIntegers(Result);
      end;
    • ReturnTPAExceptColours:
      Location: /Core/Color.simba
      Reason: Documentation error. Wrong example provided. Change 'InverseColors' to 'ReturnTPAExceptColors'.
    • GetColorArrayInfo & GetBestColor & CreateAutoColorInfo & SRL_GetBlackBackground:
      Location: /Core/Color.simba
      Reason: Move to AutoColor.simba?
    • Bitmaps.simba:
      Do these even still work? They're all from '09. Does anybody ever use these anyway?
    • ClosePinScreen:
      Location: /Core/Bank.simba
      Reason: Kinda unsafe (?) waiting 'exactly' 500ms before every mouse action. Also improved performance by not making as many calls to PinScreen.
      Simba Code:
      function ClosePinScreen: Boolean;
      var
        exitTime: Cardinal;
      begin
        exitTime := GetTimeRunning + 10000;
        while (PinScreen and (exitTime > GetTimeRunning)) do
        begin
          MouseBox(332, 258, 489, 281, mouse_Left);
          Sleep(400 + Random(300));
        end;

        Result := (not(exitTime > GetTimeRunning));
      end;
    • DepositItemBox:
      Location: /Core/Bank.simba
      Documentation error: "surround" should be "around" or "of".


    I'll browse through more files in-depth tomorrow to see what I could find, but just skimming through this is what I could see.

    Night night

    Regards,
    ~ Daniel.
    Last edited by Daniel; 08-09-2012 at 10:56 AM.
    You may contact me with any concerns you have.
    Are you a victim of harassment? Please notify me or any other staff member.

    | SRL Community Rules | SRL Live Help & Chat | Setting up Simba | F.A.Q's |

  2. #2
    Join Date
    Feb 2007
    Location
    PA, USA
    Posts
    5,240
    Mentioned
    36 Post(s)
    Quoted
    496 Post(s)

    Default

    Hey man, work is appreciated. thanks!

  3. #3
    Join Date
    Nov 2011
    Location
    England
    Posts
    3,072
    Mentioned
    296 Post(s)
    Quoted
    1094 Post(s)

    Default

    Nice work, just with the multi mouse I believe SPS uses it, so you might want to make sure it doesn't interfere with that :P

  4. #4
    Join Date
    Feb 2012
    Location
    UK
    Posts
    909
    Mentioned
    10 Post(s)
    Quoted
    191 Post(s)

    Default

    Good job, looking forward to you go through them tomorrow.

  5. #5
    Join Date
    Oct 2011
    Location
    UK
    Posts
    1,322
    Mentioned
    2 Post(s)
    Quoted
    1 Post(s)

    Default

    These changes look good, but I disagree with InvFull, the way that it is will check less inventory spots than your method if the inventory isn't full (unless it is only the last spot)

  6. #6
    Join Date
    Dec 2011
    Posts
    414
    Mentioned
    0 Post(s)
    Quoted
    18 Post(s)

    Default

    Thanks for the awesome work man!

    Much appreciated, changes look awesome.

  7. #7
    Join Date
    Dec 2006
    Location
    Sydney, New South Wales, Australia
    Posts
    4,603
    Mentioned
    15 Post(s)
    Quoted
    42 Post(s)

    Default

    Quote Originally Posted by Ollybest View Post
    Nice work, just with the multi mouse I believe SPS uses it, so you might want to make sure it doesn't interfere with that :P
    Why would SPS use MultiMouse? :s

    I know MSI does, as its stated in the header above the method. But, the current implementation literally does not wait between clicks.

    Quote Originally Posted by putonajonny View Post
    These changes look good, but I disagree with InvFull, the way that it is will check less inventory spots than your method if the inventory isn't full (unless it is only the last spot)
    The colour finding methods in Simba are fast enough to not cause really any negative performance impact
    Last edited by Daniel; 08-09-2012 at 02:23 AM.
    You may contact me with any concerns you have.
    Are you a victim of harassment? Please notify me or any other staff member.

    | SRL Community Rules | SRL Live Help & Chat | Setting up Simba | F.A.Q's |

  8. #8
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    Quote Originally Posted by Daniel View Post
    The colour finding methods in Simba are fast enough to not cause really any negative performance impact
    I agree with putonajonny. Just did a simple test:


    With an empty inventory, it takes 63 more milliseconds to execute ur function. If a script checks for InvFull constantly (like calling it in a loop) it may have quite an impact on performance (which may be crucial on some scripts, such as a mining script). So i think it's not worth the costs to simplify the function.

    Appreciate your works though, especially the MultiMouse which i use occasionally but never actually look into it and realize that there isn't any waits b/w clicks

  9. #9
    Join Date
    Dec 2006
    Location
    Sydney, New South Wales, Australia
    Posts
    4,603
    Mentioned
    15 Post(s)
    Quoted
    42 Post(s)

    Default

    Quote Originally Posted by riwu View Post
    Just did a simple test:
    Ah, very good, PascalScript user
    You may contact me with any concerns you have.
    Are you a victim of harassment? Please notify me or any other staff member.

    | SRL Community Rules | SRL Live Help & Chat | Setting up Simba | F.A.Q's |

  10. #10
    Join Date
    Feb 2012
    Location
    Wonderland
    Posts
    1,988
    Mentioned
    41 Post(s)
    Quoted
    272 Post(s)

    Default

    Quote Originally Posted by Daniel View Post
    Ah, very good, PascalScript user
    (I think this is a hint @ lape use)
    ((Which will support Simba in the near future; as well as provide overall more speed))
    Maybe ^.^

  11. #11
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    Quote Originally Posted by Le Jingle View Post
    (I think this is a hint @ lape use)
    ((Which will support Simba in the near future; as well as provide overall more speed))
    Maybe ^.^
    I sure hope so. I'd love multi-threading.

    I have just a couple modifications to add to the SRL compass angle-finding.

    Here's a more accurate way of finding CompassAngleRadians:
    Simba Code:
    Function rs_GetCompassAngleRadians: Extended;
    var
      TPA: TPointArray;
      T: TPoint;
      B: TBox;
    begin
      B := IntToBox(524, 5, 562, 43);
      with B do
        FindColorsSpiralTolerance(T.x, T.y, TPA, 65536, x1, y1, x2, y2, 0);
      if Length(TPA) < 1 then
       Exit;
      T := MiddleTPA(TPA);
      Result := ArcTan2(-(T.Y - 24), T.X - 543) + Radians(90);
      Result := fixRad(Result - Pi);
    end;

    And personally I think finding the CompassAngleDegrees should be rounded, like so:
    Simba Code:
    function rs_GetCompassAngleDegrees: Integer;
    begin
      Result := Round(Degrees(rs_GetCompassAngleRadians()));
    end;


    Oh yeah, one more thing, here's the updated version of Ixilisi's rotated SPS walking that should now walk correctly at all four angles with, roughly, 20 degrees tolerance to each (N/S/E/W).
    Simba Code:
    (*
    SPS ~ SRL Positioning System
    ============================

    Concept and original work done by marpis @ SRL-Forums.

    *)


    {$loadlib sps}

    const
      // Path where all the SPS files are
      SPS_IMG_PATH = IncludePath + 'SPS\img\';
      SPS_IMG_FMT  = '.png';

      // Surfaces
      RUNESCAPE_SURFACE = 0;
      RUNESCAPE_SURFACE_FOLDER = 'runescape_surface\';

      RUNESCAPE_OTHER = 1;
      RUNESCAPE_OTHER_FOLDER = 'runescape_other\';

    // SPS Global variables
    var
      SPS_Debug, SPS_MultiMouse: boolean;
      SPS_Areas: TStringArray;
      SPS_AreaMaps: T3DIntegerArray; // Grids of the combined SPS_Areas
      SPS_Tolerance, SPS_MatchesPercent: extended;
      SPS_Accuracy: integer; // Splits minimap/areas into squares of this side length; used for area recognition

    // Returns an image of the minimap in a TMufasaBitmap
    function SPS_GatherMinimap: TMufasaBitmap;
    var
      c: TClient;
      bCopy: TMufasaBitmap;
    begin
      try

        bCopy := TMufasaBitmap.create;
          bCopy.SetSize(150, 150);

        Result := TMufasaBitmap.Create;
        Result.SetSize(150, 150);

        c := getTClient;
        Result.CopyClientToBitmap(
            c.IOManager, false, 0, 0, MMCX-75, MMCY-75, MMCX+75, MMCY+75
          );
        Result.RotateBitmap(-rs_GetCompassAngleRadians,bCopy);
        Result.Free;
        Result := bCopy;

      except
        Writeln('SPS_GatherMinimap ERROR: '+ExceptionToString(ExceptionType, ExceptionParam));
      end;
    end;

    // Gets the starting area coordinates depending on the area image
    procedure SPS_GetAreaCoords(Area: string; var x, y: integer);
    var
      p: integer;
    begin
      // if it's a specific dungeon map (i.e. name isn't 0_0, 10_2, etc.)
      if (length(getNumbers(Area)) < 2) then
      begin
        x := 0;
        y := 0;
        Exit;
      end;

      p := pos('_', Area);

      x := StrToIntDef(copy(Area, 1, p - 1), -1);
      y := StrToIntDef(copy(Area, p + 1, Length(Area) - p), -1);

      //writeln('SPS_GetAreaCoords: '+toStr(point(x, y)));
    end;

    // Converts a point from a map piece to a point on the entire map
    function SPS_LocalToGlobal(Area: string; x, y: integer): TPoint;
    var
      cx, cy: integer;
    begin
      SPS_GetAreaCoords(Area, cx, cy);
      Result.x := (cx * 400) + x;
      Result.y := (cy * 400) + y;
    end;

    // Converts a point from the entire map to a point on the main screen
    function SPS_GlobalToLocal(x, y: integer): TPoint;
    var
      cx, cy: integer;
    begin
      cx := Floor(x / 400);
      cy := Floor(y / 400);

      Result.x := x - (cx * 400);
      Result.y := y - (cy * 400);
    end;

    // Returns the coordinates (x, y) in the form of a string
    function SPS_AreaCoordsToString(x, y: integer): string;
    begin
      Result := IntToStr(x)+'_'+IntToStr(y);
    end;

    // Author: Coh3n
    // Returns a TPA of the areas' values
    function SPS_TPAFromAreas(areas: TStringArray): TPointArray;
    var
      i: integer;
    begin
      setLength(result, length(areas));

      for i := 0 to high(areas) do
        SPS_GetAreaCoords(areas[i], result[i].x, result[i].y);
    end;

    // Author: Coh3n
    // Sorts the areas by columns, and sorts each column by rows
    // Example: ['1_5', '1_3', '0_5'] results ['0_5', '1_3', '1_5']
    function SPS_SortAreas(areas: TStringArray): TStringArray;
    var
      i, j: integer;
      tpa: TPointArray;
    begin
      setLength(tpa, length(areas));

      tpa := SPS_TPAFromAreas(areas);
      clearDoubleTPA(tpa);

      sortTPAByX(tpa, true); // first sort by column number

      // then sort the Y values for each column number
      for i := 0 to high(tpa) do
        for j := i to high(tpa) do
          if (tpa[i].x = tpa[j].x) then
            if (tpa[i].y > tpa[j].y) then
              tSwap(tpa[i], tpa[j]);

      setLength(result, length(tpa));

      for i := 0 to high(tpa) do
        result[i] := SPS_AreaCoordsToString(tpa[i].x, tpa[i].y);

      //writeln('SPS_SortAreas: '+toStr(result));
    end;

    // Loads the "Area" image
    function SPS_GetArea(Area: string; surface: integer): TMufasaBitmap;
    var
      x, y: integer;
      S: string;
    begin
      SPS_GetAreaCoords(Area, x, y);

      case surface of
        RUNESCAPE_SURFACE: s := RUNESCAPE_SURFACE_FOLDER;
        RUNESCAPE_OTHER: s := RUNESCAPE_OTHER_FOLDER;
      end;

      try
          Result := TMufasaBitmap.Create;
            Result.LoadFromFile(SPS_IMG_PATH + s + Area + SPS_IMG_FMT);
      except
        Writeln('SPS_GetArea ERROR: '+ExceptionToString(ExceptionType, ExceptionParam));
      end;
    end;

    // Author: Coh3n
    // Merges the SPS 'areas' into one bitmap (makes more more accurate GetMyPos)
    function SPS_MergeAreas(areas: TStringArray): TMufasaBitmap;
    var
      t, i, l, x, y, diffX, diffY, newWidth, newHeight: integer;
      startPoint: TPoint;
      newAreas: TStringArray;
      xVals, yVals: TIntegerArray;
      bmpTemp: TMufasaBitmap;
      tmpTPA: TPointArray;
    begin
      if (length(areas) <= 0) then
        exit;

      t := getSystemTime();

      // sort the areas from by columns/rows; remove duplicates
      newAreas := SPS_SortAreas(areas);
      l := length(newAreas);

      // if there's only one area in the array
      if (l = 1) then
      begin
        result := SPS_GetArea(areas[0], RUNESCAPE_SURFACE);
        exit;
      end;

      // get the x and y values for each area
      setLength(xVals, l);
      setLength(yVals, l);

      for i := 0 to high(newAreas) do
        SPS_GetAreaCoords(newAreas[i], xVals[i], yVals[i]);

      // get the lowest Y value so we can calculate the starting point to draw the first image
      tmpTPA := SPS_TPAFromAreas(newAreas);
      sortTPAByY(tmpTPA, true);

      try
        result := TMufasaBitmap.create();

        // calculate the starting point
        // x is always 0 because of how the areas are sorted
        // y is relative to the lowest y value in the areas
        SPS_GetAreaCoords(newAreas[0], x, y);
        startPoint.x := 0;
        startPoint.y := ((y - tmpTPA[0].y) * 400);

        // draw the first area to the starting point on the bitmap
        bmpTemp := SPS_GetArea(newAreas[0], RUNESCAPE_SURFACE);
        result.SetSize(bmpTemp.width, bmpTemp.height + startPoint.y);
        bmpTemp.fastDrawTransparent(startPoint.x, startPoint.y, result);
        bmpTemp.free();

        // loop through each area, drawing them to the result bitmap
        // coordinates are calculated relative to the first area drawn (areas[0])
        for i := 0 to (l - 2) do
        begin
          diffX := (xVals[i + 1] - xVals[0]);
          diffY := (yVals[i + 1] - yVals[0]);

          newWidth := 500 + (round(abs(diffX)) * 400);
          newHeight := 500 + (round(abs(diffY)) * 400);

          // only set the size if the width or height is increasing
          if (newWidth > result.width) then
            result.setSize(newWidth, result.height);

          if (newHeight > result.height) then
            result.setSize(result.width, newHeight);

          // copy the area image to the resulting bitmap
          bmpTemp := SPS_GetArea(newAreas[i + 1], RUNESCAPE_SURFACE);
          bmpTemp.fastDrawTransparent(startPoint.x + (diffX * 400 + 1),
                                      startPoint.y + (diffY * 400 + 1), result);
          bmpTemp.free();
        end;

        //result.saveToFile('C:/Simba/test.bmp');
      except
        Writeln('SPS_MergeAreas ERROR: '+ExceptionToString(ExceptionType, ExceptionParam));
      end;

      if (SPS_Debug) then
        writeln('SPS_MergeAreas: Merged areas in '+toStr(getSystemTime - t)+' ms.');
    end;

    // Author: Coh3n
    // Returns an SPS area of lowest x and y value. Used for calculating the
    // player's correct position
    function SPS_GetTopLeftCoords(areas: TStringArray): string;
    var
      tpa: TPointArray;
    begin
      tpa := SPS_TPAFromAreas(areas);

      if (length(tpa) <= 0) then
      begin
        result := '0_0';
        exit;
      end;

      sortTPAByX(tpa, true);
      result := toStr(tpa[0].x);

      sortTPAByY(tpa, true);
      result := result + '_'+toStr(tpa[0].y);

      //writeln('SPS_GetTopLeftCoords: '+result);
    end;

    // SPS2
    function SPS_GetMyPos(): TPoint;
    var
      Minimap: TMufasaBitmap;
      SmallMap: T3DIntegerArray;
      t, FoundMatches: integer;
      P: TPoint;
      Searches: extended;
    begin
      Result := Point(-1, -1);

      if (not LoggedIn) then
        Exit;

      if (SPS_Tolerance < 1.0) then
        SPS_Tolerance := 600.0;

      if (SPS_MatchesPercent = 0.0) then
        SPS_MatchesPercent := 0.35;

      //if (inRange(round(rs_GetCompassAngleDegrees), 10, 350)) then
        //MakeCompass('N');

      t := getSystemTime();

      Minimap := SPS_GatherMinimap;
      SPS_FilterMinimap(Minimap);
      //DrawBitmapDebugImg(Minimap.Index);
      //DisplayDebugImgWindow(150, 150);

      {$IFDEF SIMBAMAJOR990}
      SetLength(SmallMap, 0); // Using this instead of SmallMap := [];
      SPS_BitmapToMap(Minimap, SPS_Accuracy, SmallMap);
      {$ELSE}
      SmallMap := [];
      SmallMap := SPS_BitmapToMap(Minimap, SPS_Accuracy);
      {$ENDIF}

      FoundMatches := SPS_FindMapInMap(P.x, P.y, SPS_AreaMaps, SmallMap, SPS_Tolerance);
      Searches := ((Minimap.Width / SPS_Accuracy) * (Minimap.Height / SPS_Accuracy));
    {
      writeln('fx: '+toStr(p.x)+' ~ on area: '+toStr(P.X * SPS_Accuracy + (Minimap.Width / 2)));
      writeln('fy: '+toStr(p.y)+' ~ on area: '+toStr(P.Y * SPS_Accuracy + (Minimap.Width / 2)));
      writeln('matches: '+toStr(foundMatches));
      writeln('searches: '+toStr(searches));
      writeln('percent: '+toStr(FoundMatches / Searches));
    }

      if ((FoundMatches / Searches) > SPS_MatchesPercent) then
        Result := SPS_LocalToGlobal(SPS_GetTopLeftCoords(SPS_Areas), // the top left of the total area
                                    P.x * SPS_Accuracy + (Minimap.Width / 2),
                                    P.y * SPS_Accuracy + (Minimap.Width / 2));

      Minimap.Free;

      t := (GetSystemTime - t);
      if (SPS_Debug) then
        Writeln('SPS_GetMyPos: Finished in '+ToStr(t)+' ms. Result = '+ToStr(Result));
    end;

    // Finds position P in minimap by checking your own location
    function SPS_PosToMM(P: TPoint): TPoint;
    var
      MyPos: TPoint;
    begin
      if not LoggedIn then
        Exit;

      Result := Point(-1, -1);
      MyPos := SPS_GetMyPos;

      if (Distance(MyPos.X, MyPos.Y, P.X, P.Y) < 75) then
        Result := Point(MMCX + P.X - MyPos.X, MMCY + P.Y - MyPos.Y);
    end;

    // Walks to position, P.
    function SPS_WalkToPos(P: TPoint): boolean;
    var
      MM: TPoint;
    begin
      if not LoggedIn then
        Exit;

      MM := SPS_PosToMM(P);

      if (MM.X > 0) then
      begin
        if (SPS_MultiMouse) then
          MultiMouse(MM.X, MM.Y, 25, 3, false)
        else
          Mouse(MM.X, MM.Y, 0, 0, mouse_Left);

        if WaitFunc(@IsMoving, 1, 3000 + random(500)) then
          while IsMoving do
            Flag;

        Result := True;
      end;
    end;

    // Returns true if the point "Pt" is on the minimap
    function SPS_PosOnMM(Pt: TPoint): Boolean;
    var
      p: TPoint;
    begin
      p := SPS_PosToMM(Pt);
      Result := rs_OnMinimap(p.x, p.y);
    end;

    // Walks the path "Path"; always walks to the furthest point possible
    function SPS_WalkPath(Path: TPointArray): boolean;
    var
      I, H, T, D: integer;
      P, MM: TPoint;
      A: Extended;
    begin
      H := High(Path);
      T := GetSystemTime + 20000 + Random(5000);

      while (not Result) and (GetSystemTime < T) do
      begin
        RunEnergy(20);

        P := SPS_GetMyPos;
        for I := H downto 0 do
        begin
          A := -rs_GetCompassAngleRadians;
          MM.X :=  Round(MMCX + ((Path[I].X - P.X)*cos(A))-((Path[I].Y - P.Y)*sin(A)));
          MM.Y :=  Round(MMCY + ((Path[I].X - P.X)*sin(A))+((Path[I].Y - P.Y)*cos(A)));

          D := Distance(MM.X, MM.Y, MMCX, MMCY);

          if (D < 10) then
            break
          else
            if (D < 70) then
            begin
              if (SPS_MultiMouse) then
                MultiMouse(MM.X, MM.Y, 25, 3, false)
              else
                Mouse(MM.X, MM.Y, 5, 5, mouse_Left);

              FFlag(Integer(I <> H) * 15);

              T := getSystemTime + 20000 + Random(1000);
                Break;
            end;
        end;

        Result := (I = H);
      end;
    end;

    // Walks blindly from the player's current position to the point T
    function SPS_BlindWalk(P: TPoint): Boolean;
    var
      Tries: Integer;
      M: TPoint;
      ctrlPoints: TPointArray;
    begin
      repeat
        M := SPS_GetMyPos;

        if (Length(ctrlPoints) = 0) then
          ctrlPoints := TPABetweenPoints(Point(M.X, M.Y),  RotatePoint(Point(P.X, P.Y), rs_GetCompassAngleRadians, MMCX, MMCY), 20 + Random(15), 10);

        Inc(Tries);
        if (Tries > 20) then
          Exit;

        Result := SPS_WalkPath(ctrlPoints);
      until(Result);
    end;

    // Sets up SPS; needs to be called if you want to switch RS surfaces
    function SPS_Setup(surface: integer; areas: TStringArray): boolean;
    var
      t: integer;
      tmp: TMufasaBitmap;
    begin
      t := getSystemTime;

      SPS_MultiMouse := true;
      SPS_Accuracy := 4;

      if (length(areas) > 0) then
      begin
        if (surface = RUNESCAPE_SURFACE) then
          tmp := SPS_MergeAreas(areas) // combine the SPS areas into 1; makes for a more accurate read
        else
          if (surface = RUNESCAPE_OTHER) then
            if (length(areas) = 1) then
              tmp := SPS_GetArea(areas[0], surface)
            else begin
              writeln('SPS_Setup(): Invalid dungeon areas. You can only select one!');
              exit;
            end;

        result := true;
        {$IFDEF SIMBAMAJOR990}
        SPS_BitmapToMap(tmp, SPS_Accuracy, SPS_AreaMaps);
        {$ELSE}
        SPS_AreaMaps := SPS_BitmapToMap(tmp, SPS_Accuracy);
        {$ENDIF}

        if (surface = RUNESCAPE_SURFACE) then
          SPS_Areas := SPS_SortAreas(areas)
        else
          if (surface = RUNESCAPE_OTHER) then
            SPS_Areas := areas;

        tmp.free();

      end else
        writeln('SPS_Setup(): ERROR: SPS areas are not set!');

      t := (getSystemTime - t);

      if (SPS_Debug) and (result) then
        writeln('[SPS] SPS_Setup() took '+toStr(t)+' ms. Areas: '+toStr(SPS_Areas));
    end;

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


  12. #12
    Join Date
    Dec 2006
    Location
    Sydney, New South Wales, Australia
    Posts
    4,603
    Mentioned
    15 Post(s)
    Quoted
    42 Post(s)

    Default

    Quote Originally Posted by Flight View Post
    I'd love multi-threading.
    No multi-threading in La-pe
    You may contact me with any concerns you have.
    Are you a victim of harassment? Please notify me or any other staff member.

    | SRL Community Rules | SRL Live Help & Chat | Setting up Simba | F.A.Q's |

  13. #13
    Join Date
    Oct 2006
    Location
    Netherlands
    Posts
    3,285
    Mentioned
    105 Post(s)
    Quoted
    494 Post(s)

    Default

    Quote Originally Posted by putonajonny View Post
    These changes look good, but I disagree with InvFull, the way that it is will check less inventory spots than your method if the inventory isn't full (unless it is only the last spot)
    Maybe someone could do a performance check with Freeze and Unfreeze.
    Working on: Tithe Farmer

  14. #14
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    Quote Originally Posted by masterBB View Post
    Maybe someone could do a performance check with Freeze and Unfreeze.
    Freeze & Unfreeze are faster; but remember that it will make a copy of the entire screen. So you should more than say two findcolors in a smaller area to experience a positive performance impact.



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  15. #15
    Join Date
    Oct 2006
    Location
    Netherlands
    Posts
    3,285
    Mentioned
    105 Post(s)
    Quoted
    494 Post(s)

    Default

    Quote Originally Posted by Wizzup? View Post
    Freeze & Unfreeze are faster; but remember that it will make a copy of the entire screen. So you should more than say two findcolors in a smaller area to experience a positive performance impact.
    I was already afraid of that. But Daniel his function will always look 28 spots. So I wasn't sure about 28 small areas opposed to 1 big area.
    Working on: Tithe Farmer

  16. #16
    Join Date
    Dec 2006
    Location
    Sydney, New South Wales, Australia
    Posts
    4,603
    Mentioned
    15 Post(s)
    Quoted
    42 Post(s)

    Default

    Added some more (read FindFlag2 and onwards).

    Quote Originally Posted by masterBB View Post
    I was already afraid of that. But Daniel his function will always look 28 spots. So I wasn't sure about 28 small areas opposed to 1 big area.
    I was just redoing it Nonetheless though, the current implementation inside of SRL will *always* be faster due to is making less calls to FindColor. Although, it really is negligible.
    Last edited by Daniel; 08-09-2012 at 11:01 AM.
    You may contact me with any concerns you have.
    Are you a victim of harassment? Please notify me or any other staff member.

    | SRL Community Rules | SRL Live Help & Chat | Setting up Simba | F.A.Q's |

  17. #17
    Join Date
    Dec 2011
    Location
    The Netherlands
    Posts
    1,631
    Mentioned
    47 Post(s)
    Quoted
    254 Post(s)

    Default

    All the painting options are 50 px off because of the new RS navigation bar. Would be appreciated if you could add +50 to each Y coordinate. Or set the Client Area differently or something.

    Script source code available here: Github

  18. #18
    Join Date
    Dec 2006
    Location
    Sydney, New South Wales, Australia
    Posts
    4,603
    Mentioned
    15 Post(s)
    Quoted
    42 Post(s)

    Default

    Quote Originally Posted by J J View Post
    All the painting options are 50 px off because of the new RS navigation bar. Would be appreciated if you could add +50 to each Y coordinate. Or set the Client Area differently or something.
    Simba now has the ability to copy a portion of the window to form a new client. SetupSRL should fix this (unless it has not been implemented yet? If not, it will be soon)
    You may contact me with any concerns you have.
    Are you a victim of harassment? Please notify me or any other staff member.

    | SRL Community Rules | SRL Live Help & Chat | Setting up Simba | F.A.Q's |

  19. #19
    Join Date
    Dec 2011
    Location
    The Netherlands
    Posts
    1,631
    Mentioned
    47 Post(s)
    Quoted
    254 Post(s)

    Default

    Quote Originally Posted by Daniel View Post
    Simba now has the ability to copy a portion of the window to form a new client. SetupSRL should fix this (unless it has not been implemented yet? If not, it will be soon)
    My script does use SetupSRL but the painting wasn't correct.
    Unless I forgot to setup something. I've added the script.

    Script source code available here: Github

  20. #20
    Join Date
    Nov 2011
    Location
    England
    Posts
    3,072
    Mentioned
    296 Post(s)
    Quoted
    1094 Post(s)

    Default

    Quote Originally Posted by J J View Post
    My script does use SetupSRL but the painting wasn't correct.
    Unless I forgot to setup something. I've added the script.
    I spoke to brandon about this and he said he would send a pull request to fix it, no idea how far it is though being fixed though.

    Quote Originally Posted by Daniel View Post
    Why would SPS use MultiMouse? :s

    I know MSI does, as its stated in the header above the method. But, the current implementation literally does not wait between clicks.
    I cant actually find the sps_multimouse function (somehow) but I believe it does infact use multimouse in it, and it is still being used SPS_MultiMouse := true; It uses it because alot of people spam click the minimap when walking

    Another thing, If you want to update something else please go though the open bank functions, I know alot of them dont work (colours etc need updateing)/Some arent even used.
    Last edited by Olly; 08-09-2012 at 12:48 PM.

  21. #21
    Join Date
    Dec 2006
    Location
    Sydney, New South Wales, Australia
    Posts
    4,603
    Mentioned
    15 Post(s)
    Quoted
    42 Post(s)

    Default

    Quote Originally Posted by Ollybest View Post
    Another thing, If you want to update something else please go though the open bank functions, I know alot of them dont work (colours etc need updateing)/Some arent even used.
    Can you list which ones don't work?
    You may contact me with any concerns you have.
    Are you a victim of harassment? Please notify me or any other staff member.

    | SRL Community Rules | SRL Live Help & Chat | Setting up Simba | F.A.Q's |

  22. #22
    Join Date
    Nov 2011
    Location
    England
    Posts
    3,072
    Mentioned
    296 Post(s)
    Quoted
    1094 Post(s)

    Default

    Quote Originally Posted by Daniel View Post
    Can you list which ones don't work?
    Il go though them all eventually (testing them) and will edit this post, but il start with the ones i know of:

    OpenBankQuiet - Uses a bitmap to open the bank, have never seen this being used also uses no mouse randomisation Doesn't currently work it hovers over players somehow. I think it should be removed totally from SRL since there are tons of better way to find a bank.

    OpenBankGlass - Uses the glass to find bank, Doesn't currently work I think it should be removed because glass changes colour alot + semi transparent depending on when your standing + sometimes you can't even see the glass.

    OpenBankNPC - Works fine, use it in my script and have no problems with it.

    OpenBankFast - This is one needs alot of updating although alot of banks do currently work(mostly colour wise maybe the whole function?). Alot of the newer "updated" areas in rs have bank counters now and this messes the function up quite alot so it would be nice to have
    a new function "openbankbooth" and "openbankcounter"

    OpenBankChestEdge - Works fine all locations

    OpenBankChest - Works fine all locations

    OpenBank - Just loops though all the above for the set location.
    Last edited by Olly; 08-09-2012 at 06:21 PM.

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
  •