Results 1 to 14 of 14

Thread: Problem with ACA

  1. #1
    Join Date
    Apr 2012
    Posts
    32
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default Problem with ACA

    Hey guys,
    I started to script with simba about a year ago but had to stop cuz of to less time.
    So these week i started again and got a problem with ACA.

    I just wounder if theres another similar method for getting the coords of an moving NPC? becouse the color of my NPC is too much like the surroundings

    any idea will help
    thanks

  2. #2
    Join Date
    Sep 2012
    Location
    Here.
    Posts
    2,007
    Mentioned
    88 Post(s)
    Quoted
    1014 Post(s)

    Default

    Could you post a picture of the npc and surrounding area? I'm sure we could still come up with a color solution

  3. #3
    Join Date
    Apr 2012
    Posts
    32
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default



    edit:
    i know there are fighting scripts but its just for learning and thanks for your time :P

  4. #4
    Join Date
    Sep 2012
    Location
    Here.
    Posts
    2,007
    Mentioned
    88 Post(s)
    Quoted
    1014 Post(s)

    Default

    Which animal seems to have a conflicting color with the surrounding area? The brown cow seems a little close to the surrounding fence, but I don't really see anything that should be very difficult with color here. Could you be more specific with which animal and perhaps the code you're trying to use?

  5. #5
    Join Date
    Apr 2012
    Posts
    32
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    the cows are the troublemakers... so it seems to be my stupidness that i cant use ACA right? everytime i try to get a good color the fence and building in background gets colored red too... heres my code:

    Code:
    program Tests;
    {DEFINE SMART}
    {$i srl/srl.simba}
    {$i sps/sps.simba}
    
    function toCow:Boolean;
    Var
      cowPath : TPointArray;
    begin
      WriteLn('Waling to cows..');
      SPS_Setup(RUNESCAPE_SURFACE, ['8_7']);
    
      cowPath :=  [Point(3295, 2932), Point(3314, 2933), Point(3326, 2933), Point(3342, 2934), Point(3354, 2936), Point(3367, 2939), Point(3380, 2943), Point(3392, 2941), Point(3410, 2941), Point(3424, 2939), Point(3435, 2928), Point(3447, 2919), Point(3459, 2906), Point(3469, 2897), Point(3474, 2883), Point(3454, 2882)];
      SPS_WalkPath(cowPath);
      WriteLn('..at cows');
      Result := True;
    end;
    
    function fightCow:Boolean;
    Var
      i, x, y: Integer;
    begin
      if (FindObj(x, y, 'ow', CowColor, 1))
      or (FindObj(x, y, 'ow', CowColor, 1)) then
        begin
          Mouse(x, y, 2, 2, true);
          wait(6000);
        end;
    end;
    
    function CowColor: Integer;
    var
      arP: TPointArray;
      arC: TIntegerArray;
      tmpCTS, i, arL: Integer;
      X, Y, Z: Extended;
    begin
      tmpCTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.15, 2.94);
    
      FindColorsSpiralTolerance(MSCX, MSCY, arP, 11851240, MSX1, MSY1, MSX2, MSY2, 16);
      if (Length(arP) = 0) then
      begin
      //  Writeln('Failed to find the color, no result.');
        ColorToleranceSpeed(tmpCTS);
        SetColorSpeed2Modifiers(0.2, 0.2);
        Exit;
      end;
    
      arC := GetColors(arP);
      ClearSameIntegers(arC);
      arL := High(arC);
    
      for i := 0 to arL do
      begin
        ColorToXYZ(arC[i], X, Y, Z);
    
        if (X >= 37.93) and (X <= 90.11) and (Y >= 40.15) and (Y <= 94.53) and (Z >= 38.98) and (Z <= 93.61) then
        begin
          Result := arC[i];
      //    Writeln('AutoColor = ' + IntToStr(arC[i]));
          Break;
        end;
      end;
    
      ColorToleranceSpeed(tmpCTS);
      SetColorSpeed2Modifiers(0.2, 0.2);
    
      if (i = arL + 1) then
       // Writeln('AutoColor failed in finding the color.');
    end;
    
    
    
    begin
      SetupSRL;
    //  toCow;
      repeat
      fightCow;
      until(InvCount = 28);
    end.
    EDIT: OLD VERSION! function cowcolor needs to be above fight cow sry :P

  6. #6
    Join Date
    Sep 2012
    Location
    Here.
    Posts
    2,007
    Mentioned
    88 Post(s)
    Quoted
    1014 Post(s)

    Default

    Ah, I wouldn't use FindObj at all (besides, it takes a color, not a function )
    Since you're still using ACA to create a lot of your functions, I would make a couple of quick suggestions that should help out. Instead of adding all the brown colors of the cow, just add pixels one at a time (and check) and delete any that start to add in the fence and/or building. You don't need the entire cow to turn out a "red" match for it to work, you just need a good chunk of him. Also, there should be an option in one of the make functions to add an "uptext" check. At that point you can enter your 'ow' and the function it creates will not only find those groupings of brown, but it will also move the mouse over them until it matches that uptext so it knows the cow is the correct one. Then you could entirely remove your findobj and just have something more like:
    Simba Code:
    if(CowColor)then
    begin
      ClickMouse2(mouse_right);
      WaitOption('ttac', 600);
    end;//and now it's attacking the cow!

  7. #7
    Join Date
    Apr 2012
    Posts
    32
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Thanks for the quick answer Kevin. I will try it out now and will tell you if it worked :P thanks


    EDIT:
    cuz of your help i could get the script to kill the light brown cow.. still checks other items often but its a beginning. i cant find a colour from calf or dark brown cow which isnt used in another object. Changed my Code to
    Code:
    program Tests;
    {$DEFINE SMART}
    {$i srl/srl.simba}
    {$i sps/sps.simba}
    
    var
      x, y: Integer;
    
    function toCow:Boolean;
    Var
      cowPath : TPointArray;
    begin
      WriteLn('Waling to cows..');
      SPS_Setup(RUNESCAPE_SURFACE, ['8_7']);
    
      cowPath :=  [Point(3295, 2932), Point(3314, 2933), Point(3326, 2933), Point(3342, 2934), Point(3354, 2936), Point(3367, 2939), Point(3380, 2943), Point(3392, 2941), Point(3410, 2941), Point(3424, 2939), Point(3435, 2928), Point(3447, 2919), Point(3459, 2906), Point(3469, 2897), Point(3474, 2883), Point(3454, 2882)];
      SPS_WalkPath(cowPath);
      WriteLn('..at cows');
      Result := True;
    end;
    
    function CowColor(var fx, fy: Integer): Boolean;
    var
      arP, arAP: TPointArray;
      arC, arUC: TIntegerArray;
      ararP: T2DPointArray;
      tmpCTS, i, j, arL, arL2: Integer;
      P: TPoint;
      X, Y, Z: Extended;
    begin
      tmpCTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.05, 0.60);
    
      if not(FindColorsTolerance(arP, 6057091, MSX1, MSY1, MSX2, MSY2, 18)) then
      begin
        Writeln('Failed to find the color, no object found.');
        ColorToleranceSpeed(tmpCTS);
        SetColorSpeed2Modifiers(0.2, 0.2);
        Exit;
      end;
    
      arC := GetColors(arP);
      arUC := arC;
      ClearSameIntegers(arUC);
      arL := High(arUC);
      arL2 := High(arC);
    
      for i := 0 to arL do
      begin
        ColorToXYZ(arC[i], X, Y, Z);
    
        if (X >= 5.84) and (X <= 32.09) and (Y >= 5.89) and (Y <= 32.89) and (Z >= 4.95) and (Z <= 30.65) then
        begin
          for j := 0 to arL2 do
          begin
            if (arUC[i] = arC[j]) then
            begin
              SetLength(arAP, Length(arAP) + 1);
              arAP[High(arAP)] := arP[j];
            end;
          end;
        end;
      end;
    
      SortTPAFrom(arAP, Point(MSCX, MSCY));
      ararP := SplitTPAEx(arAP, 10, 10);
      arL := High(ararP);
    
      for i := 0 to arL do
      begin
        if (Length(ararP[i]) < 10) then Continue;
        P := MiddleTPA(ararP[i]);
        MMouse(P.x, P.y, 5, 5);
        Wait(100 + Random(100));
        if (IsUpText('ow')) then
        begin;
          Result := True;
          Break;
        end;
      end;
    
      ColorToleranceSpeed(tmpCTS);
      SetColorSpeed2Modifiers(0.2, 0.2);
    
      if (i = arL + 1) then
      begin
        Writeln('FindObject could not find object.');
        Exit;
      end;
    
      GetMousePos(fx, fy);
    end;
    
    
    function fightCow:Boolean;
    var
      x, y : Integer;
    begin
      if(CowColor(x, y)) then
      begin
        ClickMouse2(mouse_right);
        WaitOption('ttac',600);
      end;
    end;
    
    
    
    
    begin
      ClearDebug();
      SetupSRL;
    //  toCow;
      repeat
      fightCow;
      until(InvCount = 28);
    end.
    maybe you could help me one more time find an more effektive way? i think i understood the main thing but just cant figure out how to amke it flawless :/
    Last edited by schnubbel15; 05-21-2013 at 05:51 PM.

  8. #8
    Join Date
    Mar 2007
    Posts
    393
    Mentioned
    1 Post(s)
    Quoted
    98 Post(s)

    Default

    I think those cows have too different colors to set them all to one color and tolerance..
    Maybe take one color for each cow (these are not right colors):

    Simba Code:
    Hue := [0.01, 0.24, 0.56];
    Sat := [1.16, 0.18, 0.65];
    Col  := [1027552, 11250867, 12425252];
    Tol  := [10, 7, 11];

  9. #9
    Join Date
    Sep 2012
    Location
    Here.
    Posts
    2,007
    Mentioned
    88 Post(s)
    Quoted
    1014 Post(s)

    Default

    Another option is to add a limit for pixel count (that way you only see items/monsters of a certain size).
    Simba Code:
    for i := 0 to arL do
      begin
        if (Length(ararP[i]) < 50) then Continue;//10 is really small, almost a dot to the eye.  50 is a decent size, and if you stuck with all colors of a brown cow, perhaps 200 or more.  play with this number a little to find a decent area.

  10. #10
    Join Date
    Apr 2012
    Posts
    32
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    i have improved my script a bit (kinda messy)
    Code:
    program Tests;
    {$DEFINE SMART}
    {$i srl/srl.simba}
    {$i sps/sps.simba}
    
    var
      x, y, x2, y2: Integer;
    
    function toCow:Boolean;
    Var
      cowPath : TPointArray;
    begin
      WriteLn('Waling to cows..');
      SPS_Setup(RUNESCAPE_SURFACE, ['8_7']);
    
      cowPath :=  [Point(3295, 2932), Point(3314, 2933), Point(3326, 2933), Point(3342, 2934), Point(3354, 2936), Point(3367, 2939), Point(3380, 2943), Point(3392, 2941), Point(3410, 2941), Point(3424, 2939), Point(3435, 2928), Point(3447, 2919), Point(3459, 2906), Point(3469, 2897), Point(3474, 2883), Point(3454, 2882)];
      SPS_WalkPath(cowPath);
      WriteLn('..at cows');
      Result := True;
    end;
    
    function Cow1(var fx, fy: Integer): Boolean;
    var
      arP, arAP: TPointArray;
      arC, arUC: TIntegerArray;
      ararP: T2DPointArray;
      tmpCTS, i, j, arL, arL2: Integer;
      P: TPoint;
      X, Y, Z: Extended;
    begin
      tmpCTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.04, 0.80);
    
      if not(FindColorsTolerance(arP, 6912398, MSX1, MSY1, MSX2, MSY2, 10)) then
      begin
        Writeln('Failed to find the color, no object found.');
        ColorToleranceSpeed(tmpCTS);
        SetColorSpeed2Modifiers(0.2, 0.2);
        Exit;
      end;
    
      arC := GetColors(arP);
      arUC := arC;
      ClearSameIntegers(arUC);
      arL := High(arUC);
      arL2 := High(arC);
    
      for i := 0 to arL do
      begin
        ColorToXYZ(arC[i], X, Y, Z);
    
        if (X >= 13.27) and (X <= 29.27) and (Y >= 13.02) and (Y <= 30.07) and (Z >= 9.19) and (Z <= 27.94) then
        begin
          for j := 0 to arL2 do
          begin
            if (arUC[i] = arC[j]) then
            begin
              SetLength(arAP, Length(arAP) + 1);
              arAP[High(arAP)] := arP[j];
            end;
          end;
        end;
      end;
    
      SortTPAFrom(arAP, Point(MSCX, MSCY));
      ararP := SplitTPAEx(arAP, 10, 10);
      arL := High(ararP);
    
      for i := 0 to arL do
      begin
        if (Length(ararP[i]) < 10) then Continue;
        P := MiddleTPA(ararP[i]);
        MMouse(P.x, P.y, 5, 5);
        Wait(100 + Random(100));
        if (IsUpText('ow')) then
        begin;
          Result := True;
          Break;
        end;
      end;
    
      ColorToleranceSpeed(tmpCTS);
      SetColorSpeed2Modifiers(0.2, 0.2);
    
      if (i = arL + 1) then
      begin
        Writeln('FindObject could not find object.');
        Exit;
      end;
    
      GetMousePos(fx, fy);
    end;
    
    function Cow2(var fx, fy: Integer): Boolean;
    var
      arP, arAP: TPointArray;
      arC, arUC: TIntegerArray;
      ararP: T2DPointArray;
      tmpCTS, i, j, arL, arL2: Integer;
      P: TPoint;
      X, Y, Z: Extended;
    begin
      tmpCTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.16, 2.63);
    
      if not(FindColorsTolerance(arP, 3559506, MSX1, MSY1, MSX2, MSY2, 3)) then
      begin
        Writeln('Failed to find the color, no object found.');
        ColorToleranceSpeed(tmpCTS);
        SetColorSpeed2Modifiers(0.2, 0.2);
        Exit;
      end;
    
      arC := GetColors(arP);
      arUC := arC;
      ClearSameIntegers(arUC);
      arL := High(arUC);
      arL2 := High(arC);
    
      for i := 0 to arL do
      begin
        ColorToXYZ(arC[i], X, Y, Z);
    
        if (X >= 5.93) and (X <= 7.62) and (Y >= 6.50) and (Y <= 8.31) and (Z >= 3.39) and (Z <= 6.07) then
        begin
          for j := 0 to arL2 do
          begin
            if (arUC[i] = arC[j]) then
            begin
              SetLength(arAP, Length(arAP) + 1);
              arAP[High(arAP)] := arP[j];
            end;
          end;
        end;
      end;
    
      SortTPAFrom(arAP, Point(MSCX, MSCY));
      ararP := SplitTPAEx(arAP, 10, 10);
      arL := High(ararP);
    
      for i := 0 to arL do
      begin
        if (Length(ararP[i]) < 10) then Continue;
        P := MiddleTPA(ararP[i]);
        MMouse(P.x, P.y, 5, 5);
        Wait(100 + Random(100));
        if (IsUpText('ow')) then
        begin;
          Result := True;
          Break;
        end;
      end;
    
      ColorToleranceSpeed(tmpCTS);
      SetColorSpeed2Modifiers(0.2, 0.2);
    
      if (i = arL + 1) then
      begin
        Writeln('FindObject could not find object.');
        Exit;
      end;
    
      GetMousePos(fx, fy);
    end;
    
    function Cow3(var fx, fy: Integer): Boolean;
    var
      arP, arAP: TPointArray;
      arC, arUC: TIntegerArray;
      ararP: T2DPointArray;
      tmpCTS, i, j, arL, arL2: Integer;
      P: TPoint;
      X, Y, Z: Extended;
    begin
      tmpCTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.03, 0.57);
    
      if not(FindColorsTolerance(arP, 5800871, MSX1, MSY1, MSX2, MSY2, 5)) then
      begin
        Writeln('Failed to find the color, no object found.');
        ColorToleranceSpeed(tmpCTS);
        SetColorSpeed2Modifiers(0.2, 0.2);
        Exit;
      end;
    
      arC := GetColors(arP);
      arUC := arC;
      ClearSameIntegers(arUC);
      arL := High(arUC);
      arL2 := High(arC);
    
      for i := 0 to arL do
      begin
        ColorToXYZ(arC[i], X, Y, Z);
    
        if (X >= 20.87) and (X <= 30.08) and (Y >= 20.54) and (Y <= 29.62) and (Z >= 11.23) and (Z <= 15.95) then
        begin
          for j := 0 to arL2 do
          begin
            if (arUC[i] = arC[j]) then
            begin
              SetLength(arAP, Length(arAP) + 1);
              arAP[High(arAP)] := arP[j];
            end;
          end;
        end;
      end;
    
      SortTPAFrom(arAP, Point(MSCX, MSCY));
      ararP := SplitTPAEx(arAP, 10, 10);
      arL := High(ararP);
    
      for i := 0 to arL do
      begin
        if (Length(ararP[i]) < 10) then Continue;
        P := MiddleTPA(ararP[i]);
        MMouse(P.x, P.y, 5, 5);
        Wait(100 + Random(100));
        if (IsUpText('ow')) then
        begin;
          Result := True;
          Break;
        end;
      end;
    
      ColorToleranceSpeed(tmpCTS);
      SetColorSpeed2Modifiers(0.2, 0.2);
    
      if (i = arL + 1) then
      begin
        Writeln('FindObject could not find object.');
        Exit;
      end;
    
      GetMousePos(fx, fy);
    end;
    
    function Cow4(var fx, fy: Integer): Boolean;
    var
      arP, arAP: TPointArray;
      arC, arUC: TIntegerArray;
      ararP: T2DPointArray;
      tmpCTS, i, j, arL, arL2: Integer;
      P: TPoint;
      X, Y, Z: Extended;
    begin
      tmpCTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.36, 0.43);
    
      if not(FindColorsTolerance(arP, 4149075, MSX1, MSY1, MSX2, MSY2, 2)) then
      begin
        Writeln('Failed to find the color, no object found.');
        ColorToleranceSpeed(tmpCTS);
        SetColorSpeed2Modifiers(0.2, 0.2);
        Exit;
      end;
    
      arC := GetColors(arP);
      arUC := arC;
      ClearSameIntegers(arUC);
      arL := High(arUC);
      arL2 := High(arC);
    
      for i := 0 to arL do
      begin
        ColorToXYZ(arC[i], X, Y, Z);
    
        if (X >= 6.56) and (X <= 7.86) and (Y >= 7.01) and (Y <= 8.43) and (Z >= 5.40) and (Z <= 6.38) then
        begin
          for j := 0 to arL2 do
          begin
            if (arUC[i] = arC[j]) then
            begin
              SetLength(arAP, Length(arAP) + 1);
              arAP[High(arAP)] := arP[j];
            end;
          end;
        end;
      end;
    
      SortTPAFrom(arAP, Point(MSCX, MSCY));
      ararP := SplitTPAEx(arAP, 10, 10);
      arL := High(ararP);
    
      for i := 0 to arL do
      begin
        if (Length(ararP[i]) < 10) then Continue;
        P := MiddleTPA(ararP[i]);
        MMouse(P.x, P.y, 5, 5);
        Wait(100 + Random(100));
        if (IsUpText('ow')) then
        begin;
          Result := True;
          Break;
        end;
      end;
    
      ColorToleranceSpeed(tmpCTS);
      SetColorSpeed2Modifiers(0.2, 0.2);
    
      if (i = arL + 1) then
      begin
        Writeln('FindObject could not find object.');
        Exit;
      end;
    
      GetMousePos(fx, fy);
    end;
    
    function Cow5(var fx, fy: Integer): Boolean;
    var
      arP, arAP: TPointArray;
      arC, arUC: TIntegerArray;
      ararP: T2DPointArray;
      tmpCTS, i, j, arL, arL2: Integer;
      P: TPoint;
      X, Y, Z: Extended;
    begin
      tmpCTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.16, 0.43);
    
      if not(FindColorsTolerance(arP, 8490646, MSX1, MSY1, MSX2, MSY2, 3)) then
      begin
        Writeln('Failed to find the color, no object found.');
        ColorToleranceSpeed(tmpCTS);
        SetColorSpeed2Modifiers(0.2, 0.2);
        Exit;
      end;
    
      arC := GetColors(arP);
      arUC := arC;
      ClearSameIntegers(arUC);
      arL := High(arUC);
      arL2 := High(arC);
    
      for i := 0 to arL do
      begin
        ColorToXYZ(arC[i], X, Y, Z);
    
        if (X >= 23.75) and (X <= 28.47) and (Y >= 24.88) and (Y <= 29.68) and (Z >= 22.60) and (Z <= 26.79) then
        begin
          for j := 0 to arL2 do
          begin
            if (arUC[i] = arC[j]) then
            begin
              SetLength(arAP, Length(arAP) + 1);
              arAP[High(arAP)] := arP[j];
            end;
          end;
        end;
      end;
    
      SortTPAFrom(arAP, Point(MSCX, MSCY));
      ararP := SplitTPAEx(arAP, 10, 10);
      arL := High(ararP);
    
      for i := 0 to arL do
      begin
        if (Length(ararP[i]) < 10) then Continue;
        P := MiddleTPA(ararP[i]);
        MMouse(P.x, P.y, 5, 5);
        Wait(100 + Random(100));
        if (IsUpText('ow')) then
        begin;
          Result := True;
          Break;
        end;
      end;
    
      ColorToleranceSpeed(tmpCTS);
      SetColorSpeed2Modifiers(0.2, 0.2);
    
      if (i = arL + 1) then
      begin
        Writeln('FindObject could not find object.');
        Exit;
      end;
    
      GetMousePos(fx, fy);
    end;
    
    function Cow6(var fx, fy: Integer): Boolean;
    var
      arP, arAP: TPointArray;
      arC, arUC: TIntegerArray;
      ararP: T2DPointArray;
      tmpCTS, i, j, arL, arL2: Integer;
      P: TPoint;
      X, Y, Z: Extended;
    begin
      tmpCTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.36, 0.31);
    
      if not(FindColorsTolerance(arP, 3885132, MSX1, MSY1, MSX2, MSY2, 3)) then
      begin
        Writeln('Failed to find the color, no object found.');
        ColorToleranceSpeed(tmpCTS);
        SetColorSpeed2Modifiers(0.2, 0.2);
        Exit;
      end;
    
      arC := GetColors(arP);
      arUC := arC;
      ClearSameIntegers(arUC);
      arL := High(arUC);
      arL2 := High(arC);
    
      for i := 0 to arL do
      begin
        ColorToXYZ(arC[i], X, Y, Z);
    
        if (X >= 4.97) and (X <= 7.33) and (Y >= 5.28) and (Y <= 7.72) and (Z >= 4.11) and (Z <= 5.97) then
        begin
          for j := 0 to arL2 do
          begin
            if (arUC[i] = arC[j]) then
            begin
              SetLength(arAP, Length(arAP) + 1);
              arAP[High(arAP)] := arP[j];
            end;
          end;
        end;
      end;
    
      SortTPAFrom(arAP, Point(MSCX, MSCY));
      ararP := SplitTPAEx(arAP, 10, 10);
      arL := High(ararP);
    
      for i := 0 to arL do
      begin
        if (Length(ararP[i]) < 10) then Continue;
        P := MiddleTPA(ararP[i]);
        MMouse(P.x, P.y, 5, 5);
        Wait(100 + Random(100));
        if (IsUpText('ow')) then
        begin;
          Result := True;
          Break;
        end;
      end;
    
      ColorToleranceSpeed(tmpCTS);
      SetColorSpeed2Modifiers(0.2, 0.2);
    
      if (i = arL + 1) then
      begin
        Writeln('FindObject could not find object.');
        Exit;
      end;
    
      GetMousePos(fx, fy);
    end;
    
    function Cow7(var fx, fy: Integer): Boolean;
    var
      arP, arAP: TPointArray;
      arC, arUC: TIntegerArray;
      ararP: T2DPointArray;
      tmpCTS, i, j, arL, arL2: Integer;
      P: TPoint;
      X, Y, Z: Extended;
    begin
      tmpCTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.06, 0.27);
    
      if not(FindColorsTolerance(arP, 3755606, MSX1, MSY1, MSX2, MSY2, 3)) then
      begin
        Writeln('Failed to find the color, no object found.');
        ColorToleranceSpeed(tmpCTS);
        SetColorSpeed2Modifiers(0.2, 0.2);
        Exit;
      end;
    
      arC := GetColors(arP);
      arUC := arC;
      ClearSameIntegers(arUC);
      arL := High(arUC);
      arL2 := High(arC);
    
      for i := 0 to arL do
      begin
        ColorToXYZ(arC[i], X, Y, Z);
    
        if (X >= 6.16) and (X <= 8.47) and (Y >= 6.53) and (Y <= 8.98) and (Z >= 4.29) and (Z <= 5.86) then
        begin
          for j := 0 to arL2 do
          begin
            if (arUC[i] = arC[j]) then
            begin
              SetLength(arAP, Length(arAP) + 1);
              arAP[High(arAP)] := arP[j];
            end;
          end;
        end;
      end;
    
      SortTPAFrom(arAP, Point(MSCX, MSCY));
      ararP := SplitTPAEx(arAP, 10, 10);
      arL := High(ararP);
    
      for i := 0 to arL do
      begin
        if (Length(ararP[i]) < 10) then Continue;
        P := MiddleTPA(ararP[i]);
        MMouse(P.x, P.y, 5, 5);
        Wait(100 + Random(100));
        if (IsUpText('ow')) then
        begin;
          Result := True;
          Break;
        end;
      end;
    
      ColorToleranceSpeed(tmpCTS);
      SetColorSpeed2Modifiers(0.2, 0.2);
    
      if (i = arL + 1) then
      begin
        Writeln('FindObject could not find object.');
        Exit;
      end;
    
      GetMousePos(fx, fy);
    end;
    
    function fightCow:Boolean;
    var
      x, y : Integer;
    begin
      if(Cow1(x, y) or Cow2(x,y) or Cow3(x,y) or Cow4(x, y) or Cow5(x, y) or Cow6(x, y)) then
      begin
        ClickMouse2(mouse_right);
        WaitOption('ttac',600);
        Sleep(Random(2000));
      end;
    end;
    
    function Hide(var fx, fy: Integer): Boolean;
    var
      arP, arAP: TPointArray;
      arC, arUC: TIntegerArray;
      ararP: T2DPointArray;
      tmpCTS, i, j, arL, arL2: Integer;
      P: TPoint;
      H, S, L: Extended;
      X, Y, Z: Extended;
    begin
      tmpCTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(1);
    
      if not(FindColorsTolerance(arP, 15198706, MSX1, MSY1, MSX2, MSY2, 19)) then
      begin
        Writeln('Failed to find the color, no object found.');
        ColorToleranceSpeed(tmpCTS);
        Exit;
      end;
    
      arC := GetColors(arP);
      arUC := arC;
      ClearSameIntegers(arUC);
      arL := High(arUC);
      arL2 := High(arC);
    
      for i := 0 to arL do
      begin
        ColorToHSL(arC[i], H, S, L);
    
        if (H >= 0.00) and (H <= 7.60) and (S >= 16.65) and (S <= 73.35) and (L >= 88.22) and (L <= 97.08) then
        begin
          ColorToXYZ(arC[i], X, Y, Z);
    
          if (X >= 72.18) and (X <= 88.30) and (Y >= 75.28) and (Y <= 90.82) and (Z >= 78.40) and (Z <= 96.88) then
          begin
            for j := 0 to arL2 do
            begin
              if (arUC[i] = arC[j]) then
              begin
                SetLength(arAP, Length(arAP) + 1);
                arAP[High(arAP)] := arP[j];
              end;
            end;
          end;
        end;
      end;
    
      SortTPAFrom(arAP, Point(MSCX, MSCY));
      ararP := SplitTPAEx(arAP, 10, 10);
      arL := High(ararP);
    
      for i := 0 to arL do
      begin
        if (Length(ararP[i]) < 10) then Continue;
        P := MiddleTPA(ararP[i]);
        MMouse(P.x, P.y, 5, 5);
        Wait(100 + Random(100));
        if (IsUpText('Take')) then
        begin;
          Result := True;
          Break;
        end;
      end;
    
      ColorToleranceSpeed(tmpCTS);
    
      if (i = arL + 1) then
      begin
        Writeln('FindObject could not find object.');
        Exit;
      end;
    
      GetMousePos(fx, fy);
    end;
    
    function FindTheHide:Boolean;
    var
      x, y : Integer;
    begin
      if(Hide(x, y)) then
      begin
        ClickMouse2(mouse_right);
        WaitOption('owhide',600);
      end;
    end;
    
    
    begin
      ClearDebug();
      SetupSRL;
    //  toCow;
      repeat
     // FindTheHide;
      fightCow;
      until(InvCount = 28);
    end.
    it "works" from time to time it buggs and i think i need to recreate the colours again (some points seems to be not on cows again..) could you explain how the limit for pixel count work? its doesnt make sense to me right now

  11. #11
    Join Date
    Sep 2012
    Location
    Here.
    Posts
    2,007
    Mentioned
    88 Post(s)
    Quoted
    1014 Post(s)

    Default

    A "limit" on the pixel count would be like saying "is this grouping of pixels I'm checking smaller than I think it should be? Then don't even bother looking at it."

    So normally that for loop just loops through every grouping of pixels that match your color and tolerance, but by adding that little line you can add a limit and say "No, you're too small, I know you're wrong and I don't even want to look at you and instead I wanna check out the bigger groups!"

    :P

  12. #12
    Join Date
    Apr 2012
    Posts
    32
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    that sounds good, but im still confused in how do i use it exactly?

    nvm i think i found it but still having the problem with the tolerance for the colors.. cows keep changing their skin
    Last edited by schnubbel15; 05-21-2013 at 10:17 PM.

  13. #13
    Join Date
    Sep 2012
    Location
    Here.
    Posts
    2,007
    Mentioned
    88 Post(s)
    Quoted
    1014 Post(s)

    Default

    Quote Originally Posted by schnubbel15 View Post
    that sounds good, but im still confused in how do i use it exactly?

    nvm i think i found it but still having the problem with the tolerance for the colors.. cows keep changing their skin
    Raise the tolerance, but also raise the required minimum pixels?

  14. #14
    Join Date
    Apr 2012
    Posts
    32
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    EDIT: ok i got it to work pretty well thanks for your help guys if anyone is interested in the code:

    Code:
    program Tests;
    //{$DEFINE SMART}
    {$i srl/srl.simba}
    {$i sps/sps.simba}
    
    var
      x, y, x2, y2: Integer;
    
    function toCow:Boolean;
    Var
      cowPath : TPointArray;
    begin
      WriteLn('Waling to cows..');
      SPS_Setup(RUNESCAPE_SURFACE, ['8_7']);
    
      cowPath :=  [Point(3295, 2932), Point(3314, 2933), Point(3326, 2933), Point(3342, 2934), Point(3354, 2936), Point(3367, 2939), Point(3380, 2943), Point(3392, 2941), Point(3410, 2941), Point(3424, 2939), Point(3435, 2928), Point(3447, 2919), Point(3459, 2906), Point(3469, 2897), Point(3474, 2883), Point(3454, 2882)];
      SPS_WalkPath(cowPath);
      WriteLn('..at cows');
      Result := True;
    end;
    
    function cow1(var fx, fy: Integer): Boolean;
    var
      arP, arAP: TPointArray;
      arC, arUC: TIntegerArray;
      ararP: T2DPointArray;
      tmpCTS, i, j, arL, arL2: Integer;
      P: TPoint;
      X, Y, Z: Extended;
    begin
      tmpCTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.38, 0.35);
    
      if not(FindColorsTolerance(arP, 8226963, MSX1, MSY1, MSX2, MSY2, 6)) then
      begin
        Writeln('Failed to find the color, no object found.');
        ColorToleranceSpeed(tmpCTS);
        SetColorSpeed2Modifiers(0.2, 0.2);
        Exit;
      end;
    
      arC := GetColors(arP);
      arUC := arC;
      ClearSameIntegers(arUC);
      arL := High(arUC);
      arL2 := High(arC);
    
      for i := 0 to arL do
      begin
        ColorToXYZ(arC[i], X, Y, Z);
    
        if (X >= 19.19) and (X <= 30.56) and (Y >= 20.06) and (Y <= 31.41) and (Z >= 18.17) and (Z <= 29.27) then
        begin
          for j := 0 to arL2 do
          begin
            if (arUC[i] = arC[j]) then
            begin
              SetLength(arAP, Length(arAP) + 1);
              arAP[High(arAP)] := arP[j];
            end;
          end;
        end;
      end;
    
      SortTPAFrom(arAP, Point(MSCX, MSCY));
      ararP := SplitTPAEx(arAP, 10, 10);
      arL := High(ararP);
    
      for i := 0 to arL do
      begin
        if (Length(ararP[i]) < 100) then Continue;
        P := MiddleTPA(ararP[i]);
        MMouse(P.x, P.y, 5, 5);
        Wait(100 + Random(100));
        if (IsUpText('ow')) then
        begin;
          Result := True;
          Break;
        end;
      end;
    
      ColorToleranceSpeed(tmpCTS);
      SetColorSpeed2Modifiers(0.2, 0.2);
    
      if (i = arL + 1) then
      begin
        Writeln('FindObject could not find object.');
        Exit;
      end;
    
      GetMousePos(fx, fy);
    end;
    
    function cow2(var fx, fy: Integer): Boolean;
    var
      arP, arAP: TPointArray;
      arC, arUC: TIntegerArray;
      ararP: T2DPointArray;
      tmpCTS, i, j, arL, arL2: Integer;
      P: TPoint;
      X, Y, Z: Extended;
    begin
      tmpCTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.45, 2.01);
    
      if not(FindColorsTolerance(arP, 3624532, MSX1, MSY1, MSX2, MSY2, 4)) then
      begin
        Writeln('Failed to find the color, no object found.');
        ColorToleranceSpeed(tmpCTS);
        SetColorSpeed2Modifiers(0.2, 0.2);
        Exit;
      end;
    
      arC := GetColors(arP);
      arUC := arC;
      ClearSameIntegers(arUC);
      arL := High(arUC);
      arL2 := High(arC);
    
      for i := 0 to arL do
      begin
        ColorToXYZ(arC[i], X, Y, Z);
    
        if (X >= 5.04) and (X <= 8.95) and (Y >= 5.32) and (Y <= 9.83) and (Z >= 3.25) and (Z <= 5.97) then
        begin
          for j := 0 to arL2 do
          begin
            if (arUC[i] = arC[j]) then
            begin
              SetLength(arAP, Length(arAP) + 1);
              arAP[High(arAP)] := arP[j];
            end;
          end;
        end;
      end;
    
      SortTPAFrom(arAP, Point(MSCX, MSCY));
      ararP := SplitTPAEx(arAP, 10, 10);
      arL := High(ararP);
    
      for i := 0 to arL do
      begin
        if (Length(ararP[i]) < 100) then Continue;
        P := MiddleTPA(ararP[i]);
        MMouse(P.x, P.y, 5, 5);
        Wait(100 + Random(100));
        if (IsUpText('ow')) then
        begin;
          Result := True;
          Break;
        end;
      end;
    
      ColorToleranceSpeed(tmpCTS);
      SetColorSpeed2Modifiers(0.2, 0.2);
    
      if (i = arL + 1) then
      begin
        Writeln('FindObject could not find object.');
        Exit;
      end;
    
      GetMousePos(fx, fy);
    end;
    
    function fightCow:Boolean;
    var
      x, y : Integer;
    begin
      if(cow1(x, y) or cow2(x, y))then
        begin
             ClickMouse2(mouse_right);
             WaitOption('ttac',600);
             Sleep(4000);
          end;
    end;
    
    begin
      ClearDebug();
      SetupSRL;
    //  toCow;
      repeat
      fightCow;
      until(InvCount = 28);
    end.
    Last edited by schnubbel15; 05-22-2013 at 09:32 AM.

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
  •