Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package scripts;
- import java.awt.*;
- import org.tribot.api.Timing;
- import org.tribot.api.types.generic.Condition;
- import org.tribot.api2007.GameTab;
- import org.tribot.api2007.Interfaces;
- import org.tribot.api2007.Inventory;
- import org.tribot.api2007.Objects;
- import org.tribot.api2007.Player;
- import org.tribot.api2007.Walking;
- import org.tribot.api2007.GameTab.TABS;
- import org.tribot.api2007.types.RSInterfaceChild;
- import org.tribot.api2007.types.RSItem;
- import org.tribot.api2007.types.RSObject;
- import org.tribot.api2007.types.RSTile;
- import org.tribot.script.Script;
- import org.tribot.script.interfaces.Painting;
- public class AeroShield extends Script implements Painting {
- public static SleepCondition Skip;
- public static Double Version = 1.1;
- private int completed = 0;
- private State currentState = null;
- public enum State {
- Stab(15617, 1),
- Blunt(15619, 2),
- Slash(15620, 3),
- Magic(15618, 4);
- private int Id, ChildId;
- State(int ObjectId, int Child) {
- Id = ObjectId;
- ChildId = Child;
- }
- public int getObjectId() {
- return Id;
- }
- public int getChild() {
- return ChildId;
- }
- }
- public class SleepCondition {
- Condition C;
- Integer Timeout;
- SleepCondition(Condition c, Integer timeout) {
- C = c;
- Timeout = timeout;
- }
- }
- private final Color color1 = new Color(0, 0, 0, 130);
- private final Color color2 = new Color(0, 0, 0);
- private final Color color3 = new Color(255, 255, 255);
- private final BasicStroke stroke1 = new BasicStroke(1);
- private final Font font1 = new Font("Arial", 0, 16);
- private final Font font2 = new Font("Arial", 0, 11);
- @Override
- public void onPaint(Graphics arg0) {
- if (getRunningTime() == 0 || currentState == null)
- return;
- Integer hourRate = (int) (completed * 3600000 / (getRunningTime()));
- String TimeRun = Timing.msToString(getRunningTime()),
- Completed = String.format("%d (%d/HR)", completed, hourRate),
- State = currentState.toString();
- Graphics2D g = (Graphics2D)arg0;
- g.setColor(color1);
- g.fillRect(351, 350, 138, 95);
- g.setColor(color2);
- g.setStroke(stroke1);
- g.drawRect(351, 350, 138, 95);
- g.setFont(font1);
- g.drawString("AeroShield", 380, 374);
- g.setColor(color3);
- g.drawString("AeroShield", 379, 373);
- g.setFont(font2);
- g.setColor(color2);
- g.drawString(Completed, 417, 396);
- g.setColor(color3);
- g.drawString(Completed, 416, 395);
- g.drawString("Completed:", 357, 395);
- g.drawString("State:", 357, 413);
- g.setColor(color2);
- g.drawString(State, 391, 414);
- g.setColor(color3);
- g.drawString(State, 390, 413);
- g.drawString("Run Time:", 357, 430);
- g.setColor(color2);
- g.drawString(TimeRun, 410, 431);
- g.setColor(color3);
- g.drawString(TimeRun, 409, 430);
- }
- @Override
- public void run() {
- Skip = new SleepCondition(new Condition() {
- @Override
- public boolean active() {
- return true;
- }
- }, 1);
- println("AeroShield, you are running version " + Version + ".");
- println("Please remember to reguarly check for updates on the thread and post feedback.");
- while (true) {
- SleepCondition result = loop();
- Timing.waitCondition(result.C, result.Timeout);
- }
- }
- public SleepCondition loop() {
- SleepCondition resultCondition = Skip;
- if (Player.getPosition().distanceTo(new RSTile(2842, 3545, 1)) > 0) {
- Walking.walkTo(new RSTile(2842, 3545, 1));
- } else if (!hasShield()) {
- if (GameTab.getOpen() != TABS.INVENTORY) {
- GameTab.open(TABS.INVENTORY);
- }
- if (Inventory.find(8856)[0].click("Wield")) {
- resultCondition = new SleepCondition(new Condition() {
- @Override
- public boolean active() {
- return Inventory.find(8856).length == 0;
- }
- }, 4000);
- }
- } else {
- for (final State state : State.values()) {
- final RSObject[] objects = Objects.find(30, state.getObjectId());
- if (objects.length > 0) {
- RSInterfaceChild interfaceChild = Interfaces.get(411, state.getChild());
- if (interfaceChild != null) {
- if (interfaceChild.click("Ok")) {
- currentState = state;
- completed++;
- resultCondition = new SleepCondition(new Condition() {
- @Override
- public boolean active() {
- return Objects.find(30, state.getObjectId()).length == 0;
- }
- }, 4000);
- }
- }
- break;
- }
- }
- }
- return resultCondition;
- }
- private boolean hasShield() {
- RSInterfaceChild equip = Interfaces.get(387, 28);
- if(equip != null){
- RSItem[] items = equip.getItems();
- for(RSItem item : items) {
- if (item.getID() == 8856) {
- return true;
- }
- }
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement