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