-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathPowerMiner.java
More file actions
executable file
·120 lines (106 loc) · 3.52 KB
/
PowerMiner.java
File metadata and controls
executable file
·120 lines (106 loc) · 3.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
import org.rsbot.event.listeners.PaintListener;
import org.rsbot.script.Script;
import org.rsbot.script.ScriptManifest;
import org.rsbot.script.methods.Skills;
import org.rsbot.script.wrappers.RSItem;
import org.rsbot.script.wrappers.RSObject;
import java.awt.*;
@ScriptManifest(authors = {"LastCoder"}, name = "Iron PowerMiner", version = 1.0, description = "Any Location, just start near rocks.")
public class PowerMiner extends Script implements PaintListener {
private static enum State {
MINE, DROP
}
private static final int[] ROCKS = new int[]{11956, 11954, 11955, 37307, 37308, 37309};
private static final int IRON_ITEM = 440;
private static final int TRAINING_SKILL = Skills.MINING;
private static final Color COLOR_1 = new Color(0, 0, 0, 154);
private static final Color COLOR_2 = new Color(0, 0, 0, 147);
private static final Color COLOR_3 = new Color(255, 255, 255);
private static final Font FONT_1 = new Font("Arial", 0, 12);
private static final Font FONT_2 = new Font("Arial", 0, 10);
private static final BasicStroke STROKE_1 = new BasicStroke(1);
private long startExp;
private long startLevel;
private long startTime;
private long expGained;
private int expHour;
private State getState() {
if (inventory.isFull()) {
return State.DROP;
} else {
return State.MINE;
}
}
@Override
public int loop() {
switch (getState()) {
case MINE:
RSObject rock = objects.getNearest(ROCKS);
if (rock != null) {
if (!rock.isOnScreen()) {
camera.turnTo(rock);
for (int i = 0; i < 100 && !rock.isOnScreen(); i++)
sleep(20);
} else {
for (int i = 0; i < 100 && getMyPlayer().isMoving(); i++)
sleep(20);
rock.doAction("Mine");
for (int i = 0; i < 100
&& getMyPlayer().getAnimation() != -1; i++)
sleep(20);
}
}
break;
case DROP:
RSItem[] all = inventory.getItems();
for (RSItem item : all) {
if (item == null)
continue;
if (item.getID() == IRON_ITEM) {
item.doAction("Drop");
sleep(100);
}
}
break;
}
return 0;
}
public boolean onStart() {
startExp = (long) skills.getCurrentExp(Skills.MINING);
startLevel = (long) skills.getRealLevel(Skills.MINING);
startTime = System.currentTimeMillis();
return game.isLoggedIn();
}
public void onRepaint(Graphics g1) {
Graphics2D g = (Graphics2D) g1;
long millis = System.currentTimeMillis() - startTime;
long totalseconds = millis / 1000;
long hours = millis / (1000 * 60 * 60);
millis -= hours * 1000 * 60 * 60;
long minutes = millis / (1000 * 60);
millis -= minutes * 1000 * 60;
long seconds = millis / 1000;
if ((skills.getCurrentExp(Skills.MINING) - startExp) > 0
&& startExp > 0) {
expGained = skills.getCurrentExp(Skills.MINING) - startExp;
}
if (expGained > 0 && totalseconds > 0) {
expHour = (int) (3600 * expGained / totalseconds);
}
g.setColor(COLOR_1);
g.fillRect(366, 4, 135, 106);
g.setColor(COLOR_2);
g.setStroke(STROKE_1);
g.drawRect(366, 4, 135, 106);
g.setFont(FONT_1);
g.setColor(COLOR_3);
g.drawString("Iron PowerMiner", 393, 22);
g.setFont(FONT_2);
g.drawString("Time Run: " + hours + " : " + minutes + " : "
+ seconds, 370, 40);
g.drawString("EXP Gained: " + expGained, 370, 55);
g.drawString("EXP/Hr: " + expHour, 370, 70);
g.drawString("Levels Gained: (" + startLevel + ") Gained: "
+ (skills.getRealLevel(TRAINING_SKILL) - startLevel), 370, 85);
}
}