Advertisement
Guest User

Untitled

a guest
Oct 6th, 2015
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.35 KB | None | 0 0
  1. package com.script.nodes;
  2.  
  3. import com.frc.frc_api.game.actions.Actions2;
  4. import com.frc.frc_api.game.time.FrcTimer;
  5. import com.frc.frc_api.game.util.CombatUtil;
  6. import com.frc.frc_api.game.util.PlayerUtil;
  7. import com.frc.frc_api.node_framework.my_nodes.ChildNode;
  8. import com.script.Constants;
  9. import org.tbot.methods.Time;
  10. import org.tbot.methods.tabs.Inventory;
  11. import org.tbot.util.Condition;
  12. import org.tbot.wrappers.NPC;
  13.  
  14. /**
  15.  * Created by Eric Vue on 9/30/2015.
  16.  */
  17. public class Attack extends ChildNode {
  18.     public static FrcTimer timer = new FrcTimer(10000);
  19.  
  20.     @Override
  21.     public void execute() {
  22.         if (PlayerUtil.getHealthPercent() <= Constants.eatAt) {
  23.             eat();
  24.         } else if (CombatUtil.isAttacking()) {
  25.             combat();
  26.         } else {
  27.             attack();
  28.         }
  29.     }
  30.  
  31.     public void eat() {
  32.         if (!Inventory.contains(Constants.PEACHES_ID) && Inventory.contains(Constants.BONES_TO_PEACHES_TAB_ID)) {
  33.             if (Inventory.contains(Constants.BONES_ID)) {
  34.                 Inventory.getItemClosestToMouse(Constants.BONES_TO_PEACHES_TAB_ID).interact("Break");
  35.                 Time.sleepUntil(new Condition() {
  36.                     @Override
  37.                     public boolean check() {
  38.                         return Inventory.contains(Constants.PEACHES_ID);
  39.                     }
  40.                 }, 2000);
  41.             }
  42.         } else {
  43.             Inventory.getItemClosestToMouse(Constants.PEACHES_ID).interact("Eat");
  44.         }
  45.     }
  46.  
  47.     public void combat() {
  48.         timer.restart();
  49.     }
  50.  
  51.     public void attack() {
  52.         final NPC mob = CombatUtil.getNearestAttackableNpc(Constants.mobName);
  53.  
  54.         if (!mob.isDead() && Constants.killCount < Constants.killRange) {
  55.             Actions2.interactIn(mob, "Attack", PlayerUtil.getLocation(), 50);
  56.             Time.sleepUntil(new Condition() {
  57.                 @Override
  58.                 public boolean check() {
  59.                     return CombatUtil.isAttacking();
  60.                 }
  61.             }, 2000);
  62.         } else {
  63.             Time.sleepUntil(new Condition() {
  64.                 @Override
  65.                 public boolean check() {
  66.                     return !CombatUtil.isAttacking();
  67.                 }
  68.             }, 2000);
  69.         }
  70.     }
  71.  
  72.     @Override
  73.     public boolean validate() {
  74.         return true;
  75.     }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement