Results 1 to 15 of 15

Thread: MicroPaint (BotWatch™)

  1. #1
    Join Date
    Apr 2013
    Location
    Las Vegas
    Posts
    111
    Mentioned
    1 Post(s)
    Quoted
    35 Post(s)

    Default MicroPaint (BotWatch™)

    [SMART] Implementing MicroPaint (BotWatch™)
    [Scroll to the bottom if you simply want to see the code. This is a learning community but I do not have any issues with people copy/pasting my code.]

    What is MicroPaint (BotWatch™)
    MicroPaint (BotWatch™) is a system similar to paint that allows you to monitor your bot's location and progress in a tiny window, without having your SMART window open. It includes the bot's name, a small snapshot of the bot in-game, and optionally some quick statistics regarding the bot.

    BotWatch™ also includes a color border that will signal to you how the bot is doing. The colors go from Bright Neon Green (Just mined/chopped/looted/etc.) to green (Recently mined/chopped/looted) to yellow (been a little while since last ore mined, log chopped, or item looted) to Orange (Been a long time since last ore mined, log chopped, or item looted) to Red (It's been too long since the last loot, about to fail) to Bright Red (Script timed out, terminated, you were random'ed, or died).

    BotWatch™ is especcially useful to those running several different bots as you can do something as awesome as this:




    One look at your screen and you can instantly check the status of all bots running Simba on your computer. The colored borders are an instant gauge of where your bots are at and what their status is. The top line is the nickname, the middle is a quick snapshot of your character, and the last three lines are optional statistics.

    The Functions

    As this tutorial is hopefully in Advanced Tutorials, a simple explanation of the functions and a quick example should be sufficient.
    The following is the code used to determine what color the border will be.


    Simba Code:
    function PercToCol (percent: integer): longint;
    begin

      if (percent <= 10) then
      result := RGBtoColor (255 - (percent * 5), 0 ,0);

      if (percent > 10) then
      result := RGBtoColor (225 - (percent * 3), 0, 0);
      if (percent > 30) then
      result := RGBtoColor (255, 155 + ((percent - 35) * 3), 50 - percent);

      if (percent > 45) then
      result := RGBtoColor (255, 247 - (4 * (60 - percent)), percent);

      if (percent > 60) then
      result := RGBtoColor (20, 20 + (percent), 20);

      if (percent > 75) then
      result := RGBtoColor (20, 100 + (percent * (17 / 10)), 20);

      if (percent >= 95) then
      result := RGBtoColor (0, 255 ,0);

    end;

    PercToCol Color Outputs:



    Using PercToCol

    While the PercToCol function converts a percentage into a color, how to determine that percentage is completely up the scripter to decide. For my woodcutting script my formula to determine color is:

    Simba Code:
    if (lasttree < 0) then
    lasttree := 0 ;

    id := 100 - round(sqrt((LastTree)) / 6);
    TheStatus := PercToCol(id);

    You should mess around with the calculations and change them to be best fit depending on what you are doing, average time between successes, and any possible failures that could occur. LastTree is quite obviously the TimeFromMark of the last tree cut. It is then fed through my formula, converted into an id, and shoved into the color converter.

    Neon Green - 0 to 900 milliseconds from last cut, basically when it has just cut down a tree.
    Green - 900 milliseconds to 57.6 seconds
    Orange/Yellow - 57.6 seconds to 176.4 seconds (~3 minutes)
    Red/Dead - 176.4 seconds to 360 seconds (6 minutes)

    The formula can easily be adjusted depending on what you are doing. If it is something takes a while, increase the time limit for each color. If it is something that should be done fast, decrease the time limit.


    UpdateWatch(LastTree: integer)

    UpdateWatch is the function that creates the actual bitmap and sends it to your SRL debug window. It is really the only function that matters. This function should be called right after a success, a Show-ending event such as random/death/out of supplies, and at the end of the script. The more often you can call this procedure, the better. Word for word here is the function as in my woodcutter. I have added comments for those that need a some help decrypting my code.

    Simba Code:
    Procedure UpdateWatch(LastTree: integer);          // UpdateWatch function, includes how long since the last logs were recieved.
    var
      bot, w, h, image, text, id: integer;
      TheStatus: longint;
      offset: TPoint;
      PHour: string
    begin
     // Calculates the percentage based off of last time logs were received.
    id := 100 - round(sqrt((LastTree)) / 6);          

    // Converts the percentage into a color.  Function discussed above.
    TheStatus := PercToCol(id);      
                     
    // Offset from base cords that the client capture will be taken from.
    offset := point (8, 24);                          
    // Creating the bitmap to be worked with.
    image := CreateBitmap (115,115);                
    // Taking the snapshot of the client.  
    bot := BitmapFromClient (200 + offset.x, 100 + offset.y, 300 + offset.x, 200 + offset.y);    
     
    // Drawing the colored border to the image.
    RectangleBitmap(image, inttobox (0, 0, 114, 114), TheStatus);      

    // Draws the client snapshot on top of the colored border.
    FastDrawTransparent(7, 7, bot, image);

    // Draws the current player's name in the smallest size available.
    text := BitmapFromText(Players[CurrentPlayer].Name, StatChars07);
    // Measured the width and height of the name bitmap, in order to properly center.
    GetBitmapSize(text, w, h);
    // Sets the text's black background as transparent.
    SetTransparentcolor (text, 0);
    // Uses the width/height measured to properly center the players name.
    FastDrawTransparent(round ((115 * 0.5) - (w / 2)), 12, text, image);
    // Frees the bitmap.  All the bitmaps we are making, they NEED to be free'd.
    FreeBitmap(text);


    // Prints the 'Time' label.  Very similar to the above script.
    text := BitmapFromText('Time: ', StatChars07);
    SetTransparentcolor (text, 0);
    FastDrawTransparent(14, 74, text, image)
    FreeBitmap(text);

    // Prints the time running. Timize can be found in my tutorial on paint. Similar to above.
    text := BitmapFromText(timize(round (GetTimeRunning / 1000)), StatChars07);
    GetBitmapSize(text, w, h);
    SetTransparentcolor (text, 0);
    FastDrawTransparent(99 - w, 74, text, image);
    FreeBitmap(text);

    // Prints the 'Logs' label.  Similar to above...
    text := BitmapFromText('Logs: ', StatChars07);
    SetTransparentcolor (text, 0);
    FastDrawTransparent(14, 84, text, image)
    FreeBitmap(text);

    // Prints the amount of logs cut.  Similar to above...
    text := BitmapFromText(groupdigits (magics, ','), StatChars07);
    GetBitmapSize(text, w, h);
    SetTransparentcolor (text, 0);
    FastDrawTransparent(99 - w, 84, text, image);
    FreeBitmap(text);

    // Prints the 'cash' label.  Similar to above...
    text := BitmapFromText('Cash: ', StatChars07);
    SetTransparentcolor (text, 0);
    FastDrawTransparent(14,94, text, image)
    FreeBitmap(text);

    // Prints the amount of cash made.  Similar to above...
    text := BitmapFromText(groupdigits (magics * price, ','), StatChars07);
    GetBitmapSize(text, w, h);
    SetTransparentcolor (text, 0);
    FastDrawTransparent(99 - w, 94, text, image);
    FreeBitmap(text);

    // Loads and displays the MicroPaint.
    DrawBitmapDebugImg(image);
    DisplayDebugImgWindow(115, 115);

    // Frees out bitmaps, an absolute must.
    FreeBitmap(bot);
    FreeBitmap(image);

    end;

    Final Product. (See BotWatch in action)

    While I am sure most scriptwriters here already know how to implement this code into their script, I will write a simple program to show the final product for those who would rather copy and paste. I threw together a quick magic tree simulator. Copy and paste this code into your Simba to see what BotWatch can do.

    Simba Code:
    program BotWatch;
    {$DEFINE SMART8}
    {$I SRL-OSR/SRL.Simba}
    const
      Player_Name         =       'zezima';       // Player's name.  In real script this would come from declareplayers.
      Price               =       1200;           // The price of each log.
    var
      Logs_Cut, Last_Cut: integer;


    function ClockReel(i: integer): string;
    begin

      if (i < 10) then
      begin
      result := '0' + inttostr(i);
      Exit;
      end;

    result := inttostr(i);

    end;
    function Timize(Time: Integer): String;
    var
      seconds, minutes, hours: integer;
      final: String;
    begin

      if (time < 60) then
      begin
      seconds := time;
      Result := '0:00:' + clockReel(time);
      Exit;
      end;

      hours := floor(time / 3600);
      time := time - (hours * 3600);

      minutes := floor(time / 60);
      time := time - (minutes * 60);

      seconds := time;

      final := (inttostr(hours) + ':' + clockReel(minutes) + ':' + clockReel(seconds));

      Result := final;

    end;
    function PercToCol (percent: integer): longint;
    begin

      if (percent <= 10) then
      result := RGBtoColor (255 - (percent * 5), 0 ,0);

      if (percent > 10) then
      result := RGBtoColor (225 - (percent * 3), 0, 0);
      if (percent > 30) then
      result := RGBtoColor (255, 155 + ((percent - 35) * 3), 50 - percent);

      if (percent > 45) then
      result := RGBtoColor (255, 247 - (4 * (60 - percent)), percent);

      if (percent > 60) then
      result := RGBtoColor (20, 20 + (percent), 20);

      if (percent > 75) then
      result := RGBtoColor (20, 100 + (percent * (17 / 10)), 20);

      if (percent >= 95) then
      result := RGBtoColor (0, 255 ,0);

    end;

    Procedure UpdateWatch(LastTree: integer);          // UpdateWatch function, includes how long since the last logs were recieved.
    var
      bot, w, h, image, text, id: integer;
      TheStatus: longint;
      offset: TPoint;
    begin
     // Calculates the percentage based off of last time logs were received.
    id := 100 - round(sqrt((LastTree)) / 6);

    // Converts the percentage into a color.  Function discussed above.
    TheStatus := PercToCol(id);

    // Offset from base cords that the client capture will be taken from.
    offset := point (8, 24);
    // Creating the bitmap to be worked with.
    image := CreateBitmap (115,115);
    // Taking the snapshot of the client.
    bot := BitmapFromClient (200 + offset.x, 100 + offset.y, 300 + offset.x, 200 + offset.y);

    // Drawing the colored border to the image.
    RectangleBitmap(image, inttobox (0, 0, 114, 114), TheStatus);

    // Draws the client snapshot on top of the colored border.
    FastDrawTransparent(7, 7, bot, image);

    // Draws the current player's name in the smallest size available.
    text := BitmapFromText(Player_Name, StatChars07);
    // Measured the width and height of the name bitmap, in order to properly center.
    GetBitmapSize(text, w, h);
    // Sets the text's black background as transparent.
    SetTransparentcolor (text, 0);
    // Using our width and height we can center the players name.
    FastDrawTransparent(round ((115 * 0.5) - (w / 2)), 12, text, image);
    // Frees the bitmap.  All the bitmaps we are making, they NEED to be free'd.
    FreeBitmap(text);


    // Prints the 'Time' label.  Very similar to the above script.
    text := BitmapFromText('Time: ', StatChars07);
    SetTransparentcolor (text, 0);
    FastDrawTransparent(14, 74, text, image)
    FreeBitmap(text);

    // Prints the time running. Timize can be found in my tutorial on paint. Similar to above.
    text := BitmapFromText(timize(round (GetTimeRunning / 1000)), StatChars07);
    GetBitmapSize(text, w, h);
    SetTransparentcolor (text, 0);
    FastDrawTransparent(99 - w, 74, text, image);
    FreeBitmap(text);

    // Prints the 'Logs' label.  Similar to above...
    text := BitmapFromText('Logs: ', StatChars07);
    SetTransparentcolor (text, 0);
    FastDrawTransparent(14, 84, text, image)
    FreeBitmap(text);

    // Prints the amount of logs cut.  Similar to above...
    text := BitmapFromText(groupdigits (logs_cut, ','), StatChars07);
    GetBitmapSize(text, w, h);
    SetTransparentcolor (text, 0);
    FastDrawTransparent(99 - w, 84, text, image);
    FreeBitmap(text);

    // Prints the 'cash' label.  Similar to above...
    text := BitmapFromText('Cash: ', StatChars07);
    SetTransparentcolor (text, 0);
    FastDrawTransparent(14,94, text, image)
    FreeBitmap(text);

    // Prints the amount of cash made.  Similar to above...
    text := BitmapFromText(groupdigits (logs_cut * price, ','), StatChars07);
    GetBitmapSize(text, w, h);
    SetTransparentcolor (text, 0);
    FastDrawTransparent(99 - w, 94, text, image);
    FreeBitmap(text);

    // Loads and displays the MicroPaint.
    DrawBitmapDebugImg(image);
    DisplayDebugImgWindow(115, 115);

    // Frees out bitmaps, an absolute must.
    FreeBitmap(bot);
    FreeBitmap(image);

    end;

    Procedure Kill;
    begin
    writeLn ('Script terminated, you must restart.');

    UpdateWatch(360000);

    end;
    begin
    setupSRL;
    AddOnTerminate('kill');
    MarkTime(Last_Cut);

      Repeat

        if (RandomRange (1,15) = 1) then
        begin
        Logs_cut := Logs_cut + 1;
        writeln ('We recieved some logs.');
        MarkTime(Last_Cut);
        UpdateWatch (0);
        end;

      UpdateWatch (TimeFromMark(Last_Cut));
      wait (randomrange(200,4000));

      until (false);

    end.

    If you haven't already please check out my guide for Paint over in the intermediate section. Any comments, suggestions, questions are always welcome. If one person was helped by this tutorial the time spent on it has been worth it.
    Last edited by bob_dole; 06-17-2013 at 12:25 AM.

  2. #2
    Join Date
    Apr 2013
    Posts
    395
    Mentioned
    1 Post(s)
    Quoted
    177 Post(s)

    Default

    I think this is really cool!

  3. #3
    Join Date
    Jan 2013
    Posts
    294
    Mentioned
    1 Post(s)
    Quoted
    121 Post(s)

    Default

    i agree, this is well thought

  4. #4
    Join Date
    Apr 2013
    Location
    Las Vegas
    Posts
    111
    Mentioned
    1 Post(s)
    Quoted
    35 Post(s)

    Default

    Thanks guys. If there are any scripts you use that would like this scripted into just post them below and I can add it for you.

  5. #5
    Join Date
    Sep 2012
    Location
    Australia.
    Posts
    839
    Mentioned
    16 Post(s)
    Quoted
    225 Post(s)

    Default

    Quote Originally Posted by bob_dole View Post
    Thanks guys. If there are any scripts you use that would like this scripted into just post them below and I can add it for you.
    To get your thread moved, either PM a staff member, mention them or report your thread and ask for a move. :3

    Very nice guide and idea here.

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

    Default

    Saw this on your signature, this is really cool

    Creds to DannyRS for this wonderful sig!

  7. #7
    Join Date
    Apr 2013
    Location
    Las Vegas
    Posts
    111
    Mentioned
    1 Post(s)
    Quoted
    35 Post(s)

    Default

    Quote Originally Posted by Sjoe View Post
    Saw this on your signature, this is really cool
    Thanks. Hoping to get this a little more exposure. I think it can be really useful, mainly to those who bot multiple accounts.

  8. #8
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    This looks like a neat little tool

  9. #9
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    This idea looks pretty clever indeed. Original, very helpful for both users and scripters alike, and I will always be in support of new and original, progressive ideas; I'm a huge fan of ingenuity. But, if I might ask, in essence does this simply draw & display a colored bitmap of a specified area on the current target window and add text / status debugging to it? If that's the case how would it differ from simply hovering the mouse over the target (browser or SMART) while the script is running, to get a glimpse of the script in action?

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


  10. #10
    Join Date
    Apr 2013
    Location
    Las Vegas
    Posts
    111
    Mentioned
    1 Post(s)
    Quoted
    35 Post(s)

    Default

    Quote Originally Posted by Flight View Post
    This idea looks pretty clever indeed. Original, very helpful for both users and scripters alike, and I will always be in support of new and original, progressive ideas; I'm a huge fan of ingenuity. But, if I might ask, in essence does this simply draw & display a colored bitmap of a specified area on the current target window and add text / status debugging to it? If that's the case how would it differ from simply hovering the mouse over the target (browser or SMART) while the script is running, to get a glimpse of the script in action?
    Yep that's exactly what it does, along with a color border. Most users can simply hover over the window to see the script's status, but will not be able to see the additional information/color-border of the script. Users operating on windows XP or older will also not be able to do this. BotWatch however, allows a user to check the status of all bots on the computer at the exact same time without needing to individually hover over each window.

    I am currently designing a script that will allow a botter to view and manage bots on several different systems all from one computer or possibly even from their smartphone.

  11. #11
    Join Date
    Feb 2012
    Location
    DON'T PM ME ASKING FOR STUFF
    Posts
    2,170
    Mentioned
    38 Post(s)
    Quoted
    423 Post(s)

    Default

    Quote Originally Posted by bob_dole View Post
    Yep that's exactly what it does, along with a color border. Most users can simply hover over the window to see the script's status, but will not be able to see the additional information/color-border of the script. Users operating on windows XP or older will also not be able to do this. BotWatch however, allows a user to check the status of all bots on the computer at the exact same time without needing to individually hover over each window.

    I am currently designing a script that will allow a botter to view and manage bots on several different systems all from one computer or possibly even from their smartphone.
    Bob Dole,

    I would really love to offer my help with this Would it be possible to make it so this posts the image once every 30 minutes to a server and displays it on a web page? I can do all the PHP etc. It would be amazing to make a page for each script created which shows the hotspots and possibly compare them to the rest of the RS map? :P

  12. #12
    Join Date
    Oct 2006
    Location
    Netherlands
    Posts
    3,285
    Mentioned
    105 Post(s)
    Quoted
    494 Post(s)

    Default

    May I suggest:

    Simba Code:
    function PercToCol (percent: integer): longint;
    begin
      result := HSLtoColor(I / 3.0, 100, 50);
    end;
    Working on: Tithe Farmer

  13. #13
    Join Date
    Apr 2013
    Location
    Las Vegas
    Posts
    111
    Mentioned
    1 Post(s)
    Quoted
    35 Post(s)

    Default

    Quote Originally Posted by xtrapsp View Post
    Bob Dole,

    I would really love to offer my help with this Would it be possible to make it so this posts the image once every 30 minutes to a server and displays it on a web page? I can do all the PHP etc. It would be amazing to make a page for each script created which shows the hotspots and possibly compare them to the rest of the RS map? :P
    Yes, this is more than possible. I was going to go even as far as to use JQuery to display a crude video that also allows you to send clicks to be executed on the SMART window. The PHP/MySQL is my favorite part.

  14. #14
    Join Date
    Feb 2012
    Location
    DON'T PM ME ASKING FOR STUFF
    Posts
    2,170
    Mentioned
    38 Post(s)
    Quoted
    423 Post(s)

    Default

    Quote Originally Posted by bob_dole View Post
    Yes, this is more than possible. I was going to go even as far as to use JQuery to display a crude video that also allows you to send clicks to be executed on the SMART window. The PHP/MySQL is my favorite part.
    If you have it under control no worries ^^

  15. #15
    Join Date
    Apr 2013
    Location
    Las Vegas
    Posts
    111
    Mentioned
    1 Post(s)
    Quoted
    35 Post(s)

    Default

    Quote Originally Posted by xtrapsp View Post
    If you have it under control no worries ^^
    Yes it may take a little while before it is finished/released to the public. Meanwhile, if you need I can whip up a quick script that will send a picture of the SMART window to your server every X minutes.

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
  •