Don't like ads? PRO users don't see any ads ;-)
Guest

Thomas First Script

By: a guest on May 2nd, 2012  |  syntax: None  |  size: 2.65 KB  |  hits: 20  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import org.powerbot.concurrent.Task;
  2. import org.powerbot.concurrent.strategy.Condition;
  3. import org.powerbot.concurrent.strategy.Strategy;
  4. import org.powerbot.game.api.ActiveScript;
  5. import org.powerbot.game.api.Manifest;
  6. import org.powerbot.game.api.methods.Calculations;
  7. import org.powerbot.game.api.methods.Walking;
  8. import org.powerbot.game.api.methods.interactive.Players;
  9. import org.powerbot.game.api.methods.node.SceneEntities;
  10. import org.powerbot.game.api.methods.tab.Inventory;
  11. import org.powerbot.game.api.util.Filter;
  12. import org.powerbot.game.api.util.Time;
  13. import org.powerbot.game.api.wrappers.Tile;
  14. import org.powerbot.game.api.wrappers.node.SceneObject;
  15.  
  16. @Manifest(authors = { "Thomas0013" }, name = "T Chopepr", description = "Chops down trees", version = 1.0)
  17. public class TChop extends ActiveScript{
  18.        
  19.         private static final int[] LOG = {1521};
  20.        
  21.         Tile destinationTile = new Tile(3281, 3415, 0);
  22.  
  23.         @Override
  24.         protected void setup() {
  25.                 final Chop chop = new Chop();
  26.                 final Strategy chopAction = new Strategy(chop, chop);
  27.                 final Walk walk = new Walk();
  28.                 final Strategy walkAction = new Strategy(walk, walk);
  29.                 final Drop drop = new Drop();
  30.                 final Strategy dropAction = new Strategy(drop, drop);
  31.                 provide(chopAction);
  32.                 provide(walkAction);
  33.                 provide(dropAction);
  34.         }
  35.        
  36.         private class Chop implements Task, Condition {
  37.                 @Override
  38.                 public void run() {
  39.                         SceneObject tree = SceneEntities.getNearest(new Filter<SceneObject>() {
  40.                                 public boolean accept(SceneObject entity) {
  41.                                         return entity.getId() == 38732; //need to fill in the correct id of the entity you want
  42.                                 }
  43.                         });
  44.                        
  45.                         if (tree != null) {
  46.                                 if (tree.isOnScreen()) {
  47.                                         tree.interact("Chop");
  48.                                         Time.sleep(1000);
  49.                                 }
  50.                         }
  51.                 }
  52.  
  53.                 @Override
  54.                 public boolean validate() {
  55.                         return Inventory.getCount() < 28 && Players.getLocal().getAnimation() == -1;
  56.                 }
  57.         }
  58.        
  59.         private class Walk implements Task, Condition {
  60.                 SceneObject tree = SceneEntities.getNearest(new Filter<SceneObject>() {
  61.                         public boolean accept(SceneObject entity) {
  62.                                 return entity.getId() == 38732; //need to fill in the correct id of the entity you want
  63.                         }
  64.                 });
  65.                 @Override
  66.                 public void run() {
  67.                         while (!tree.isOnScreen()) {
  68.                                 Walking.walk(destinationTile);
  69.                                 Time.sleep(1500);
  70.                         }
  71.                 }
  72.  
  73.                 @Override
  74.                 public boolean validate() {
  75.                         return tree != null && Calculations.distanceTo(tree) > 15;
  76.                 }
  77.                
  78.         }
  79.        
  80.         private class Drop implements Task, Condition {
  81.  
  82.                 @Override
  83.                 public void run() {
  84.                         Inventory.getItem(LOG).getWidgetChild().interact("Drop");
  85.                 }
  86.  
  87.                 @Override
  88.                 public boolean validate() {
  89.                         return Inventory.getCount() == 28;
  90.                 }
  91.                
  92.         }
  93.  
  94. }