Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package jugfiller;
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.Graphics2D;
- import java.util.List;
- import java.util.Random;
- import org.osbot.rs07.api.map.Position;
- import org.osbot.rs07.api.model.Player;
- import org.osbot.rs07.api.model.RS2Object;
- import org.osbot.rs07.api.ui.Message;
- import org.osbot.rs07.api.ui.Message.MessageType;
- import org.osbot.rs07.script.MethodProvider;
- import org.osbot.rs07.script.Script;
- import org.osbot.rs07.utility.Area;
- public class JugFiller extends Script
- {
- Position[] PATH_TO_BANK = { new Position(3281,3180,0),
- new Position(3270,3167,0) };
- Position[] PATH_TO_FOUNTAIN = { new Position(3281,3180,0),
- new Position(3292,3175,0) };
- int fountainTimes = 0;
- private Area AlKharidBank = new Area(3268,3163,3272,3171);
- private Area AlKharidFountain = new Area(3290,3170,3295,3175);
- private String State = "";
- long startTime;
- private enum state
- {
- BANK_JUGS, //als hij geen jugs meer heeft maar WEL water, en in bank is
- FILL_JUGS; //als hij empty jugs heeft en in de area fountain is
- }
- public void onStop() {}
- public void onStart()
- {
- State = "Starting up...wait a moment";
- startTime = System.currentTimeMillis();
- }
- public int onLoop() throws InterruptedException {
- switch(getState())
- {
- case BANK_JUGS:
- bank();
- break;
- case FILL_JUGS:
- fill();
- break;
- default:
- break;
- }
- return 0;
- }
- private void bank() {
- try {
- if (AlKharidBank.contains(myPlayer())) {
- this.State = "BANKING_JUGS";
- if (!this.bank.isOpen()) {
- this.bank.open();
- withdrawJugs();
- } else
- withdrawJugs();
- } else if (AlKharidFountain.contains(myPlayer())) {
- this.State = "WALKING_TO_BANK";
- this.localWalker.walkPath(this.PATH_TO_BANK);
- EXECUTE_ANTIBAN();
- }
- } catch (Exception exception) {
- exception.printStackTrace();
- }
- }
- public void fill() {
- try {
- if (AlKharidFountain.contains(myPlayer())) {
- this.State = "FILLING_JUGS";
- RS2Object fountain = (RS2Object)this.objects.closest(new String[] { "Fountain" });
- if (fountain != null) {
- getInventory().getItem(new String[] { "Jug" }).interact(new String[] { "Use" });
- fountain.interact(" -> ");
- MethodProvider.sleep(random(18000, 20000));
- }
- } else if (AlKharidBank.contains(myPlayer())) {
- this.State = "WALKING_TO_FOUNTAIN";
- this.localWalker.walkPath(this.PATH_TO_FOUNTAIN);
- EXECUTE_ANTIBAN();
- }
- } catch (Exception exception) {
- exception.printStackTrace();
- }
- }
- private void withdrawJugs() throws InterruptedException {
- this.bank.depositAll();
- this.bank.withdrawAll("Jug");
- this.bank.close();
- }
- private void EXECUTE_ANTIBAN() throws InterruptedException {
- Random r1 = new Random();
- float chance = r1.nextFloat();
- if (chance <= 0.4F) {
- antiban();
- }
- }
- public void antiban() throws InterruptedException {
- int select = random(3, 6);
- switch (select) {
- case 3:
- int pitch = random(22, 67);
- getCamera().movePitch(pitch);
- break;
- case 4:
- int yaw = random(1, 360);
- getCamera().moveYaw(yaw);
- break;
- case 5:
- List<Player> p = getPlayers().getAll();
- if (p != null) {
- int randomNum = Script.random(0, p.size() - 1);
- Player randomPlayer = (Player) p.get(randomNum);
- if (randomPlayer != null) {
- randomPlayer.hover();
- getMouse().click(true);
- sleep(random(200, 500));
- }
- }
- break;
- case 6:
- List<Player> pl = getPlayers().getAll();
- if (pl != null) {
- int randomNum = Script.random(0, pl.size() - 1);
- Player randomPlayer = (Player) pl.get(randomNum);
- if (randomPlayer != null) {
- randomPlayer.hover();
- }
- }
- break;
- }
- }
- public void onPaint(Graphics2D g) {
- long elapsed = System.currentTimeMillis() - startTime;
- g.setColor(Color.BLACK);
- g.setFont(new Font("Arial", Font.PLAIN, 10));
- g.drawString("Visited fountain: "+fountainTimes+" times", 320, 290);
- g.drawString("run time: "+format(elapsed)+" times", 320, 315);
- g.drawString("current state: "+State+"", 320, 330);
- }
- public void onMessage(Message c) {
- if (c.getType() == MessageType.GAME) {
- String m = c.getMessage().toLowerCase();
- try {
- if(m.contains("fill")) {
- fountainTimes++;
- }
- } catch (Exception exception) {
- exception.printStackTrace();
- }
- }
- }
- private state getState()
- {
- if(this.equipment.contains(1935) && AlKharidFountain.contains(myPlayer()))
- {
- return state.FILL_JUGS;
- }
- if(!this.equipment.contains(1935) && this.equipment.contains(1937) && AlKharidBank.contains(myPlayer()))
- {
- return state.BANK_JUGS;
- }
- return null;
- }
- public String format(long time) {
- StringBuilder string = new StringBuilder();
- long totalSeconds = time / 1000L;
- long totalMinutes = totalSeconds / 60L;
- long totalHours = totalMinutes / 60L;
- int seconds = (int) totalSeconds % 60;
- int minutes = (int) totalMinutes % 60;
- int hours = (int) totalHours % 24;
- if (hours > 0) {
- string.append(hours + "h ");
- }
- if (minutes > 0) {
- string.append(minutes + "m ");
- }
- string.append(seconds + "s");
- return string.toString();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement