Results 1 to 9 of 9

Thread: Simba SRL5 RS3 InvBox

  1. #1
    Join Date
    Jul 2012
    Posts
    113
    Mentioned
    7 Post(s)
    Quoted
    34 Post(s)

    Default Simba SRL5 RS3 InvBox


    It uses red and blue tiles in the inventory to find which size the window is and where the slots are.
    .---. ``````````` .---. .
    \___ `,-. ,-. ,-. \___ ·|- ,-. ,-
    ``` \ |-'`,-| | | ``` \ | `,-| |
    `---' `-' `-^ ' ' `---' `' `-^ '

  2. #2
    Join Date
    Mar 2006
    Location
    Belgium
    Posts
    3,564
    Mentioned
    111 Post(s)
    Quoted
    1475 Post(s)

    Default

    share?

    Creds to DannyRS for this wonderful sig!

  3. #3
    Join Date
    Jul 2012
    Posts
    113
    Mentioned
    7 Post(s)
    Quoted
    34 Post(s)

    Default

    Quote Originally Posted by Sjoe View Post
    share?
    You requested it... code is extremely sloppy and has debugging paint in it, but you can easily remove that.
    Simba Code:
    program newprogram;
    {$i SRL/Srl.simba}

    var
      W1, H1, DebugBMP, i: Integer;
      TestBox, Inv: TBox;

    //By Bandland100, modified to shift mouse speeds after every step
    Procedure SuperWindMouse(xs, ys, xe, ye, gravity, wind, minWait, maxWait, maxStep, targetArea: extended);
    Var
      veloX,veloY,windX,windY,veloMag,dist,randomDist,lastDist,step: extended;
      lastX,lastY,MSP,W: integer;
      sqrt2,sqrt3,sqrt5: extended;
    Begin
      MSP  := MouseSpeed;
      sqrt2:= sqrt(2);
      sqrt3:= sqrt(3);
      sqrt5:= sqrt(5);
      While hypot(xs - xe, ys - ye) > 1 Do
      Begin
        dist:= hypot(xs - xe, ys - ye);
        wind:= minE(wind, dist);
        If dist >= targetArea Then
        Begin
          windX:= windX / sqrt3 + (random(round(wind) * 2 + 1) - wind) / sqrt5;
          windY:= windY / sqrt3 + (random(round(wind) * 2 + 1) - wind) / sqrt5;
        End Else
        Begin
          windX:= windX / sqrt2;
          windY:= windY / sqrt2;
          If (maxStep < 3) Then
          Begin
            maxStep:= random(3) + 3.0;
          End Else
          Begin
            maxStep:= maxStep / sqrt5;
          End;
        End;
        veloX:= veloX + windX;
        veloY:= veloY + windY;
        veloX:= veloX + gravity * (xe - xs) / dist;
        veloY:= veloY + gravity * (ye - ys) / dist;
        if hypot(veloX, veloY) > maxStep then
        Begin
          randomDist:= maxStep / 2.0 + random(round(maxStep) div 2);
          veloMag:= sqrt(veloX * veloX + veloY * veloY);
          veloX:= (veloX / veloMag) * randomDist;
          veloY:= (veloY / veloMag) * randomDist;
        End;
        lastX:= Round(xs);
        lastY:= Round(ys);
        xs:= xs + veloX;
        ys:= ys + veloY;

        Case Random(50) Of
          1..25: W := (MSP + (Random((MSP/4))));
          26..50: W := (MSP - (RandomRange((MSP/2), MSP-1)));
        End;
        If (W < 1) Then
          W := 1;

        If (lastX <> Round(xs)) Or (lastY <> Round(ys)) Then
          MoveMouse(Round(xs), Round(ys));

        step:= hypot(xs - lastX, ys - lastY);
        //W := round((maxWait - minWait) * (step / maxStep) + minWait);
        wait(W);
        lastdist:= dist;
      End;

      If (Round(xe) <> Round(xs)) or (Round(ye) <> Round(ys)) Then
        MoveMouse(Round(xe), Round(ye));

      MouseSpeed := MSP;
    End;

    Procedure HumanMMouse(eX, eY, ranX, ranY: Integer);
    Var
      randSpeed: extended;
      X,Y,X2,Y2,j,Dist,MP: integer;
    Begin
      j := MouseSpeed;
      GetMousePos(X, Y);
      Dist := Distance(X, Y, eX, eY);
      MP := Round(Dist/150);
      If MP < 0 Then
        MP := 1;

      randSpeed := (random(MouseSpeed) / 2.0 + MouseSpeed) / 10.0;
      X2 := RandomRange(eX-(j*MP), eX+(j*MP));
      Y2 := RandomRange(eY-(j*MP), eY+(j*MP));
      SuperWindMouse(X, Y, X2, Y2, 11, 8, 10.0 / randSpeed, 12.0 / randSpeed, 10.0 * randSpeed, 10.0 * randSpeed);
      GetMousePos(X, Y);
      MMouse(eX, eY, ranX, ranY);
      MouseSpeed := j;
    End;

    procedure DrawBox(Box: TBox);
    var
      x, y: Integer;
    begin
        for x := Box.x1 to Box.x2 do
        begin
          FastSetPixel(DebugBMP,x,Box.y1,ClYellow)
          FastSetPixel(DebugBMP,x,Box.y2,ClYellow)
        end;
        for y := Box.y1 to Box.y2 do
        begin
          FastSetPixel(DebugBMP,Box.x1,y,ClYellow)
          FastSetPixel(DebugBMP,Box.x2,y,ClYellow)
        end;
    end;

    function FindInv: TBox;
    var
      RedTile, BlueTile, x, y, X1, Y1, X2, Y2: Integer;
      Box, Box2: TBox;
    begin
      RedTile := BitmapFromString(38, 34, 'meJyVV0uP20YMPrWJX5L27fVDlq2HHyPZ3mTtXe9uixTNreceiqAokOSQW3LZLJBf0J/dj+SIGsubFgUIYcSh5huSHzmjzQ9/X7eeNq1vm+Z35brxb7P/Q1pPuybBjXr+eHg6YYnDMx7I81k5q43HA5Lv25+6Nqvz3zeNb4DrnrzonvzYO3sB6fNTpX/+8nAsg8FFw509FMyK8PokibeDs4CGcnjxMuw2IKPLxqjXJLlsVNJrRqLhAWTcb0Eiq3/OuFwBYyw7vGgQYudh6z8ikvJVOmylYVue2cgOrEYlbCc8yNRSDcTYsdepmGeH3eb06Ket9zWLzgQuIZvOfOxNR1inhec86tBz7IlSBOvMoo5MqY3KfNyBQTn2xAD755g0Z8Gbrf91llwS3KAJ4wVLHvuLciyvpJnIa1v1ZA+9nWrnsWvfcc2mETbZnvQb+cmvW/9plvQkVpgtUt9MvCIN8tjLJ+0i8TCARoWnAjwheF1NyRIfuja1T/AKN2EDH4F44z/O4kvAiSO0SHa8zLCOv0x93kDHQM8iQKIU+/8UGK+yAIjwMR0C8e2NRDWkmMtWYUNwWbBMq6+KJDDlIqvsCOLMBrIB2Ki9Isq2FdEcv70JHoGYcaI5qsH+DvdeFQWI69mRi6he1+CWiVckiImvPm5PP8/ZRyAi3Zw4u1v9djWlOKuP5D6LAMFMslDNlhrZoSFqERWBYk7fbE++5NM+uEo+TiiP+omIBHDp7Fy2hKmCI8aDQEFFT4PEK6NNUQVjKaqE+DnPCHHGSkEUH/VbG59qD8fC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atmeaaU3EC5b1YKIRItgQLEJw8iRjTzyME0IlxTVU8Mkf1E6TWdEiMg7LLJnN336k++FIjM1clgvuCUmR34zr2LXCOicrVy6zO5lyN2K0D88UE0GTmKOf2avImMBm509fO+EGkJ1ExBoekxV33pIxDXx57ucuo+VTQLVXFN5C+VACGya+oeCXP+oAmb2RdNwwdtLI7qoy8IsTx08npkMpCPyIuqRCIhoxskUS00sAtJZOYAEWzZ3qw/+izayHz4SPejuPpn7c08qiQGxRQTu2Iv70WkpHOaHUAgfh5dnvjUyelZwrmjTThcsUZEoLjkqZtxK56hrqZTJhheo/cVEA/uh5cnAdC5y6WzF5OqQZ0d8zak2uTWVAyFvmjyeuyWP3pn+du74Yb0Ud7IgquJN3Mb5oTkTnKuxguHYSXOCTHr8foby9/cG1Ae0eUKecwTiuqj9PkztKfqY6BYj03ycD2O5I0MRPh4ZW3AHQBRpXRTvZupNDMb69eO6a+6TNnBkBORcxWI390JrkwjyVXxBoCP/ETE2ZTo+y7XKL1NN7UsihobZDJ9eiC7nCvf8I5A/PqO8BFvV/Gcc+RLQPIqlm8eNNuoJ978pJSrllzC24w6ng0NLbGQgTEVded3K/j3ce31pe/3+59sZRh8+Nbyjc367tXG3rsN/NJg76oam5q9c5rn2oupFkx3Nutbby5//PbifzugMdc=');
      if (FindBitmapToleranceIn(BlueTile, X2, Y2, 0, 0, W1-1, H1-1, 100) and
          FindBitmapToleranceIn(RedTile, X1, Y1, 0, 0, W1-1, H1-1, 70)) then
      begin
        Box := IntToBox(X2,Y2,X2+38,Y2+34);
        Box2 := IntToBox(X1,Y1,X1+38,Y1+34);
        for x := Box.x1 to Box.x2 do
        begin
          FastSetPixel(DebugBMP,x,Box.y1,ClRed)
          FastSetPixel(DebugBMP,x,Box.y2,ClRed)
        end;
        for y := Box.y1 to Box.y2 do
        begin
          FastSetPixel(DebugBMP,Box.x1,y,ClRed)
          FastSetPixel(DebugBMP,Box.x2,y,ClRed)
        end;
        for x := Box2.x1 to Box2.x2 do
        begin
          FastSetPixel(DebugBMP,x,Box2.y1,ClYellow)
          FastSetPixel(DebugBMP,x,Box2.y2,ClYellow)
        end;
        for y := Box2.y1 to Box2.y2 do
        begin
          FastSetPixel(DebugBMP,Box2.x1,y,ClYellow)
          FastSetPixel(DebugBMP,Box2.x2,y,ClYellow)
        end;
        Result.X1 := X1;
        Result.Y1 := Y1;
        Result.X2 := X2;
        Result.Y2 := Y2;
      end;
      FreeBitmap(RedTile);
      FreeBitmap(BlueTile);
    end;

    function InvBox2(X1,Y1,X2,Y2,Item: Integer): TBox;
    var
      x, y, Rows, Cols, RowW, ColW: Integer;
      Box: TBox;
    begin
        Rows := ((Y2 - Y1)/35)+1;
        Cols := ((X2 - X1)/42)+1;
        RowW := ((Y2 - Y1) / (Rows - 1));
        ColW := ((X2 - X1) / (Cols - 1));

        Box.X1 := X1+ 4+ ((Item - 1) mod Cols * ColW);
        Box.Y1 := Y1+ 2+ ((Item - 1) div Cols * RowW);
        Box.X2 := Box.X1 + 34;
        Box.Y2 := Box.Y1 + 30;

        Result := Box;
    end;

    procedure Setup;
    begin
      ClearDebug;
      SetupSRL;
    end;
    Begin
      Setup;
      GetClientDimensions(W1,H1);
      DebugBMP := BitmapFromClient(0,0,W1-1,H1-1);
      Inv := FindInv;
      TestBox := InvBox2(Inv.X1,Inv.Y1,Inv.X2,Inv.Y2,27);
      HumanMMouse( ((TestBox.X2 - TestBox.X1)/2)+TestBox.X1, ((TestBox.Y2 - TestBox.Y1)/2)+TestBox.Y1,
      ((TestBox.X2 - TestBox.X1)/2), ((TestBox.Y2 - TestBox.Y1)/2) );
      //DrawBitmapDebugImg(DebugBMP);
      //DisplayDebugImgWindow(W1-1, H1-1);
      FreeBitmap(DebugBMP);
    End.

    Just remember to set your red tile as the top left tile and your blue tile as the bottom right tile. (Has to be the farthest right tile, if it comes out unevenly)
    Also don't have anything in the slots with the colored tiles or it won't find it. Script was meant to really be calibrated once (Maybe even save them as settings somewhere) and then use the coordinates for all future tasks.
    .---. ``````````` .---. .
    \___ `,-. ,-. ,-. \___ ·|- ,-. ,-
    ``` \ |-'`,-| | | ``` \ | `,-| |
    `---' `-' `-^ ' ' `---' `' `-^ '

  4. #4
    Join Date
    Mar 2006
    Location
    Belgium
    Posts
    3,564
    Mentioned
    111 Post(s)
    Quoted
    1475 Post(s)

    Default

    Sweet mate!

    Creds to DannyRS for this wonderful sig!

  5. #5
    Join Date
    Jun 2012
    Posts
    4,867
    Mentioned
    74 Post(s)
    Quoted
    1663 Post(s)

    Default

    Does it do something like make a TPA of the invslot color and then add a bit to the bounds?



    Simba Code:
    function GetInvBox: TBox;
    var
      InvSlotsTPA: TPointArray;
      tInvBox: TBox;
    begin
      FindColors(InvSlotsTPA, 2234891, 1, 1, 798, 598);
      if (Length(InvSlotsTPA) < 1) then exit;
      tInvBox := GetTPABounds(InvSlotsTPA);
      Result := IntToBox(tInvBox.x1 - 10, tInvBox.y1 - 10, tInvBox.x2 + 10, tInvBox.y2 + 10)
    end;

  6. #6
    Join Date
    Jul 2012
    Posts
    113
    Mentioned
    7 Post(s)
    Quoted
    34 Post(s)

    Default

    Quote Originally Posted by BMWxi View Post
    Does it do something like make a TPA of the invslot color and then add a bit to the bounds?



    Simba Code:
    function GetInvBox: TBox;
    var
      InvSlotsTPA: TPointArray;
      tInvBox: TBox;
    begin
      FindColors(InvSlotsTPA, 2234891, 1, 1, 798, 598);
      if (Length(InvSlotsTPA) < 1) then exit;
      tInvBox := GetTPABounds(InvSlotsTPA);
      Result := IntToBox(tInvBox.x1 - 10, tInvBox.y1 - 10, tInvBox.x2 + 10, tInvBox.y2 + 10)
    end;
    I actually hadn't thought of that, it uses the red and blue tiles that you can set by right clicking.
    .---. ``````````` .---. .
    \___ `,-. ,-. ,-. \___ ·|- ,-. ,-
    ``` \ |-'`,-| | | ``` \ | `,-| |
    `---' `-' `-^ ' ' `---' `' `-^ '

  7. #7
    Join Date
    Jun 2012
    Posts
    4,867
    Mentioned
    74 Post(s)
    Quoted
    1663 Post(s)

    Default

    Quote Originally Posted by SeanStar View Post
    I actually hadn't thought of that, it uses the red and blue tiles that you can set by right clicking.
    Ok, neat idea

  8. #8
    Join Date
    Mar 2013
    Location
    Shaolin
    Posts
    863
    Mentioned
    24 Post(s)
    Quoted
    519 Post(s)

    Default

    I just set the coords of each box in the include... could have been done better, but hey it works and I didn't know how to fix the spacing between slots without setting individual coords/box. This looks interesting but not every single inventory slot has blue and red boxes around it..
    You have permission to steal anything I've ever made...

  9. #9
    Join Date
    Jun 2012
    Posts
    4,867
    Mentioned
    74 Post(s)
    Quoted
    1663 Post(s)

    Default

    Quote Originally Posted by Wu-Tang Clan View Post
    I just set the coords of each box in the include... could have been done better, but hey it works and I didn't know how to fix the spacing between slots without setting individual coords/box. This looks interesting but not every single inventory slot has blue and red boxes around it..
    I didn't need to fix anything except for the MI constants in globals.simba, and updating the Slot1 and Slot6 coords in inventory.simba.

    Also if I understand correctly, what his does is uses the location of the blue and red boxes to get the bounds, which should work fine as long as they're in opposite corners

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
  •