Results 1 to 7 of 7

Thread: My second ever script, help me improve my skills (which arent bad)

  1. #1
    Join Date
    Jul 2007
    Posts
    70
    Mentioned
    0 Post(s)
    Quoted
    25 Post(s)

    Default My second ever script, help me improve my skills (which arent bad)

    Server is imagine, script kills hank the tank.
    Feel free to comment on my second script, and or help me improve my skills overall. Thanks!

    Code:
    program HANKTHETANK;
    
    //camera north, high as possible
    
    const
      STOP_KEY = 113; // F2 to exit
    
    Procedure FailSafe();
    var
      x,y,pikachu:Integer;
    begin
      pikachu := BitmapFromString(31, 26, 'meJytlu9LU1EYx+1lL3rhi0EMhC' +
                'EiMiRkGMOhOFqLaVu4MBctRTcVZEmasloylunSzJzmtHT0c2bDFMm' +
                'skKAXERGERiAR4Z9i0GecOoyp272X4OFyuOecz33O9/k+Z7PYT5uq' +
                'T+4bln9ThwoKDlqTGSwzb+1UmD0MDIYKQsmWkfmlvHwWVFZ5S8pql' +
                'ZPFrqnn78SWHGuqrO16g0kVWWycXHiTA55Wo6ZNlRpyY8far+Ia50' +
                'FwQTZWONWSxV7/6g9jvZeBiL0LtJHF3uiDFE9bKG69cqc6MJTJZ0w' +
                'FpdRqyelKdYYbJlYckQRwc1sw8xQCq0Fqomn+fezZa5h1Nx8Br+mO' +
                'Hm/pK3e1llgbSo22omKzxKoityx+TUdqExOeCs8RfIIjmM53A6e+R' +
                '42VRWabQjXkSYnWpW+usVTzwpeLyc/TLzbOjL8kc1twCsGBl9obCw' +
                '1lwI/oi3Wlx5Q017XR2Z7IXTKkcCf6J9qWv/tWtskcZfhQGh6KW7p' +
                'uoDlwg8VxWKcXkbe5BqeTkAOhqCTjbZ4XHn90x1ZdI4sIrgSeeXz5' +
                '5nZiuT863XV1mLOjLcbuXN/hiTLnZt5KeG3PKHyUKXN4kEXCZYjtL' +
                'Mt0rJztG5okf8jtr36iCZkDR/P64Sf2gVl2UVMyp5QIzheRiylnNM' +
                'mAoNbM7jUnA96ExubQB3hhoY60PYkPwFFGwIXPqUJjfJ04e2+NKY4' +
                'MEKzMcF9z8h5yR18EwYHjGe/TT6CAkLyAIwvH4X144mFzIGix1Vvr' +
                '3FnMHPdbk+8S8N3d30KWpvsb6ZqOpf7K4r9OgcCiNoaUBVX+05Buo' +
                'tQmTYTPOT69T01lQVEApjB5XivuyydngBwffcickokmov3pfbCkTW' +
                'i+DEkbA2xtbcMXaWOVcrcfOGPhCg3kLH+StvQhLZzlCg3kLH/2DsZ' +
                'wNVqhv4abMEf+A+MJ/IlDuCGDt2Y0/C7k1cffG+YPhu/ywP+FS324' +
                'fukdVfA/TVJ00Q==');
    
        presskey(27); //activate invo to check
        wait(75);
    
        if FindBitmapToleranceIn(pikachu, x, y, 548, 206, 733, 466, 25) then
        begin
          writeln('We have died');
          terminatescript();
        end;
      FreeBitmap(pikachu);
    end;
    
    Procedure ClickMonster();
    var
      x,y,xi,yi:Integer;
    begin
        if FindColorTolerance(x, y, 65280, 229, 1, 393, 231, 5){health bar green} or FindColorTolerance(x, y, 255, 229, 1, 393, 231, 5){health bar red} or FindColorTolerance(x, y, 606819, 229, 1, 393, 231, 10){his brown eyes} then //1st phase color
        begin
          movemouse(x,y+25);//+25 in case health bar is found (ensure click the monster)
          wait(250);
            if FindColorTolerance(xi, yi, 65535, 56, 9, 93, 18, 10) then //if find uptext then it is ok to click
            begin
              clickmouse(x,y+25,1);//+25 in case health bar is found (ensure click the monster)
              writeln('Click Monster');
            end;
      end;
    end;
    
    Procedure QuickPrayer();
    var
      x,y,color:Integer
    begin
        //activate prayer tab first
        KeyDown(114);//f3 key press
        wait(20);
        KeyUp(114);//f3 key press
        wait(75);
        color := getcolor(680,352);
          if color = 3292228  then //qucik prayers highlight color when active
          begin
            movemouse(722,70);
            wait(200);
            clickmouse(722, 70,1);//click quick prayer
            ClickMonster();//re enter combat
            writeln('Turn ON quick prayers'); //ss
          end;
    end;
    
    Procedure EquipMainItems();
    var
      xs,ys,xw,yw,Weapon,Shield:Integer;
    begin
      //dragon bone ss (located in 2nd or 3rd invo slot)
      Shield := BitmapFromString(29, 30, 'meJyt1t0rQ3EYwPHJldLyNim0Ce' +
            'VltrNjO9ty0JALJblxIUliXiJJJCWSG/+1Lw+P+Z1zfmc29VzYcc5' +
            'nz9v5NddfcwPRkUgQwevtBODVfPWmtPC/ONTudG5/1jmccx8qy3+V' +
            'o5Lh4kh3ksgke7Ympq+L1SbTltseq7U7b9Fyg/jgm+NTtEUvRsXb8' +
            'vqzv2IvMJNxCLl/NT1GT249nzTuy0s8SEpPC7UXfxVH4tVf60ylE3' +
            '3D3M+Dsc0R/DhflKjniydO6dTxzgoeCNHZP6ohZpDlOg+SklGgwQZ' +
            'N+RiaKhe3J2cOsgUKlNIok8IvCmXA3t6UBOaFW1FTQDtLD49y85du' +
            'hQWgmaSNSaipYYBqhrIMXes1QkH522R7hizD2pvJR7GKK/Ujf5tR7' +
            'MbYZPOsmvZUMcmWxmpE9SHUtLCMLDswKEvFVvDx3PGMjf2R40zjnd' +
            'VXbKirmyFy5igrSWrajbttOS4E1K+W3YCtf7Jae3Dfmv8KYTnE2GR' +
            'jUrJgobhELEuHg6wsP9ECy1M7U1neZaZmjF4nFXpCxrLsGyetARrT' +
            '13FoWHrLv37l2WBalj+2pQQmB45ReOMG/tUEJD7K1wyTKdXaMTkMF' +
            'Ww0WytcTlfDVLYFE4okT/OlL/Nba6eZaOw8LynTD2qtmYCcVKwoP2' +
            'ba1IJdNcDQO3PVWpPmO5ehuCc=');
      //ornate katana (located in 2nd or 3rd invo slot)
      Weapon := BitmapFromString(17, 18, 'meJxjZGBgZGCwrVsNJI1sXIhBgc' +
            'sfOcWWANUrKBgAETFanLv3muRMgmgh0hagYq8ZZ90mHiHeYRBdHkY' +
            'KvvOvk6oLiHznXoUwiNclJcgJRNEOWhBdxOgFqvExVQKGobOeLJDt' +
            'qiVIpC6gRZYaUrKCDEBETEgC1UAU68U16ETXEBn4QGWCGuat+99Yl' +
            'sxVcksgMjSAyo4e3DP12DugFhWfdJJ0GaX31Ox+rRaYT7yuw/t36S' +
            'U2KzjHaIWVEq9rz85NBUk+Kp4pkNAgUte+XVuKU3xlbUOkrAKI17V' +
            '/97ZpdaETK4NISk4H92yf2RC2fdMaANLr1FA=');
    
        presskey(27); //activate invo to check
        wait(75);
          if FindBitmapToleranceIn(Weapon, xw, yw,593, 205, 687, 250, 15) then
          //check to see if main weapon & shield still in invo, if so equip them
          begin
            movemouse(xw, yw);
            wait(250);  //seems like good wait time
            clickmouse(xw, yw, 1);
            writeln('Found weapon, equiping now');
          end;
          wait(250); {make sure not clicking too fast, both items get equiped}
          if FindBitmapToleranceIn(Shield, xs, ys, 593, 205, 687, 250, 15) then
          //check to see if main weapon & shield still in invo, if so equip them
          begin
            movemouse(xs, ys);
            wait(250);  //seems like good wait time
            clickmouse(xs, ys, 1);
            writeln('Found shield, equiping now');
          end;
      FreeBitmap(Shield);
      FreeBitmap(Weapon);
    end;
    
    Procedure getSpecWeapon();
    var
      x,y,xi,yi,AB,color:Integer;
    begin
      // abby bludgeon (2nd or 3rd invo slots)
      AB :=BitmapFromString(10, 9, 'meJxjZGBgZGAwsnHBigQFRYGIEay' +
          'GEUMlJ68HRAEDgxoYySIrWLHvWPuCVRISUiAFnHoMnKbIClrnryju' +
          'mNDeuaq6dnZBYW9ScrWJaTRQVkHBAChbO2UuxLolu4/0Lt+U19QVl' +
          'V3YuWgNRDtEGZAEStVNnZ/T0AFRHJtfBlEAMQTuZojiruXrNDRskN' +
          '0PFIcgiOKw1BwA0rM6Ig==');
    
      presskey(27); //activate invo to check
      wait(75);
        if FindBitmapToleranceIn(AB, x, y, 593, 205, 687, 250, 20) then
          begin
            movemouse(x, y);
            wait(250);
            color := getcolor(161,17);
             if color = 4231423  then //make sure its not our other weapon (AB uptext is longer : ))
             begin
              clickmouse(x, y,1);
              writeln('Found Spec Weapon');
             end;
          end;
      FreeBitmap(AB);
    end;
    
    Procedure isSpec();
    var
      x,y,color:Integer
    begin
        KeyDown(116); //f5 for combat mode selector tab
        wait(20);
        KeyUp(116);
        wait(200);
          if findcolortolerance(x, y, 3501876, 586, 417, 627, 429, 5) then //we have spec availible
          begin
            color := getcolor(695,222);
            writeln('equipping spec weapon');
            getSpecWeapon();
              if color = 2070783  then // check to make sure AB is equiped
              begin
                KeyDown(116); //f5 for combat mode selector tab
                wait(20);
                KeyUp(116);
                wait(100);
    
                movemouse(644,424) ;
                wait(400);
                holdmouse(644,424,1);//click spec
                wait(10);
                releasemouse(644,424,1);
                wait(400);
                ClickMonster();
                wait(250);
    
                EquipMainItems();//re equip our good gear
                writeln('equip main items');
                ClickMonster();
              end;
          end;
    end;
    
    Procedure GetHealth();
    var
      x,y,xi,yi,Bandage:Integer;
    begin
      Bandage:=BitmapFromString(32, 27, 'meJytln9rEnEcx9cD6CEEewQR+6' +
              '/on6D+KYIWa41EWPvJTI7D3NQOkWM5Z4coa4p4iGvZcs0SRTTb2Ng' +
              'eWa/4wJfj3G7mDV6Mm/p9vz8/vzr18PGUD25NTIAfBW/lNV3Plcs8' +
              'PHjy7GaVw9H1dD5fOThoHx/jciNZiHLEMAq2/fP3oH9+Pri4aPb7k' +
              'sLk5D2fyhup1E61iiAxd05Ouqen0Ds7+97paLHY2Clw0EinUW50uz' +
              '96PfQJHlqDP2K0/6uV3S2OkYKEncpmibDean1rt4FnjFxe1cND6qZ' +
              'SuLbdoryZyyELHK8dHe01m0C0Li+MyvV6NJkEmSUPfVHe3vmMDpT2' +
              'v3IWGBW70cDoKq/dWi1umh5VEmWrVOI4MCTUHDh4O34HxAsj5SWfF' +
              'CPTjH/Y/AjDjRZlBCU8mgUYMXj5SkXE4VovTjEJrhT4l1PySQoOLM' +
              '5WoUCJQIyUhRNOFfe+OAv4rwOZDEgKdIEHeRewBt5lYMC0LPESOyW' +
              'r8gKpIUbKyzAiHASx4K9EDqwP0CNqqLyGw5bUnDUUO4kcQqGF9WhY' +
              'VYkHCijoiQRjDEyaeF1aGZUaXiBtBU1biW1o0k3Elb60Fd5F3nNxs' +
              'ezg7SVl5EVB19cScd2pDGoLeFHmGZbC4RVN40rEa9hOlgg7eSALSk' +
              'EULmVprlNftgnmV1dhIRTCSHmJHV6AEaBMKTAZVr5queQqoFNv5t8' +
              'GFhchuLzstJNEqAxtvTRm7wuHXsmmv5ybexUIwOtgEC8geIpMQxlI' +
              'piyzlRxd2WkhFyPhPZ2efj4z82J2lvpQbZSZcDqZ3U65xuO/buNS0' +
              'eIyRIoiUBCUGT8Wh21wKY/xbSXrzJUOzB5bw9JRCuuT6V9ZpWDbBb' +
              '4vuC6Q5TYaXXnEnxCocZ1w63gr+/lB4rMawt37jzze9aPszPEvmEt' +
              'rVw==');
    
        presskey(27); //activate invo to check
        wait(75);
    //looks at health orb for red or orange, or yellow color, which means eat now
    //if found it will eat the monkey bandage,located at top left invo slot
    
          if findcolortolerance(x, y,65535, 721, 28, 742, 41, 40) or  FindColorTolerance(x, y, 2070783, 721, 28, 742, 41, 40) or FindColorTolerance(x, y, 255, 721, 28, 742, 41, 40) then
          begin
            writeln('Found low health');
              if FindBitmapToleranceIn(Bandage, xi, yi, 548, 209, 599, 253, 25) then
              begin
                movemouse(xi, yi);
                wait(200);
                clickmouse(xi, yi,1); //eat monkey bandage, can at most every 5 secs?
                ClickMonster(); //re-enter fight
                writeln('Found food, now healing');
                quickprayer();
              end;
          end;
      FreeBitmap(Bandage);
    end;
    
    Procedure GetPrayer();
    var
      x,y,xi,yi,xii,yii,ox,oy:Integer;
    begin
        //looks at prayer orb for yellow or orange color
        //also the timing is good at this point to reup on overload
        if {FindColorTolerance(x, y, 2070783, 737, 67, 758, 80, 40) or}{yellow} FindColorTolerance(x, y, 255, 737, 67, 758, 80, 40){orange} then
        begin
          presskey(27); //activate invo to check
            if FindColorTolerance(xi, yi, 6765735, 556, 247, 722, 360, 40) then  //super pot
            begin
            //if found it will sip on the super pots in invo, 2nd,3rd,4th rows
            movemouse(xi,yi);
            wait(250);
            clickmouse(xi,yi,1);
            writeln('Restoring PP');
              if FindColorTolerance(xii, yii, 6765735,556, 247, 722, 360, 40) then
                begin
                  movemouse(xii,yii);
                  wait(2000);
                  clickmouse(xii,yii,1);
                  writeln('Restoring PP #2');
                end;
              if FindColortolerance(ox, oy, 921106, 558, 358, 725, 430, 2) then
              begin
                //if found it will sip on the the 2 rows of overloads in invo, 5&6 row
                movemouse(ox, oy);
                wait(2000);
                clickmouse(ox, oy,1);
                writeln('Restoring Stat Boost');
              end;
            end;
    
          //teminate if no pp left
          if not FindColorTolerance(xi, yi, 6765735,604, 209, 721, 360, 40) then
          begin
            writeln('No super restores found, end script');
            terminatescript();
          end;
          ClickMonster();  //re-enter fight
        end;
    end;
    
    Procedure Combat();
    var
      x,y:Integer;
    begin
    //1   Start of fight (if no uptext found, we are not in combat > start fight)
        if not FindColorTolerance(x, y, 16645629, 48, 21, 110, 30, 40) then
        begin
          FailSafe(); //if we die script will terminate
          ClickMonster();
          wait(200);
        end;
     //2  General fight (if uptext found)
        if FindColorTolerance(x, y, 16645629, 48, 21, 110, 30, 5) then
        begin
          getprayer();
          gethealth();
          //isSpec(); still finishing up tweaking this to run better
        end;
    end;
    
    begin
      while not(isKeyDown(STOP_KEY)) do
      Combat();
    end.
    Last edited by imalama101; 05-08-2018 at 03:58 AM.

  2. #2
    Join Date
    Dec 2011
    Posts
    2,147
    Mentioned
    221 Post(s)
    Quoted
    1068 Post(s)

    Default

    Quote Originally Posted by imalama101 View Post
    Server is imagine, script kills hank the tank.
    Feel free to comment on my second script, and or help me improve my skills overall. Thanks!
    Nice second script. I don't know anything about this private server so I can only give a couple general tips. I'm assuming it has no anticheat hence the static hardcoded clicking and lack of randomness. You might want to consider using DTMs instead of bitmaps for things like inventory items or situations where objects you want to find have changing things in their backgrounds. DTMs are used similarly to bitmaps (DTMfromString := '...', if findDTM() then, freeDTM(someDTM)) and allow for more flexibility whereas a bitmap (unless you use bitmap tolerance, deformed bitmap) will fail if the exact match pixel-by-pixel isn't found. You can make DTMs using the built-in DTM editor extension in Simba. A useful feature in that editor is "Show Matching DTMs" which will show all matches with a red X. Old tutorial by YoHoJo: https://www.youtube.com/watch?v=SlS4q9MiFX4

    Also,
    Simba Code:
    color := getcolor(680,352);
    if color = 3292228 then
    begin
    {...}
    end;

    can be simplified to:

    Simba Code:
    if getColor(680, 352) = 3292228 then
    begin
    {...}
    end;

  3. #3
    Join Date
    May 2012
    Location
    Glorious Nippon
    Posts
    1,011
    Mentioned
    50 Post(s)
    Quoted
    505 Post(s)

    Default

    Quote Originally Posted by Clarity View Post
    You might want to consider using DTMs instead of bitmaps for things like inventory items or situations where objects you want to find have changing things in their backgrounds. DTMs are used similarly to bitmaps (DTMfromString := '...', if findDTM() then, freeDTM(someDTM)) and allow for more flexibility whereas a bitmap (unless you use bitmap tolerance, deformed bitmap) will fail if the exact match pixel-by-pixel isn't found. You can make DTMs using the built-in DTM editor extension in Simba. A useful feature in that editor is "Show Matching DTMs" which will show all matches with a red X. Old tutorial by YoHoJo: https://www.youtube.com/watch?v=SlS4q9MiFX4
    I'm curious as to why you recommend DTMs over bitmaps + tolerance. To me, bitmaps seem a lot easier to make and manage, and I can't think of any case where I'd prefer a DTM over a bitmap. Could easily just be my lack of experience with DTMs though.

  4. #4
    Join Date
    Jul 2007
    Posts
    70
    Mentioned
    0 Post(s)
    Quoted
    25 Post(s)

    Default

    Quote Originally Posted by Citrus View Post
    I'm curious as to why you recommend DTMs over bitmaps + tolerance. To me, bitmaps seem a lot easier to make and manage, and I can't think of any case where I'd prefer a DTM over a bitmap. Could easily just be my lack of experience with DTMs though.
    Citrus, is there anything you see that I could be doing better?

  5. #5
    Join Date
    Jul 2007
    Posts
    70
    Mentioned
    0 Post(s)
    Quoted
    25 Post(s)

    Default

    Quote Originally Posted by Citrus View Post
    I'm curious as to why you recommend DTMs over bitmaps + tolerance. To me, bitmaps seem a lot easier to make and manage, and I can't think of any case where I'd prefer a DTM over a bitmap. Could easily just be my lack of experience with DTMs though.
    Citrus any improvemen's you see that I could use?

  6. #6
    Join Date
    May 2012
    Location
    Glorious Nippon
    Posts
    1,011
    Mentioned
    50 Post(s)
    Quoted
    505 Post(s)

    Default

    Quote Originally Posted by imalama101 View Post
    Citrus any improvemen's you see that I could use?
    No need to post the same thing twice...

    For uptext, Simba can probably handle that: http://docs.villavu.com/simba/scriptref/ocr.html
    See my RSPS scripts for an example.

    You're creating and freeing bitmaps repeatedly throughout the script. Generally you want to create them all at the beginning and free them when the script stops. Check out the AddOnTerminate function.

  7. #7
    Join Date
    Dec 2011
    Posts
    2,147
    Mentioned
    221 Post(s)
    Quoted
    1068 Post(s)

    Default

    Quote Originally Posted by Citrus View Post
    I'm curious as to why you recommend DTMs over bitmaps + tolerance. To me, bitmaps seem a lot easier to make and manage, and I can't think of any case where I'd prefer a DTM over a bitmap. Could easily just be my lack of experience with DTMs though.
    I've found DTMs to be more flexible with detection and bitmaps more prone to break scripts. Maybe I make bad bitmaps :P

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
  •