/**
   * Checks the xp in the GameTab.Skills of one of the skills we are currently training.
   *
   * @return true if succesfully checked a skill
   */
  public static boolean doCheckXP() {

    General.println(
        "Current time: "
            + System.currentTimeMillis()
            + ". Next XP_CHECK at: "
            + (System.currentTimeMillis() - getUtil().TIME_TRACKER.CHECK_XP.next())
            + ". (next(): "
            + getUtil().TIME_TRACKER.CHECK_XP.next()
            + ")");
    if (getUtil().TIME_TRACKER.CHECK_XP.next() > 0L
        && System.currentTimeMillis() < getUtil().TIME_TRACKER.CHECK_XP.next()) return false;

    General.println("Checking XP");

    List<SKILLS> gainedXPInSkill = new ArrayList<SKILLS>();

    for (Entry<SKILLS, Integer> set : PaintMgr.startSkillInfo.entrySet()) {
      if (Skills.getXP(set.getKey()) > set.getValue()) gainedXPInSkill.add(set.getKey());
    }

    if (gainedXPInSkill.isEmpty()) return false;

    LANChaosKiller.statusText = "Antiban - Check XP";

    TABS oldTab = GameTab.getOpen();
    GameTab.open(TABS.STATS);

    SKILLS skillToCheck = gainedXPInSkill.get(General.random(1, gainedXPInSkill.size()) - 1);

    int index = 0;

    switch (skillToCheck) {
      case ATTACK:
        index = 1;
        break;
      case STRENGTH:
        index = 2;
        break;
      case DEFENCE:
        index = 3;
        break;
      case HITPOINTS:
        index = 9;
        break;
      case RANGED:
        index = 4;
        break;
      case MAGIC:
        index = 6;
        break;
      default:
        break;
    }

    if (index > 0) {

      final RSInterfaceChild skillInterface = Interfaces.get(320, index);

      if (skillInterface != null) {

        if (Clicking.hover(skillInterface)) {

          General.sleep(2500, 4000);
          GameTab.open(oldTab);

          return true;
        }
      }
    }

    getUtil().TIME_TRACKER.CHECK_XP.reset();

    return false;
  }
Example #2
0
  @Override
  public void run() {
    // Count slots used for not-bones vs how many bananas worth of bones we have
    int slotsUsed = 0;
    int potentialBananas = 0;
    RSItem[] items = Inventory.getAll();
    for (RSItem item : items) {
      // If this isn't a bone count it
      if (item.getID() < 6904 || item.getID() > 6907) {
        slotsUsed++;
      } else {
        // Item id    bone amount
        // 6904       1
        // 6905       2
        // 6906       3
        // 6907       4
        potentialBananas += 1 + item.getID() - 6904;
      }
    }

    int slotsAvailable = 28 - slotsUsed;

    RSItem[] food = Inventory.find(1963);

    // If have bananas/peaches, deposit them, else collect bones
    if (food.length > 0) {
      // Heal and then deposit
      float eatHealth = m_settings.m_eatHealth * Skills.getActualLevel(SKILLS.HITPOINTS);
      float eatTo = m_settings.m_eatTo * Skills.getActualLevel(SKILLS.HITPOINTS);

      if (food.length > 0 && Skills.getCurrentLevel(SKILLS.HITPOINTS) < eatHealth) {
        // Eat
        while (food.length > 0 && Skills.getCurrentLevel(SKILLS.HITPOINTS) < eatTo) {
          food[0].click("Eat");
          m_script.sleep(300, 600);
          food = Inventory.find(1963);
        }
      } else {
        // Deposit
        RSObject[] objs = Objects.findNearest(50, "Food chute");
        if (objs.length > 0) {
          while (!objs[0].isOnScreen()) {
            Walking.blindWalkTo(objs[0]);
            m_script.sleep(250);
          }
          objs[0].click("Deposit");
          m_script.sleep(1200);
        }
      }
    } else {
      // If we have more than a full load of bananas worth of bones, cast bones to peaches
      if (potentialBananas >= slotsAvailable) {
        // Cast bones to peaches
        Magic.selectSpell("Bones to Bananas");
      } else {
        // Collect bananas
        RSObject[] bonePiles = Objects.findNearest(10725, 10726, 10727, 10728);
        if (bonePiles.length > 0) {
          while (!bonePiles[0].isOnScreen()) {
            Walking.blindWalkTo(bonePiles[0]);
            m_script.sleep(250);
          }
          bonePiles[0].click("Grab");
          m_script.sleep(150);
        }
      }
    }
  }