Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.testes;
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.Graphics2D;
- import com.runemate.game.api.client.paint.PaintListener;
- import com.runemate.game.api.hybrid.local.Skill;
- import com.runemate.game.api.hybrid.local.hud.interfaces.Bank;
- import com.runemate.game.api.hybrid.local.hud.interfaces.InterfaceComponent;
- import com.runemate.game.api.hybrid.local.hud.interfaces.Interfaces;
- import com.runemate.game.api.hybrid.local.hud.interfaces.Inventory;
- import com.runemate.game.api.hybrid.local.hud.interfaces.SpriteItem;
- import com.runemate.game.api.hybrid.region.Players;
- import com.runemate.game.api.hybrid.util.StopWatch;
- import com.runemate.game.api.hybrid.util.calculations.Random;
- import com.runemate.game.api.script.Execution;
- import com.runemate.game.api.script.framework.task.Task;
- import com.runemate.game.api.script.framework.task.TaskScript;
- public class FletchingExample extends TaskScript implements PaintListener {
- int logs = 1517, bows = 62;
- StopWatch tempoPercorrido = new StopWatch();
- int expInicial = 0;
- int currentLevel;
- String status = ""; // vai indicar o que o script ta fazendo no momento
- @Override
- public void onStart(String... args) {
- add(new Depositar(), new Pegar(), new Fechar(), new Cortar());
- getEventDispatcher().addListener(this); // <-- isso aqui faz aparecer o
- // paint
- setLoopDelay(400, 800);
- tempoPercorrido.start(); // inicia o tempo percorrido
- expInicial = Skill.FLETCHING.getExperience(); // armazena o valor do seu
- // exp total atual
- currentLevel = Skill.FLETCHING.getCurrentLevel();
- }
- public class Depositar extends Task {
- @Override
- public void execute() {
- if (!Bank.isOpen()) {
- status = "Abrindo o banco";
- if (Bank.open() == true) {
- Execution.delayUntil(() -> Players.getLocal().getAnimationId() == -1, 500, 1000);
- }
- } else if (Bank.isOpen()) {
- status = "Depositando os pauzinhos";
- if (Bank.depositInventory() == true) {
- Execution.delayUntil(() -> Players.getLocal().getAnimationId() == -1, 500, 1000);
- }
- }
- }
- @Override
- public boolean validate() {
- return Players.getLocal().getAnimationId() == -1 && Inventory.containsAllOf(bows)
- && Inventory.containsOnly("Maple shieldbow (u)");
- }
- }
- public class Pegar extends Task {
- @Override
- public void execute() {
- if (Bank.isOpen()) {
- status = "Retirando lenhas (pauzoes)";
- // if (Bank.withdraw(logs, 28)) {
- // Execution.delayUntil(() -> Players.getLocal().getAnimationId() == -1, 500, 1000);
- // }
- Bank.withdraw(logs, 28);
- } else {
- status = "Abrindo banco";
- Bank.open();
- }
- }
- @Override
- public boolean validate() {
- return Inventory.isEmpty();
- }
- }
- public class Fechar extends Task {
- @Override
- public void execute() {
- status = "Fechando o banco";
- Bank.close();
- }
- @Override
- public boolean validate() {
- return Bank.isOpen() && Inventory.containsAllOf(logs);
- }
- }
- public class Cortar extends Task {
- @Override
- public void execute() {
- SpriteItem bagLog = Inventory.newQuery().names("Maple logs").results().first();
- InterfaceComponent botaoFletch = Interfaces.newQuery().textContains("Fletch").results().first();
- if (botaoFletch != null && botaoFletch.isVisible()) {
- status = "Clicando no botao azul";
- if (botaoFletch.click()) {
- if (Execution.delayUntil(() -> botaoFletch == null || !botaoFletch.isVisible(),
- Random.nextInt(1500, 2000))) {
- Execution.delayUntil(() -> Players.getLocal().getAnimationId() != -1,
- Random.nextInt(1500, 2000));
- status = "Fazendo pauzinhos...";
- }
- }
- } else {
- if (bagLog != null) {
- status = "Clicando na lenha (pauzao)";
- if (bagLog.click()) {
- if (Execution.delayUntil(() -> botaoFletch != null && botaoFletch.isVisible(),
- Random.nextInt(1500, 2000))) {
- }
- }
- }
- }
- }
- @Override
- public boolean validate() {
- return !Bank.isOpen() && Inventory.containsOnly("Maple logs") && Players.getLocal().getAnimationId() == -1;
- }
- }
- @Override
- public void onPaint(Graphics2D arg0) {
- int expObtido = Skill.FLETCHING.getExperience() - expInicial;
- int expHora = (int) ((3600000D * expObtido) / tempoPercorrido.getRuntime());
- int levelsObtidos = Skill.FLETCHING.getCurrentLevel() - currentLevel;
- arg0.setFont(new Font("Impact",Font.PLAIN,14));
- arg0.setColor(Color.black);
- arg0.fillRect(10,10,400,105); //x,y,largura,altura
- arg0.setColor(Color.WHITE);
- arg0.drawString("Tempo rodando: " + tempoPercorrido.getRuntimeAsString(), 20, 30);
- arg0.drawString("Experience obtida: " + expObtido + " (" + expHora + "/ hora)", 20, 50);
- arg0.drawString("Current level: " + currentLevel + " (+" + levelsObtidos + " levels gained)", 20, 70);
- arg0.drawString("Status: " + status, 20, 90);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement