Advertisement
LucasSousa

Runemate FletchingScript feito por mim

Feb 22nd, 2017
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.88 KB | None | 0 0
  1. package com.testes;
  2.  
  3. import java.awt.Color;
  4. import java.awt.Font;
  5. import java.awt.Graphics2D;
  6. import com.runemate.game.api.client.paint.PaintListener;
  7. import com.runemate.game.api.hybrid.local.Skill;
  8. import com.runemate.game.api.hybrid.local.hud.interfaces.Bank;
  9. import com.runemate.game.api.hybrid.local.hud.interfaces.InterfaceComponent;
  10. import com.runemate.game.api.hybrid.local.hud.interfaces.Interfaces;
  11. import com.runemate.game.api.hybrid.local.hud.interfaces.Inventory;
  12. import com.runemate.game.api.hybrid.local.hud.interfaces.SpriteItem;
  13. import com.runemate.game.api.hybrid.region.Players;
  14. import com.runemate.game.api.hybrid.util.StopWatch;
  15. import com.runemate.game.api.hybrid.util.calculations.Random;
  16. import com.runemate.game.api.script.Execution;
  17. import com.runemate.game.api.script.framework.task.Task;
  18. import com.runemate.game.api.script.framework.task.TaskScript;
  19.  
  20. public class FletchingExample extends TaskScript implements PaintListener {
  21.  
  22.     int logs = 1517, bows = 62;
  23.  
  24.     StopWatch tempoPercorrido = new StopWatch();
  25.     int expInicial = 0;
  26.     int currentLevel;
  27.    
  28.     String status = ""; // vai indicar o que o script ta fazendo no momento
  29.  
  30.     @Override
  31.     public void onStart(String... args) {
  32.         add(new Depositar(), new Pegar(), new Fechar(), new Cortar());
  33.         getEventDispatcher().addListener(this); // <-- isso aqui faz aparecer o
  34.                                                 // paint   
  35.        
  36.         setLoopDelay(400, 800);
  37.  
  38.         tempoPercorrido.start(); // inicia o tempo percorrido
  39.         expInicial = Skill.FLETCHING.getExperience(); // armazena o valor do seu
  40.                                                         // exp total atual
  41.        
  42.         currentLevel = Skill.FLETCHING.getCurrentLevel();
  43.     }
  44.  
  45.     public class Depositar extends Task {
  46.  
  47.         @Override
  48.         public void execute() {
  49.  
  50.             if (!Bank.isOpen()) {
  51.                 status = "Abrindo o banco";
  52.                 if (Bank.open() == true) {
  53.                     Execution.delayUntil(() -> Players.getLocal().getAnimationId() == -1, 500, 1000);
  54.                 }
  55.             } else if (Bank.isOpen()) {
  56.                 status = "Depositando os pauzinhos";
  57.                 if (Bank.depositInventory() == true) {
  58.                     Execution.delayUntil(() -> Players.getLocal().getAnimationId() == -1, 500, 1000);
  59.                 }
  60.  
  61.             }
  62.         }
  63.  
  64.         @Override
  65.         public boolean validate() {
  66.             return Players.getLocal().getAnimationId() == -1 && Inventory.containsAllOf(bows)
  67.                     && Inventory.containsOnly("Maple shieldbow (u)");
  68.         }
  69.     }
  70.  
  71.     public class Pegar extends Task {
  72.  
  73.         @Override
  74.         public void execute() {
  75.             if (Bank.isOpen()) {
  76.                 status = "Retirando lenhas (pauzoes)";
  77. //              if (Bank.withdraw(logs, 28)) {
  78. //                  Execution.delayUntil(() -> Players.getLocal().getAnimationId() == -1, 500, 1000);
  79. //              }
  80.                 Bank.withdraw(logs, 28);
  81.             } else {
  82.                 status = "Abrindo banco";
  83.                 Bank.open();
  84.             }
  85.         }
  86.  
  87.         @Override
  88.         public boolean validate() {
  89.             return Inventory.isEmpty();
  90.         }
  91.     }
  92.  
  93.     public class Fechar extends Task {
  94.  
  95.         @Override
  96.         public void execute() {
  97.             status = "Fechando o banco";
  98.             Bank.close();
  99.  
  100.         }
  101.  
  102.         @Override
  103.         public boolean validate() {
  104.             return Bank.isOpen() && Inventory.containsAllOf(logs);
  105.         }
  106.  
  107.     }
  108.  
  109.     public class Cortar extends Task {
  110.         @Override
  111.         public void execute() {
  112.  
  113.             SpriteItem bagLog = Inventory.newQuery().names("Maple logs").results().first();
  114.             InterfaceComponent botaoFletch = Interfaces.newQuery().textContains("Fletch").results().first();
  115.             if (botaoFletch != null && botaoFletch.isVisible()) {
  116.                 status = "Clicando no botao azul";
  117.                 if (botaoFletch.click()) {
  118.                     if (Execution.delayUntil(() -> botaoFletch == null || !botaoFletch.isVisible(),
  119.                             Random.nextInt(1500, 2000))) {
  120.                         Execution.delayUntil(() -> Players.getLocal().getAnimationId() != -1,
  121.                                 Random.nextInt(1500, 2000));
  122.                         status = "Fazendo pauzinhos...";
  123.                     }
  124.                 }
  125.             } else {
  126.                 if (bagLog != null) {
  127.                     status = "Clicando na lenha (pauzao)";
  128.                     if (bagLog.click()) {
  129.                         if (Execution.delayUntil(() -> botaoFletch != null && botaoFletch.isVisible(),
  130.                                 Random.nextInt(1500, 2000))) {
  131.                         }
  132.                     }
  133.                 }
  134.             }
  135.         }
  136.  
  137.         @Override
  138.         public boolean validate() {
  139.  
  140.             return !Bank.isOpen() && Inventory.containsOnly("Maple logs") && Players.getLocal().getAnimationId() == -1;
  141.         }
  142.     }
  143.  
  144.     @Override
  145.     public void onPaint(Graphics2D arg0) {
  146.         int expObtido = Skill.FLETCHING.getExperience() - expInicial;
  147.         int expHora = (int) ((3600000D * expObtido) / tempoPercorrido.getRuntime());
  148.         int levelsObtidos = Skill.FLETCHING.getCurrentLevel() - currentLevel;
  149.         arg0.setFont(new Font("Impact",Font.PLAIN,14));
  150.         arg0.setColor(Color.black);
  151.         arg0.fillRect(10,10,400,105); //x,y,largura,altura
  152.         arg0.setColor(Color.WHITE);
  153.         arg0.drawString("Tempo rodando: " + tempoPercorrido.getRuntimeAsString(), 20, 30);
  154.         arg0.drawString("Experience obtida: " + expObtido + " (" + expHora + "/ hora)", 20, 50);
  155.         arg0.drawString("Current level: " + currentLevel + " (+" + levelsObtidos + " levels gained)", 20, 70);
  156.         arg0.drawString("Status: " + status, 20, 90);
  157.     }
  158. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement