Results 1 to 20 of 20

Thread: How would I make the script Rotate the camera if it doesn't find a color?

  1. #1
    Join Date
    Dec 2011
    Posts
    445
    Mentioned
    26 Post(s)
    Quoted
    256 Post(s)

    Default How would I make the script Rotate the camera if it doesn't find a color?

    This is for a RSPS, I doubt that makes a difference though. I made a script for finding an Ardy knight and Pick'ing it. Sometimes the knight will get stuck behind a tree or building and the bot won't be able to find it. How would I make it rotate the camera if it doesn't find the knight, until it finds it?

    Simba Code:
    // Find and PickPocket Knight \\
    procedure FindKnight;
      var
      X, Y:Integer;
    begin
     if FindColorTolerance(X, Y, KnightColor, 5, 3, 511, 329, 10) then
      begin
          WriteLn('Found Knight');
          MMouse(x, y, 0, 0);
          ClickMouse2(False);
          wait(2000);
          ChooseOption('Pickpocket Knight');
          wait(250);
          WriteLn('Picked Knight');
          inc(PickPockets);
       end;
    end;

  2. #2
    Join Date
    Jul 2012
    Posts
    437
    Mentioned
    10 Post(s)
    Quoted
    165 Post(s)

    Default

    something like below 69 is code for the letter "e". Ill update when I find the arrow key codes.

    else
    begin
    keydown(69);
    wait(500);
    keyup(69);
    end;

  3. #3
    Join Date
    Dec 2011
    Posts
    445
    Mentioned
    26 Post(s)
    Quoted
    256 Post(s)

    Default

    Quote Originally Posted by tealc View Post
    something like below 69 is code for the letter "e". Ill update when I find the arrow key codes.

    else
    begin
    keydown(69);
    wait(500);
    keyup(69);
    end;
    Ahhhh, didn't realize the Else statements works the same way as Java's else..
    I found the list though, http://docs.villavu.com/simba/script...d-virtual-keys

    Thanks

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

    Default

    Quote Originally Posted by Twinki View Post
    Ahhhh, didn't realize the Else statements works the same way as Java's else..
    I found the list though, http://docs.villavu.com/simba/script...d-virtual-keys

    Thanks
    MakeCompass might be easier to use.

    Creds to DannyRS for this wonderful sig!

  5. #5
    Join Date
    Jun 2012
    Location
    Howell, Michigan
    Posts
    1,585
    Mentioned
    34 Post(s)
    Quoted
    553 Post(s)

    Default

    Quote Originally Posted by Twinki View Post
    Ahhhh, didn't realize the Else statements works the same way as Java's else..
    I found the list though, http://docs.villavu.com/simba/script...d-virtual-keys

    Thanks
    Simba Code:
    procedure FindKnight;
      var
      X, Y:Integer;
    begin
     if FindColorTolerance(X, Y, KnightColor, 5, 3, 511, 329, 10) then
      begin
          WriteLn('Found Knight');
          MMouse(x, y, 0, 0);
          ClickMouse2(False);
          wait(2000);
          ChooseOption('Pickpocket Knight');
          wait(250);
          WriteLn('Picked Knight');
          inc(PickPockets);
       end
       else
        CompassMovement( 60, 120, true);
    end;

    That will move the compass a minimum of 60 degrees, max of 120 and return to the original position afterwards, set it to 'false' to stay where it lands.

  6. #6
    Join Date
    Jul 2012
    Posts
    437
    Mentioned
    10 Post(s)
    Quoted
    165 Post(s)

    Default

    He said its for a private server will those compass functions still work?

  7. #7
    Join Date
    Dec 2011
    Posts
    445
    Mentioned
    26 Post(s)
    Quoted
    256 Post(s)

    Default

    Quote Originally Posted by tealc View Post
    He said its for a private server will those compass functions still work?
    Well the RSPS is just like EoC, well right before it was launched basically. I'll try both

  8. #8
    Join Date
    Dec 2011
    Posts
    445
    Mentioned
    26 Post(s)
    Quoted
    256 Post(s)

    Default

    Quote Originally Posted by King View Post
    Simba Code:
    procedure FindKnight;
      var
      X, Y:Integer;
    begin
     if FindColorTolerance(X, Y, KnightColor, 5, 3, 511, 329, 10) then
      begin
          WriteLn('Found Knight');
          MMouse(x, y, 0, 0);
          ClickMouse2(False);
          wait(2000);
          ChooseOption('Pickpocket Knight');
          wait(250);
          WriteLn('Picked Knight');
          inc(PickPockets);
       end
       else
        CompassMovement( 60, 120, true);
    end;

    That will move the compass a minimum of 60 degrees, max of 120 and return to the original position afterwards, set it to 'false' to stay where it lands.
    Neither of them aren't working actually, it doesn't even start the 'Else'
    Simba Code:
    procedure FindKnight;
      var
      X, Y:Integer;
    begin
     if FindColorTolerance(X, Y, KnightColor, 5, 3, 511, 329, 10) then
      begin
          WriteLn('Found Knight');
          MMouse(x, y, 0, 0);
          ClickMouse2(False);
          wait(2000);
          ChooseOption('Pickpocket Knight');
          wait(250);
          WriteLn('Picked Knight');
          inc(PickPockets);
          end
          else
          begin
          WriteLn('Knight not found, rotating camera')
          keydown(37);
          wait(500);
          keyup(37);
          end;
      end;

  9. #9
    Join Date
    Jul 2012
    Posts
    437
    Mentioned
    10 Post(s)
    Quoted
    165 Post(s)

    Default

    so it writes 'Found Knight' and moves the mouse? Try a smaller tolerance.

  10. #10
    Join Date
    Feb 2013
    Location
    Narnia
    Posts
    615
    Mentioned
    8 Post(s)
    Quoted
    252 Post(s)

    Default

    if it doesnt start the else then its finding your colors somewhere, your procedure looks correct. i would recommend adding a repeat until to your else otherwise it will only move the camera once for half a second, unless thats enough time to find the knight? you also dont have it going back to pickpocket the knight once it finds it

    View my OSR Script Repository!


    Botted to max
    Guides: How to Report Bugs to the Scripter
    ~~~~ Moved to Java. Currently Lurking ~~~~

  11. #11
    Join Date
    Dec 2011
    Posts
    445
    Mentioned
    26 Post(s)
    Quoted
    256 Post(s)

    Default

    Quote Originally Posted by tealc View Post
    so it writes 'Found Knight' and moves the mouse? Try a smaller tolerance.
    Yeah, then it moves the mouse to the bottom right, like it does when it can't find something.

    My ACA will wright out that it doesn't find it, but not move the camera / write out what I coded.

  12. #12
    Join Date
    Jul 2012
    Posts
    437
    Mentioned
    10 Post(s)
    Quoted
    165 Post(s)

    Default

    which cts are you using

    example of cts 2
    Simba Code:
    procedure
    //vars
       tmpCTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(hue mod, sat mod);//these are found on ACA and these two are only for cts 2
    begin
     if FindColorTolerance(X, Y, KnightColor, 5, 3, 511, 329, 10) then
     begin
          WriteLn('Found Knight');
         MMouse(x, y, 0, 0);
          ClickMouse2(False);
         wait(2000);
          ChooseOption('Pickpocket Knight');
          wait(250);
          WriteLn('Picked Knight');
          inc(PickPockets);
          end
          else
          begin
          WriteLn('Knight not found, rotating camera')
          keydown(37);
          wait(500);
          keyup(37);
          end;
      ColorToleranceSpeed(tmpCTS);
      SetColorSpeed2Modifiers(0.2, 0.2);
      end;

  13. #13
    Join Date
    Dec 2011
    Posts
    445
    Mentioned
    26 Post(s)
    Quoted
    256 Post(s)

    Default

    Quote Originally Posted by tealc View Post
    which cts are you using

    example of cts 2
    Simba Code:
    procedure
    //vars
       tmpCTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(hue mod, sat mod);//these are found on ACA and these two are only for cts 2
    begin
     if FindColorTolerance(X, Y, KnightColor, 5, 3, 511, 329, 10) then
     begin
          WriteLn('Found Knight');
         MMouse(x, y, 0, 0);
          ClickMouse2(False);
         wait(2000);
          ChooseOption('Pickpocket Knight');
          wait(250);
          WriteLn('Picked Knight');
          inc(PickPockets);
          end
          else
          begin
          WriteLn('Knight not found, rotating camera')
          keydown(37);
          wait(500);
          keyup(37);
          end;
      ColorToleranceSpeed(tmpCTS);
      SetColorSpeed2Modifiers(0.2, 0.2);
      end;
    Full ACA:

    Simba Code:
    // ACA for Knight \\
    function KnightColor: Integer;
    var
      arP: TPointArray;
      arC: TIntegerArray;
      tmpCTS, i, arL: Integer;
      X, Y, Z: Extended;
    begin
      tmpCTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.19, 0.78);

      FindColorsSpiralTolerance(MSCX, MSCY, arP, 11542895, MSX1, MSY1, MSX2, MSY2, 21);
      if (Length(arP) = 0) then
      begin
        Writeln('Failed to find Knight, 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 >= 2.75) and (X <= 26.73) and (Y >= 1.72) and (Y <= 15.51) and (Z >= 7.95) and (Z <= 84.02) 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('Failed to find the Knight');
    end;

    CTS 2 (I think...)
    Simba Code:
    tmpCTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.19, 0.78);

  14. #14
    Join Date
    Jun 2012
    Location
    Howell, Michigan
    Posts
    1,585
    Mentioned
    34 Post(s)
    Quoted
    553 Post(s)

    Default

    Simba Code:
    function FindKnight: Boolean; // Returns true if found, use like this If FindNight then blah blah blah
    var
      X, Y, Failcount: Integer;
    begin
      result := false; //sets to false so all other but success automagically = false
      repeat
        if FindColorTolerance(X, Y, KnightColor, MSX1 MSY1, MSX2, MSY2, 10) then //Try using a lesser tolerance / TPA, find color isnt the most useful
        begin
          WriteLn('Found Knight'); //Debug
          MMouse(x, y, 2, 2); // Always add randomness
          ClickMouse2(False);
          WaitOption('Pickpocket ', 350); // Same effect, waits for the option of PickPocket
          wait(randomrange(250, 350)); //Once again randomness
          WriteLn('Picked Knight');
          inc(PickPockets); // proggy
          result := true; // Results true for the function
        end
        else
        begin
          writeln('Did not find the knight, moving compass'); //Lets us know where we are at
          CompassMovement(60, 120, false); // Moves the compass between 60-120 degrees
          inc(FailCount); // Increases the failcount for our loop
        end;
      until (result or (FailCount >= 10)); // Stops when the result is true (result = default true) or we fail 10 times
    end;

    ^ should work, commented code, learn TPAs/ATPA's here, they make life much easier!(:

  15. #15
    Join Date
    Dec 2011
    Posts
    445
    Mentioned
    26 Post(s)
    Quoted
    256 Post(s)

    Default

    Quote Originally Posted by King View Post
    Simba Code:
    function FindKnight: Boolean; // Returns true if found, use like this If FindNight then blah blah blah
    var
      X, Y, Failcount: Integer;
    begin
      result := false; //sets to false so all other but success automagically = false
      repeat
        if FindColorTolerance(X, Y, KnightColor, MSX1 MSY1, MSX2, MSY2, 10) then //Try using a lesser tolerance / TPA, find color isnt the most useful
        begin
          WriteLn('Found Knight'); //Debug
          MMouse(x, y, 2, 2); // Always add randomness
          ClickMouse2(False);
          WaitOption('Pickpocket ', 350); // Same effect, waits for the option of PickPocket
          wait(randomrange(250, 350)); //Once again randomness
          WriteLn('Picked Knight');
          inc(PickPockets); // proggy
          result := true; // Results true for the function
        end
        else
        begin
          writeln('Did not find the knight, moving compass'); //Lets us know where we are at
          CompassMovement(60, 120, false); // Moves the compass between 60-120 degrees
          inc(FailCount); // Increases the failcount for our loop
        end;
      until (result or (FailCount >= 10)); // Stops when the result is true (result = default true) or we fail 10 times
    end;

    ^ should work, commented code, learn TPAs/ATPA's here, they make life much easier!(:
    I didn't add randomness because this is an RSPS.. and I've had permission from the owner to script bots. But thanks i'll try it out

    EDIT: Also this doesn't move the compass either when it can't find it, and I know this wasn't a fix for it was just saying :P
    Last edited by Twinki; 05-01-2013 at 03:40 AM.

  16. #16
    Join Date
    Jun 2012
    Location
    Howell, Michigan
    Posts
    1,585
    Mentioned
    34 Post(s)
    Quoted
    553 Post(s)

    Default

    Quote Originally Posted by Twinki View Post
    I didn't add randomness because this is an RSPS.. and I've had permission from the owner to script bots. But thanks i'll try it out

    EDIT: Also this doesn't move the compass either when it can't find it.
    Then I really dont know what to say, tested this with my own colors, worked finee

  17. #17
    Join Date
    Dec 2011
    Posts
    445
    Mentioned
    26 Post(s)
    Quoted
    256 Post(s)

    Default

    Quote Originally Posted by King View Post
    Then I really dont know what to say, tested this with my own colors, worked finee
    Well I noticed that even if the knight isn't visible, it still acts as if it does. If that makes sense :P

    If I just run the script and make the window the simba window, it'll still say it found the Knight and say it pickpocketed it. It'll even right click...

  18. #18
    Join Date
    Jun 2012
    Location
    Howell, Michigan
    Posts
    1,585
    Mentioned
    34 Post(s)
    Quoted
    553 Post(s)

    Default

    Quote Originally Posted by Twinki View Post
    Well I noticed that even if the knight isn't visible, it still acts as if it does. If that makes sense :P

    If I just run the script and make the window the simba window, it'll still say it found the Knight and say it pickpocketed it. It'll even right click...
    Then you need to redo the colors matey :P I would just use a color from ACA not the entire function, more than likely because you are using a tolerance on an already colored function. So just use findcolorspiral, without tolerance

  19. #19
    Join Date
    Dec 2011
    Posts
    445
    Mentioned
    26 Post(s)
    Quoted
    256 Post(s)

    Default

    Quote Originally Posted by King View Post
    Then you need to redo the colors matey :P I would just use a color from ACA not the entire function, more than likely because you are using a tolerance on an already colored function. So just use findcolorspiral, without tolerance
    Yeah it has something to do with the ACA Function, but there isn't a good color that shows up on both the back and front of the knight..

  20. #20
    Join Date
    Jun 2012
    Location
    Howell, Michigan
    Posts
    1,585
    Mentioned
    34 Post(s)
    Quoted
    553 Post(s)

    Default

    Quote Originally Posted by Twinki View Post
    Yeah it has something to do with the ACA Function, but there isn't a good color that shows up on both the back and front of the knight..
    Pm me a screenshot, Ill find a Good color combination today/ tomorrow. I may just make a TPA finding function if you like

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
  •