brandon1000

FISHER : BANK ERROR & PICKUP ERRORS

Jul 27th, 2012
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.11 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.awt.*;
  3.  
  4. import org.powerbot.concurrent.Task;
  5. import org.powerbot.concurrent.strategy.Condition;
  6. import org.powerbot.concurrent.strategy.Strategy;
  7. import org.powerbot.game.api.ActiveScript;
  8. import org.powerbot.game.api.Manifest;
  9. import org.powerbot.game.api.methods.Game;
  10. import org.powerbot.game.api.methods.Tabs;
  11. import org.powerbot.game.api.methods.Widgets;
  12. import org.powerbot.game.api.methods.input.Mouse;
  13. import org.powerbot.game.api.methods.interactive.NPCs;
  14. import org.powerbot.game.api.methods.interactive.Players;
  15. import org.powerbot.game.api.methods.node.GroundItems;
  16. import org.powerbot.game.api.methods.tab.Inventory;
  17. import org.powerbot.game.api.util.Filter;
  18. import org.powerbot.game.api.util.Random;
  19. import org.powerbot.game.api.util.Time;
  20. import org.powerbot.game.api.util.Timer;
  21. import org.powerbot.game.api.wrappers.Area;
  22. import org.powerbot.game.api.wrappers.Tile;
  23. import org.powerbot.game.api.wrappers.interactive.NPC;
  24. import org.powerbot.game.api.wrappers.map.TilePath;
  25. import org.powerbot.game.api.wrappers.node.Item;
  26. import org.powerbot.game.api.wrappers.widget.WidgetChild;
  27. import org.powerbot.game.bot.event.listener.PaintListener;
  28.  
  29. @Manifest(name = "TEST FISHER", description = "TEST THIS ONE", version = 0.1, authors = {"brandon"})
  30. public class TEST extends ActiveScript implements PaintListener {
  31. //PAINT VARRIABLES
  32. String status;
  33. String Location;
  34. public Timer TIME;
  35. public Timer ERROR_TIMES;
  36. long runtime;
  37.  
  38. int runningFishCount = -1;
  39. int startCount = -1;
  40. int bankedfishCount = 0;
  41. int animation;
  42. int client_state;
  43.  
  44. int fish = 0;
  45.  
  46. int before;
  47. int after;
  48. int FISH;
  49.  
  50.  
  51.  
  52. private final boolean fishing = true;
  53. private final boolean fly = true;
  54. private final boolean bank = true;
  55.  
  56. private final boolean pickup = true;
  57. private final boolean GP_priority = true;
  58. private final boolean XP_priotiy = false;
  59.  
  60. private final int fishies[] = {335,331,349};
  61. private final int fishA1 = 335;// trout
  62. private final int fishA2 = 331;//salmon
  63. private final int fishA3 = 349;//pike
  64. private final int pools[] = {328};
  65. private final int items[] = {314,313};
  66. //private final int fishA[] = {623};
  67. private final int banks = 553;
  68.  
  69.  
  70. //barbarian outpost
  71. private final Area lebank = new Area(new Tile(3091, 3488, 0) , new Tile(3097, 3498, 0));
  72. private final Area lefish = new Area(new Tile(3099, 3423, 0) , new Tile(3112, 3440, 0));
  73. public final Tile[] Bankpath = {
  74. new Tile(3105, 3431, 0), new Tile(3100, 3440, 0),
  75. new Tile(3097, 3450, 0), new Tile(3096, 3460, 0),
  76. new Tile(3098, 3470, 0), new Tile(3101, 3481, 0),
  77. new Tile(3093, 3491, 0)
  78. };
  79. private final TilePath pathToBank = new TilePath(Bankpath);
  80. public final Tile[] Fishpath = {
  81. new Tile(3093, 3491, 0) , new Tile(3101, 3481, 0),
  82. new Tile(3098, 3470, 0), new Tile(3096, 3460, 0),
  83. new Tile(3097, 3450, 0), new Tile(3100, 3440, 0),
  84. new Tile(3105, 3431, 0)
  85. };
  86. public final TilePath pathToFish = new TilePath(Fishpath);
  87.  
  88.  
  89. public void setup(){
  90. provide(new Strategy(new Fish_1(), new Fish_1()));
  91. provide(new Strategy(new Fish_2(), new Fish_2()));
  92. provide(new Strategy(new Pick_up_1(), new Pick_up_1()));
  93. provide(new Strategy(new Pick_up_2(), new Pick_up_2()));
  94. provide(new Strategy(new Drop(),new Drop()));
  95. provide(new Strategy(new Walk_to_bank(), new Walk_to_bank()));
  96. provide(new Strategy(new Bank(), new Bank()));
  97. provide(new Strategy(new Walk_to_fish(), new Walk_to_fish()));
  98. provide(new Strategy(new Record_error(), new Record_error()));
  99. provide(new Strategy(new Anti_Ban(), new Anti_Ban()));
  100. }
  101.  
  102.  
  103. public class Fish_1 implements Task, Condition{
  104. public void run(){
  105. status = "fishing";
  106. NPC pool = NPCs.getNearest(pools);
  107. if(lefish.contains(Players.getLocal().getLocation()))
  108. pool.interact("lure");
  109. Time.sleep(Random.nextInt(6000, 12000));
  110.  
  111. }
  112.  
  113. public boolean validate() {
  114. return fishing == true
  115. && GP_priority == true
  116. && pickup == true
  117. && fly == true
  118. && Players.getLocal().getAnimation() == -1
  119. && !Inventory.isFull()
  120. && GroundItems.getLoaded(fishA1) == null
  121. && GroundItems.getLoaded(fishA2) == null
  122. && GroundItems.getLoaded(fishA3) == null;
  123. }
  124.  
  125. }
  126.  
  127. public class Fish_2 implements Task, Condition{
  128. public void run(){
  129. status = "fishing";
  130. NPC pool = NPCs.getNearest(pools);
  131. if(lefish.contains(Players.getLocal().getLocation()))
  132. pool.interact("lure");
  133. Time.sleep(Random.nextInt(6000, 12000));
  134. }
  135.  
  136. public boolean validate(){
  137. return XP_priotiy == true
  138. && fishing == true
  139. && pickup == true
  140. && fly == true
  141. && Players.getLocal().getAnimation() == -1
  142. && !Inventory.isFull();
  143. }
  144. }
  145.  
  146. public class Pick_up_1 implements Task, Condition{
  147.  
  148. public void run(){
  149. status = "picking up fish";
  150. before = Inventory.getCount(fishies);
  151. if(lefish.contains(Players.getLocal().getLocation())){
  152. Mouse.click(GroundItems.getNearest(fishies).getLocation().getCentralPoint(), true);
  153. Time.sleep(Random.nextInt(300, 500));
  154. after = Inventory.getCount(fishies);
  155. if(after - before == 1){
  156. ++fish;
  157. }
  158.  
  159. }
  160.  
  161. }
  162.  
  163. public boolean validate(){
  164. return pickup == true
  165. && fly == true
  166. && Players.getLocal().getAnimation() == -1
  167. && !Inventory.isFull()
  168. && GP_priority == true;
  169. }
  170. }
  171.  
  172. public class Pick_up_2 implements Task, Condition{
  173. public void run(){
  174. status = "picking up fish";
  175. before = Inventory.getCount(fishies);
  176. if(lefish.contains(Players.getLocal().getLocation())){
  177. Mouse.click(GroundItems.getNearest(fishies).getLocation().getCentralPoint(), true);
  178. Time.sleep(Random.nextInt(300, 500));
  179. after = Inventory.getCount(fishies);
  180. if(after - before == 1){
  181. ++fish;
  182. }
  183. }
  184. }
  185.  
  186. public boolean validate(){
  187. return XP_priotiy == true
  188. && NPCs.getLoaded(pools) == null;
  189. }
  190. }
  191.  
  192. public class Drop implements Task, Condition{
  193. public void run(){
  194. status = "droping";
  195. dropAllExcept(items);
  196. Time.sleep(Random.nextInt(300, 500));
  197. }
  198.  
  199. public boolean validate(){
  200. return Inventory.isFull()
  201. && Players.getLocal().getAnimation() == -1
  202. && bank == false
  203. && pickup == false;
  204. }
  205. }
  206.  
  207. public class Walk_to_bank implements Task, Condition{
  208. public void run(){
  209. status = "walking to bank";
  210. traverse(pathToBank);
  211. }
  212.  
  213. public boolean validate(){
  214. return Players.getLocal().getAnimation() == -1
  215. && Inventory.isFull()
  216. && bank == true;
  217. }
  218.  
  219. }
  220.  
  221. public class Bank implements Task, Condition{
  222. public void run(){
  223. status = "banking";
  224. NPC bank = NPCs.getNearest(new Filter<NPC>(){
  225. public boolean accept(NPC npc){
  226. return npc.getId() == banks;
  227. }
  228. });
  229. if( lebank.contains(Players.getLocal().getLocation())){
  230.  
  231. status = "selecting bank";
  232. if (bank != null){
  233. if (bank.isOnScreen()){
  234. bank.interact("bank");
  235. Time.sleep(Random.nextInt(300, 500));
  236. status = "interacting";
  237. }}
  238. status = "storing";
  239. Time.sleep(Random.nextInt(100,150 ));
  240. depositAllExcept(items);
  241. Time.sleep(Random.nextInt(250,300));
  242. Widgets.get(11, 15).interact("Close");
  243. }
  244.  
  245. }
  246.  
  247. public boolean validate(){
  248. return bank == true
  249. && Inventory.isFull()
  250. && Players.getLocal().getAnimation() == -1;
  251. }
  252. }
  253.  
  254. public class Walk_to_fish implements Task, Condition{
  255. public void run(){
  256. status = "walking to fish";
  257. if(!lefish.contains(Players.getLocal().getLocation()))
  258. {traverse(pathToFish);
  259. Time.sleep(Random.nextInt(400, 600));
  260. }
  261. }
  262.  
  263. public boolean validate(){
  264. return !Inventory.isFull()
  265. && Players.getLocal().getAnimation() == -1;
  266. }
  267. }
  268.  
  269. public class Record_error implements Task, Condition{
  270. public void run(){
  271.  
  272. if(Game.getClientState() == 3){
  273. runtime = TIME.getElapsed();
  274. log.info("what was it doing ?"+status);
  275. log.info("how long did it run?"+ runtime);
  276. log.info("Start again?");
  277. }
  278. }
  279.  
  280.  
  281. public boolean validate(){
  282. return true;
  283. }
  284. }
  285.  
  286. public class Get_paint_info implements Task, Condition{
  287. public void run(){
  288. animation = Players.getLocal().getAnimation();
  289. client_state = Game.getClientState();
  290. }
  291.  
  292. public boolean validate(){
  293. return true;
  294. }
  295. }
  296.  
  297. public class Anti_Ban implements Task, Condition{
  298. public void run(){
  299.  
  300. }
  301.  
  302. public boolean validate(){
  303. return true;
  304. }
  305. }
  306. public void traverse(TilePath path) {
  307. if (Tabs.INVENTORY.isOpen()) {
  308. if (Players.getLocal().getSpeed() == 0) {
  309. for (int i=0; i<10 && (Players.getLocal().getSpeed() == 0); i++) {
  310. path.getNext().clickOnMap();
  311. Time.sleep(500);
  312. }
  313. if (Players.getLocal().getSpeed() == 0) { //used as a failsafe when mouse keeps trying to traverse but just clicks edge of minimap
  314. Mouse.click(Random.nextInt(627-30, 627 + 30), Random.nextInt(85-30, 85+30), true); // x:627 & y:85 = exact center of minimap
  315. }
  316. } else {
  317. path.traverse();
  318. }
  319. } else {
  320. Tabs.INVENTORY.open();
  321. }
  322. }
  323. public void depositAllExcept(int... item) {
  324. ArrayList<Integer> ids = new ArrayList<Integer>();
  325. int ninvCount = -1;
  326. int invCount = Inventory.getCount();
  327. for (int id : item) {
  328. ids.add(id);
  329. }
  330. for (int i = 0; i < 28; i++) {
  331. WidgetChild slot = Widgets.get(679, 0).getChild(i);
  332. int slotId = slot.getChildId();
  333. if (slot.validate() && Inventory.getCount(slotId) > 0) {
  334. if (!ids.contains(slotId)) {
  335. for (int tries = 0; tries < 5; tries++) {
  336. if (Inventory.getCount(slotId) > 1) {
  337. if (slot.interact("Deposit-All"));
  338. else
  339. tries = 5;
  340. } else {
  341. if (slot.interact("Deposit"));
  342. else
  343. tries = 5;
  344. }
  345. Time.sleep(625, 902);
  346. ninvCount = Inventory.getCount();
  347. if (invCount > ninvCount) {
  348. invCount = ninvCount;
  349. tries = 5;
  350. }
  351. }
  352. }
  353. }
  354. }
  355. }
  356. public void dropAllExcept(final int... nodrop) {
  357. for(Item item : Inventory.getItems(new Filter<Item>() {
  358. @Override
  359. public boolean accept(Item arg0) {
  360. for(int i : nodrop) {
  361. if(arg0.getId() == i)
  362. return false;
  363. }
  364. return true;
  365. }
  366. })) {
  367. item.getWidgetChild().interact("Drop");
  368. Time.sleep(150, 300);
  369. }
  370. }
  371.  
  372.  
  373. private final Color color1 = new Color(255, 255, 255);
  374. private final Color color2 = new Color(0, 0, 0);
  375. private final BasicStroke stroke1 = new BasicStroke(1);
  376. private final Font font1 = new Font("Arial", 0, 20);
  377. private final Font font2 = new Font("Arial", 0, 10);
  378.  
  379. public void onRepaint(Graphics g1) {
  380. Graphics2D g = (Graphics2D)g1;
  381. g.setColor(color1);
  382. g.fillRect(22, 357, 468, 87);
  383. g.setColor(color2);
  384. g.setStroke(stroke1);
  385. g.drawRect(22, 357, 468, 87);
  386. g.setFont(font1);
  387. g.drawString("FISHER", 223, 378);
  388. g.setFont(font2);
  389. g.drawString("status" + status, 26, 395);
  390. g.drawString("client state" + client_state, 27, 414);
  391. g.drawString("time:" + TIME, 29, 434);
  392. g.drawString("fish cought:" + fish, 295, 393);
  393. }
  394. //END: Code generated using Enfilade's Easel
  395. }
Add Comment
Please, Sign In to add comment