Results 1 to 5 of 5

Thread: Help with finding bitmap and acting on it if found

  1. #1
    Join Date
    Aug 2007
    Posts
    8
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Help with finding bitmap and acting on it if found

    Hey there, thanks for taking the time to read this.
    For my first script I decided to make a Chest Thiever, specifically the Nature Rune chest in Ardougne. So far I have the basics working, it steals from the chest indefinitely.
    I think I have the basic AntiRandoms working, but I don't believe there are any antirandoms for the Poison Gas Chest random while thieving. So, I set about seeing what I could do to make one of my own. I thieved away until I triggered the gas, and took a screenshot of when I was damaged by it. From this, I took a small section of the green damage "splat", 4x12 pixels, and saved it as a BMP.

    I converted this to a string, and have (hopefully) loaded it into my script correctly. I set up a procedure to find this bitmap within a certain area of the screen, and if it is found, it should click the mouse in an area that will move me safely away from the gas, wait two minutes, then resume thieving. Now I think I have done everything correctly, but was hoping if someone could look it over, I feel I must have done something wrong as this is my first script.

    I also need advice as to where in the script I should call the FindPoisonDmg procedure, and how I should set it so that it will work as I had hoped. Thanks for your time.

    Script is attached.

    EDIT: Ok, just got the gas event and it is NOT doing anything, I dont know whether it is a problem with finding the bitmap or what I have coded it to do afterwards but it didnt find it after the gas had hurt me ten times

  2. #2
    Join Date
    Sep 2007
    Posts
    15
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    umm what are bitmaps

  3. #3
    Join Date
    Aug 2007
    Posts
    8
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Bitmaps are picture files, in SCAR they are used to find objects, as an alternative to finding single colours (I believe, dont take my word for it, im still a noob)

  4. #4
    Join Date
    Nov 2006
    Location
    Location, Location
    Posts
    1,126
    Mentioned
    6 Post(s)
    Quoted
    41 Post(s)

    Default

    Okay, I looked at your code, and its pretty good for a start. I changed the look for gas procedure to look in the main screen, also made it so it wasn't an infinite loop. Added another variable to make it so your search isn't quite an infinite loop(for later expansion). Look through the code I just posted, i commented where I edited.

    SCAR Code:
    program New;
    {.include SRL/SRL.scar}

    var
      PoisonDmg, x, y : integer;
    const
      ChestColour = 549475; //Colour of the Chest
      WaitTime = 17150; //Time to wait in between thieving attempts (ms)

    procedure DeclarePlayers;
    begin
      SetupPlayers;

      Players[0].Name := '';
      Players[0].Pass := '';
      Players[0].Nick := '';
      Players[0].Active := True;

      LoadPlayerArray;
    end;

    procedure LoadBitmap;
    begin
      PoisonDmg := BitmapFromString2(False, 'aF599A78DAA58E490E80' +
           '200C45AFD43215978CF73F92FC6A8889E242593C7E1E1D202266A' +
           '6714A1F080631302E9F1BB24BD30472F012C11EC0046FA27A5FA6' +
           '3FE68828BD4EEE1B72B2D388D3F909BD622B72D5860A63DAD8E2B' +
           '2FE0C38F3CA5CFDAAFEFEFA5EFF67FE8ADFF63E7307048');
    end;

    procedure FindPoisonDmg;  //repeat until would make it an infinite loop and i
    begin                     //made it search the whole main screen
      if FindBitmapToleranceIn(PoisonDmg, x, y, MSX1, MSY1, MSX2, MSY2, 20) then
        begin
           Writeln('Found Poison Damage')
           Mouse(680, 91, 0, 0, true);
           Wait(10000+random(2000))
        end;
    end;

    procedure ThieveChest;
    var
      t : boolean;
    begin
      if not Loggedin then Exit;      //added a boolean that will be false until it
      repeat                          //finds the chest, changing to true so its not
      t := false;                     //an infinite loop
        if FindObj(x, y, 'hest', ChestColour, 10) then
        begin
           Mouse(x, y, 0, 0, False);
           ChooseOption('rch');
           Wait(500+random(500));
           FindPoisonDmg;             //Search for poison damage after searching chest
           Mouse(x, y, 0, 0, False);
           ChooseOption('rch');
           Wait(WaitTime + random(400));
           FindPoisonDmg;
           t := true;
           FindNormalRandoms;
        end;
      until t;
    end;
    begin
      SetupSRL;
      DeclarePlayers;
      if not(Loggedin) then LoginPlayer;
      SetScreenName(Players[CurrentPlayer].Nick);
      repeat
         ThieveChest;
      until false
    end.

  5. #5
    Join Date
    Aug 2007
    Posts
    429
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by Shenlok View Post
    EDIT: Ok, just got the gas event and it is NOT doing anything, I dont know whether it is a problem with finding the bitmap or what I have coded it to do afterwards but it didnt find it after the gas had hurt me ten times
    K, well since in your script after you search for the bitmap you have
    SCAR Code:
    Writeln('Found Poison Damage')

    SO, after testing it if you see that ^ in the debug box then it's a problem with the coding afterwards, if you dont see 'Found Poison Damage' in the debug box then it's a problem with your bitmap =]

    Hope that helps you figure it out =]

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. bitmap finding procedure help
    By Awkwardsaw in forum OSR Help
    Replies: 0
    Last Post: 09-21-2008, 01:01 AM
  2. Problems on Bitmap Finding?!
    By Raepor in forum OSR Help
    Replies: 10
    Last Post: 04-15-2008, 09:07 AM
  3. Finding MS Objects Using Bitmap Slices
    By Fizzi in forum OSR Help
    Replies: 2
    Last Post: 09-03-2007, 11:39 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
  •