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