Results 1 to 11 of 11

Thread: How does LoadBitmap work?

  1. #1
    Join Date
    Jul 2008
    Posts
    79
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default How does LoadBitmap work?

    In the game I'm playing, the monsters are many different colors which isn't too much of a problem but I realized that other things are the same color. So I end of clicking on scenery as well. So what I want to do is take a small section of the animal on all sides in all kinds of animation they preform, load them, and have an auto clicker that will click the closet recognized image. So I know how to load the images, how do I make the script find them? My code-

    SCAR Code:
    program Goonzu_AutoHunt;
    const
         PinkBunny = 11907831;
         BossBunny = 16777215;
    var
    x, y:integer;
    begin
    if (1 < 10) then
      repeat
        KeyDownSilent(0);
        FindColorSpiralTolerance(x, y, PinkBunny, 364, 216, 633, 464, 0)
        ClickMouse(x, y, true);
        writeln('Pink Bunny found!');
        Wait(2000);
                   FindColorSpiralTolerance(x, y, BossBunny, 364, 216, 633, 464, 0)
                   ClickMouse(x, y, true);
                   writeln('Boss Bunny found!')
                   Wait(2000);
        until(false);
        KeyUpSilent(0);
        writeln('Couldnt fins anymore Pink Bunny or Boss Bunny');
    end.

    Also, I can't seem to find where I can place the LoadBitmap(); function. Everywhere I put it there's an error. Maybe my syntax is wrong, could you show me?

  2. #2
    Join Date
    Jan 2008
    Location
    NC, USA.
    Posts
    4,429
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default

    You can place a bitmap after the first begin, but you shoul acctually have procedures and a main line. Like this,

    SCAR Code:
    program Goonzu_AutoHunt;
    const
         PinkBunny = 11907831;
         BossBunny = 16777215;
    var
    x, y:integer;

    Procedure Load_Bitmaps;
    begin
    //Place bitmap here (delete this message)
    end;

    Procedure hunt;
    begin
    if (1 < 10) then
      repeat
        KeyDownSilent(0);
        FindColorSpiralTolerance(x, y, PinkBunny, 364, 216, 633, 464, 0)
        ClickMouse(x, y, true);
        writeln('Pink Bunny found!');
        Wait(2000);
                   FindColorSpiralTolerance(x, y, BossBunny, 364, 216, 633, 464, 0)
                   ClickMouse(x, y, true);
                   writeln('Boss Bunny found!')
                   Wait(2000);
        until(false);
        KeyUpSilent(0);
        writeln('Couldnt fins anymore Pink Bunny or Boss Bunny');
    end;


    begin
    Load_Bitmaps;
    repeat
    Hunt;
    Until false
    end.
    Quote Originally Posted by irc
    [00:55:29] < Guest3097> I lol at how BenLand100 has become noidea
    [01:07:40] <@BenLand100> i'm not noidea i'm
    [01:07:44] -!- BenLand100 is now known as BenLand42-
    [01:07:46] <@BenLand42-> shit
    [01:07:49] -!- BenLand42- is now known as BenLand420
    [01:07:50] <@BenLand420> YEA

  3. #3
    Join Date
    Jul 2008
    Posts
    79
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Ok, but how can I replace the variable for color (PinkBunny and BossBunny) with the bitmap? Should I give it a variable name and it will work just the same?

  4. #4
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,446
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    noidea: that's very misleading as they were asking about the actual function LoadBitmap
    LoadBitmap will open a bitmap from a place on your pc that you can specify, such as "C:\Program Files\Scar3.15\Bitmaps\pinkbunny.bmp" or you can save them in the same directory that you launch your script from and use ScriptPath to get the path up where the script is, meaning you just add the bitmap name to the end, such as "ScriptPath + 'pinkbunny.bmp'".
    To use the bitmap, you have to assign LoadBitmap to a variable, so for example, "bunnyBmp := LoadBitmap(ScriptPath + 'pinkbunny.bmp';"
    And you can then use bunnyBmp in a bitmap finding procedure.
    You may want to open up the Scar manual (press f1 when Scar is open) and check out some of the bitmap finding options as some will be better suited to what you're trying to do
    Edit: set up the variable you assign LoadBitmap to as an Integer, so:
    bunnyBmp: Integer;
    By reading this signature you agree that mixster is superior to you in each and every way except the bad ways but including the really bad ways.

  5. #5
    Join Date
    Jul 2008
    Posts
    79
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Is this right? It's not working, that's for sure. But it's not displaying that there are any errors so I don't know what's wrong.

    SCAR Code:
    program Goonzu_Rabbit_Hunter;

    var
    x, y:integer;
    PinkBunny01:integer;
    PinkBunny02:integer;
    PinkBunny03:integer;
    PinkBunny04:integer;
    PinkBunny05:integer;
    PinkBunny06:integer;
    PinkBunny07:integer;

    Procedure Load_Bitmaps;
    begin
         PinkBunny01 := LoadBitmap('.\PinkBunny01.bmp');
         PinkBunny02 := LoadBitmap('.\PinkBunny02.bmp');
         PinkBunny03 := LoadBitmap('.\PinkBunny03.bmp');
         PinkBunny04 := LoadBitmap('.\PinkBunny04.bmp');
         PinkBunny05 := LoadBitmap('.\PinkBunny05.bmp');
         PinkBunny06 := LoadBitmap('.\PinkBunny06.bmp');
         PinkBunny07 := LoadBitmap('.\PinkBunny07.bmp');
    end;

    Procedure Hunt;
    begin
    if FindBitmapSpiralTolerance(x, y, PinkBunny01, 0, 0, 9999, 9999, 10) or
       FindBitmapSpiralTolerance(x, y, PinkBunny01, 0, 0, 9999, 9999, 10) or
       FindBitmapSpiralTolerance(x, y, PinkBunny01, 0, 0, 9999, 9999, 10) or
       FindBitmapSpiralTolerance(x, y, PinkBunny01, 0, 0, 9999, 9999, 10) or
       FindBitmapSpiralTolerance(x, y, PinkBunny01, 0, 0, 9999, 9999, 10) or
       FindBitmapSpiralTolerance(x, y, PinkBunny01, 0, 0, 9999, 9999, 10) or
       FindBitmapSpiralTolerance(x, y, PinkBunny01, 0, 0, 9999, 9999, 10) then
       ClickMouse(x, y, true);
       Wait(2000);
    end;

    begin
         Load_Bitmaps;
    repeat
          Hunt;
    Until(false)
          writeln('Couldnt find any of the images');
    end.

  6. #6
    Join Date
    Jul 2008
    Location
    California
    Posts
    255
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    With it searching 99980001 pixels for the bitmap (9999 x 9999 square) it will take a very long time to search for all 7 of those bitmaps. Try a smaller area because I doubt that any game goes up to 9999 pixels. If the game takes the entire screen you can try matching it to your monitor's resolution.

    IE if you're using a 1024x768 resolution you would try:

    SCAR Code:
    Procedure Hunt;
    begin
    if FindBitmapSpiralTolerance(x, y, PinkBunny01, 0, 0, 1024, 768, 10) or
       FindBitmapSpiralTolerance(x, y, PinkBunny01, 0, 0, 1024, 768, 10) or
       FindBitmapSpiralTolerance(x, y, PinkBunny01, 0, 0, 1024, 768, 10) or
       FindBitmapSpiralTolerance(x, y, PinkBunny01, 0, 0, 1024, 768, 10) or
       FindBitmapSpiralTolerance(x, y, PinkBunny01, 0, 0, 1024, 768, 10) or
       FindBitmapSpiralTolerance(x, y, PinkBunny01, 0, 0, 1024, 768, 10) or
       FindBitmapSpiralTolerance(x, y, PinkBunny01, 0, 0, 1024, 768, 10) then
       ClickMouse(x, y, true);
       Wait(2000);
    end;

    But to make it even faster you can match it to the resolution of the game that you're playing.
    Unfortunately, no active scripts atm.

  7. #7
    Join Date
    Jul 2008
    Posts
    79
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Ok, I see. But after fixing this it takes a bit to search the screen, then just zooms to the top left. What does this mean? Is it not finding anything? I don't know how this is possible because I'm using a screenshot from which I got the images. o.O

  8. #8
    Join Date
    Jul 2008
    Location
    California
    Posts
    255
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    Couple of questions:

    1 - What are you trying to click? There are better ways than using Bitmaps... I've found bitmaps to be rather unreliable.

    2 - Is this for RuneScape?

    3 - If its not for RuneScape, what is it for?


    If it goes to the top left, then it is not able to find any of the bitmaps. Bitmaps take a while to look for and quite often do not work (atleast for me). Try using TPAs or DTMs if possible.
    Unfortunately, no active scripts atm.

  9. #9
    Join Date
    Jul 2008
    Posts
    79
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    1. I'm trying to click Pink Bunnys or Boss Bunnys ^^
    2. No
    3. Luminary Online (Global Version)

  10. #10
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,446
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    This will probably seem confusing, but this *should* work now:
    SCAR Code:
    Program GoonzuRabbitHunter;
    var
      x, y, w, h, i: Integer;
      rabbitBmp: array [1..7] of Integer;

    begin
      for i := 1 to 7 do
        rabbitBmp[i] := LoadBitmap(ScriptPath + 'PinkBunny0' + IntToStr(i));
      GetClientDimensions(w, h);
      repeat
        for i := 1 to 7 do
        begin
          if FindBitmapSpiralTolerance(x, y, rabbitBmp[i], 0, 0, w, h, 10) then
          begin
            MoveMouse(x, y);
            Wait(250);
            ClickMouse(x, y, True);
            Break;
          end;
        end;
        Wait(2500);
      until false;
    end.

    It makes use of arrays and for loops to do the bitmap loading and searching. It will firstly load the various bitmaps into the rabbitBmp integer array using IntToStr(i) to load the different bitmaps. It then does the searching by going through the numbers 1 to 7 seeing if the bitmap can be found on the screen. GetClientDimensions just returns the size of the screen you set with the crosshairs meaning you don't have to get the size yourself. There may be a couple of mistakes as I just typed it out without Scar syntax, but they should be easy enough to fix.
    By reading this signature you agree that mixster is superior to you in each and every way except the bad ways but including the really bad ways.

  11. #11
    Join Date
    Jul 2008
    Posts
    79
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Yes that appears to be working slightly. And I sorta get it the script. I understand what I'm seeing but I probably wouldn't be able to recode it.

    Ok, so I think it's searching for the first one and stopping. I opened the image files individually and searched and it only found the first one. And so on every 2 seconds.

    Edit:

    Hmm, you know. I think I'm going about this all wrong. Instead of finding the images and clicking them. I should just exclude images of dead bunnies (or other scenery that is the same color)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Why doesn't this work... :s
    By Dervish in forum OSR Help
    Replies: 2
    Last Post: 11-05-2008, 12:07 PM
  2. Stream Read Error because of LoadBitmap
    By mixster in forum OSR Help
    Replies: 2
    Last Post: 04-01-2008, 01:40 PM
  3. Why won't this work.
    By omgwoot in forum OSR Help
    Replies: 12
    Last Post: 08-16-2007, 07:48 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •