Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program new;
- {$DEFINE SRL_USE_REMOTEINPUT}
- {$I SRL/osr.simba}
- const
- WHAT_TO_MAKE = ERSCraftItem.RUBY_AMULET;
- GEM_NEEDED_2_MAKE = 'Ruby';
- LOGIN_NAME = 'yourname';
- LOGIN_PASS = 'yourpass';
- IS_MEMBER = False;
- type
- TSimpleCrafter = record
- RSW: TRSWalker;
- end;
- const
- F2P_WORLDS = [301,308,380,434,435,436,437,451];
- P2P_WORLDS = [302,303,304,305,306,307,309,310,311,312,313,314,315,317,318,319,320];
- procedure TMouse.Move(Rect: TRectangle; ForcedMove: Boolean = False); override;
- begin
- if (ForcedMove) or (not Rect.Contains(Mouse.Position())) then
- Mouse.Move(srl.rowp(mouse.Position(), Rect));
- end;
- function TSimpleCrafter.WorldToMS(PlayerPoint, WorldPoint: TPoint): TRectangle;
- var pt: TPoint;
- begin
- pt := RSW.WorldToMM(PlayerPoint, WorldPoint, Minimap.GetCompassAngle(False));
- Result := Minimap.PointToMsRect(pt);
- end;
- procedure TSimpleCrafter.DeclarePlayers();
- begin
- if IS_MEMBER then
- Login.AddPlayer(LOGIN_NAME, LOGIN_PASS, '', P2P_WORLDS)
- else
- Login.AddPlayer(LOGIN_NAME, LOGIN_PASS, '', F2P_WORLDS);
- end;
- procedure TSimpleCrafter.DoAntiban();
- begin
- Antiban.DismissRandom();
- if Antiban.DoAntiban() then
- Login.LoginPlayer(); // if we got logged out, and not logged back in
- end;
- function TSimpleCrafter.FindFurnace(): TRectangle;
- var
- pipe, bricks, concrete: TPointArray;
- ATPA: T2DPointArray;
- m: TPoint;
- v: Vector3;
- r1,r2: TRectangle;
- t: Double;
- begin
- srl.FindColors(pipe, CTS1(1776416, 0), MainScreen.Bounds);
- srl.FindColors(concrete, CTS2(8421769, 5, 0.40, 0.19), MainScreen.Bounds);
- srl.FindColors(bricks, CTS2(3755630, 7, 0.10, 0.17), MainScreen.Bounds);
- pipe := pipe.PointsInRangeOf(bricks, 0, 15);
- pipe := pipe.PointsInRangeOf(concrete, 0, 5);
- if Length(pipe) = 0 then Exit;
- ATPA := pipe.Cluster(1);
- pipe := ATPA.Biggest();
- m := pipe.Mean();
- v := MainScreen.PointToMM(m, 9);
- r1 := Minimap.VecToMsRect(Vec3(v.x,v.y,4), 0.5,1);
- r2 := Minimap.VecToMsRect(Vec3(v.x,v.y,0), 0.5,1);
- r1 := r1.Expand(-MainScreen.NormalizeDistance(5));
- r2 := r2.Expand(-MainScreen.NormalizeDistance(5));
- RSClient.Image.Clear();
- Result := TPointArray([r1.ToTPA+r2.ToTPA]).MinAreaRect();
- end;
- function TSimpleCrafter.OpenEdgevilleBank(BoothCoord: TPoint = [4353,2047]): Boolean;
- var
- r: TRectangle;
- booth, grayOfBank, frameOfBank: TPointArray;
- begin
- // Generate a searcharea near the approximate location of the bankbooth.
- r := Self.WorldToMS(Self.RSW.GetMyPos(), BoothCoord).Expand(10);
- (*
- Filter logic:
- 1. Find gray panel of the bank
- 2. Find wood frame of bank
- 3. With the use of PointInRangeOf we combine the two where they are in range
- of 10 px from eachother. So, where gray is found near brown frame.
- 4. We apply some minimal errotion to the resulting points in order to
- reduce pixelation noise.
- 5. We cluster it, and select the largest cluster, with the assumption that
- it will be the bank booth itself.
- *)
- // 1. and 2.
- srl.FindColors(grayOfBank, CTS2(6251883, 6, 1.07, 0.87), r.Bounds());
- srl.FindColors(frameOfBank, CTS2(1069673, 6, 0.11, 1.29), r.Bounds());
- // 3.
- booth := grayOfBank.PointsInRangeOf(frameOfBank, 0, 10);
- booth += frameOfBank.PointsInRangeOf(grayOfBank, 0, 10);
- // 4. and 5.
- booth := booth.Erode(1).Cluster(1).Biggest();
- // R now contains a rectangle of approximately the same area as the bank
- // it may at times be a little large though, meaning unclickable pixels.
- r := booth.MinAreaRect();
- // you can now debug it to see what we found:
- //RSClient.Image.DrawTPA(Bank, $00FF00);
- //RSClient.Image.DrawRect(R, $0000FF);
- // because of the note above we will try a few times, each time it will generate
- // a new random point in the rectangle:
- for 1 to 5 do
- if Bank.Open(srl.rowp(Mouse.Position(), r)) then
- Exit(True);
- end;
- function TSimpleCrafter.SmeltThatShit(): Boolean;
- var
- t: TCountdown;
- XP: Int32;
- r: TRectangle;
- function WaitSmelting(ItemReduced: string): Boolean;
- begin
- WriteLn('Waiting while smelting - using: '+ ItemReduced);
- XP := XPBar.Read();
- t.Init(Random(4000,5000));
- while not t.IsFinished() do
- begin
- if XPBar.Read() > XP then
- begin
- XP := XPBar.Read();
- t.Init(Random(4000,5000));
- if (Inventory.CountItem(ItemReduced) = 0) then break;
- end;
- end;
- end;
- begin
- Self.RSW.WebWalk([4402, 2022], 0, 1.0);
- if Inventory.CountItem('Gold ore') > 0 then
- begin
- r := Self.FindFurnace();
- Mouse.Click(r, MOUSE_LEFT);
- if not Make.IsOpen(3000) then
- RaiseException('AFASGLSKADGS!! FUCK GOD DAMN IT... SLACKY Y U MAKE BAD BOTS!!!');
- Make.Select(4, -1, False);
- WaitSmelting('Gold ore');
- end;
- r := Self.FindFurnace();
- Mouse.Click(r, MOUSE_LEFT);
- if CraftScreen.IsOpen(3000) then
- begin
- if not CraftScreen.CraftItem(WHAT_TO_MAKE, -1, False) then
- RaiseException('Crafting failed');
- WaitSmelting('Gold bar');
- end else
- RaiseException('AAAAAARRRRRRGGGGG!!!! SHIT BOT OMG!!! RAAAAAGEEEEE!!!!!');
- end;
- function TSimpleCrafter.DoBankingStuff(): Boolean;
- begin
- Self.RSW.WebWalk([4352,2040], 0, 1.0);
- for 0 to 3 do
- begin
- if Self.OpenEdgevilleBank() then
- break;
- end;
- bank.DepositAll;
- WaitUntil(Inventory.Count() = 0, 50, 5000);
- if not bank.WithdrawItem(['Amulet mould', 1, False], False) then
- RaiseException('Amoulet mould extraction failed -- cool!');
- if not bank.WithdrawItem(['Gold bar', 13, False], False) then
- if not bank.WithdrawItem(['Gold ore', 13, False], False) then
- RaiseException('Gold extraction failed -- cool!');
- if not bank.WithdrawItem([GEM_NEEDED_2_MAKE, 13, False], False) then
- RaiseException(GEM_NEEDED_2_MAKE+' extraction failed -- cool!');
- end;
- procedure TSimpleCrafter.SetupAntiban();
- begin
- Antiban.Skills := [ERSSkill.CRAFTING];
- Antiban.MaxZoom := 60;
- Antiban.MinZoom := 30;
- Antiban.AddTask(ONE_MINUTE*5, @Antiban.LoseFocus );
- Antiban.AddTask(ONE_MINUTE*10, @Antiban.HoverSkills );
- Antiban.AddTask(ONE_MINUTE*10, @Antiban.RandomTab );
- Antiban.AddTask(ONE_MINUTE*25, @Antiban.RandomRightClick);
- Antiban.AddTask(ONE_MINUTE*40, @Antiban.RandomRotate );
- Antiban.AddBreak(25 * ONE_MINUTE, 01 * ONE_MINUTE, 0.01);
- Antiban.AddBreak(45 * ONE_MINUTE, 05 * ONE_MINUTE, 0.05);
- Antiban.AddBreak(02 * ONE_HOUR, 10 * ONE_MINUTE, 0.15);
- Antiban.AddBreak(04 * ONE_HOUR, 45 * ONE_MINUTE, 0.85);
- Antiban.AddBreak(17 * ONE_HOUR, 08 * ONE_HOUR, 0.99);
- end;
- procedure TSimpleCrafter.Setup();
- begin
- Mouse.Speed := Random(14, 16);
- RSW.Setup([RSWalkerRegions.EDGEVILLE]);
- self.DeclarePlayers();
- self.SetupAntiban();
- Login.LoginPlayer();
- end;
- var
- bot: TSimpleCrafter;
- retry: Boolean;
- begin
- bot.Setup();
- while True do begin
- bot.RSW.AdaptiveWalk := Random() > 0.9;
- WriteLn('---- RESTART ----');
- bot.DoBankingStuff();
- Bot.DoAntiban();
- retry := False;
- repeat
- try
- bot.SmeltThatShit();
- except
- Writeln GetExceptionMessage();
- retry := True;
- end;
- Bot.DoAntiban();
- until(not retry) or (not Chat.LeveledUp());
- end;
- end.
Add Comment
Please, Sign In to add comment