View difference between Paste ID: j4PJWXJi 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 = "Mining", name = "Conderoga's Cavern Miner", version = 1.01,description = "Mines and banks gold and coal in the LRC.")
22
/*UpdateLog:
23
   v1.00 - initial release
24
   v1.01 - Fixed logout bug and deathwalking bugs
25
26
 */
27
28
public class CCMine extends Script implements PaintListener, ServerMessageListener, MouseListener{
29
	//GUI stuff
30
	private String version = "1.01";
31
	public CCMineGUI gui;
32
	private boolean guiWait = true;
33
	private boolean guiExit = true;
34
	private String rockType;
35
	private boolean quickDeposit = false;
36
	private boolean evade = false;
37
	private boolean fastBank = false;
38
39
	//IDS and such
40
	private int bankID = 45079;
41
	private int goldID = 444;
42
	private int coalID = 453;
43
	private int rockPrice = 1;
44
	private int [] picks = {1265,1267,1269,1271,1273,1275,15259};
45
	private int closedCoalRock = 5990;
46
	private int closedGoldRock = 45075;
47
	private int openGoldRock = 45076;
48
	private int openCoalRock = 5999;
49
	private int openID;
50
	private int closedID;
51
	private RSTile bankTile = new RSTile(3653,5113);
52
	private RSTile [][] bankToRocks;
53
	private RSTile [][] rocksToBank;
54
	private RSTile [][] rocksToRocks;
55
	private boolean isDead = false;
56
57
	//Timers Stuff
58
	private RSTile [] rocks;
59
	private boolean [] rockStatus = new boolean [3];
60
	private long [] rockTimeDead = new long [3];
61
	private long [] rockDeadTime = new long [3];
62
	private long [] rockTimeAlive = new long [3];
63
	private long [] rockAliveTime = new long [3];
64
	private int nextRock = 0;
65
	int safety = 0;
66
67
68
	//Paint Stuff
69
	private String status = "";
70
	private int numGold;
71
	private int numCoal;
72
	private boolean full = false;
73
	private int startLevel;
74
	private int startExp;
75
	private int expGained;
76
	private int lvlsGained;
77
	private long startTime;
78
	private double startTimeDbl;
79
	private long ExpHr;
80
	private Point [] rockPoints;
81
	private final Image img1 = getImage("http://www.conderogascripts.99k.org/CCMine.png");
82
	private final Image img2 = getImage("http://i263.photobucket.com/albums/ii158/zpogo/Bar.png");
83
	private final Image img4 = getImage("http://i263.photobucket.com/albums/ii158/zpogo/EXPback-1copy.png");
84
	private boolean showPaint = true;
85
	private boolean fancyPaint = true;
86
	private Point p;
87
	private Color mouseColor = Color.RED;
88
89
90
 	public boolean onStart() {
91
      startTime = System.currentTimeMillis();
92
      startTimeDbl = System.currentTimeMillis();
93
      //Credits to Zombieknight for this:-----------------
94
      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);
95
	  if (welcome == 0) {
96
		final String message = "<html>Thank you for your support!<br /></html>";
97
		JOptionPane.showMessageDialog(null, message);
98
		openURL("http://adf.ly/AgSn");
99
		}
100
	//=------------------------------------------------------*/
101
102
      gui = new CCMineGUI();
103
      gui.setVisible(true);
104
      while(guiWait)
105
      {
106
        sleep(100);
107
      }
108
      return !guiExit;
109
    }
110
111
 	public void setUp(){
112
 		status = "Setting Up";
113
 		if(rockType.equals("Gold")){
114
 			openID = openGoldRock;
115
 			closedID = closedGoldRock;
116
 			status = "Looking up Prices";
117
 			rockPrice = getGEValue("Gold ore",goldID);
118
 			log("Gold ore price: "+rockPrice);
119
120
 			rocks = new RSTile [2];
121
 			rocks[0] = new RSTile(3668,5076);
122
 			rocks[1] = new RSTile(3638,5095);
123
124
125
 			bankToRocks = new RSTile[2][];
126
 			rocksToBank = new RSTile[2][];
127
 			rocksToRocks = new RSTile [1][];
128
			RSTile [] bankToRock1 = {new RSTile(3654,5114),new RSTile(3658,5101),new RSTile(3662,5090),new RSTile(3666,5080),new RSTile(3669,5077),new RSTile(3669,5075)};
129
 			bankToRocks[0] = bankToRock1;
130
 			rocksToBank[0] = walking.reversePath(bankToRock1);
131
 			RSTile [] bankToRock2 = {new RSTile(3654,5114),new RSTile(3657,5105),new RSTile(3651,5096),new RSTile(3639,5096)};
132
 			bankToRocks[1] = bankToRock2;
133
 			rocksToBank[1] = walking.reversePath(bankToRock2);
134
 			RSTile [] rock2ToRock1 = {new RSTile(3639,5094),new RSTile(3648,5092),new RSTile(3658,5088),new RSTile(3666,5082),new RSTile(3669,5077)};
135
 			rocksToRocks[0] = rock2ToRock1;
136
 			rockPoints = new Point [2];
137
 		}
138
 		if(rockType.equals("Coal")){
139
 			openID = openCoalRock;
140
 			closedID = closedCoalRock;
141
 			status = "Looking up Prices";
142
 			rockPrice = getGEValue("Coal",coalID);
143
 			log("Coal price: "+rockPrice);
144
145
 			rocks = new RSTile[3];
146
 			rocks[0] = new RSTile(3665,5091);
147
 			rocks[1] = new RSTile(3675,5099);
148
 			rocks[2] = new RSTile(3688,5108);
149
 			rockPoints = new Point [3];
150
151
 			bankToRocks = new RSTile[3][];
152
 			rocksToBank = new RSTile[3][];
153
 			rocksToRocks = new RSTile[3][];
154
155
 			RSTile[] bankToRock1 ={new RSTile(3654,5114),new RSTile(3660,5104),new RSTile(3661,5095),new RSTile(3665,5092)};
156
 			RSTile[] bankToRock2 ={new RSTile(3654,5114),new RSTile(3660,5114),new RSTile(3667,5111),new RSTile(3673,5104),new RSTile(5674,5101)};
157
 			RSTile[] bankToRock3 ={new RSTile(3654,5114),new RSTile(3662,5114),new RSTile(3671,5112),new RSTile(3678,5107),new RSTile(3686,5108),new RSTile(3689,5106)};
158
159
 			bankToRocks[0] = bankToRock1;
160
 			bankToRocks[1] = bankToRock2;
161
 			bankToRocks[2] = bankToRock3;
162
163
 			rocksToBank[0] = walking.reversePath(bankToRock1);
164
 			rocksToBank[1] = walking.reversePath(bankToRock2);
165
 			rocksToBank[2] = walking.reversePath(bankToRock3);
166
167
 			RSTile [] rock1ToRock2 = {new RSTile(3665,5092),new RSTile(3670,5095),new RSTile(3673,5098)};
168
 			RSTile [] rock1ToRock3 = {new RSTile(3665,5092),new RSTile(3670,5097),new RSTile(3675,5102),new RSTile(3680,5105),new RSTile(3686,5108),new RSTile(3689,5106)};
169
 			RSTile [] rock2ToRock3 = {new RSTile(3673,5098),new RSTile(3675,5102),new RSTile(3680,5105),new RSTile(3686,5108),new RSTile(3689,5106)};
170
171
			rocksToRocks[0] = rock1ToRock2;
172
			rocksToRocks[1] = rock1ToRock3;
173
			rocksToRocks[2] = rock2ToRock3;
174
 		}
175
176
 	}
177
 	public boolean mineCheck(){
178
  for(int i = 0; i<5;i++){
179
   if(players.getMyPlayer().getAnimation()==12189||players.getMyPlayer().getAnimation()==6746||players.getMyPlayer().getAnimation()==6750||players.getMyPlayer().getAnimation()==6751||players.getMyPlayer().getAnimation()==6749||players.getMyPlayer().getAnimation()==6748||players.getMyPlayer().getAnimation()==6747)
180
   {status = "Mining!";
181
    return true;}
182
    sleep(random(200,300));
183
     }
184
     status = "Not mining.";
185
 return false;
186
 }
187
 	public void updateStatus()
188
 {
189
 	antiBan(random(1,100));
190
 	if(evade){
191
 	if(getMyPlayer().isInCombat())
192
 		status = "Evading combat.";
193
 	}
194
 	else{
195
 	if(getMyPlayer().isInCombat())
196
 		status = "Being attacked.";
197
 	}
198
 	if(evade&&status.equals("Evading combat."))
199
 	{
200
 	}
201
 	else{
202
 	boolean temp = mineCheck();
203
 	boolean temp2 = false;
204
 	for(int i = 0; i<rockStatus.length;i++){
205
 		if(rockStatus[i])
206
 			temp2 = true;
207
 	}
208
 	if(!temp&&!temp2)
209
 	{
210
 		status = "Waiting.";
211
 	}
212
 	}
213
 }
214
	public int floorHeight(){
215
		int y = (int)getMyPlayer().getLocation().getY();
216
		if(y<3400)
217
			return 0;
218
		else if( y< 9000 && y>4000)
219
			return -2;
220
		else
221
			return -1;
222
	}
223
 	public void walkToMine(){
224
 		sleep(random(1000,2000));
225
 		int floor = floorHeight();
226
 		if(floor==-2){
227
 			status = "Resuming.";
228
 			if(playerIsNear(new RSTile(3654,5114),5))
229
 				isDead = false;
230
 			else
231
 				walking.walkTileMM(new RSTile(3654,5114));
232
 			sleep(random(600,800));
233
234
 			updateStatus();
235
 		}
236
 		if(floor==-1){
237
 			RSTile [] path = {new RSTile(3058, 9776), new RSTile(3049, 9780),new RSTile(3043, 9787),new RSTile(3042, 9796),new RSTile(3040, 9804),new RSTile(3041, 9814),new RSTile(3040, 9822),new RSTile(3035, 9833),new RSTile(3025, 9828),new RSTile(3017, 9831),new RSTile(3012, 9832)};
238
 			long startTime = System.currentTimeMillis();
239
 			status = "Walking cave.";
240
 			camera.setPitch(true);
241
 			int lastTileToWalkTo = -1;
242
 			int tempTileToWalkTo = 0;
243
 			boolean clickedLastTile = false;
244
245
 			while(!playerIsNear(new RSTile(3012, 9832),5)&&System.currentTimeMillis()-startTime<20000)
246
 			{
247
 			if(!walking.isRunEnabled()&&walking.getEnergy()>20){
248
 	 	 		walking.setRun(true);
249
 	 	 		sleep(random(600,800));
250
 	 	 		}
251
252
 			if(!getMyPlayer().isMoving()){
253
 				sleep(random(600,800));
254
 			if(!getMyPlayer().isMoving())
255
 				lastTileToWalkTo=-1;
256
 			}
257
 			boolean clicked = false;
258
       		tempTileToWalkTo = walkPath(path);
259
       		if(tempTileToWalkTo>lastTileToWalkTo){
260
       				if(walking.walkTileMM(path[tempTileToWalkTo],1,1))
261
       						clicked = true;
262
       				sleep(random(400,500));
263
       				if(getMyPlayer().isMoving())
264
       					clicked = true;
265
       		}
266
       		if(clicked){
267
       			lastTileToWalkTo = tempTileToWalkTo;
268
       		}
269
       		sleep(random(200, 300));
270
 			}
271
 			if(playerIsNear(new RSTile(3012, 9832),5))
272
 			{
273
 				status = "Going down rope.";
274
 				RSObject o=null;
275
 				RSObject [] test = objects.getAllAt(new RSTile(3012,9831));
276
 				for(RSObject oa : test){
277
 					if(oa.getID()==45077)
278
 						o = oa;
279
 				}
280
 				if(o!=null){
281
 					while(getMyPlayer().isMoving())
282
 						sleep(random(100,200));
283
 					RSModel m = o.getModel();
284
 					Point p = m.getPoint();
285
 					mouse.move(p);
286
 					sleep(600,800);
287
 					menu.doAction("Climb Rope");
288
 				}
289
 			}
290
 			walkToMine();
291
 		}
292
 		if(floor==0){
293
 			RSItem [] inv = inventory.getItems();
294
 			if(inventory.getCount()>0){
295
 			status = "Equipping items.";
296
 			for(int i = 0; i<3;i++){
297
 				if(inv[i].getID()!=coalID&&inv[i].getID()!=goldID)
298
 					if(!inv[i].doAction("Wield"))
299
 						if(!inv[i].doAction("Wear"))
300
 							inv[i].doAction("Equip");
301
302
 			}
303
 			}
304
 			RSTile [] Fpath = {new RSTile(2970, 3339),new RSTile(2964, 3349),new RSTile(2965, 3360),new RSTile(2965, 3370),new RSTile(2968, 3377),new RSTile(2977, 3377),new RSTile(2983, 3373),new RSTile(2991, 3370),new RSTile(3000, 3363),new RSTile(3008, 3363),new RSTile(3020, 3362),new RSTile(3029, 3366),new RSTile(3036, 3369),new RSTile(3044, 3369),new RSTile(3054, 3369),new RSTile(3061, 3374)};
305
 			RSTile [] Lpath = {new RSTile(3220,3219),new RSTile(3218,3210),new RSTile(3209,3205),new RSTile(3203,3205),new RSTile(3198,3218),new RSTile(3183,3221),new RSTile(3175,3228),new RSTile(3166,3231),new RSTile(3151,3233),new RSTile(3138,3228),new RSTile(3126,3225),new RSTile(3112,3229),new RSTile(3099,3235),new RSTile(3090,3237),new RSTile(3081,3241),new RSTile(3072,3249),new RSTile(3071,3261),new RSTile(3067,3276),new RSTile(3054,3276),new RSTile(3041,3276),new RSTile(3027,3277),new RSTile(3016,3278),new RSTile(3009,3279),new RSTile(3007,3292),new RSTile(3007,3306),new RSTile(3007,3315),new RSTile(3007,3329),new RSTile(3007,3343),new RSTile(3007,3354),new RSTile(3016,3362),new RSTile(3026,3366),new RSTile(3043,3370),new RSTile(3057,3371),new RSTile(3061,3374)};
306
 			RSTile [] path = new RSTile [0];
307
 			if(playerIsNear(new RSTile(2970,3339),7)){
308
 				log("You died and respawned in Falador, walking back to mine.");
309
 				path = fixPath(Fpath);
310
 			}
311
 			else if(playerIsNear(new RSTile(3220,3219),7)){
312
 				log("You died and respawned in Lumbridge, walking back to mine.");
313
 				log("This could take a while...");
314
 				path = fixPath(Lpath);
315
 			}
316
 				long startTime = System.currentTimeMillis();
317
 			status = "Walking to mine.";
318
 			camera.setPitch(true);
319
 			int lastTileToWalkTo = -1;
320
 			int tempTileToWalkTo = 0;
321
 			boolean clickedLastTile = false;
322
323
 			while(!playerIsNear(new RSTile(3061, 3374),5)&&System.currentTimeMillis()-startTime<300000)
324
 			{
325
 			if(!walking.isRunEnabled()&&walking.getEnergy()>20){
326
 	 	 		walking.setRun(true);
327
 	 	 		sleep(random(600,800));
328
 	 	 		}
329
330
 			if(!getMyPlayer().isMoving()){
331
 				sleep(random(600,800));
332
 			if(!getMyPlayer().isMoving())
333
 				lastTileToWalkTo=-1;
334
 			}
335
 			boolean clicked = false;
336
       		tempTileToWalkTo = walkPath(path);
337
       		if(tempTileToWalkTo>lastTileToWalkTo){
338
       				if(walking.walkTileMM(path[tempTileToWalkTo],1,1))
339
       						clicked = true;
340
       				sleep(random(400,500));
341
       				if(getMyPlayer().isMoving())
342
       					clicked = true;
343
       		}
344
       		if(clicked){
345
       			lastTileToWalkTo = tempTileToWalkTo;
346
       		}
347
       		sleep(random(200, 300));
348
 			}
349
 			RSObject door=null;
350
 			if(playerIsNear(new RSTile(3061, 3374),5)){
351
 				boolean doorClosed = false;
352
 				RSObject [] check = objects.getAllAt(new RSTile(3061,3374));
353
354
 				for(RSObject o : check){
355
 					if(o.getID()==11714){
356
 						doorClosed = true;
357
 						door = o;
358
 					}
359
 				}
360
 				if(doorClosed&&getMyPlayer().getLocation().getY()<3375){
361
 					while(getMyPlayer().isMoving())
362
 						sleep(random(100,200));
363
 					RSModel m = door.getModel();
364
 					Point p = m.getPoint();
365
 					mouse.move(p);
366
 					sleep(600,800);
367
 					menu.doAction("Open Door");
368
 				}
369
 			}
370
 				RSObject stairs=null;
371
 				RSObject [] check2 = objects.getAllAt(new RSTile(3060,3377));
372
 					for(RSObject j : check2){
373
 						if(j.getID()==30944)
374
 							stairs = j;
375
 					}
376
 				if(stairs!=null){
377
 					while(getMyPlayer().isMoving())
378
 						sleep(random(100,200));
379
 					RSModel m = stairs.getModel();
380
 					Point p = m.getPoint();
381
 					mouse.move(p);
382
 					sleep(600,800);
383
 					menu.doAction("Climb-down Stairs");
384
 				}
385
 			walkToMine();
386
 		}
387
 	}
388
 	public RSObject getNextRock(){
389
 		RSObject[] check = objects.getAllAt(rocks[nextRock-1]);
390
 		for(RSObject o : check)
391
 			if(o.getID()==openID||o.getID()==closedID)
392
 				return o;
393
 		return null;
394
 	}
395
 	public int nearRock(){
396
 		for(int i  =0; i<rocks.length;i++){
397
 			if(playerIsNear(rocks[i],5))
398
 				return i+1;
399
 		}
400
 		return 0;
401
 	}
402
 	public void checkRocks(){
403
	for(int r = 0; r< rocks.length;r++){
404
	RSObject[] check = objects.getAllAt(rocks[r]);
405
		for(int i = 0; i< check.length; i++)
406
		{
407
		    if(check[i].getID()==closedID&&rockStatus[r])
408
			{	rockStatus[r] = false;
409
				rockDeadTime[r] = System.currentTimeMillis();
410
				rockTimeAlive[r] = -1;
411
			}
412
			else if(check[i].getID()==openID&&!rockStatus[r])
413
			{	rockStatus[r] = true;
414
				rockAliveTime[r] = System.currentTimeMillis();
415
				rockTimeDead[r] = -1;
416
			}
417
			else if(check[i].getID()==openID)
418
			{	rockStatus[r] = true;
419
				rockTimeAlive[r] = System.currentTimeMillis()-rockAliveTime[r];}
420
			else if(check[i].getID()==closedID)
421
			{	rockStatus[r] = false;
422
				rockTimeDead[r] = System.currentTimeMillis()-rockDeadTime[r];}
423
		}
424
	}
425
}
426
 	public boolean allRocksClosed(){
427
 		boolean allClosed = true;
428
 		for(int i=0;i<rockStatus.length;i++)
429
 		{
430
 			if(rockStatus[i])
431
 				allClosed = false;
432
 		}
433
 		return allClosed;
434
 	}
435
 	public void calculateNextRock(){
436
 	if(allRocksClosed())
437
 {
438
 	long num = -2;
439
 	int index = 0;
440
 	for(int i =0; i < rockTimeDead.length; i++)
441
 	{
442
 		if(rockTimeDead[i]>=num)
443
 		{index = i;
444
 		num = rockTimeDead[i];
445
 		}
446
 	}
447
 	nextRock = index+1;
448
 }
449
 else{
450
 	long num = -2;
451
 	int index = 0;
452
 	for(int i =0; i < rockTimeAlive.length; i++)
453
 	{
454
 		if(rockTimeAlive[i]>=num)
455
 		{index = i;
456
 		num = rockTimeAlive[i];
457
 		}
458
 	}
459
 	nextRock = index+1;
460
 	}
461
 }
462
 	public void moveToNextRock(){
463
 		long start = System.currentTimeMillis();
464
 		status = "Moving to rock "+nextRock;
465
 		RSTile [] path = new RSTile[0];
466
 		if(rockType.equals("Gold")){
467
 			path = (nextRock==1) ? rocksToRocks[0] : walking.reversePath(rocksToRocks[0]);
468
 			}
469
 		else if(rockType.equals("Coal")){
470
 			boolean near1 = playerIsNear(rocks[0],4);
471
 			boolean near2 = playerIsNear(rocks[1],4);
472
 			boolean near3 = playerIsNear(rocks[2],4);
473
474
 			if(near1&&nextRock==2)
475
 				path = rocksToRocks[0];
476
 			else if(near1)
477
 				path = rocksToRocks[1];
478
 			else if(near2&&nextRock==1)
479
 				path = walking.reversePath(rocksToRocks[0]);
480
 			else if(near2)
481
 				path = rocksToRocks[2];
482
 			else if(near3&&nextRock==1)
483
 				path = walking.reversePath(rocksToRocks[1]);
484
 			else
485
 				path = walking.reversePath(rocksToRocks[2]);
486
 		}
487
488
 			path = fixPath(path);
489
 			long startTime = System.currentTimeMillis();
490
 			camera.setPitch(true);
491
 			int lastTileToWalkTo = -1;
492
 			int tempTileToWalkTo = 0;
493
 			boolean clickedLastTile = false;
494
495
 			while(!playerIsNear(path[path.length-1],5)&&System.currentTimeMillis()-startTime<20000)
496
 			{
497
 			if(!walking.isRunEnabled()&&walking.getEnergy()>20){
498
 	 	 		walking.setRun(true);
499
 	 	 		sleep(random(600,800));
500
 	 	 		}
501
502
 			if(!getMyPlayer().isMoving()){
503
 				sleep(random(600,800));
504
 			if(!getMyPlayer().isMoving())
505
 				lastTileToWalkTo=-1;
506
 			}
507
 			boolean clicked = false;
508
       		tempTileToWalkTo = walkPath(path);
509
       		if(tempTileToWalkTo>lastTileToWalkTo){
510
       				if(walking.walkTileMM(path[tempTileToWalkTo],1,1))
511
       						clicked = true;
512
       				sleep(random(400,500));
513
       				if(getMyPlayer().isMoving())
514
       					clicked = true;
515
       		}
516
       		if(clicked){
517
       			lastTileToWalkTo = tempTileToWalkTo;
518
       		}
519
       		sleep(random(200, 300));
520
 			}
521
522
 		}
