Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program new;
- {$DEFINE SMART}
- {$I SRL/OSR.simba}
- (*
- A simple minimalistic powerminer I created to teach someone some basics of Simba scripting.
- *)
- //declare our player.
- procedure DeclarePlayers();
- begin
- with players.New()^ do
- begin
- LoginName := '';
- Password := '';
- IsActive := True;
- IsMember := True;
- World := 336;
- end;
- Players.SetCurrent(0);
- end;
- //call this method anywhere!
- procedure Antiban();
- begin
- case Random(7000) of //increase the number if it's to rare or too often.
- 1:begin
- stats.MouseOver(SKILL_MINING);
- Wait(Random(2000,6000));
- if Random(0, 4) > 1 then
- Inventory.Open();
- end;
- 2:begin
- Wait(Random(5000,40000));
- end;
- 3: begin
- //do something?
- end;
- end;
- end;
- //check if player is animating. Uses 0.9 seconds by default and 250pixels has to change.
- function IsAnimating(B:TBox=[223,132,303,212]; minShift:Int32=250; maxWait:Int32=900): Boolean;
- var
- t,shift:UInt32;
- function GetPixelShift(T:Int32; B:TBox):Integer;
- var
- BMP1,BMP2:Int32;
- begin
- BMP1 := BitmapFromClient(B);
- Wait(T);
- BMP2 := BitmapFromClient(B);
- Result := CalculatePixelShift(BMP1,BMP2,[0,0,B.Width()-1,B.Height()-1]);
- FreeBitmaps([BMP1,BMP2]);
- end;
- begin
- t := GetTimeRunning() + maxWait;
- repeat
- shift := GetPixelShift(70,B);
- if (shift > minShift) then
- Exit(True);
- until GetTimeRunning() > t;
- end;
- //click a rock if one can be found
- procedure ClickRocks();
- var
- i:Int32;
- TPA:TPointArray;
- ATPA:T2DPointArray;
- B:TBox;
- begin
- SetColorToleranceSpeed(2);
- FindColorsTolerance(TPA, 2174283, 250,120,310,200, 14);
- ATPA := ClusterTPA(TPA, 4); //split it into separate stones
- SortATPAFromMidPoint(ATPA, MainScreen.GetMiddle()); //sort the groups from where we stand, so that we click what's closest
- //just for show (debugging):
- Smart.Image.DrawBox(TBox([200,115,328,210]), $FF0000);
- Smart.Image.DebugATPA(ATPA); //debug the groups.
- //end of that
- //we need to loop though each group
- for i:=0 to High(ATPA) do
- begin
- B := GetTPABounds(ATPA[i]);
- //if the group isn't dense enough, skip to next iteration of the loop.
- if Length(ATPA[i]) / (B.Width()*B.Height()) < 0.6 then
- Continue; //jumps back to the start of the loop, and increases `i`
- //if width or height is too small, skip to next iteration.
- if (B.Width() < 20) or (B.Height() < 20) then
- Continue;
- Mouse.Move(MiddleTPA(ATPA[i]), 5);
- Wait(Random(70,130));
- if mainscreen.IsUpText(['Mine Rocks']) then
- begin
- mouse.Click(mouse_left);
- //wait while character is doing stuff
- while IsAnimating() do
- Wait(70);
- break; //stop the loop, we clicked our stone!
- end;
- end;
- Smart.Image.DrawClear(0);
- end;
- begin
- //declare our character.
- DeclarePlayers();
- //setup smart
- Smart.EnableDrawing := True;
- Smart.Init();
- Players.LoginCurrent();
- MainScreen.SetAngle(True);
- //repeat forever!
- repeat
- Antiban();
- //while inventory isn't full click a rock:
- while not Inventory.IsFull() do
- ClickRocks();
- //drop EVERYTHING in our inventory now.
- Inventory.DropItems(DROP_PATTERN_SNAKE);
- until False;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement