Results 1 to 9 of 9

Thread: Picking a random point in an area

  1. #1
    Join Date
    Jun 2012
    Posts
    2,182
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Picking a random point in an area

    For my teleport script, I used findcolorspiraltolerance to pick a random pixel on the teleport button, so it wasnt always picking the same pixel. Is there a way to pick a random pixel in a pre-defined area?
    Thanks guys

  2. #2
    Join Date
    May 2012
    Location
    Texas
    Posts
    365
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I'm sure there is but for teleporting I would recommend using a DTM and then when you use the mouse to move to it, you can just add some randomness. If you need any help with DTMs there are a few really great tutorials or I could help you out. Good luck with your script

    Generally color finding such as findcolorspiraltolerance is used for finding objects and things on the main screen while DTMs and Bitmaps are used for finding stationary objects that do not change such as Items and spells
    Mostly Inactive, School

  3. #3
    Join Date
    Jun 2012
    Posts
    2,182
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Well this is my second day scripting, so I havnt even heard of DTM's, lol. Ill check out a few tutorials. One more thing. If I want to set my script to repeat the main loop X amount of times, how would I do that? right now I have
    begin
    Repeat
    Teleport;
    Randoms;
    until(false);
    end.
    as my main loop. Thanks!

  4. #4
    Join Date
    Feb 2006
    Location
    Helsinki, Finland
    Posts
    1,395
    Mentioned
    30 Post(s)
    Quoted
    107 Post(s)

    Default

    Simba Code:
    var
      runs, timesToRun: Integer;

    begin
      timesToRun := 100 + Random(50);
      for runs := 0 to timesToRun do
      begin  
        Teleport;
        Randoms;
      end;
    end.

    You'll use for..to..do (or for..downto..do) loop.
    You can of course also add a variable for repeat loop, that needs to be increased with every run..

    Example:

    Simba Code:
    var
      runsDone, maximumRuns: Integer;

    begin
      maximumRuns := 200;
      repeat
        Teleport;
        Randoms;
        Inc(runsDone); // ..or runsDone := runsDone + 1;
      until (runsDone >= maximumRuns);
    end.

  5. #5
    Join Date
    May 2012
    Location
    Texas
    Posts
    365
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Generally people use a repeat loop for the main loop such as.
    Code:
    Repeat
      mainloop;
    Until (Not LoggedIn)//Could change this to while has runes or something along those lines aswell
    And then you could just TerminateScript; or break out of the loop after X amount of casts or what ever

    Edit: For loops are also useful
    Last edited by Based Lord; 06-22-2012 at 09:40 PM.
    Mostly Inactive, School

  6. #6
    Join Date
    Jun 2012
    Posts
    2,182
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Alright, thanks! i guess I'll ask one more question. Someone else helped me make this code for repeating camelot teleport. Pretty basic, but it should get by. However, when I run it, It opens the magic tab, which is before the repeating stuff, then starts to move very slowly towards the spell button. Why isnt it going straight there? Sorry if I'm asking noobish questions, i guess im a noob at this point, lol

    EDIT: heres my script, probably should have included that
    program CamTele;
    {$i srl/srl.simba}

    //Made for Epicbot

    Procedure Start;
    begin
    movemouse(743, 452)
    clickmouse(743, 452, 1)
    end;

    Procedure Teleport;
    var
    x, y:integer;

    begin
    repeat
    if FindColorSpiralTolerance(x, y, 6102593, 674, 268, 694, 284, 10) then
    begin
    MMouse(x, y, 4, 4);
    Mouse(x, y, 2, 2, 1);
    wait(randomrange(2000, 2500));
    end;
    until(false);
    end;

    Procedure Randoms;
    begin
    if findnormalrandoms or findnoninventoryrandoms then
    begin
    logout;
    terminatescript;
    end;
    end;

    begin
    Start
    Repeat
    Teleport;
    Randoms;
    until(false);
    end.
    Last edited by Footy; 06-22-2012 at 09:49 PM.

  7. #7
    Join Date
    Mar 2012
    Location
    Color :D
    Posts
    938
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    You need to put SetupSRL; into your script.

    And you can also use mousebox for clicking the spell since the spell is always at a fixed position.

  8. #8
    Join Date
    May 2012
    Location
    Texas
    Posts
    365
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Foooty View Post
    Alright, thanks! i guess I'll ask one more question. Someone else helped me make this code for repeating camelot teleport. Pretty basic, but it should get by. However, when I run it, It opens the magic tab, which is before the repeating stuff, then starts to move very slowly towards the spell button. Why isnt it going straight there? Sorry if I'm asking noobish questions, i guess im a noob at this point, lol
    Could be a number of things but not really able to tell you without seeing what your using. (Using a DTM would fix that tho )
    Mostly Inactive, School

  9. #9
    Join Date
    Jun 2012
    Posts
    2,182
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I gotta go, But I;ve posted my script. Ill reply later tonight

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
  •