523
 	public void mine(boolean secondTry){
524
	safety = 1;
525
	RSObject rockToMine = getNextRock();
526
	if(rockToMine!=null){
527
	RSModel m = rockToMine.getModel();
528
529
	if(m!=null){
530
   	Point temp = m.getPoint();
531
    mouse.move(temp);
532
   	if(menu.doAction("Mine Mineral deposit")){
533
534
535
    sleep(random(600,800));
536
   	while (players.getMyPlayer().isMoving()) {
537
						sleep(random(100, 200));
538
	}
539
	if(!mineCheck()&&!secondTry)
540
		mine(true);
541
 	}
542
   	else if(!secondTry){
543
   		mine(true);
544
   	}
545
	}
546
	}
547
}
548
	public void hoverMouse(){
549
		if(calc.tileOnScreen(rocks[nextRock-1])){
550
		Point temp = calc.tileToScreen(rocks[nextRock-1]);
551
		try{
552
		if(temp.getY()-10>1)
553
		mouse.move(new Point((int)temp.getX(),(int)temp.getY()-10),1,1);
554
		else
555
		mouse.move(new Point((int)temp.getX(),(int)temp.getY()),1,1);
556
		}catch(Exception e){};
557
		}
558
	}
559
 	public void walkToBank(){
560
 	long startTime = System.currentTimeMillis();
561
 	status = "Walking to bank.";
562
 	mouse.setSpeed(random(5,8));
563
 	if(random(1,3)==2)
564
 	camera.setPitch(true);
565
 	int lastTileToWalkTo = -1;
566
 	int tempTileToWalkTo = 0;
567
 	boolean clickedLastTile = false;
568
 	RSTile [] path = new RSTile [0];
569
570
	if(playerIsNear(rocks[0],5))
571
 		path = rocksToBank[0];
572
 	else if(playerIsNear(rocks[1],5))
573
 		path = rocksToBank[1];
574
 	else if(rocks.length>2&&playerIsNear(rocks[2],5))
575
 		path = rocksToBank[2];
576
 	else
577
 		path = rocksToBank[0];
578
579
580
	path = fixPath(path);
581
 	while(!playerIsNear(bankTile,6)&&System.currentTimeMillis()-startTime<20000)
582
 	{
583
 		if(!walking.isRunEnabled()&&walking.getEnergy()>20){
584
 	 	 	walking.setRun(true);
585
 	 	 	sleep(random(600,800));
586
 	 	 	}
587
 	status = "Walking to bank..";
588
589
 		if(!getMyPlayer().isMoving()){
590
 			sleep(random(600,800));
591
 			if(!getMyPlayer().isMoving())
592
 				lastTileToWalkTo=-1;
593
 		}
594
 			boolean clicked = false;
595
       		tempTileToWalkTo = walkPath(path);
596
       		if(tempTileToWalkTo>lastTileToWalkTo){
597
       				if(walking.walkTileMM(path[tempTileToWalkTo],1,1))
598
       						clicked = true;
599
       				sleep(random(400,500));
600
       				if(getMyPlayer().isMoving())
601
       					clicked = true;
602
       		}
603
       		if(clicked){
604
       			lastTileToWalkTo = tempTileToWalkTo;
605
       		}
606
       		sleep(random(200, 300));
607
 	}
608
 	}
609
	public boolean compareTiles(RSTile t1, RSTile t2){
610
		if(t1==null||t2==null)
611
			return false;
612
		return t1.getX()==t2.getX()&&t1.getY()==t2.getY();
613
	}
614
	public int walkPath(RSTile [] path){
615
  		int temp = 0;
616
  		boolean nearSomething = false;
617
  		for(int i = 0; i<path.length;i++)
618
  		{
619
  			if(playerIsNear(path[i],5))
620
  			{
621
  			nearSomething = true;
622
  			temp = i+1;
623
  			antiBan(random(1,200));
624
  			for(int j = i; j<path.length; j++)
625
  			{
626
  				if(calc.tileToMinimap(path[j]).x<0)
627
  				{
628
  					temp=j-1;
629
  					break;
630
  				}
631
  				if(j==path.length-1&&calc.tileToMinimap(path[j]).x>0)
632
  				{
633
  					temp=j;
634
  					break;
635
  				}
636
  			}
637
  			return temp;
638
  			}
639
  		}
640
  		if(!nearSomething){
641
  			RSTile tempTileToCompare = walking.nextTile(path);
642
  			for(int i = 0; i<path.length;i++)
643
  			{
644
  				if(compareTiles(path[i],tempTileToCompare))
645
  					return i;
646
  			}
647
648
  		}
649
  		return 0;
650
  	}
651
 	public void bank(){
652
 		while(getMyPlayer().isMoving())
653
 			sleep(random(100,200));
654
 			mouse.setSpeed(random(7,8));
655
 			boolean tryAgain = true;
656
 			while(inventory.isFull()){
657
 				tryAgain = true;
658
 					while(tryAgain) {
659
 						status = "Opening bank.";
660
 						RSObject [] test = objects.getAllAt(bankTile);
661
 						RSObject bankBox = null;
662
 						for(int i = 0; i<test.length;i++)
663
 							if(test[i].getID()==bankID)
664
 								bankBox = test[i];
665
 						RSModel m = bankBox.getModel();
666
 						Point p = m.getPoint();
667
 						mouse.move(p,1,1);
668
 						if(menu.doAction("Deposit Pulley lift"))
669
 							tryAgain = false;
670
 					}
671
 				sleep(random(1500,2000));
672
 	status = "Depositing.";
673
 	sleep(random(600,800));
674
  	if(!quickDeposit)
675
  	bank.depositAllExcept(picks);
676
  	else
677
  	bank.depositAll();
678
	sleep(random(600,800));
679
  	bank.close();
680
 	}
681
  	if(fastBank){
682
  		walkToRocks();
683
  	}
684
 }
685
 	public void walkToRocks(){
686
 		long startTime = System.currentTimeMillis();
687
 		status = "Walking to rocks.";
688
 		int lastTileToWalkTo = -1;
689
 		mouse.setSpeed(random(5,8));
690
691
 		RSTile [] path;
692
 		if(nextRock==3)
693
 			path = bankToRocks[2];
694
 		else if(nextRock==2)
695
 			path = bankToRocks[1];
696
 		else
697
 			path = bankToRocks[0];
698
699
		path = fixPath(path);
700
 		int tempTileToWalkTo = walkPath(path);
701
 		boolean clickedLastTile = false;
702
703
704
 		while(!playerIsNear(rocks[nextRock-1],5)&&System.currentTimeMillis()-startTime<20000){
705
 			if(!walking.isRunEnabled()&&walking.getEnergy()>20){
706
 		 	 	walking.setRun(true);
707
 		 	 	sleep(random(600,800));
708
 		 	 	}
709
 			status = "Walking to rocks.";
710
711
 			if(!getMyPlayer().isMoving()){
712
 				sleep(random(600,800));
713
 				if(!getMyPlayer().isMoving())
714
 						lastTileToWalkTo=-1;
715
 			}
716
 			boolean clicked = false;
717
 			tempTileToWalkTo = walkPath(path);
718
 			if(tempTileToWalkTo>lastTileToWalkTo){
719
 				if(walking.walkTileMM(path[tempTileToWalkTo],1,1))
720
 					clicked = true;
721
 				sleep(random(400,500));
722
   				if(getMyPlayer().isMoving())
723
   					clicked = true;
724
 				}
725
 			if(clicked){
726
 				lastTileToWalkTo = tempTileToWalkTo;
727
 			}
728
 			sleep(random(200, 300));
729
		}
730
 	}
731
 	public void doBank(int num)
732
{	if(num==0)
733
	{
734
	walkToBank();
735
	sleep(random(600,800));
736
	}
737
	bank();
738
	sleep(random(600,800));
739
	walkToRocks();
740
	sleep(random(600,800));
741
}
742
 	public void serverMessageRecieved(final ServerMessageEvent a){
743
    final String serverString = a.getMessage();
744
    if (serverString.toLowerCase().contains("dead"))
745
      isDead = true;
746
  }
747
  	public boolean playerIsNear(RSTile tile, int d)
748
  	{
749
  		return (Math.abs(getMyPlayer().getLocation().getX()-tile.getX())<d&&Math.abs(getMyPlayer().getLocation().getY()-tile.getY())<d);
750
  	}
751
    public void mouseExited(MouseEvent e) {
752
    }
753
    public void mouseEntered(MouseEvent e) {
754
    }
755
    public void mouseReleased(MouseEvent e) {
756
    	mouseColor = Color.RED;
757
    }
758
    public void mousePressed(MouseEvent e) {
759
    	mouseColor = new Color(255,0,0,100);
760
    }
761
    public void mouseClicked(MouseEvent e) {
762
    p = e.getPoint();
763
        if(showPaint && p.getX()>447&&p.getX()<513&& p.getY()>458&&p.getY()<473)
764
            showPaint = false;
765
        else if(!showPaint && p.getX()>447&&p.getX()<513&& p.getY()>458&&p.getY()<473)
766
            showPaint = true;
767
        else if(showPaint && fancyPaint && p.getX()>397&&p.getX()<448&& p.getY()>458&&p.getY()<473)
768
        	fancyPaint = false;
769
        else if(showPaint && !fancyPaint && p.getX()>397&&p.getX()<448&& p.getY()>458&&p.getY()<473)
770
        	fancyPaint = true;
771
    mouseColor = new Color(255,0,0,100);
772
    }
773
    public int distanceTo(RSTile test){
774
    	RSTile myLoc = players.getMyPlayer().getLocation();
775
    	return (int)Math.pow(Math.pow(test.getY()-myLoc.getY(),2)+Math.pow(test.getX()-myLoc.getX(),2),.5);
776
    }
777
    public int distanceBetween(RSTile t1, RSTile t2){
778
    	return (int)Math.pow(Math.pow(t1.getY()-t2.getY(),2)+Math.pow(t1.getX()-t2.getX(),2),.5);
779
    }
780
    public RSTile[] fixPath(RSTile [] path){
781
    	ArrayList<RSTile> newPath = new ArrayList<RSTile>();
782
    	for(RSTile t : path)
783
    		newPath.add(t);
784
    	newPath = fixPath(newPath);
785
    	path = new RSTile[newPath.size()];
786
    	for(int i=0; i<path.length;i++){
787
    		path[i]=newPath.get(i);
788
        	}
789
    		return path;
790
       }
791
    public ArrayList<RSTile> fixPath(ArrayList<RSTile> path){
792
    	boolean madeSwap = false;
793
    	do{
794
    		madeSwap = false;
795
    		for(int i = 0; i<path.size()-1;i++)
796
    			if(distanceBetween(path.get(i),path.get(i+1))>7){
797
    				path.add(i+1,getMidTile(path.get(i),path.get(i+1)));
798
    				madeSwap = true;
799
    			}
800
    	}while(madeSwap);
801
    	return path;
802
    }
803
    public RSTile getMidTile(RSTile tile1, RSTile tile2)
804
 {
805
 	int x1 = tile1.getX();
806
 	int y1 = tile1.getY();
807
 	int x2 = tile2.getX();
808
 	int y2 = tile2.getY();
809
810
 	return new RSTile((int)(x1+x2)/2,(int)(y1+y2)/2);
811
 }
812
    public static int getGEValue(String name, int id){
813
    	try{
814
    		String [] temp = name.split(" ");
815
    		String newName = "";
816
    		for(int i = 0; i<temp.length; i++)
817
    			if(i==temp.length-1)
818
    				newName+=temp[i];
819
    			else
820
    				newName+="_"+temp[i];
821
    		URL url = new URL("http://services.runescape.com/m=itemdb_rs/"+newName+"/viewitem.ws?obj="+id);
822
    		InputStream is = url.openStream();
823
    		InputStreamReader isr = new InputStreamReader(is);
824
    		BufferedReader br = new BufferedReader(isr);
825
    		String line;
826
    		String num = "";
827
    		while((line=br.readLine())!=null){
828
    			if(line.contains("Current guide price:"))
829
    			 num = line;
830
    		}
831
    		System.out.println(num);
832
    		if(num.length()<29)
833
    			return -1;
834
    		else{
835
    			num = num.substring(28);
836
    			num = num.replaceAll(",", "");
837
    			return Integer.parseInt(num);
838
    		}
839
840
    		}catch(Exception e){
841
    			return -1;
842
    		}
843
    		}
844
//LOOP====================================================================================================================
845
	public int loop() {
846
       // try{
847
        if(safety<1)
848
          {
849
          	if(!game.isFixed())
850
          		for(int i = 0; i<3;i++)
851
          		log("For best results, please set your window mode to 'fixed'.");
852
          	setUp();
853
854
          camera.setPitch(true);
855
          safety=1;
856
857
          full = inventory.isFull();
858
          if(!full&&playerIsNear(bankTile,5))
859
          		walkToRocks();
860
          else if(full&&playerIsNear(bankTile,5))
861
          	doBank(1);
862
          else if(full)
863
          	doBank(0);
864
          if(playerIsNear(new RSTile(2970,3339),8)||playerIsNear(new RSTile(3220,3219),8))
865
		  	isDead=true;
866
         }
867
868
		  mouse.setSpeed(random(5,8));
869
          antiBan(random(1,120));
870
          updateStatus();
871
		  full = inventory.isFull();
872
		  if(playerIsNear(new RSTile(2970,3339),8)||playerIsNear(new RSTile(3220,3219),8))
873
		  	isDead=true;
874
		  if(isDead){
875
		  	walkToMine();
876
		  }
877
		  if(full&&playerIsNear(bankTile,5))
878
		  {
879
		  	doBank(1);
880
		  }
881
		  else if(!full&&playerIsNear(bankTile,5)){
882
			  walkToRocks();
883
		  }
884
		  else if(full) //BANK
885
		  {
886
		  	doBank(0);
887
		  }
888
		  else if(status.equals("Evading combat.")){
889
		  	walkToBank();
890
		  	status = "Evading...";
891
		  	sleep(random(2000,3000));
892
		  	status = "Returning.";
893
		  	walkToRocks();
894
		  }
895
		  if(status.equals("Mining!"))
896
		  {
897
		  	if(random(1,5)==2)
898
		  	if(safety<3)
899
		  	{hoverMouse();
900
		  	safety++;
901
		  	}
902
		  }
903
          else if(status.equals("Not mining.")||status.contains("Moving to rock"))
904
          {
905
          	long tempTimer = System.currentTimeMillis();
906
          	while(nearRock()!=nextRock&&System.currentTimeMillis()-tempTimer<5000)
907
          	moveToNextRock();
908
            mine(false);
909
          }
910
          else if(status.equals("Waiting."))
911
          {
912
          	if(safety==3)
913
          	{
914
          	long tempTimer = System.currentTimeMillis();
915
          	while(nearRock()!=nextRock&&System.currentTimeMillis()-tempTimer<10000)
916
          	moveToNextRock();
917
          	camera.turnToTile(rocks[nextRock-1]);
918
          	camera.setPitch(random(20,50));
919
          	}
920
          	if(safety<5)
921
          		hoverMouse();
922
          	safety++;
923
          }
924
          else{
925
926
          }
927
       // }
928
   // catch (Exception e){log("Error in loop: "+e);
929
    //	log(e.getMessage()+"");}
930
    return random(300,500);
931
    }
