Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Graphics;
- import java.awt.Point;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.MouseEvent;
- import java.awt.event.MouseListener;
- import java.awt.event.MouseMotionListener;
- import java.awt.*;
- import javax.imageio.ImageIO;
- import java.io.IOException;
- import java.net.URL;
- import java.util.Random;
- import org.rsbot.event.events.MessageEvent;
- import org.rsbot.event.listeners.MessageListener;
- import org.rsbot.event.listeners.PaintListener;
- import org.rsbot.script.Script;
- import org.rsbot.script.ScriptManifest;
- import org.rsbot.script.methods.Game;
- import org.rsbot.script.methods.Inventory;
- import org.rsbot.script.methods.Skills;
- import org.rsbot.script.util.Filter;
- import org.rsbot.script.util.Timer;
- import org.rsbot.script.wrappers.RSArea;
- import org.rsbot.script.wrappers.RSGroundItem;
- import org.rsbot.script.wrappers.RSItem;
- import org.rsbot.script.wrappers.RSNPC;
- import org.rsbot.script.wrappers.RSObject;
- import org.rsbot.script.wrappers.RSPath;
- import org.rsbot.script.wrappers.RSPlayer;
- import org.rsbot.script.wrappers.RSTile;
- @ScriptManifest(authors = { "Wei Su" }, name = "Blue Dragon Resource Killer", version = 1.0, description = "Kills blue dragons for loot in the taverly resource dungeon", keywords = {
- "Dragon", "money", "admin" })
- public class WeiDK extends Script implements PaintListener, MessageListener,
- ActionListener, MouseMotionListener, MouseListener {
- public int[] oD = { 4665, 4682, 4683, 4666 };
- public int count;
- public int[] dragonsID = { 55, 4681, 4682, 4683, 4684 };
- public int foodID = 7946;
- public int foodAmount = 5;
- public int tab = 8009;
- public int[] supplies = {foodID, tab};
- public final static RSArea insideDungeon = new RSArea(2877, 9781, 2925,
- 9815);
- public final static RSArea falador = new RSArea(2936, 3344, 2983, 3392);
- public final static RSArea faladorBank = new RSArea(2944, 3367, 2948, 3374);
- public final static RSArea outsideFalador = new RSArea(2850, 3325, 2935,
- 3404);
- public final static RSArea dragonsLair = new RSArea(950, 4480, 1025, 4545);
- public RSTile destination = null;
- @Override
- public boolean onStart() {
- sleep(1000);
- return true;
- }
- @Override
- public int loop() {
- try {
- RSObject crumblingWall = objects.getNearest(11844);
- RSObject bankBooth = objects.getNearest(11758);
- RSObject ladder = objects.getNearest(55404);
- RSObject shortcut = objects.getNearest(9293);
- RSObject resourceEntrance = objects.getNearest(52852);
- RSNPC outDragons = npcs.getNearest(oD);
- switch (getCase()) {
- case 1:
- doFaladorWalking();
- log("doFaladorWalking");
- return random(50, 100);
- case 2:
- doFaladorBanking();
- log("doFaladorBanking");
- return random(50, 100);
- case 3:
- doWithdrawing();
- log("doWithdrawing");
- return random(50, 100);
- case 4:
- crumblingWallPath();
- log("crumblingWallPath");
- return random(50, 100);
- case 5:
- climbCrumblingWall();
- log("climbCrumblingWall");
- return random(50, 100);
- case 6:
- walkToDungeon();
- log("walkToDungeon");
- return random(50, 100);
- case 7:
- climbDownLadder();
- log("climbDownLadder");
- return random(50, 100);
- case 8:
- usePipe();
- log("usePipe");
- return random(50, 100);
- case 9:
- walkToResource();
- log("walkToResource");
- return random(50, 100);
- case 10:
- enterResource();
- log("enterResource");
- return random(50, 100);
- case 11:
- attack();
- log("attack");
- return random(50, 100);
- case 12:
- healing();
- log("healing");
- return random(50, 100);
- case 13:
- teleSafe();
- log("teleSafe");
- return random(50, 100);
- case 14:
- teleSafe();
- log("teleSafe");
- return random(50, 100);
- }
- } catch (Exception ignore) {
- }
- return (random(80, 90));
- }
- public int getCase() {
- RSObject crumblingWall = objects.getNearest(11844);
- RSObject bankBooth = objects.getNearest(11758);
- RSObject ladder = objects.getNearest(55404);
- RSObject shortcut = objects.getNearest(9293);
- RSObject resourceEntrance = objects.getNearest(52852);
- RSNPC outDragons = npcs.getNearest(oD);
- if (inFalador() && !inBank()
- && (inventory.isFull() || getLifePoints()<90)) {
- log("1");
- return 1;
- }
- if (!needToHeal() && inLair() && killDragons()
- && !getMyPlayer().isInCombat()
- && getMyPlayer().getInteracting() == null) {
- log("11");
- return 11;
- }
- if (needToHeal() && canHeal()) {
- log("12)");
- return 12;
- }
- if (needTeleSafe() && inLair()) {
- log("13");
- return 13;
- }
- if (inFalador() && inBank() && inventory.isFull()) {
- log("2");
- return 2;
- }
- if (inFalador() && inBank() && needSupplies()) {
- log("3");
- return 3;
- }
- if (inFalador() && readyForDungeon() && !crumblingWall.isOnScreen()) {
- log("4");
- return 4;
- }
- if (inFalador() && readyForDungeon() && crumblingWall != null) {
- log("5");
- return 5;
- }
- if (outsideFally() && readyForDungeon()
- && (ladder == null || calc.distanceTo(ladder) > 5)) {
- log("6");
- return 6;
- }
- if (outsideFally() && readyForDungeon() && calc.distanceTo(ladder) < 5) {
- log("7");
- return 7;
- }
- if (getMyPlayer().getLocation().getY() > 9000 && needToPipe()
- && readyForDungeon()) {
- log("8");
- return 8;
- }
- if (!resourceEntrance.isOnScreen() && inDungeon() && readyForDungeon()
- && insideDungeon.contains(getMyPlayer().getLocation())) {
- log("9");
- return 9;
- }
- if (inDungeon() && readyForDungeon() && resourceEntrance.isOnScreen()
- && insideDungeon.contains(getMyPlayer().getLocation())) {
- log("10");
- return 10;
- }
- if (tripEnded()) {
- log("14");
- return 14;
- }
- return -9001;
- }
- public boolean inFalador() {
- if (falador.contains(getMyPlayer().getLocation())) {
- return true;
- } else {
- return false;
- }
- }
- public boolean inBank() {
- if (faladorBank.contains(getMyPlayer().getLocation())) {
- return true;
- } else {
- return false;
- }
- }
- public void walking() {
- RSPath path = null;
- if (path == null) {
- path = walking.getPath(destination);
- }
- path.traverse();
- }
- public void doFaladorWalking() {
- destination = new RSTile(2946, 3369);
- walking();
- }
- public void doFaladorBanking() {
- RSObject bankBooth = objects.getNearest(11758);
- if (!bank.isOpen()) {
- if (bankBooth.isOnScreen()) {
- bankBooth.doAction("Use-q");
- } else {
- camera.turnTo(bankBooth);
- }
- } else {
- bank.depositAll();
- }
- }
- public boolean needSupplies() {
- if (inventory.containsAll(supplies)) {
- return false;
- } else {
- return true;
- }
- }
- public void doWithdrawing() {
- RSObject bankBooth = objects.getNearest(11758);
- if(bankBooth.isOnScreen()){
- if(bank.isOpen()){
- if(inventory.getCount(foodID) != foodAmount ){
- bank.withdraw(foodID, foodAmount);
- sleep(random(1000,1200));
- }
- if(inventory.contains(tab)){
- bank.withdraw(tab, 1);
- }
- }
- } else {
- camera.turnTo(bankBooth);
- }
- }
- public boolean readyForDungeon() {
- if (getLifePoints()>90 && !needSupplies() && !inventory.isFull()) {
- return true;
- } else {
- return false;
- }
- }
- public void crumblingWallPath() {
- destination = new RSTile(2936, 3355);
- walking();
- }
- public void climbCrumblingWall() {
- RSObject crumblingWall = objects.getNearest(11844);
- if (crumblingWall.isOnScreen()) {
- crumblingWall.doAction("Climb");
- sleep(random(900, 1200));
- } else {
- camera.turnTo(crumblingWall);
- }
- }
- public boolean outsideFally() {
- return outsideFalador.contains(getMyPlayer().getLocation());
- }
- public void walkToDungeon() {
- destination = new RSTile(2885, 3395);
- walking();
- }
- public void climbDownLadder() {
- RSObject ladder = objects.getNearest(55404);
- if (ladder.isOnScreen()) {
- ladder.doAction("Climb");
- sleep(random(900, 1200));
- } else {
- camera.turnTo(ladder);
- }
- }
- public boolean inDungeon() {
- RSObject shortcut = objects.getNearest(9293);
- RSNPC outDragons = npcs.getNearest(oD);
- if (shortcut.isOnScreen() || outDragons.isOnScreen()) {
- return true;
- } else {
- return false;
- }
- }
- public boolean needToPipe() {
- if (getMyPlayer().getLocation().getX() < 2889) {
- return true;
- } else {
- return false;
- }
- }
- public void usePipe() {
- RSObject shortcut = objects.getNearest(9293);
- shortcut.doAction("Squeeze");
- sleep(random(900, 1300));
- }
- public void walkToResource() {
- destination = new RSTile(2912, 9810);
- walking();
- }
- public void enterResource() {
- RSObject resourceEntrance = objects.getNearest(52852);
- if (resourceEntrance.isOnScreen()) {
- resourceEntrance.doAction("Enter");
- sleep(random(900, 1300));
- } else {
- camera.turnTo(resourceEntrance);
- }
- }
- public void attack() {
- RSNPC npc = getNpc();
- if (npc != null) {
- camera.turnTo(npc);
- if (!npc.isOnScreen())
- destination = (npc.getLocation());
- walking();
- if (!getMyPlayer().isInCombat()
- && getMyPlayer().getInteracting() == null)
- npc.doAction("Attack");
- }
- }
- public RSNPC getNpc() {
- final Filter<RSNPC> filter = new Filter<RSNPC>() {
- public boolean accept(RSNPC n) {
- return (validNpc(n) && (!n.isInCombat() && n.getInteracting() == null))
- && n.getHPPercent() != 0;
- }
- };
- return npcs.getNearest(filter);
- }
- public boolean validNpc(RSNPC n) {
- if (n != null) {
- for (int id : dragonsID) {
- if (id == n.getID())
- return true;
- }
- if (n.getName().toLowerCase().contains("dragon".toLowerCase()))
- return true;
- }
- return false;
- }
- public boolean inLair() {
- if (dragonsLair.contains(getMyPlayer().getLocation())) {
- return true;
- } else {
- return false;
- }
- }
- public boolean killDragons() {
- if (!inventory.isFull() && inventory.contains(tab)
- && getLifePoints() > 50) {
- return true;
- } else {
- return false;
- }
- }
- public int getLifePoints() {
- try {
- return ((int) ((Integer.parseInt(interfaces.get(748).getComponent(8).getText().trim()) / (double)(skills.getRealLevel(Skills.CONSTITUTION) * 10)) * 100));
- } catch (Exception e) {
- return 100;
- }
- }
- public boolean needToHeal() {
- if (getLifePoints()<50) {
- return true;
- } else {
- return false;
- }
- }
- public boolean canHeal() {
- if (inventory.containsOneOf(foodID)) {
- return true;
- } else {
- return false;
- }
- }
- public boolean needTeleSafe() {
- if (needToHeal() && !canHeal()) {
- return true;
- } else {
- return false;
- }
- }
- public boolean tripEnded() {
- if (inventory.isFull()
- && dragonsLair.contains(getMyPlayer().getLocation())) {
- return true;
- } else {
- return false;
- }
- }
- public void teleSafe() {
- RSItem teleTab = inventory.getItem(8009);
- teleTab.doAction("Break");
- }
- public void healing() {
- // eat
- }
- @Override
- public void onFinish() {
- }
- public void onRepaint(Graphics g1) {
- }
- // END: Code generated using Enfilade's Easel
- @Override
- public void mouseClicked(MouseEvent arg0) {
- // TODO Auto-generated method stub
- }
- @Override
- public void mouseEntered(MouseEvent arg0) {
- // TODO Auto-generated method stub
- }
- @Override
- public void mouseExited(MouseEvent arg0) {
- // TODO Auto-generated method stub
- }
- @Override
- public void mousePressed(MouseEvent arg0) {
- // TODO Auto-generated method stub
- }
- @Override
- public void mouseReleased(MouseEvent arg0) {
- // TODO Auto-generated method stub
- }
- @Override
- public void mouseDragged(MouseEvent arg0) {
- // TODO Auto-generated method stub
- }
- @Override
- public void mouseMoved(MouseEvent arg0) {
- // TODO Auto-generated method stub
- }
- @Override
- public void actionPerformed(ActionEvent arg0) {
- // TODO Auto-generated method stub
- }
- @Override
- public void messageReceived(MessageEvent arg0) {
- // TODO Auto-generated method stub
- }
- }
Add Comment
Please, Sign In to add comment