Janilabo

Untitled

Apr 4th, 2013
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 7.61 KB | None | 0 0
  1. //OSRS07 - Willow Cutter and banker v0.7
  2. //Amberleaf
  3. //Instructions & more scripts can be found at http://www.scar-divi.com
  4. //2/4/13
  5.  
  6. {$DEFINE RS07}                         // V - Bright Settings
  7. {$DEFINE SMART}                        // Comment out to use normal browser
  8. {$DEFINE OSI_RS07_Color_Anti_Randoms}
  9.  
  10. {$I OSI\OSI.scar}
  11. {$I MSSL\MSSL.scar}
  12.  
  13. const
  14.   USERNAME = 'username';
  15.   PASSWORD = 'password';
  16.   BANK_PIN = 'pin'; // Change if you use bank pin
  17.   CHOP_DELAY = 1500; // Minimum delay between chops.
  18.   MAXIMUM_INTERVAL = 30000; // Maximum interval between chopped logs? Prevents our player from getting stuck (happens rarely).
  19.                      
  20. {$IFNDEF MSSL_1.04-2(+)}
  21.   begin                
  22.     ClearDebug;
  23.     WriteLn('MSSL is OUTDATED! Please update it with Includes Manager.');
  24.   end.
  25. {$ENDIF}
  26.  
  27. var
  28.   oldTreePt: TPoint; // We use this to store our last tree spot point, when we found 1.
  29.   lastChop: Integer;
  30.   forceBanking: Boolean;
  31.  
  32. procedure DeclarePlayers;
  33. begin
  34.   RS07_SetActivePlayer(USERNAME, PASSWORD, '', MSSL_TCAToTIA(MSSL_StrToTCA(BANK_PIN)));
  35. end;
  36.  
  37. procedure ScriptTerminate;
  38. begin
  39.   MSSL_Unsetup;
  40.   FreeOSI;
  41. end;
  42.  
  43. function EvilTreeAt(x, y: Integer): Boolean; // Make sure treeName is exactly the same as in uptext! CASE-SENSITIVE
  44. var
  45.   p: TPoint;
  46.   t: Integer;
  47.   b: Boolean;
  48.   a: TStrArray;
  49. begin
  50.   Result := False;  
  51.   p := Point(x, y); // We create 'p' point of x,y coordinates
  52.   if (PointInBox(p, RS07_GameActionBx) and RS07_LoggedIn) then // We check that point is inside main screen AND that we are logged in, before we continue.
  53.   begin
  54.     a := ['Chop down Tree', 'Chop down Oak', 'Chop down Willow', 'Chop down Maple', 'Chop down Yew', 'Chop down Magic tree'];    
  55.     t := GetSystemTime; // Timer reset
  56.     repeat    
  57.       case MSSL_MouseNearPt(p, 2) of // With this step we case the next action of.. If mouse is not near our point, we will move it to it.
  58.         True:                        // ..and else we will check for result.
  59.         if ((GetSystemTime - t) > 35) then // If time since mouse movement has been over 35 ms. then we can check for result...
  60.         begin
  61.           Result := RS07_IsUpTextCustomEx(a, [16777215, 65535], RS07_UpTextTol); // Is uptext with white and yellow as "Chop down *"? Result will be set as true, if it is...
  62.           if not Result then // OK, so result wasn't true, lets check for other texts...
  63.             b := (RS07_IsUpTextCustomEx(a, [16777215, 16776960], RS07_UpTextTol) or RS07_IsUpText('Walk here')); // If uptext is normal tree-text OR "Walk here", then variable 'b' will be set as true
  64.         end;
  65.         False:  
  66.         begin
  67.           case RS07_QuickObjectCheck of // If this MSSL variable is set as true, then...
  68.             True: SetMousePos(p.X, p.Y); // SetMousePos() will be used and else...
  69.             False: RS07_MoveMouse(p.X, p.Y); // Normal RS07_MoveMouse() movement!
  70.           end;    
  71.           t := GetSystemTime; // We mark the timer as current time (after movement)
  72.         end;
  73.       end;
  74.       MSSL_Wait(0); // MSSL_Wait with hotkey check!
  75.     until (Result or b or ((GetSystemTime - t) > 250)); // If this or this or this, then we are ready to break out!
  76.   end;
  77. end;
  78.  
  79. procedure GetBanking;
  80. var
  81.   x, y: Integer;
  82.   c: TPoint;
  83. begin
  84.   if (forceBanking or RS07_InventoryFull) then  // bag full
  85.   begin  
  86.     forceBanking := False; // resets the force.                    
  87.     c := BoxCenter(RS07_GameActionBx); // Stores center point from RS07_GameActionBx (main screen) to 'c' variable (TPoint).
  88.     SetCompassAngleAndHeight(Dir_North, True);      
  89.     if MSSL_FindColorSpiralTolCS(227, 159, x, y, 4969197, 558, 8, 730, 164, 8, MSSL_ColorSettings2(2, 0.19, 2.34)) then
  90.     begin
  91.       Mouse(x, y, 0, 0, True); // left click position and run to bank
  92.       MSSL_WaitRange(5000, 8999);
  93.       if RS07_OpenBank(RS07_BANK_DRAYNOR) then //find bank
  94.       begin
  95.         MSSL_WaitRange(990, 2100);          
  96.         RS07_DepositEverythingEx([0]);
  97.         MMouse(577, 231, 0, 0);
  98.         MSSL_WaitRange(250, 750);    
  99.         MSSL_WaitRange(500, 1400);
  100.         MSSL_WaitRange(550, 1250);  
  101.         RS07_SetCompass(Dir_North);
  102.         Mouse(626, 134, 1, 1, True);
  103.         MSSL_WaitRange(8000, 9999);
  104.       end;
  105.     end;
  106.   end;
  107. end;
  108.  
  109. procedure GetChopping;
  110. var
  111.   f: Boolean;
  112.   o, n, x, y, t: Integer;
  113.   c: TPoint;
  114.   p: TPointArray;
  115. begin
  116.   c := BoxCenter(RS07_GameActionBx);
  117.   if ((GetSystemTime - lastChop) > CHOP_DELAY) then
  118.     f := RS07_FindObjectsEx(p, ['Chop down Willow'], um_IsUpTextCustom, MSSL_ColorSettings2(2, 0.23, 0.72), 2581337, 3, 40, RS07_GameActionBx.X1, RS07_GameActionBx.Y1, RS07_GameActionBx.X2, RS07_GameActionBx.Y2, 1, oldTreePt);
  119.   case (((GetSystemTime - lastChop) <= CHOP_DELAY) or f) of  
  120.     True:
  121.     begin
  122.       WriteLn(MSSL_TheTime + ': Found a tree...');
  123.       if (f and ((GetSystemTime - lastChop) > CHOP_DELAY)) then
  124.       begin          
  125.         oldTreePt := Point(p[0].X, p[0].Y);
  126.         Mouse(p[0].X, p[0].Y, 0, 0, True);
  127.         lastChop := GetSystemTime;
  128.       end else                  
  129.         if f then
  130.           RS07_MoveMouse(p[0].X, p[0].Y);
  131.       SetLength(p, 0);  
  132.       t := GetSystemTime;
  133.       o := RS07_UsedInventorySlots;
  134.       repeat      
  135.         n := RS07_UsedInventorySlots;
  136.         if ((n > -1) and (n <> o)) then // To make sure the used slots were detected correctly
  137.         begin    
  138.           t := GetSystemTime; // We reset the timing mark of when we got last log to our inventory.
  139.           o := n;
  140.         end;
  141.         GetBanking;
  142.         c := BoxCenter(RS07_GameActionBx);
  143.         if MSSL_FindColorSpiralTolCS(227, 159, x, y, 610633, 1, 1, 510, 334, 2, MSSL_ColorSettings2(2, 0.06, 0.03)) then //check for nests
  144.         begin
  145.           MMouse(x, y, 0, 0);
  146.           WriteLn('found a nest or root random');
  147.           MSSL_WaitRange(40, 50);
  148.           if (RS07_UpTextContains('Take') or RS07_UpTextContains('Pick')) then
  149.           begin
  150.             Mouse(x, y, 0, 0, True);
  151.             MSSL_WaitRange(3000, 5000);
  152.           end;    
  153.         end;
  154.         if FindColorTol(x, y, 3240548, 39, 363, 90, 405, 2) then //lvl up check
  155.           Mouse(292, 447, 0, 0, True);
  156.         //OSIFindRandoms;  //wip  
  157.         if RS07_IsUpText('Chop down') then // Just to check that we still have mouse inside the tree.
  158.         begin          
  159.           GetMousePos(x, y);
  160.           forceBanking := EvilTreeAt(x, y);
  161.           if forceBanking then
  162.             GetBanking;
  163.         end;
  164.       until (not RS07_IsUpText('Chop down') or ((GetSystemTime - t) > MAXIMUM_INTERVAL));  
  165.     end;  
  166.     False: oldTreePt := BoxCenter(RS07_GameActionBx);    
  167.   end;      
  168. end;
  169.  
  170. procedure ScriptSetup;
  171. begin
  172.   RS07_UpTextCustomColors := [16777215, 16776960]; // Used for detecting only normal Willow tree's with RS07_FindObject()
  173.   DeclarePlayers;
  174.   Login;      
  175.   RS07_SetCompass(Dir_North);
  176.   RS07_SetCameraAngleH;
  177.   RS07_SetMoveSpeed(1);
  178.   RS07_OpenGameTab(3);
  179.   oldTreePt := BoxCenter(RS07_GameActionBx);  
  180.   RS07_ControlCameraScriptwise := True; // We set the camera to highest angle manually, so banking functions don't need to worry about it!
  181. end;
  182.  
  183. begin
  184.   SetUpOSI;
  185.   MSSL_Setup;  
  186.   ScriptSetup;
  187.   repeat    
  188.     case RS07_LoggedIn of
  189.       False:
  190.       if RS07_LogInPlayer then // Logins with currently active player's details.  
  191.       begin    
  192.         RS07_SetCompass(Dir_North);
  193.         RS07_SetCameraAngleH;
  194.         RS07_SetMoveSpeed(1);
  195.         RS07_OpenGameTab(3);
  196.         oldTreePt := BoxCenter(RS07_GameActionBx);      
  197.       end;
  198.       True: GetChopping;
  199.     end;    
  200.     MSSL_Wait(0);
  201.   until False;
  202. end.
Advertisement
Add Comment
Please, Sign In to add comment