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