932
//LOOP====================================================================================================================
933
    public void antiBan(int rand){
934
	status += "(AB)";
935
	mouse.setSpeed(random(7,8));
936
	if(rand==1)
937
      if(random(1, 8) == 2)
938
            mouse.moveRandomly(900,1200);
939
   if(rand==2)
940
      if(random(1, 8) == 2)
941
            mouse.moveRandomly(400,800);
942
   if(rand==3)
943
      if(random(1, 8) == 2)
944
            mouse.moveRandomly(200,700);
945
946
   if(rand==4) //THIS CHECKS THE MINING STAT
947
      if(random(1, 6) == 2)
948
        {
949
            game.openTab(game.TAB_STATS);
950
            sleep(random(600,800));
951
            mouse.move(random(674, 733), random(211, 232),0,0);
952
            sleep(random(1900,2000));
953
            game.openTab(game.TAB_INVENTORY);
954
        }
955
   if(rand==5) //THIS CLICKS THE XP BUTTON UNDER THE COMPASS
956
   	  if(random(1, 24) == 2 && game.isFixed())
957
   	  {
958
   	  	mouse.move(random(527, 540), random(58, 65),0,0);
959
   	  	sleep(random(800,1000));
960
   	  	mouse.click(true);
961
   	  	mouse.moveRandomly(20,50);
962
   	  	sleep(random(1000,1500));
963
   	  }
964
   	  if(rand==7) //RANDOM SPIN
965
       if(random(1, 3) == 2)
966
       {int r = random(1,2);
967
       	camera.setAngle(random(1,359));
968
       	if(r!=1)
969
        camera.setPitch(random(1,99));}
970
971
     if(rand==8) //THIS CHECKS A RANDOM TAB
972
      if(random(1, 4) == 2)
973
        {
974
        	int[] tabs = {0,2,3,5,6,7,9,10,11,12,13,14,15};
975
            game.openTab(tabs[random(0,tabs.length-1)]);
976
            mouse.moveRandomly(175,200);
977
            sleep(random(1600,1800));
978
            sleep(random(900,1000));
979
980
        }
981
     if(rand==9)
982
     	if(random(1,10)==2)
983
     	mouse.moveOffScreen();
984
     status=status.substring(0,status.indexOf('('));
985
986
}
987
    public void onRepaint(Graphics g)
988
    {
989
        if(game.isLoggedIn())
990
         {
991
         	try{
992
          	checkRocks();
993
          	calculateNextRock();
994
         	}catch(Exception e){};
995
         	if(startExp==0)
996
          		{
997
            		startExp = skills.getCurrentExp(skills.getIndex("mining"));
998
            		startLevel = skills.getCurrentLevel(skills.getIndex("mining"));
999
          		}
1000
           	lvlsGained = skills.getCurrentLevel(skills.getIndex("mining")) - startLevel;
1001
           	expGained =  skills.getCurrentExp(skills.getIndex("mining")) - startExp;
1002
		   	long expToLvl = skills.getExpToNextLevel(skills.getIndex("mining"));
1003
       		//setting up the time
1004
          	long ms = System.currentTimeMillis() - startTime;
1005
          	double ms2 = System.currentTimeMillis() - startTimeDbl;
1006
        	long hours = ms/3600000;
1007
         	ms = ms-(hours*3600000);
1008
        	long minutes = ms/60000;
1009
          	ms = ms-(minutes*60000);
1010
         	long seconds =  ms/1000;
1011
          	long time2Lvl = 0;
1012
    		long time2LvlHrs = 0;
1013
			long time2LvlMins = 0;
1014
    		long time2LvlSec = 0;
1015
    		if(ms2!=0&&expGained!=0){
1016
    		time2Lvl = (long)(expToLvl/(expGained/(ms2/3600000))*3600000);
1017
    		time2LvlHrs = time2Lvl/3600000;
1018
    		time2Lvl -= time2LvlHrs*3600000;
1019
    		time2LvlMins = time2Lvl/60000;
1020
    		time2Lvl -= time2LvlMins*60000;
1021
   	 		time2LvlSec = time2Lvl/1000;
1022
   			}
1023
   			numGold = expGained/65;
1024
   			numCoal = expGained/50;
1025
1026
1027
         	if(fancyPaint)
1028
         	{
1029
					if(showPaint){
1030
        			onRepaint2(g,true);
1031
1032
                //Text Color and Output
1033
                g.setColor(new Color(0,0,0,255));
1034
                g.setFont(new Font("Comic Sans MS", Font.PLAIN, 12));
1035
                g.drawString("     "+version,453,360);
1036
            	g.setFont(new Font("Comic Sans MS", Font.PLAIN, 11));
1037
                g.drawString("Levels Gained: "+lvlsGained,16,40);
1038
                if(rockType.equals("Gold"))
1039
                g.drawString("Gold Mined: "+numGold,395,22);
1040
                else if(rockType.equals("Coal"))
1041
                g.drawString("Coal Mined: "+numCoal,395,22);
1042
                g.drawString("Exp Gained: "+expGained,16,55);
1043
                g.drawString("Time Running: "+hours+":"+minutes+":"+seconds,16,97);
1044
1045
		        //Determine Length:
1046
		        double difference = skills.XP_TABLE[skills.getCurrentLevel(skills.getIndex("mining"))+1]-skills.XP_TABLE[skills.getCurrentLevel(skills.getIndex("mining"))];
1047
	        	double barLength = ((difference-expToLvl)/difference)*512;
1048
1049
	        	  //Progress Bar
1050
	        	g.setColor(new Color(255,0,0,255));
1051
                g.fillRoundRect(4,320,512,18,8,8); //Bar background
1052
                g.setColor(new Color(51,153,0,255)); //GREEN
1053
                g.fillRoundRect(4,320,(int)barLength,18,4,4);
1054
                g.setColor(new Color(0,0,0,255));
1055
                g.drawString(skills.getPercentToNextLevel(skills.getIndex("mining"))+"% to: "+(skills.getCurrentLevel(skills.getIndex("mining"))+1)+" ("+expToLvl+" exp)",215,334);
1056
            	g.setColor(new Color(255,255,255,100));
1057
            	g.fillRoundRect(4,320,512,9,4,4);
1058
1059
1060
                if(ms2!=0)
1061
	        	g.setColor(new Color(0,0,0,255));
1062
                g.drawString("Exp/Hr: "+(int)(expGained/(ms2/3600000)),16,69);
1063
             	g.drawString("Status: "+status,16,22);
1064
1065
             	if(rockType.equals("Gold"))
1066
             		{
1067
             		g.drawString("Money Gained: "+numGold*rockPrice,154,22);
1068
             		if(ms2!=0)
1069
             			g.drawString("Money/Hr: "+(int)((numGold*rockPrice)/(ms2/3600000)),289,22);
1070
             		}
1071
             	else if(rockType.equals("Coal"))
1072
             		{
1073
             		g.drawString("Money Gained: "+numCoal*rockPrice,154,22);
1074
             		if(ms2!=0)
1075
     					g.drawString("Money/Hr: "+(int)((numCoal*rockPrice)/(ms2/3600000)),289,22);
1076
          	      	}
1077
                g.drawString("Est. Time to Lvl: "+time2LvlHrs+":"+time2LvlMins+":"+time2LvlSec,16,83);
1078
                //Mouse Stuff
1079
                   Point tempPoint = mouse.getLocation();
1080
                   int tempXCoordinate = (int)tempPoint.getX();
1081
                   int tempYCoordinate = (int)tempPoint.getY();
1082
                   g.setColor(mouseColor);
1083
        		   g.drawLine(tempXCoordinate,0,tempXCoordinate,501);
1084
        		   g.drawLine(0,tempYCoordinate,764,tempYCoordinate);
1085
        		   g.fillRect(tempXCoordinate-1,tempYCoordinate-1,3,3);
1086
        		   Color tempColor = new Color(255,0,0,100);
1087
        		   if(mouseColor.equals(tempColor))
1088
        		   	mouseColor=Color.RED;
1089
1090
      	//timer drawing
1091
       for(int i = 0; i < rockPoints.length; i++){
1092
       	rockPoints[i] = calc.tileToScreen(rocks[i]);
1093
       	if(rockStatus[i]&&rockAliveTime[i]!=0){
1094
       		g.setColor(Color.GREEN);
1095
       		g.drawString((int)(rockTimeAlive[i]/1000)+"s",(int)rockPoints[i].getX(),(int)rockPoints[i].getY());
1096
       	}
1097
       	if(!rockStatus[i]&&rockDeadTime[i]!=0){
1098
       		g.setColor(Color.RED);
1099
       		g.drawString((int)(rockTimeDead[i]/1000)+"s",(int)rockPoints[i].getX(),(int)rockPoints[i].getY());
1100
       	}
1101
       }
1102
1103
1104
		}
1105
		else
1106
		{
1107
		g.setColor(Color.RED);
1108
		g.fillRect(448,459,(512-448),(472-459));
1109
		g.setColor(new Color(0,0,0,255));
1110
		g.drawRect(448,459,(512-448),(472-459));
1111
		g.drawString("Hide/Show",450,470);
1112
		}
1113
1114
       }
1115
       else
1116
       {
1117
       	if(showPaint){
1118
       	onRepaint2(g,false);
1119
       	g.setColor(new Color(0, 0, 0, 205));
1120
    	g.fillRoundRect(333, 160, 181, 179, 6, 6);
1121
       	g.setColor(new Color(255,0,0,255));
1122
        g.setFont(new Font("Comic Sans MS", Font.PLAIN, 12));
1123
        g.drawString("C's Cavern Miner "+version,338,177);
1124
    	g.setFont(new Font("Comic Sans MS", Font.PLAIN, 11));
1125
        g.drawString("Levels Gained: "+lvlsGained,344,192);
1126
        if(rockType.equals("Gold"))
1127
        g.drawString("Gold Mined: "+numGold,344,207);
1128
        else if(rockType.equals("Coal"))
1129
        g.drawString("Coal Mined: "+numCoal,344,207);
1130
        g.drawString("Exp Gained: "+expGained,344,222);
1131
        g.drawString("Time Running: "+hours+":"+minutes+":"+seconds,344, 237);
1132
1133
        //Progress Bar
1134
1135
    	g.setColor(new Color(255,0,0,255));
1136
        g.fillRoundRect(344,241,150,20,8,8); //Bar background
1137
        g.setColor(new Color(0,255,0,255)); //GREEN
1138
        g.fillRoundRect(344,241,(int)(skills.getPercentToNextLevel(skills.getIndex("mining"))*1.5),20,8,8);
1139
        g.setColor(new Color(255,255,255,100));
1140
        g.drawString(skills.getPercentToNextLevel(skills.getIndex("mining"))+"% to: "+(skills.getCurrentLevel(skills.getIndex("mining"))+1)+" ("+expToLvl+" exp)",348,256);
1141
    	g.fillRoundRect(345,251,148,10,8,8);
1142
    	g.setColor(new Color(0,0,0,255));
1143
        g.drawString(skills.getPercentToNextLevel(skills.getIndex("mining"))+"% to: "+(skills.getCurrentLevel(skills.getIndex("mining"))+1)+" ("+expToLvl+" exp)",347,255);
1144
        g.setColor(new Color(255,0,0,255));
1145
        if(ms2!=0)
1146
         g.drawString("Exp/Hr: "+(int)(expGained/(ms2/3600000)),344,274);
1147
     g.drawString("Status: "+status,344,289);
1148
1149
     if(rockType.equals("Gold"))
1150
     	{
1151
     	g.drawString("Money Gained: "+numGold*rockPrice,344,304);
1152
     	if(ms2!=0)
1153
     		g.drawString("Money/Hr: "+(int)((rockPrice*numGold)/(ms2/3600000)),344,319);
1154
     	}
1155
     else if(rockType.equals("Coal"))
1156
     	{
1157
     	g.drawString("Money Gained: "+rockPrice*numCoal,344,304);
1158
     	if(ms2!=0)
1159
     		g.drawString("Money/Hr: "+(int)((rockPrice*numCoal)/(ms2/3600000)),344,319);
1160
     	}
1161
1162
     g.drawString("Est. Time to Lvl: "+time2LvlHrs+":"+time2LvlMins+":"+time2LvlSec,344,334);
1163
     //Mouse Stuff
1164
        Point tempPoint = mouse.getLocation();
1165
        int tempXCoordinate = (int)tempPoint.getX();
1166
        int tempYCoordinate = (int)tempPoint.getY();
1167
        g.setColor(new Color(0,255,0,100));
1168
        	g.drawLine(tempXCoordinate,0,tempXCoordinate,501);
1169
        	g.drawLine(0,tempYCoordinate,764,tempYCoordinate);
1170
1171
       //timer drawing
1172
       for(int i = 0; i < rockPoints.length; i++){
1173
       	rockPoints[i] = calc.tileToScreen(rocks[i]);
1174
       	if(rockStatus[i]&&rockAliveTime[i]!=0){
1175
       		g.setColor(Color.GREEN);
1176
       		g.drawString((int)(rockTimeAlive[i]/1000)+"s",(int)rockPoints[i].getX(),(int)rockPoints[i].getY());
1177
       	}
1178
       	if(!rockStatus[i]&&rockDeadTime[i]!=0){
1179
       		g.setColor(Color.RED);
1180
       		g.drawString((int)(rockTimeDead[i]/1000)+"s",(int)rockPoints[i].getX(),(int)rockPoints[i].getY());
1181
       	}
1182
1183
       	}}
1184
       	else
1185
       	{
1186
       	g.setColor(Color.RED);
1187
		g.fillRect(448,459,(512-448),(472-459));
1188
		g.setColor(new Color(0,0,0,255));
1189
		g.drawRect(448,459,(512-448),(472-459));
1190
		g.drawString("Hide/Show",450,470);
1191
       	}
1192
       }
1193
       //}catch (Exception e){log("Error in paint: "+e);
1194
    //	log(e.getMessage()+"");}
1195
    }
1196
    }
1197
	private Image getImage(String url) {
1198
        try {
1199
            return ImageIO.read(new URL(url));
1200
        } catch(IOException e) {
1201
            return null;
1202
        }
1203
    }
1204
    private final Color color1 = new Color(1, 1, 1);
1205
    private final Font font1 = new Font("Arial", 0, 12);
1206
    public void onRepaint2(Graphics g1 , boolean fancy) {
1207
        Graphics2D g = (Graphics2D)g1;
1208
        if(fancy){
1209
        g.drawImage(img1, 342, 350, null);
1210
        g.drawImage(img2, 5, 6, null);
1211
        g.drawImage(img4, 5, 29, null);
1212
        }
1213
        g.setColor(Color.RED);
1214
		g.fillRect(448,459,(512-448),(472-459));
1215
		g.fillRect(398,459,(448-398),(472-459));
1216
		g.setColor(new Color(0,0,0,255));
1217
		g.drawRect(448,459,(512-448),(472-459));
1218
		g.drawRect(398,459,(448-398),(472-459));
1219
		g.drawString("Hide/Show",450,470);
1220
		if(fancy)
1221
		g.drawString("Simple",405,470);
1222
		else
1223
		g.drawString("Adv.",415,470);
1224
		}
1225
    public void onFinish() {
1226
        log("Exp gained: "+expGained);
1227
        log("Levels gained: "+lvlsGained);
1228
        log("Thanks for using Conderoga's Cavern Miner!");
1229
    }
1230
	public void openURL(final String url) { // Credits ZombieKnight
1231
    //who gave credits to Dave who gave credits
1232
    // to
1233
    // some guy who made this.
1234
    final String osName = System.getProperty("os.name");
1235
    try {
1236
      if (osName.startsWith("Mac OS")) {
1237
        final Class<?> fileMgr = Class
1238
            .forName("com.apple.eio.FileManager");
1239
        final Method openURL = fileMgr.getDeclaredMethod("openURL",new Class[]{String.class});
1240
        openURL.invoke(null, new Object[]{url});
1241
      } else if (osName.startsWith("Windows")) {
1242
        Runtime.getRuntime().exec(
1243
            "rundll32 url.dll,FileProtocolHandler " + url);
1244
      } else { // assume Unix or Linux
1245
        final String[] browsers = {"firefox", "opera", "konqueror",
1246
            "epiphany", "mozilla", "netscape"};
1247
        String browser = null;
1248
        for (int count = 0; count < browsers.length && browser == null; count++) {
1249
          if (Runtime.getRuntime().exec(
1250
              new String[]{"which", browsers[count]})
1251
              .waitFor() == 0) {
1252
            browser = browsers[count];
1253
          }
1254
        }
1255
        if (browser == null) {
1256
          throw new Exception("Could not find web browser");
1257
        } else {
1258
          Runtime.getRuntime().exec(new String[]{browser, url});
1259
        }
1260
      }
1261
    }catch(Exception e){};
1262
  }
1263
 public class CCMineGUI extends JFrame {
1264
       private static final long serialVersionUID = 1L;
1265
        public CCMineGUI()
1266
          {
1267
          initComponents();
1268
         }
1269
1270
        private void button2ActionPerformed(ActionEvent e)
1271
          {
1272
          try{
1273
          guiWait = false;
1274
           guiExit = true;
1275
           dispose();
1276
          }catch(Exception f){log("WTF.");}
1277
          }
1278
1279
        private void button1ActionPerformed(ActionEvent e)
1280
          {
1281
          try{
1282
          rockType = comboBox1.getSelectedItem().toString();
1283
          quickDeposit = checkBox1.isSelected();
1284
          evade = checkBox2.isSelected();
1285
          fastBank = checkBox3.isSelected();
1286
          guiExit = false;
1287
          guiWait = false;
1288
          dispose();
1289
          }catch(Exception f){log("WTF.");}
1290
          }
1291
1292
        private void initComponents() {
1293
        label1 = new JLabel();
1294
        label2 = new JLabel();
1295
        label3 = new JLabel();
1296
        button1 = new JButton();
1297
        button2 = new JButton();
1298
        checkBox1 = new JCheckBox("Quick Deposit?",false);
1299
        checkBox2 = new JCheckBox("Evade Combat?",true);
1300
        checkBox3 = new JCheckBox("Faster Banking?",false);
1301
    comboBox1 = new JComboBox();
1302
1303
    setTitle("Conderoga's Cavern Miner");
1304
    setResizable(false);
1305
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
1306
    Container contentPane = getContentPane();
1307
    contentPane.setLayout(null);
1308
1309
    //---- label1 ----
1310
    label1.setText("Conderoga's Cavern Miner Settings");
1311
    label1.setFont(new Font("Comic Sans MS", Font.PLAIN, 16));
1312
    contentPane.add(label1);
1313
    label1.setBounds(10, -10, 380, 70);
1314
1315
     //---- label2 ----
1316
    label2.setText("Select what to mine: ");
1317
    contentPane.add(label2);
1318
    label2.setBounds(new Rectangle(new Point(15, 50), label2.getPreferredSize()));
1319
1320
    //---- comboBox1 ----
1321
    comboBox1.setMaximumRowCount(2);
1322
    comboBox1.setModel(new DefaultComboBoxModel(new String[] {
1323
      "Gold",
1324
      "Coal"
1325
1326
1327
1328
    }));
1329
    contentPane.add(comboBox1);
1330
    comboBox1.setBounds(175, 45, 125, 25);
1331
    //---- label3 ----
1332
    label3.setText("Version: "+version);
1333
    contentPane.add(label3);
1334
    label3.setBounds(15, 80, 124, label3.getPreferredSize().height);
1335
1336
	//CheckBox1-------
1337
	checkBox1.setText("Quick Deposit?");
1338
	contentPane.add(checkBox1);
1339
	checkBox1.setBounds(new Rectangle(new Point(115, 75), checkBox1.getPreferredSize()));
1340
	//CheckBox2-------
1341
	checkBox2.setText("Evade Combat?");
1342
	contentPane.add(checkBox2);
1343
	checkBox2.setBounds(new Rectangle(new Point(115, 95), checkBox2.getPreferredSize()));
1344
	//CheckBox3-------
1345
	checkBox3.setText("Faster Banking?");
1346
	contentPane.add(checkBox3);
1347
	checkBox3.setBounds(new Rectangle(new Point(115, 115), checkBox3.getPreferredSize()));
1348
1349
1350
1351
    //---- button1 ----
1352
    button1.setText("Start!");
1353
    button1.addActionListener(new ActionListener() {
1354
      public void actionPerformed(ActionEvent e) {
1355
        button1ActionPerformed(e);
1356
      }
1357
    });
1358
    contentPane.add(button1);
1359
    button1.setBounds(40, 115, 75, 30);
1360
1361
    //---- button2 ----
1362
    button2.setText("Exit");
1363
    button2.addActionListener(new ActionListener() {
1364
      public void actionPerformed(ActionEvent e) {
1365
        button2ActionPerformed(e);
1366
      }
1367
    });
1368
    contentPane.add(button2);
1369
    button2.setBounds(225, 115, 75, 30);
1370
1371
    { // compute preferred size
1372
      Dimension preferredSize = new Dimension();
1373
      for(int i = 0; i < contentPane.getComponentCount(); i++)
1374
        {
1375
        Rectangle bounds = contentPane.getComponent(i).getBounds();
1376
        preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
1377
        preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
1378
        }
1379
      Insets insets = contentPane.getInsets();
1380
      preferredSize.width += insets.right;
1381
      preferredSize.height += insets.bottom;
1382
      contentPane.setMinimumSize(preferredSize);
1383
      contentPane.setPreferredSize(preferredSize);
1384
    }
1385
    setSize(325, 190);
1386
    setLocationRelativeTo(getOwner());
1387
  }
1388
  private JLabel label1;
1389
  private JLabel label2;
1390
  private JComboBox comboBox1;
1391
  private JLabel label3;
1392
  private JButton button1;
1393
  private JButton button2;
1394
  private JCheckBox checkBox1;
1395
  private JCheckBox checkBox2;
1396
  private JCheckBox checkBox3;
1397
}
1398
}