Advertisement
Guest User

Untitled

a guest
May 29th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 11.41 KB | None | 0 0
  1. import xobot.bot.Context;
  2. import xobot.client.ItemDef;
  3. import xobot.client.callback.listeners.PaintListener;
  4. import xobot.script.ActiveScript;
  5. import xobot.script.Manifest;
  6. import xobot.script.methods.*;
  7. import xobot.script.methods.tabs.Equipment;
  8. import xobot.script.methods.tabs.Inventory;
  9. import xobot.script.methods.tabs.Prayer;
  10. import xobot.script.methods.tabs.Prayer.Prayers;
  11. import xobot.script.methods.tabs.Skills;
  12. import xobot.script.util.Time;
  13. import xobot.script.util.Timer;
  14. import xobot.script.wrappers.Tile;
  15. import xobot.script.wrappers.interactive.GameObject;
  16. import xobot.script.wrappers.interactive.Item;
  17. import xobot.script.wrappers.interactive.NPC;
  18.  
  19. import javax.swing.*;
  20. import java.awt.*;
  21.  
  22. @Manifest(authors = {""}, name = "nDung Upgradable")
  23. public class nDung extends ActiveScript implements PaintListener {
  24.  
  25.     private final Tile[] dung = {new Tile(3233, 9315), new Tile(2618, 9797)};
  26.     //floor 1
  27.     private final Tile wall = new Tile(3232, 9295);
  28.     private final Tile[] wallP = new Tile[]{wall, new Tile(3217, 9315), new Tile(3214, 9331)};
  29.     //floor 2
  30.     private final Tile sculptureT = new Tile(2609, 9823);
  31.     private final Tile crateT = new Tile(2565, 9833);
  32.     private final Tile crateP = new Tile(2585, 9838);
  33.     private final int[] bosses = {10044, 10110, 10116, 9989, 9916, 10064};
  34.  
  35.     private final String[] eq = {"platebody", "platelegs", "full helm", "2h"};
  36.     private final Color color1 = new Color(0, 0, 0, 43);
  37.     private final Color color2 = new Color(204, 0, 0);
  38.     private final BasicStroke stroke1 = new BasicStroke(1);
  39.     private final Font font1 = new Font("Arial", Font.PLAIN, 24);
  40.     private final Font font2 = new Font("Arial", Font.PLAIN, 16);
  41.     private int startxp = 0;
  42.     private Timer t;
  43.     private int floor = -1;
  44.  
  45.     public boolean onStart() {
  46.         JDialog frame = new JDialog();
  47.         frame.setPreferredSize(new Dimension(250, 90));
  48.         frame.setLocationRelativeTo(null);
  49.         frame.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
  50.         FlowLayout layout = new FlowLayout();
  51.         layout.setHgap(5);
  52.         layout.setVgap(5);
  53.         frame.setLayout(layout);
  54.  
  55.         JComboBox<String> combo = new JComboBox<>();
  56.         combo.setPreferredSize(new Dimension(150, 30));
  57.         combo.setFocusable(false);
  58.         combo.addItem("Floor 1");
  59.         combo.addItem("Floor 2");
  60.  
  61.         JButton button = new JButton("Start");
  62.         button.setFocusable(false);
  63.         button.setPreferredSize(new Dimension(60, 32));
  64.         button.addActionListener(a -> {
  65.             switch ((String) combo.getSelectedItem()) {
  66.                 case "Floor 1":
  67.                     floor = 1;
  68.                     break;
  69.                 case "Floor 2":
  70.                     floor = 2;
  71.                     break;
  72.             }
  73.             frame.dispose();
  74.         });
  75.  
  76.         frame.add(combo);
  77.         frame.add(button);
  78.         frame.setTitle("NeoDungeoneering Modified");
  79.  
  80.         frame.pack();
  81.         frame.setVisible(true);
  82.         while (frame.isVisible()) {
  83.             Time.sleep(500);
  84.         }
  85.         t = new Timer();
  86.         startxp = Skills.DUNGEONEERING.getCurrentExp();
  87.         return floor != -1;
  88.     }
  89.  
  90.     @Override
  91.     public int loop() {
  92.         if (inDung()) {
  93.             switch (floor) {
  94.                 case 1:
  95.                     return floor1();
  96.                 case 2:
  97.                     return floor2();
  98.             }
  99.         } else {
  100.             NPC master = NPCs.getNearest(9713);
  101.             if (master != null) {
  102.                 if (Widgets.getBackDialogId() == 4887) {
  103.                     Packets.sendAction("Continue", "", 679, 0, 0, 4892, 0);
  104.                     Time.sleep(() -> Widgets.getBackDialogId() == 2469, 4500);
  105.                     Packets.sendAction("Ok", null, 315, 0, 0, 2471, 0);
  106.                     Time.sleep(() -> Widgets.getBackDialogId() == 2459, 4500);
  107.                     Packets.sendAction("Ok", null, 315, 0, 0, 2461, 0);
  108.                     Time.sleep(() -> Widgets.getBackDialogId() == 2469, 4500);
  109.                     Packets.sendAction("Ok", null, 315, 0, 0, 2470 + floor, 0);
  110.                     Time.sleep(this::inDung, 4500);
  111.                     return 450;
  112.                 }
  113.                 master.interact("talk-to");
  114.             }
  115.         }
  116.         return 1500;
  117.     }
  118.  
  119.     private boolean inDung() {
  120.         return dung[floor - 1].getDistance() < 100 || NPCs.getNearest(bosses) != null;
  121.     }
  122.  
  123.     private void equip() {
  124.         for (Item i : Inventory.getItems()) {
  125.             ItemDef id = Context.client.forItemId(i.getID());
  126.             if (id != null) {
  127.                 String invItem = id.getName();
  128.                 if (invItem != null) {
  129.                     for (String arm : this.eq) {
  130.                         if (invItem.toLowerCase().contains(arm))
  131.                             if (!isWearing(arm)) {
  132.                                 i.interact("wear");
  133.                                 Time.sleep(() -> isWearing(arm), 1500);
  134.                             }
  135.                     }
  136.                 }
  137.  
  138.             }
  139.         }
  140.     }
  141.  
  142.  
  143.     private boolean isWearing(String name) {
  144.         if (name.toLowerCase().contains("2h"))
  145.             return Equipment.isWearing(Equipment.WEAPON);
  146.         else if (name.toLowerCase().contains("body"))
  147.             return Equipment.isWearing(Equipment.BODY);
  148.         else if (name.toLowerCase().contains("legs"))
  149.             return Equipment.isWearing(Equipment.LEGS);
  150.         else if (name.toLowerCase().contains("helm"))
  151.             return Equipment.isWearing(Equipment.HELMET);
  152.         return false;
  153.     }
  154.  
  155.     private int floor1() {
  156.         if (dung[0].isReachable()) {
  157.             if (Inventory.Contains(18165)) {
  158.                 GameObject door = GameObjects.getNearest(6553);
  159.                 if (door != null) {
  160.                     door.interact("open");
  161.                     Time.sleep(() -> !dung[0].isReachable(), 4500);
  162.                 }
  163.             } else {
  164.                 equip();
  165.                 GameObject sarc = GameObjects.getNearest(6516);
  166.                 if (sarc != null) {
  167.                     sarc.interact("search");
  168.                     Time.sleep(() -> Inventory.Contains(18165), 4500);
  169.                 }
  170.             }
  171.         } else {
  172.             NPC boss = NPCs.getNearest(bosses);
  173.             if (boss != null) {
  174.                 if (Prayer.getRemainingPoints() > 0 && Skills.PRAYER.getCurrentLevel() > 60) {
  175.                     Prayers.PROTECT_FROM_MAGIC.Activate();
  176.                     Prayers.CHIVALRY.Activate();
  177.                 }
  178.                 if (Skills.CONSTITUTION.getCurrentLevel() < 60) {
  179.                     Item food = Inventory.getItem(18165);
  180.                     if (food != null) {
  181.                         food.interact("eat");
  182.                         return 450;
  183.                     }
  184.                 }
  185.                 xobot.script.wrappers.interactive.Character c = Players.getMyPlayer().getInteractingCharacter();
  186.                 if (c != null) {
  187.                     if (c.equals(boss)) {
  188.                         return 150;
  189.                     }
  190.                 }
  191.                 boss.interact("attack");
  192.             } else if (wall.getDistance() < 100) {
  193.                 if (Players.getMyPlayer().getLocation().equals(wall)) {
  194.                     GameObject wallO = GameObjects.getNearest(2156);
  195.                     if (wallO != null) {
  196.                         wallO.interact("enter");
  197.                         Time.sleep(() -> wall.getDistance() > 20, 4500);
  198.                     }
  199.                 } else {
  200.                     Tile next = getTile();
  201.                     if (next != null) {
  202.                         next.walk();
  203.                     }
  204.                     return 4500;
  205.                 }
  206.             }
  207.         }
  208.         return 1500;
  209.     }
  210.  
  211.     private Tile getTile() {
  212.         for (Tile t : wallP) {
  213.             if (Calculations.realDistanceTo(t, false) < 70) {
  214.                 return t;
  215.             }
  216.         }
  217.         return null;
  218.     }
  219.  
  220.     private int floor2() {
  221.         NPC boss = NPCs.getNearest(bosses);
  222.         if (boss != null) {
  223.             if (Prayer.getRemainingPoints() > 0 && Skills.PRAYER.getCurrentLevel() > 60
  224.                     && (!Prayers.PROTECT_FROM_MAGIC.isActivated() || !Prayers.CHIVALRY.isActivated())) {
  225.                 if (!Prayers.PROTECT_FROM_MAGIC.isActivated())
  226.                     Prayers.PROTECT_FROM_MAGIC.Activate();
  227.                 if (!Prayers.CHIVALRY.isActivated())
  228.                     Prayers.CHIVALRY.Activate();
  229.             } else {
  230.                 xobot.script.wrappers.interactive.Character c = Players.getMyPlayer().getInteractingCharacter();
  231.                 if (c != null) {
  232.                     if (NPCs.getNearest(bosses) != null && c.equals(boss)) {
  233.                         return 150;
  234.                     }
  235.                 } else {
  236.                     NPCs.getNearest(bosses).interact("attack");
  237.                     return 1500;
  238.                 }
  239.             }
  240.         } else if (!Inventory.Contains(18165) && dung[1].getDistance() < 10) {
  241.             equip();
  242.             GameObject chest = GameObjects.getNearest(5270);
  243.             if (chest != null) {
  244.                 chest.interact("open");
  245.                 Time.sleep(() -> Inventory.Contains(18165), 4500);
  246.             }
  247.         } else if (Inventory.Contains(1480)) {
  248.             if (Inventory.Contains(6821)) {
  249.                 GameObject shrine = GameObjects.getNearest(3634);
  250.                 if (shrine != null) {
  251.                     shrine.interact("touch");
  252.                     return 4500;
  253.                 }
  254.             } else {
  255.                 GameObject crate = GameObjects.getNearest(o -> o.getId() == 357 && o.getLocation().equals(crateT));
  256.                 if (crate != null && crate.getDistance() < 30) {
  257.                     crate.interact("search");
  258.                     Time.sleep(() -> Inventory.Contains(6821), 4500);
  259.                 } else {
  260.                     if (crateP.getDistance() > 30) {
  261.                         sculptureT.walk();
  262.                         return 150;
  263.                     }
  264.                     crateP.walk();
  265.                     return 3500;
  266.                 }
  267.             }
  268.  
  269.         } else {
  270.             GameObject sculpture = GameObjects.getNearest(5808);
  271.             if (sculpture != null && sculpture.getDistance() < 20) {
  272.                 sculpture.interact("look");
  273.                 Time.sleep(() -> Inventory.Contains(1480), 4500);
  274.             } else {
  275.                 sculptureT.walk();
  276.                 if (sculpture != null) {
  277.                     Time.sleep(() -> sculpture.getDistance() < 22, 4500);
  278.                     return 150;
  279.                 }
  280.                 return 3500;
  281.             }
  282.         }
  283.         return 1500;
  284.     }
  285.  
  286.     @Override
  287.     public void repaint(Graphics g1) {
  288.         int xp = Skills.DUNGEONEERING.getCurrentExp() - startxp;
  289.         int ph = (int) ((xp) * 3600000D / (t.getElapsed()));
  290.  
  291.         Graphics2D g = (Graphics2D) g1;
  292.         g.setColor(color1);
  293.         g.fillRect(1, 183, 309, 155);
  294.         g.setColor(color2);
  295.         g.setStroke(stroke1);
  296.         g.drawRect(1, 183, 309, 155);
  297.         g.setFont(font1);
  298.         g.drawString("NeoDungeoneering", 77, 214);
  299.         g.setFont(font2);
  300.         g.drawString("Neo ", 268, 333);
  301.         g.drawString("Time: " + t.toElapsedString(), 10, 245);
  302.         g.drawString("XP: " + xp + "(" + ph + ")", 10, 265);
  303.     }
  304.  
  305. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement