Advertisement
WarPie90

Work in progress

Jun 12th, 2016
413
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 3.33 KB | None | 0 0
  1. program new;
  2. {$DEFINE SMART}
  3. {$I SRL/OSR.simba}
  4. (*
  5.   A simple minimalistic powerminer I created to teach someone some basics of Simba scripting.
  6. *)
  7.  
  8. //declare our player.
  9. procedure DeclarePlayers();
  10. begin
  11.   with players.New()^ do
  12.   begin
  13.     LoginName := '';
  14.     Password  := '';
  15.     IsActive  := True;
  16.     IsMember  := True;
  17.     World     := 336;
  18.   end;
  19.   Players.SetCurrent(0);
  20. end;
  21.  
  22. //call this method anywhere!
  23. procedure Antiban();
  24. begin
  25.   case Random(7000) of //increase the number if it's to rare or too often.
  26.     1:begin
  27.         stats.MouseOver(SKILL_MINING);
  28.         Wait(Random(2000,6000));
  29.         if Random(0, 4) > 1 then
  30.           Inventory.Open();
  31.       end;
  32.     2:begin
  33.         Wait(Random(5000,40000));
  34.       end;
  35.     3: begin
  36.          //do something?
  37.        end;
  38.   end;
  39. end;
  40.  
  41.  
  42. //check if player is animating. Uses 0.9 seconds by default and 250pixels has to change.
  43. function IsAnimating(B:TBox=[223,132,303,212]; minShift:Int32=250; maxWait:Int32=900): Boolean;
  44. var
  45.   t,shift:UInt32;
  46.   function GetPixelShift(T:Int32; B:TBox):Integer;
  47.   var
  48.     BMP1,BMP2:Int32;
  49.   begin
  50.     BMP1 := BitmapFromClient(B);
  51.     Wait(T);
  52.     BMP2 := BitmapFromClient(B);
  53.     Result := CalculatePixelShift(BMP1,BMP2,[0,0,B.Width()-1,B.Height()-1]);
  54.     FreeBitmaps([BMP1,BMP2]);
  55.   end;
  56.  
  57. begin
  58.   t := GetTimeRunning() + maxWait;
  59.   repeat
  60.     shift := GetPixelShift(70,B);
  61.     if (shift > minShift) then
  62.       Exit(True);
  63.   until GetTimeRunning() > t;
  64. end;
  65.  
  66. //click a rock if one can be found
  67. procedure ClickRocks();
  68. var
  69.   i:Int32;
  70.   TPA:TPointArray;
  71.   ATPA:T2DPointArray;
  72.   B:TBox;
  73. begin
  74.   SetColorToleranceSpeed(2);
  75.   FindColorsTolerance(TPA, 2174283, 250,120,310,200,  14);
  76.  
  77.   ATPA := ClusterTPA(TPA, 4);                           //split it into separate stones
  78.   SortATPAFromMidPoint(ATPA, MainScreen.GetMiddle());   //sort the groups from where we stand, so that we click what's closest
  79.  
  80.   //just for show (debugging):
  81.   Smart.Image.DrawBox(TBox([200,115,328,210]), $FF0000);
  82.   Smart.Image.DebugATPA(ATPA);  //debug the groups.
  83.   //end of that
  84.  
  85.  
  86.   //we need to loop though each group
  87.   for i:=0 to High(ATPA) do
  88.   begin
  89.     B := GetTPABounds(ATPA[i]);
  90.  
  91.     //if the group isn't dense enough, skip to next iteration of the loop.
  92.     if Length(ATPA[i]) / (B.Width()*B.Height()) < 0.6 then
  93.       Continue; //jumps back to the start of the loop, and increases `i`
  94.  
  95.     //if width or height is too small, skip to next iteration.
  96.     if (B.Width() < 20) or (B.Height() < 20) then
  97.       Continue;
  98.  
  99.     Mouse.Move(MiddleTPA(ATPA[i]), 5);
  100.     Wait(Random(70,130));
  101.     if mainscreen.IsUpText(['Mine Rocks']) then
  102.     begin
  103.       mouse.Click(mouse_left);
  104.  
  105.       //wait while character is doing stuff
  106.       while IsAnimating() do
  107.         Wait(70);
  108.  
  109.       break; //stop the loop, we clicked our stone!
  110.     end;
  111.   end;
  112.   Smart.Image.DrawClear(0);
  113. end;
  114.  
  115. begin
  116.   //declare our character.
  117.   DeclarePlayers();
  118.  
  119.   //setup smart
  120.   Smart.EnableDrawing := True;
  121.   Smart.Init();
  122.  
  123.   Players.LoginCurrent();
  124.   MainScreen.SetAngle(True);
  125.  
  126.   //repeat forever!
  127.   repeat
  128.     Antiban();
  129.  
  130.     //while inventory isn't full click a rock:
  131.     while not Inventory.IsFull() do
  132.       ClickRocks();
  133.  
  134.     //drop EVERYTHING in our inventory now.
  135.     Inventory.DropItems(DROP_PATTERN_SNAKE);
  136.   until False;
  137. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement