Results 1 to 3 of 3

Thread: Pixel Shift Function

  1. #1
    Join Date
    Nov 2011
    Location
    Australia
    Posts
    418
    Mentioned
    2 Post(s)
    Quoted
    86 Post(s)

    Default Pixel Shift Function

    I'm making a Lobster fisher for ProjectRS06, Since its a RSPS I can't use most of the SRL include of course.
    I tried using Until(not(Fishing)); but it'd still fish.
    So I tried using the pixel shift function, so It could tell when it was fishing or not by the animation.
    Here is what I've done:
    Simba Code:
    program Projectrs06_LobsterFisher;
    {$define srl5}
    {$loadlib sps}
    {$i srl/srl.simba}
    {$i sps/sps.simba}

    var
    full:boolean;
    Lobster, DropLobster, Cage:Integer;

    Procedure DeclareBits;
    begin
    Lobster := BitmapFromString(15, 12, 'meJxlkc8HwnAYxrc/oMMYY2SNSY' +
            'ekRGIaFStNP9RUdOjQJTpEhw6jQ4eIiA6d+md7vnvmNcVjvt7v5/u' +
            '+z/tM1zRd03rjpT+KIZyL3ZNhmMUwcaObN3uiUirVITBWewfp6ROo' +
            '4LQBk3dGV3f6IAwSUlf9M2VUhhAripzcpTNhVYxuqKOV2dzIW7b9h' +
            '73Fy4vfdudg+/tfOH7nYcuy6daoThRMS2FS8AIa1nMJ8CG+VmtLPy' +
            'AhuMoLAGDGgrMzuKiNFq/y+sNBZmOFDhhnB8d8gBk8fZAEhmURKRZ' +
            'hkuJc/YgwEXtmbZ41JJluIW5Jih8ZLcsK8EOCURmSTDHYQ4xkvnfP' +
            'ajk=');


    DropLobster := BitmapFromString(104, 5, 'meJy9VEkOgDAI7NO8+QGv/skfY5' +
            'VIJqw1jRIOdNoMdKAluqy1tm47PdZuE4SXHHcwwdGXg8SFUHBGOFa' +
            '4u1S0jJdUCKrzYhYvmbuT0Q3v6O4mcaJbtGVF4CJf6VbGbmqXczBL' +
            'rsC8bnnTbUmupPO6IU856m5n/9dNNT2/IEr9kW45T/SiFe7+ZshPY' +
            'OqkxQcLi4ZKdbaktb+BO7oljlvRyKnsJzkul7o=');

    Cage := BitmapFromString(116, 8, 'meJy9lFESgzAIRLldL9Df3v8Yqd' +
            'ox3S4Lkqhl/MisG0ieYGtrmNnj+br7saWQq/URJzYW9/7zoXO2mG2' +
            'DOKNzaQfEtvCebpMi7c08gR550DaUk8SIbdeXQFyjuvysHqY0CG5b' +
            'dvLzvZTH9pNJvAd13d6SvnM47NvuGV0nIyPFrB/gLnT3UU9xpip5k' +
            'vz1vq3wxA8xx7aPueyHC9cC76V1ESMuJvoTkUqwdbb38czZXlvXjz' +
            '9ikf+Euj7BFgfT4DAn7+jT6oNFdZ3Or5QuJoIu/huk+/9J5CdDIuY' +
            'V59bftHHfyrqILocj9TcfiHdB');

      end;

     Procedure RiverTroll;
     var
     x, y:Integer;
     begin
     If FindcolorTolerance(x, y, 7966560, 0, 0, 511, 334, 5) then
     writeln('Found Trollarch :D');
     Mouse(584, 61, 5, 5, true);
     writeln('clicked on trollarch');
     wait(15000 + random (1000));
     Mouse(636, 474, 10, 10, true);
     Wait(100);
     Mouse(639, 346, 3, 40, true);
     wait(10);
     WriteLn('River Troll Detected! -logging out');
    end;

    Procedure StartFishing;
    var
      tmpCTS, i, l, r,x,y,counter,failed,Fishing:integer;
      FishTPA:TPointArray;
      begin
        tmpCTS :=GetToleranceSpeed;
        SetColorToleranceSpeed(2);
        SetToleranceSpeed2Modifiers(0.38, 0.87);
        FindColorsTolerance(FishTPA, 15647904, 3, 2, 514, 336, 4);
        SetColorToleranceSpeed(tmpCTS);
        SetToleranceSpeed2Modifiers(0.02, 0.02);

        L:= High(FishTPA);
        marktime(counter);
        for i := 0 to L do
          begin
          r := random(L);
          wait(randomrange(63,202));
          mmouse(FishTPA[r].x, FishTPA[r].y,2,2);
          if WaitUptext('age',300) then
          writeln('found fishing spot');
            Break;
            if TimeFromMark(counter) > 3000 then
              begin
              inc(failed);
              if(failed>10)then;
                Terminatescript;
                writeln('Failed to find spot 10 times');
                break;
              end;
            end;
    GetMousePos(x, y);
    Mouse(x, y, 2, 2, false);
    if FindBitmap(Cage,x,y) then
    MMouse(x, y, 1, 1);
    wait(20);
    Mouse(x, y, 0, 0, true);
    While Fishing Do Wait(200+random(50));
    end;
    Function IsFishing: Boolean;
      var
        PBox: TBox;
      begin
        PBox := IntToBox(245, 130, 285, 195);
        Result := (AveragePixelShift(PBox, 250, 500) > 400);
      end;




    Procedure DropInventory;
    var
    x, y, x2, y2:Integer;
    Begin;
    repeat
    If (FindBitmapToleranceIn(Lobster, x, y, 546, 184, 753, 453, 15)) then
    begin
    wait(10);
    Mouse(x, y, 3, 3, False);
    wait(10);
    if FindBitmapToleranceIn(DropLobster, x2, y2, 546, 184, 753, 453, 15)then
    wait(20);
    MMouse(x, y, 0, 0);
    Mouse(x2, y2, 50, 3, True);
    wait(1000 + Random(100));
    end else
    begin
    Full := False
    DeclareBits;
    StartFishing;
    end;
    until(Full = False)
    end;

      Function Fishing: Boolean;
      var
        PBox: TBox;
      begin
        PBox := IntToBox(245, 130, 285, 195);
        Result := (AveragePixelShift(PBox, 250, 500) > 400);
      end;

    Procedure CheckFull;
    var
    x, y:Integer;
    Begin
    repeat
    DeclareBits;
    If (FindBitmapToleranceIn(Lobster, x, y, 690, 405, 737, 444, 15)) then
    begin
    Full := True
    DropInventory;
    end else;
    begin
    Full := True
    DropInventory;
    end;
    wait(10000 + Random(1000));
    until(Full = True)
    end;

    Procedure Randoms;
    begin
    If(Full = False) then
    repeat
    Rivertroll;
    Wait (10 + random(7000));
    until(Full = True)
    end;



    begin
     ClearDebug;
     SetupSRL;
     While IsFishing Do Wait(200+Random(50));
     StartFishing;
     CheckFull;
     Randoms;
     FreeBitmap(Lobster);
     FreeBitmap(DropLobster);
     FreeBitmap(Cage);
    end.

    I'm getting "Type Mismatch at line 132"(the line where I call the function "While Is Fishing do"). I'm fairly sure I'm not meant to declare the function as a variable in the procedure? I don't know what've I've done wrong here.
    Thanks
    Last edited by Syntax; 01-11-2013 at 05:32 AM.

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

    Default

    You've
    Simba Code:
    While Fishing Do Wait(200+random(50));
    instead, in which Fishing is an integer, hence a type mismatch.

    If it's meant to be 'IsFishing', move that function above 'StartFishing' (or do a forward) and change Fishing to IsFishing.

  3. #3
    Join Date
    Nov 2011
    Location
    Australia
    Posts
    418
    Mentioned
    2 Post(s)
    Quoted
    86 Post(s)

    Default

    Quote Originally Posted by riwu View Post
    You've
    Simba Code:
    While Fishing Do Wait(200+random(50));
    instead, in which Fishing is an integer, hence a type mismatch.

    If it's meant to be 'IsFishing', move that function above 'StartFishing' (or do a forward) and change Fishing to IsFishing.
    Legend.

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
  •