View difference between Paste ID: PYMntD0t and
SHOW:
|
|
- or go back to the newest paste.
1 | - | |
1 | + | import java.awt.event.*; |
2 | import java.awt.*; | |
3 | import java.util.*; | |
4 | import java.io.*; | |
5 | import java.nio.channels.*; | |
6 | import java.net.*; | |
7 | import java.util.List; | |
8 | import java.util.logging.Level; | |
9 | import java.lang.reflect.Method; | |
10 | import javax.accessibility.*; | |
11 | import javax.swing.*; | |
12 | import org.rsbot.*; | |
13 | import org.rsbot.bot.Bot; | |
14 | import org.rsbot.script.*; | |
15 | import org.rsbot.script.wrappers.*; | |
16 | import org.rsbot.event.listeners.*; | |
17 | import org.rsbot.event.events.ServerMessageEvent; | |
18 | import org.rsbot.util.ScreenshotUtil; | |
19 | import javax.imageio.ImageIO; | |
20 | ||
21 | @ScriptManifest(authors = { "Conderoga" }, keywords = "Fishing", name = "C's Leaping Fisher", version = 1.00,description = "Fishes leaping fish and banks caviar.") | |
22 | ||
23 | /*UpdateLog: | |
24 | v1.00 - Initial Release | |
25 | */ | |
26 | ||
27 | ||
28 | public class CLeap extends Script implements PaintListener, ServerMessageListener, MouseListener{ | |
29 | ||
30 | //Paint stuff | |
31 | private int startLevelf; | |
32 | private int startLevela; | |
33 | private int startLevels; | |
34 | private int startExp; | |
35 | private int expGained; | |
36 | private int lvlsGainedf; | |
37 | private int lvlsGaineda; | |
38 | private int lvlsGaineds; | |
39 | private long startTime; | |
40 | private double startTimeDbl; | |
41 | private long ExpHr; | |
42 | private boolean showPaint = true; | |
43 | private boolean fancyPaint = true; | |
44 | private final Image img2 = getImage("http://i263.photobucket.com/albums/ii158/zpogo/Bar.png"); | |
45 | private final Image img4 = getImage("http://i263.photobucket.com/albums/ii158/zpogo/EXPback-1copy.png"); | |
46 | private Point p; | |
47 | ||
48 | //Script stuff | |
49 | private int [] equipAndCaviar = {11323,314,946,11326}; | |
50 | private int [] equipAndSturg = {11323,314,946,11332}; | |
51 | private int [] equipment = {11323,314,946}; | |
52 | private int [] equipment2 = {11323,314}; | |
53 | private RSTile [] toBank = {new RSTile(2503,3497),new RSTile(2499,3507),new RSTile(2501,3519),new RSTile(2506,3529),new RSTile(2506,3540),new RSTile(2508,3551),new RSTile(2516,3561),new RSTile(2520,3569),new RSTile(2531,3571),new RSTile(2536,3573)}; | |
54 | private RSTile [] toFish; | |
55 | private int animId; | |
56 | private int spawnID; | |
57 | private String action; | |
58 | private String status; | |
59 | private int failSafe; | |
60 | private int amntLTrout; | |
61 | private int amntLSalmon; | |
62 | private int amntLSturgeon; | |
63 | private int amntCaviar; | |
64 | private int[] GEPRICES = new int [4]; | |
65 | private int bankerID; | |
66 | private double [] columns= {563,605,647,689}; | |
67 | private double [] rows = {213,249,285,321,357,393,429}; | |
68 | private boolean caviarMade = false; | |
69 | ||
70 | //Other stuff | |
71 | private int safety = 0; | |
72 | private String version = "v1.00"; | |
73 | CLeapGUI gui; | |
74 | private boolean guiWait = true; | |
75 | private boolean guiExit = true; | |
76 | public String type; | |
77 | private RSTile loc; | |
78 | ||
79 | public boolean onStart() { | |
80 | //Credits to Zombieknight for this:----------------- | |
81 | final int welcome = JOptionPane.showConfirmDialog(null,"Before using my script, would you like to thank me\nby clicking some adverts?","Welcome", JOptionPane.YES_NO_OPTION); | |
82 | if (welcome == 0) { | |
83 | final String message = "<html>Thank you for your support!<br /></html>"; | |
84 | JOptionPane.showMessageDialog(null, message); | |
85 | openURL("http://adf.ly/317631/agsn"); | |
86 | } | |
87 | //=------------------------------------------------------*/ | |
88 | gui = new CLeapGUI(); | |
89 | gui.setVisible(true); | |
90 | while(guiWait) | |
91 | { | |
92 | sleep(100); | |
93 | } | |
94 | startTime = System.currentTimeMillis(); | |
95 | startTimeDbl = System.currentTimeMillis(); | |
96 | return !guiExit; | |
97 | } | |
98 | public boolean checkAnim() | |
99 | { | |
100 | for(int i = 0; i<4;i++){ | |
101 | ||
102 | if(getMyPlayer().getAnimation()==animId||getMyPlayer().getAnimation()==animId-1||getMyPlayer().getAnimation()==animId+1) | |
103 | { status = "Fishing."; | |
104 | failSafe=0; | |
105 | return true; | |
106 | } | |
107 | sleep(300); | |
108 | } | |
109 | failSafe++; | |
110 | status = "Not fishing."; | |
111 | return false; | |
112 | } | |
113 | public void fish() | |
114 | { | |
115 | RSNPC test = npcs.getNearest(spawnID); | |
116 | if(test!=null) | |
117 | { | |
118 | RSTile spawn = test.getLocation(); | |
119 | if(calc.tileOnScreen(spawn)) | |
120 | { | |
121 | status = "Clicking Spawn."; | |
122 | mouse.move(calc.tileToScreen(spawn),3,3); | |
123 | menu.doAction(action); | |
124 | } | |
125 | sleep(random(600,800)); | |
126 | while(players.getMyPlayer().isMoving()) | |
127 | { | |
128 | status = "Moving to Spawn."; | |
129 | sleep(random(100,200)); | |
130 | } | |
131 | if(!checkAnim()) | |
132 | {status = "Didn't click spawn."; | |
133 | failSafe++; | |
134 | } | |
135 | } | |
136 | else | |
137 | failSafe++; | |
138 | } | |
139 | public void setUp() | |
140 | { | |
141 | toFish = walking.reversePath(toBank); | |
142 | animId=623; | |
143 | spawnID = 2722; | |
144 | action = "Use-rod Fishing spot"; | |
145 | amntLTrout = 0; | |
146 | amntLSalmon = 0; | |
147 | amntLSturgeon = 0; | |
148 | amntCaviar = 0; | |
149 | } | |
150 | public void serverMessageRecieved(final ServerMessageEvent a){ | |
151 | final String serverString = a.getMessage(); | |
152 | if(serverString.toLowerCase().contains("you catch a leaping trout")) | |
153 | amntLTrout++; | |
154 | else if(serverString.toLowerCase().contains("you catch a leaping salmon")) | |
155 | amntLSalmon++; | |
156 | else if(serverString.toLowerCase().contains("you catch a leaping sturgeon")) | |
157 | amntLSturgeon++; | |
158 | else if(serverString.toLowerCase().contains("caviar")) | |
159 | amntCaviar++; | |
160 | } | |
161 | public void bank(){ | |
162 | mouse.setSpeed(random(7,8)); | |
163 | boolean tryAgain = true; | |
164 | while(inventory.isFull()){ | |
165 | tryAgain = true; | |
166 | while(tryAgain) { | |
167 | status = "Opening bank."; | |
168 | RSObject [] test = objects.getAllAt(new RSTile(2537,3573)); | |
169 | RSObject bankBox = null; | |
170 | for(int i = 0; i<test.length;i++) | |
171 | if(test[i].getID()==20228) | |
172 | bankBox = test[i]; | |
173 | RSModel m = bankBox.getModel(); | |
174 | Point p = m.getPoint(); | |
175 | mouse.move(p,1,1); | |
176 | if(menu.doAction("Deposit Bank deposit box")) | |
177 | tryAgain = false; | |
178 | } | |
179 | status = "Depositing."; | |
180 | sleep(random(3000,4000)); | |
181 | if(type.equals("Bank Fish")) | |
182 | bank.depositAllExcept(equipment2); | |
183 | else | |
184 | bank.depositAllExcept(equipment); | |
185 | sleep(random(600,800)); | |
186 | mouse.move(random(427,440),random(36,47),0,0); | |
187 | sleep(random(300,400)); | |
188 | mouse.click(true); | |
189 | sleep(random(1000,2000)); | |
190 | } | |
191 | } | |
192 | public void door() | |
193 | { | |
194 | if(calc.tileToScreen(new RSTile(2521,3571)).x!=-1) | |
195 | { | |
196 | RSObject door = getDoor(); | |
197 | while(isDoorClosed()){ | |
198 | status = "Opening door."; | |
199 | walking.walkTileMM(new RSTile(2521,3571),1,1); | |
200 | RSModel m = door.getModel(); | |
201 | Point temp = m.getPoint(); | |
202 | mouse.move(temp,1,1); | |
203 | if(menu.doAction("Open Barbarian Door")) | |
204 | status = "Door opened."; | |
205 | sleep(random(600,800)); | |
206 | } | |
207 | } | |
208 | } | |
209 | public boolean isDoorClosed() | |
210 | { | |
211 | RSObject [] test = objects.getAllAt(new RSTile(2521,3571)); | |
212 | for(int i = 0; i<test.length;i++) | |
213 | { | |
214 | if(test[i].getID()==20195){ | |
215 | return true; | |
216 | } | |
217 | } | |
218 | return false; | |
219 | } | |
220 | public RSObject getDoor(){ | |
221 | RSObject [] test = objects.getAllAt(new RSTile(2521,3571)); | |
222 | RSObject door = null; | |
223 | for(int i = 0; i<test.length;i++) | |
224 | { | |
225 | if(test[i].getID()==20195){ | |
226 | door = test[i]; | |
227 | } | |
228 | } | |
229 | return door; | |
230 | } | |
231 | public void walkToBank() | |
232 | { | |
233 | status = "Walking to bank."; | |
234 | camera.setPitch(true); | |
235 | while(!atBank()) | |
236 | { | |
237 | if(walking.getEnergy()> 40) | |
238 | walking.setRun(true); | |
239 | status = "Walking to bank.."; | |
240 | door(); | |
241 | walkPath(toBank); | |
242 | sleep(random(1500,2000)); | |
243 | } | |
244 | } | |
245 | public void walkToFish() | |
246 | { | |
247 | status = "Walking to fish."; | |
248 | camera.setPitch(true); | |
249 | while(!atFish()) | |
250 | { | |
251 | if(walking.getEnergy()> 40) | |
252 | walking.setRun(true); | |
253 | status = "Walking to fish.."; | |
254 | door(); | |
255 | walkPath(toFish); | |
256 | sleep(random(1500,2000)); | |
257 | } | |
258 | } | |
259 | public boolean atBank(){ | |
260 | return players.getMyPlayer().getLocation().getX()<2537&&players.getMyPlayer().getLocation().getX()>2533&&players.getMyPlayer().getLocation().getY()<3575&&players.getMyPlayer().getLocation().getY()>3571; | |
261 | } | |
262 | public boolean atFish(){ | |
263 | return players.getMyPlayer().getLocation().getX()<2507&&players.getMyPlayer().getLocation().getY()<3519; | |
264 | } | |
265 | public int getGEValue(String name, int id){ | |
266 | try{ | |
267 | String [] temp = name.split(" "); | |
268 | String newName = ""; | |
269 | for(int i = 0; i<temp.length; i++) | |
270 | if(i==temp.length-1) | |
271 | newName+=temp[i]; | |
272 | else | |
273 | newName+="_"+temp[i]; | |
274 | URL url = new URL("http://services.runescape.com/m=itemdb_rs/"+newName+"/viewitem.ws?obj="+id); | |
275 | InputStream is = url.openStream(); | |
276 | InputStreamReader isr = new InputStreamReader(is); | |
277 | BufferedReader br = new BufferedReader(isr); | |
278 | String line; | |
279 | String num = ""; | |
280 | while((line=br.readLine())!=null){ | |
281 | if(line.contains("Current guide price:")) | |
282 | num = line; | |
283 | } | |
284 | System.out.println(num); | |
285 | if(num.length()<29) | |
286 | return -1; | |
287 | else{ | |
288 | num = num.substring(28); | |
289 | num = num.replaceAll(",", ""); | |
290 | return Integer.parseInt(num); | |
291 | } | |
292 | ||
293 | }catch(Exception e){ | |
294 | return -1; | |
295 | } | |
296 | } | |
297 | public void walkPath(RSTile [] path) | |
298 | { | |
299 | if(playerIsNear(path[path.length-2])) | |
300 | walking.walkTileMM(path[path.length-1],1,1); | |
301 | else{ | |
302 | int temp = 0; | |
303 | boolean nearSomething = false; | |
304 | for(int i = 0; i<path.length;i++) | |
305 | { | |
306 | if(playerIsNear(path[i])) | |
307 | { | |
308 | nearSomething = true; | |
309 | temp = i+1; | |
310 | antiBan(random(1,200)); | |
311 | for(int j = i; j<path.length; j++) | |
312 | { | |
313 | if(calc.tileToMinimap(path[j]).x==-1) | |
314 | { | |
315 | temp=j-1; | |
316 | break; | |
317 | } | |
318 | if(j==path.length-1&&calc.tileToMinimap(path[j]).x!=-1) | |
319 | { | |
320 | temp=j; | |
321 | break; | |
322 | } | |
323 | } | |
324 | door(); | |
325 | walking.walkTileMM(path[temp],1,1); | |
326 | } | |
327 | } | |
328 | if(!nearSomething){ | |
329 | door(); | |
330 | walking.walkTileMM(walking.nextTile(path),1,1); | |
331 | } | |
332 | } | |
333 | } | |
334 | public boolean playerIsNear(RSTile tile) | |
335 | { | |
336 | return (Math.abs(getMyPlayer().getLocation().getX()-tile.getX())<6&&Math.abs(getMyPlayer().getLocation().getY()-tile.getY())<6); | |
337 | } | |
338 | public int loop() { | |
339 | try{ | |
340 | if(safety<1) | |
341 | { | |
342 | setUp(); | |
343 | GEPRICES[0]=getGEValue("Leaping trout",11328); | |
344 | GEPRICES[0]=getGEValue("Leaping salmon",11330); | |
345 | GEPRICES[0]=getGEValue("Leaping sturgeon",11332); | |
346 | GEPRICES[3]=getGEValue("Caviar",11326); | |
347 | camera.setPitch(true); | |
348 | safety=1; | |
349 | } | |
350 | if(atBank()&&inventory.isFull()){ | |
351 | bank(); | |
352 | sleep(random(600,800)); | |
353 | walkToFish(); | |
354 | } | |
355 | antiBan(random(1,50)); | |
356 | boolean full = inventory.isFull(); | |
357 | if(!full&&!checkAnim()&&!caviarMade&&atFish()) | |
358 | fish(); | |
359 | if(!inventory.contains(equipment[1])) | |
360 | { | |
361 | failSafe++; | |
362 | } | |
363 | if(failSafe>5) | |
364 | { | |
365 | camera.setPitch(false); | |
366 | int angle = camera.getAngle(); | |
367 | if(angle<259) | |
368 | camera.setAngle(camera.getAngle()+random(80,100)); | |
369 | else | |
370 | camera.setAngle(random(0,10)); | |
371 | fish(); | |
372 | if(!status.equals("Fishing.")) | |
373 | { | |
374 | if(failSafe>15) | |
375 | walking.walkTo(new RSTile(2500,3515)); | |
376 | while(players.getMyPlayer().isMoving()) | |
377 | sleep(random(100,200)); | |
378 | fish(); | |
379 | if(failSafe>25) | |
380 | { | |
381 | if(!inventory.contains(equipment[1])) | |
382 | { | |
383 | log("Out of feathers, stopping script."); | |
384 | game.logout(true); | |
385 | stopScript(); | |
386 | } | |
387 | } | |
388 | } | |
389 | else | |
390 | failSafe = 0; | |
391 | } | |
392 | if(caviarMade) | |
393 | { | |
394 | walkToBank(); | |
395 | caviarMade=false; | |
396 | } | |
397 | if(atBank()&&full) | |
398 | { | |
399 | bank(); | |
400 | sleep(random(600,800)); | |
401 | walkToFish(); | |
402 | } | |
403 | if(!atBank()&&!atFish()&&full&&!type.equals("PowerFish")) | |
404 | { | |
405 | walkToBank(); | |
406 | } | |
407 | if(inventory.isFull()){ | |
408 | if(caviarMade) | |
409 | walkToBank(); | |
410 | else if(type.equals("PowerFish")) | |
411 | dropAll(equipment2); | |
412 | else if(type.equals("Bank Caviar")){ | |
413 | if((!inventory.contains(11330)&&!inventory.contains(11328))||dropAll(equipAndSturg)){ | |
414 | if((!inventory.contains(11330)&&!inventory.contains(11328))){ | |
415 | mouse.move((int)columns[random(0,3)]+random(10,20),(int)rows[random(1,5)]+random(10,20),3,3); | |
416 | sleep(random(300,800)); | |
417 | menu.doAction("Drop"); | |
418 | sleep(random(300,800)); | |
419 | } | |
420 | makeCaviar(); | |
421 | } | |
422 | } | |
423 | else if(type.equals("Bank Fish")) | |
424 | { | |
425 | walkToBank(); | |
426 | } | |
427 | } | |
428 | } | |
429 | catch (Exception e){} | |
430 | return random(300,500); | |
431 | } | |
432 | public void makeCaviar(){ | |
433 | status = "Making caviar."; | |
434 | RSItem knife = null; | |
435 | RSItem sturgeon = null; | |
436 | RSItem [] inv = inventory.getItems(); | |
437 | for(int i = 0; i < inv.length;i++){ | |
438 | if(inv[i].getID()==946&&knife==null) | |
439 | knife = inv[i]; | |
440 | if(inv[i].getID()==11332&&sturgeon==null) | |
441 | sturgeon = inv[i]; | |
442 | if(knife!=null&&sturgeon!=null) | |
443 | break; | |
444 | } | |
445 | inventory.useItem(knife,sturgeon); | |
446 | sleep(random(1000,1500)); | |
447 | mouse.move(random(208,308),random(393,455),0,0); | |
448 | mouse.click(true); | |
449 | sleep(random(600,800)); | |
450 | animId = 6702; | |
451 | while(checkAnim()){ | |
452 | sleep(random(100,200)); | |
453 | antiBan(random(1,300)); | |
454 | } | |
455 | caviarMade = inventory.contains(11326); | |
456 | animId= 623; | |
457 | } | |
458 | public boolean dropAll(int [] ids) | |
459 | { | |
460 | status = "Dropping."; | |
461 | mouse.setSpeed(random(6,8)); | |
462 | if(ids.length==4){ | |
463 | int count = 0; | |
464 | RSItem [] inv = inventory.getItems(); | |
465 | for(int i =0; i<inv.length;i++) | |
466 | if(inv[i].getID()!=ids[0]&&inv[i].getID()!=ids[1]&&inv[i].getID()!=ids[2]&&inv[i].getID()!=ids[3]) | |
467 | count++; | |
468 | RSItem [] toDrop = new RSItem [count-28]; | |
469 | ||
470 | count = 0; | |
471 | for(int i =0; i<inv.length;i++){ | |
472 | if(count==toDrop.length) | |
473 | break; | |
474 | if(inv[i].getID()!=ids[0]&&inv[i].getID()!=ids[1]&&inv[i].getID()!=ids[2]&&inv[i].getID()!=ids[3]) | |
475 | {toDrop[count] = inv[i]; | |
476 | count++; | |
477 | } | |
478 | } | |
479 | int [] dropOrder = new int[toDrop.length]; | |
480 | int index = 0; | |
481 | for(int j = 0; j<columns.length;j++) | |
482 | for(int i =0; i<toDrop.length;i++) | |
483 | { | |
484 | if(toDrop[i].getComponent().getLocation().getX()==columns[j]) | |
485 | { | |
486 | dropOrder[index]=i; | |
487 | index++; | |
488 | } | |
489 | } | |
490 | for(int i =0; i<toDrop.length;i++) | |
491 | { | |
492 | if(!toDrop[dropOrder[i]].doAction("Drop")) | |
493 | {status = "Attempting to Destroy"; | |
494 | if(toDrop[dropOrder[i]].doAction("Destroy")){ | |
495 | sleep(random(1000,1500)); | |
496 | mouse.move(random(304,338),random(380,392),0,0); | |
497 | sleep(random(600,800)); | |
498 | mouse.click(true); | |
499 | sleep(random(600,800)); | |
500 | } | |
501 | } | |
502 | } | |
503 | if(toDrop.length==1) | |
504 | return true; | |
505 | if(toDrop.length>1) | |
506 | fish(); | |
507 | } | |
508 | else if(ids.length==2){ | |
509 | int count = 0; | |
510 | RSItem [] inv = inventory.getItems(); | |
511 | for(int i =0; i<inv.length;i++) | |
512 | if(inv[i].getID()!=ids[0]&&inv[i].getID()!=ids[1]) | |
513 | count++; | |
514 | RSItem [] toDrop = new RSItem [(count/2)-1]; | |
515 | count = 0; | |
516 | for(int i =0; i<inv.length;i++){ | |
517 | if(count==toDrop.length) | |
518 | break; | |
519 | if(inv[i].getID()!=ids[0]&&inv[i].getID()!=ids[1]) | |
520 | {toDrop[count] = inv[i]; | |
521 | count++; | |
522 | } | |
523 | } | |
524 | int [] dropOrder = new int[toDrop.length]; | |
525 | int index = 0; | |
526 | for(int j = 0; j<columns.length;j++) | |
527 | for(int i =0; i<toDrop.length;i++) | |
528 | { | |
529 | if(toDrop[i].getComponent().getLocation().getX()==columns[j]) | |
530 | { | |
531 | dropOrder[index]=i; | |
532 | index++; | |
533 | } | |
534 | } | |
535 | for(int i =0; i<toDrop.length;i++) | |
536 | { | |
537 | if(!toDrop[dropOrder[i]].doAction("Drop")) | |
538 | {status = "Attempting to Destroy"; | |
539 | if(toDrop[dropOrder[i]].doAction("Destroy")){ | |
540 | sleep(random(1000,1500)); | |
541 | mouse.move(random(304,338),random(380,392),0,0); | |
542 | sleep(random(600,800)); | |
543 | mouse.click(true); | |
544 | sleep(random(600,800)); | |
545 | }} | |
546 | } | |
547 | if(toDrop.length>1) | |
548 | fish(); | |
549 | } | |
550 | return false; | |
551 | } | |
552 | public void antiBan(int rand){ | |
553 | status += "(AB)"; | |
554 | mouse.setSpeed(random(7,8)); | |
555 | if(rand==1) | |
556 | if(random(1, 4) == 2) | |
557 | mouse.moveRandomly(900,1200); | |
558 | if(rand==2) | |
559 | if(random(1, 4) == 2) | |
560 | mouse.moveRandomly(400,800); | |
561 | if(rand==3) | |
562 | if(random(1, 4) == 2) | |
563 | mouse.moveRandomly(200,700); | |
564 | ||
565 | if(rand==4) //THIS CHECKS THE FISHING STAT | |
566 | if(random(1, 12) == 2) | |
567 | { | |
568 | game.openTab(game.TAB_STATS); | |
569 | sleep(random(600,800)); | |
570 | mouse.move(random(681, 690), random(269, 291),0,0); | |
571 | sleep(random(900,1000)); | |
572 | game.openTab(game.TAB_INVENTORY); | |
573 | } | |
574 | if(rand==5) //THIS CLICKS THE XP BUTTON UNDER THE COMPASS | |
575 | if(random(1, 12) == 2) | |
576 | { | |
577 | mouse.move(random(527, 540), random(58, 65),0,0); | |
578 | sleep(random(800,1000)); | |
579 | mouse.click(true); | |
580 | mouse.moveRandomly(20,50); | |
581 | sleep(random(3000,4000)); | |
582 | } | |
583 | if(rand==6) //THIS CHECKS CURRENT GOAL | |
584 | if(random(1, 12) == 2) | |
585 | { | |
586 | game.openTab(8); | |
587 | sleep(random(300,1000)); | |
588 | mouse.move(random(604, 630), random(394, 399),0,0); | |
589 | sleep(random(3000,4000)); | |
590 | } | |
591 | if(rand==7) //RANDOM SPIN | |
592 | if(random(1, 3) == 2) | |
593 | {int r = random(1,2); | |
594 | camera.setAngle(random(1,359)); | |
595 | if(r!=1) | |
596 | camera.setPitch(random(1,99));} | |
597 | ||
598 | if(rand==8) //THIS CHECKS A RANDOM TAB | |
599 | if(random(1, 4) == 2) | |
600 | { | |
601 | int[] tabs = {0,2,3,5,6,7,9,10,11,12,13,14,15}; | |
602 | game.openTab(tabs[random(0,tabs.length-1)]); | |
603 | mouse.moveRandomly(150,200); | |
604 | sleep(random(1600,1800)); | |
605 | sleep(random(900,1000)); | |
606 | ||
607 | } | |
608 | if(rand==9) | |
609 | if(random(1,10)==2) | |
610 | mouse.moveOffScreen(); | |
611 | status=status.substring(0,status.indexOf('(')); | |
612 | ||
613 | } | |
614 | public void openURL(final String url) { // Credits ZombieKnight | |
615 | //who gave credits to Dave who gave credits | |
616 | // to | |
617 | // some guy who made this. | |
618 | final String osName = System.getProperty("os.name"); | |
619 | try { | |
620 | if (osName.startsWith("Mac OS")) { | |
621 | final Class<?> fileMgr = Class | |
622 | .forName("com.apple.eio.FileManager"); | |
623 | final Method openURL = fileMgr.getDeclaredMethod("openURL",new Class[]{String.class}); | |
624 | openURL.invoke(null, new Object[]{url}); | |
625 | } else if (osName.startsWith("Windows")) { | |
626 | Runtime.getRuntime().exec( | |
627 | "rundll32 url.dll,FileProtocolHandler " + url); | |
628 | } else { // assume Unix or Linux | |
629 | final String[] browsers = {"firefox", "opera", "konqueror", | |
630 | "epiphany", "mozilla", "netscape"}; | |
631 | String browser = null; | |
632 | for (int count = 0; count < browsers.length && browser == null; count++) { | |
633 | if (Runtime.getRuntime().exec( | |
634 | new String[]{"which", browsers[count]}) | |
635 | .waitFor() == 0) { | |
636 | browser = browsers[count]; | |
637 | } | |
638 | } | |
639 | if (browser == null) { | |
640 | throw new Exception("Could not find web browser"); | |
641 | } else { | |
642 | Runtime.getRuntime().exec(new String[]{browser, url}); | |
643 | } | |
644 | } | |
645 | }catch(Exception e){}; | |
646 | } | |
647 | public void mouseExited(MouseEvent e) { | |
648 | } | |
649 | public void mouseEntered(MouseEvent e) { | |
650 | } | |
651 | public void mouseReleased(MouseEvent e) { | |
652 | } | |
653 | public void mousePressed(MouseEvent e) { | |
654 | } | |
655 | public void mouseClicked(MouseEvent e) { | |
656 | p = e.getPoint(); | |
657 | if(showPaint && p.getX()>447&&p.getX()<513&& p.getY()>458&&p.getY()<473) | |
658 | showPaint = false; | |
659 | else if(!showPaint && p.getX()>447&&p.getX()<513&& p.getY()>458&&p.getY()<473) | |
660 | showPaint = true; | |
661 | else if(showPaint && fancyPaint && p.getX()>397&&p.getX()<448&& p.getY()>458&&p.getY()<473) | |
662 | fancyPaint = false; | |
663 | else if(showPaint && !fancyPaint && p.getX()>397&&p.getX()<448&& p.getY()>458&&p.getY()<473) | |
664 | fancyPaint = true; | |
665 | } | |
666 | public void onRepaint(Graphics g) | |
667 | { | |
668 | if(game.isLoggedIn()) | |
669 | { | |
670 | try{ | |
671 | if(startExp==0) | |
672 | { | |
673 | startExp = skills.getCurrentExp(skills.getIndex("fishing")); | |
674 | startLevelf = skills.getCurrentLevel(skills.getIndex("fishing")); | |
675 | startLevela = skills.getCurrentLevel(skills.getIndex("agility")); | |
676 | startLevels = skills.getCurrentLevel(skills.getIndex("strength")); | |
677 | } | |
678 | lvlsGainedf = skills.getCurrentLevel(skills.getIndex("fishing")) - startLevelf; | |
679 | lvlsGaineda = skills.getCurrentLevel(skills.getIndex("agility")) - startLevela; | |
680 | lvlsGaineds = skills.getCurrentLevel(skills.getIndex("strength")) - startLevels; | |
681 | expGained = skills.getCurrentExp(skills.getIndex("fishing")) - startExp; | |
682 | long ms = System.currentTimeMillis() - startTime; | |
683 | double ms2 = System.currentTimeMillis() - startTimeDbl; | |
684 | long hours = ms/3600000; | |
685 | ms = ms-(hours*3600000); | |
686 | long minutes = ms/60000; | |
687 | ms = ms-(minutes*60000); | |
688 | long seconds = ms/1000; | |
689 | ||
690 | ||
691 | long expToLvl = skills.getExpToNextLevel(skills.getIndex("fishing")); | |
692 | long time2Lvl = 0; | |
693 | long time2LvlHrs = 0; | |
694 | long time2LvlMins = 0; | |
695 | long time2LvlSec = 0; | |
696 | if(ms2!=0&&expGained!=0){ | |
697 | time2Lvl = (long)(expToLvl/(expGained/(ms2/3600000))*3600000); | |
698 | time2LvlHrs = time2Lvl/3600000; | |
699 | time2Lvl -= time2LvlHrs*3600000; | |
700 | time2LvlMins = time2Lvl/60000; | |
701 | time2Lvl -= time2LvlMins*60000; | |
702 | time2LvlSec = time2Lvl/1000; | |
703 | } | |
704 | if(fancyPaint) | |
705 | { | |
706 | if(showPaint){ | |
707 | onRepaint2(g,true); | |
708 | ||
709 | //Text Color and Output | |
710 | g.setColor(new Color(0,0,0,255)); | |
711 | g.setFont(new Font("Comic Sans MS", Font.PLAIN, 12)); | |
712 | g.drawString(" "+version,450,360); | |
713 | g.setFont(new Font("Comic Sans MS", Font.PLAIN, 11)); | |
714 | if(lvlsGaineds==0&&lvlsGaineda==0) | |
715 | g.drawString("Fishing levels Gained: "+lvlsGainedf,16,40); | |
716 | else if(lvlsGaineds==0) | |
717 | g.drawString("Levels Gained: "+lvlsGainedf+"f "+lvlsGaineda+"a",16,40); | |
718 | else if(lvlsGaineda==0) | |
719 | g.drawString("Levels Gained: "+lvlsGainedf+"f "+lvlsGaineds+"s",16,40); | |
720 | else | |
721 | g.drawString("Levels Gained: "+lvlsGainedf+"f "+lvlsGaineda+"a "+lvlsGaineds+"s",16,40); | |
722 | g.drawString("Fish Caught: "+(amntLTrout+amntLSalmon+amntLSturgeon),415,22); | |
723 | g.drawString("Fish Exp Gained: "+expGained,16,55); | |
724 | g.drawString("Time Running: "+hours+":"+minutes+":"+seconds,16,97); | |
725 | ||
726 | //Determine Length: | |
727 | double difference = skills.XP_TABLE[skills.getCurrentLevel(skills.getIndex("fishing"))+1]-skills.XP_TABLE[skills.getCurrentLevel(skills.getIndex("fishing"))]; | |
728 | double barLength = ((difference-expToLvl)/difference)*512; | |
729 | ||
730 | //Progress Bar | |
731 | g.setColor(new Color(255,0,0,255)); | |
732 | g.fillRoundRect(4,320,512,18,8,8); //Bar background | |
733 | g.setColor(new Color(51,153,0,255)); //GREEN | |
734 | g.fillRoundRect(4,320,(int)barLength,18,4,4); | |
735 | g.setColor(new Color(0,0,0,255)); | |
736 | int fishToLvl =0; | |
737 | if(amntLTrout+amntLSalmon+amntLSturgeon!=0) | |
738 | fishToLvl = (int)(expToLvl/(expGained/(amntLTrout+amntLSalmon+amntLSturgeon))); | |
739 | g.drawString(skills.getPercentToNextLevel(skills.getIndex("fishing"))+"% to: "+(skills.getCurrentLevel(skills.getIndex("fishing"))+1)+" ("+expToLvl+" exp / "+fishToLvl+" fish)",215,334); | |
740 | g.setColor(new Color(255,255,255,100)); | |
741 | g.fillRoundRect(4,320,512,9,4,4); | |
742 | ||
743 | ||
744 | if(ms2!=0) | |
745 | g.setColor(new Color(0,0,0,255)); | |
746 | g.drawString("Fish Exp/Hr: "+(int)(expGained/(ms2/3600000)),16,69); | |
747 | g.drawString("Status: "+status,11,22); | |
748 | ||
749 | if(type.equals("Bank Caviar")) | |
750 | { | |
751 | g.drawString("Profit: "+(amntCaviar*GEPRICES[3])+" ("+amntCaviar+" caviar)",149,22); | |
752 | if(ms2!=0) | |
753 | g.drawString("Profit/Hr: "+(int)((amntCaviar*GEPRICES[3])/(ms2/3600000)),293,22); | |
754 | } | |
755 | else if(type.equals("Bank Fish")) | |
756 | { | |
757 | g.drawString("Profit: "+(amntLTrout*GEPRICES[0]+amntLSalmon*GEPRICES[1]+amntLSturgeon*GEPRICES[2]),149,22); | |
758 | if(ms2!=0) | |
759 | g.drawString("Profit/Hr: "+(int)((amntLTrout*GEPRICES[0]+amntLSalmon*GEPRICES[1]+amntLSturgeon*GEPRICES[2])/(ms2/3600000)),293,22); | |
760 | } | |
761 | g.drawString("Est. Time to Lvl: "+time2LvlHrs+":"+time2LvlMins+":"+time2LvlSec,16,83); | |
762 | //Mouse Stuff | |
763 | Point tempPoint = mouse.getLocation(); | |
764 | int tempXCoordinate = (int)tempPoint.getX(); | |
765 | int tempYCoordinate = (int)tempPoint.getY(); | |
766 | g.setColor(new Color(51,153,0,255)); | |
767 | g.drawLine(tempXCoordinate,0,tempXCoordinate,501); | |
768 | g.drawLine(0,tempYCoordinate,764,tempYCoordinate); | |
769 | g.fillRect(tempXCoordinate-1,tempYCoordinate-1,3,3); | |
770 | } | |
771 | else | |
772 | { | |
773 | g.setColor(new Color(51,153,0,255)); | |
774 | g.fillRect(448,459,(512-448),(472-459)); | |
775 | g.setColor(new Color(0,0,0,255)); | |
776 | g.drawRect(448,459,(512-448),(472-459)); | |
777 | g.drawString("Hide/Show",450,470); | |
778 | } | |
779 | ||
780 | } | |
781 | else | |
782 | { | |
783 | if(showPaint){ | |
784 | onRepaint2(g,false); | |
785 | //Background | |
786 | g.setColor(new Color(0, 0, 0, 205)); | |
787 | g.fillRoundRect(333, 175, 181, 194, 6, 6); //Background | |
788 | //Text Color and Output | |
789 | g.setColor(new Color(255,0,0,255)); | |
790 | g.setFont(new Font("Comic Sans MS", Font.PLAIN, 12)); | |
791 | g.drawString("C's Leaping Fisher "+version,338,192); | |
792 | g.setFont(new Font("Comic Sans MS", Font.PLAIN, 11)); | |
793 | if(lvlsGaineds==0&&lvlsGaineda==0) | |
794 | g.drawString("Fishing levels Gained: "+lvlsGainedf,344,207); | |
795 | else if(lvlsGaineds==0) | |
796 | g.drawString("Levels Gained: "+lvlsGainedf+"f "+lvlsGaineda+"a",344,207); | |
797 | else if(lvlsGaineda==0) | |
798 | g.drawString("Levels Gained: "+lvlsGainedf+"f "+lvlsGaineds+"s",344,207); | |
799 | else | |
800 | g.drawString("Levels Gained: "+lvlsGainedf+"f "+lvlsGaineda+"a "+lvlsGaineds+"s",344,207); | |
801 | g.drawString("Fish Caught: "+(amntLTrout+amntLSalmon+amntLSturgeon),344,222); | |
802 | g.drawString("Fish Exp Gained: "+expGained,344,237); | |
803 | g.drawString("Time Running: "+hours+":"+minutes+":"+seconds,344, 252); | |
804 | ||
805 | //Progress Bar | |
806 | g.fillRoundRect(344,256,150,20,8,8); //Bar background | |
807 | g.setColor(new Color(0,255,0,255)); //GREEN | |
808 | g.fillRoundRect(344,256,(int)(skills.getPercentToNextLevel(skills.getIndex("fishing"))*1.5),20,8,8); | |
809 | g.setColor(new Color(0,0,0,255)); | |
810 | g.setColor(new Color(255,255,255,100)); | |
811 | g.drawString(skills.getPercentToNextLevel(skills.getIndex("fishing"))+"% to: "+(skills.getCurrentLevel(skills.getIndex("fishing"))+1)+" ("+expToLvl+" exp)",348,271); | |
812 | g.fillRoundRect(345,266,148,10,8,8); | |
813 | g.setColor(new Color(0,0,0,255)); | |
814 | g.drawString(skills.getPercentToNextLevel(skills.getIndex("fishing"))+"% to: "+(skills.getCurrentLevel(skills.getIndex("fishing"))+1)+" ("+expToLvl+" exp)",347,270); | |
815 | g.setColor(new Color(255,0,0,255)); | |
816 | if(ms2!=0) | |
817 | g.drawString("Fish Exp/Hr: "+(int)(expGained/(ms2/3600000)),344,289); | |
818 | g.drawString("Status: "+status,344,304); | |
819 | if(expGained!=0&&amntLTrout+amntLSalmon+amntLSturgeon!=0) | |
820 | g.drawString("Fish to Lvl: "+(int)(expToLvl/(expGained/(amntLTrout+amntLSalmon+amntLSturgeon))),344,319); | |
821 | g.drawString("Est. Time to Lvl: "+time2LvlHrs+":"+time2LvlMins+":"+time2LvlSec,344,334); | |
822 | g.drawString("Profit: "+(amntCaviar*GEPRICES[3])+" ("+amntCaviar+" caviar)",344,349); | |
823 | if(ms2!=0) | |
824 | g.drawString("Profit/Hr: "+(int)((amntCaviar*GEPRICES[3])/(ms2/3600000)),344,364); | |
825 | //Mouse Stuff | |
826 | Point tempPoint = mouse.getLocation(); | |
827 | int tempXCoordinate = (int)tempPoint.getX(); | |
828 | int tempYCoordinate = (int)tempPoint.getY(); | |
829 | g.setColor(new Color(0,255,0,100)); | |
830 | g.drawLine(tempXCoordinate,0,tempXCoordinate,501); | |
831 | g.drawLine(0,tempYCoordinate,764,tempYCoordinate); | |
832 | ||
833 | } | |
834 | else | |
835 | { | |
836 | g.setColor(new Color(51,153,0,255)); | |
837 | g.fillRect(448,459,(512-448),(472-459)); | |
838 | g.setColor(new Color(0,0,0,255)); | |
839 | g.drawRect(448,459,(512-448),(472-459)); | |
840 | g.drawString("Hide/Show",450,470); | |
841 | } | |
842 | } | |
843 | }catch (Exception e){}; | |
844 | } | |
845 | } | |
846 | private Image getImage(String url) { | |
847 | try { | |
848 | return ImageIO.read(new URL(url)); | |
849 | } catch(IOException e) { | |
850 | return null; | |
851 | } | |
852 | } | |
853 | private final Color color1 = new Color(1, 1, 1); | |
854 | private final Font font1 = new Font("Arial", 0, 12); | |
855 | public void onRepaint2(Graphics g1 , boolean fancy) { | |
856 | Graphics2D g = (Graphics2D)g1; | |
857 | if(fancy){ | |
858 | g.drawImage(img2, 5, 6, null); | |
859 | g.drawImage(img4, 5, 29, null); | |
860 | } | |
861 | g.setColor(new Color(51,153,0,255)); | |
862 | g.fillRect(448,459,(512-448),(472-459)); | |
863 | g.fillRect(398,459,(448-398),(472-459)); | |
864 | g.setColor(new Color(0,0,0,255)); | |
865 | g.drawRect(448,459,(512-448),(472-459)); | |
866 | g.drawRect(398,459,(448-398),(472-459)); | |
867 | g.drawString("Hide/Show",450,470); | |
868 | if(fancy) | |
869 | g.drawString("Simple",405,470); | |
870 | else | |
871 | g.drawString("Adv.",415,470); | |
872 | } | |
873 | public void onFinish() { | |
874 | log("Exp gained: "+expGained); | |
875 | log("Fishing levels gained: "+lvlsGainedf); | |
876 | log("Agility levels gained: "+lvlsGaineda); | |
877 | log("Strength levels gained: "+lvlsGaineds); | |
878 | log("Thanks for using Conderoga's Leaping Fisher!"); | |
879 | env.saveScreenshot(true); | |
880 | } | |
881 | public class CLeapGUI extends JFrame { | |
882 | private static final long serialVersionUID = 1L; | |
883 | public CLeapGUI() | |
884 | { | |
885 | initComponents(); | |
886 | } | |
887 | ||
888 | private void button2ActionPerformed(ActionEvent e) | |
889 | { | |
890 | guiWait = false; | |
891 | guiExit = true; | |
892 | dispose(); | |
893 | } | |
894 | ||
895 | private void button1ActionPerformed(ActionEvent e) | |
896 | { | |
897 | type = comboBox1.getSelectedItem().toString(); | |
898 | guiExit = false; | |
899 | guiWait = false; | |
900 | dispose(); | |
901 | } | |
902 | ||
903 | private void initComponents() { | |
904 | label1 = new JLabel(); | |
905 | label2 = new JLabel(); | |
906 | label3 = new JLabel(); | |
907 | button1 = new JButton(); | |
908 | button2 = new JButton(); | |
909 | comboBox1 = new JComboBox(); | |
910 | ||
911 | setTitle("Conderoga's Leaping Fisher"); | |
912 | setResizable(false); | |
913 | setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); | |
914 | Container contentPane = getContentPane(); | |
915 | contentPane.setLayout(null); | |
916 | ||
917 | //---- label1 ---- | |
918 | label1.setText("Conderoga's Leaping Fisher Settings"); | |
919 | label1.setFont(new Font("Comic Sans MS", Font.PLAIN, 16)); | |
920 | contentPane.add(label1); | |
921 | label1.setBounds(10, -10, 380, 70); | |
922 | ||
923 | //---- label2 ---- | |
924 | label2.setText("Select the Action: "); | |
925 | contentPane.add(label2); | |
926 | label2.setBounds(new Rectangle(new Point(15, 50), label2.getPreferredSize())); | |
927 | ||
928 | //---- comboBox1 ---- | |
929 | comboBox1.setMaximumRowCount(3); | |
930 | comboBox1.setModel(new DefaultComboBoxModel(new String[] { | |
931 | "Bank Caviar", | |
932 | "Bank Fish", | |
933 | "PowerFish" | |
934 | ||
935 | ||
936 | })); | |
937 | contentPane.add(comboBox1); | |
938 | comboBox1.setBounds(175, 45, 125, 25); | |
939 | //---- label3 ---- | |
940 | label3.setText(version); | |
941 | contentPane.add(label3); | |
942 | label3.setBounds(15, 80, 124, label3.getPreferredSize().height); | |
943 | ||
944 | //---- button1 ---- | |
945 | button1.setText("Start!"); | |
946 | button1.addActionListener(new ActionListener() { | |
947 | public void actionPerformed(ActionEvent e) { | |
948 | button1ActionPerformed(e); | |
949 | } | |
950 | }); | |
951 | contentPane.add(button1); | |
952 | button1.setBounds(40, 115, 75, 30); | |
953 | ||
954 | //---- button2 ---- | |
955 | button2.setText("Exit"); | |
956 | button2.addActionListener(new ActionListener() { | |
957 | public void actionPerformed(ActionEvent e) { | |
958 | button2ActionPerformed(e); | |
959 | } | |
960 | }); | |
961 | contentPane.add(button2); | |
962 | button2.setBounds(200, 115, 75, 30); | |
963 | ||
964 | { // compute preferred size | |
965 | Dimension preferredSize = new Dimension(); | |
966 | for(int i = 0; i < contentPane.getComponentCount(); i++) | |
967 | { | |
968 | Rectangle bounds = contentPane.getComponent(i).getBounds(); | |
969 | preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width); | |
970 | preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height); | |
971 | } | |
972 | Insets insets = contentPane.getInsets(); | |
973 | preferredSize.width += insets.right; | |
974 | preferredSize.height += insets.bottom; | |
975 | contentPane.setMinimumSize(preferredSize); | |
976 | contentPane.setPreferredSize(preferredSize); | |
977 | } | |
978 | setSize(325, 190); | |
979 | setLocationRelativeTo(getOwner()); | |
980 | } | |
981 | private JLabel label1; | |
982 | private JLabel label2; | |
983 | private JComboBox comboBox1; | |
984 | private JLabel label3; | |
985 | private JButton button1; | |
986 | private JButton button2; | |
987 | } | |
988 | } |