-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPainter.java
More file actions
122 lines (115 loc) · 3.65 KB
/
Painter.java
File metadata and controls
122 lines (115 loc) · 3.65 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
121
122
package scripts.MegaHunter;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.Polygon;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
import org.tribot.api2007.Objects;
import org.tribot.api2007.Projection;
import org.tribot.api2007.Skills;
import org.tribot.api2007.types.RSObject;
import org.tribot.api2007.types.RSObjectDefinition;
import scripts.MegaHunter.Trap.trapState;
import scripts.MegaHunter.utils.RSBuddyItem;
public class Painter {
public static void paint(Graphics g) {
if (MegaHunt.Status != null) {
List<Trap> traps = new ArrayList<Trap>(MegaHunt.Status.getTraps());
if (traps != null && traps.size() > 0) {
for (Trap t : traps) {
trapState state = t.getState();
if (state.equals(trapState.ANIMATION)) {
g.setColor(Color.ORANGE);
} else if (state.equals(trapState.IDLE)) {
g.setColor(Color.BLUE);
} else if (state.equals(trapState.BROKEN)) {
g.setColor(Color.RED);
} else if (state.equals(trapState.CAPTURED)) {
g.setColor(Color.GREEN);
} else if (state.equals(trapState.NULL)) {
g.setColor(Color.PINK);
}
for (RSObject o : Objects.getAt(t.getLocation())) {
RSObjectDefinition def = o.getDefinition();
if (def != null && t.checkName(def.getName())) {
Point p = o.getModel().getCentrePoint();
g.drawString(
"Time: "
+ (System.currentTimeMillis() - t
.getTime()) / 1000, p.x,
p.y);
}
}
Polygon pt = Projection.getTileBoundsPoly(t.getLocation(),
0);
if (pt != null) {
g.drawPolygon(pt);
}
}
}
g.setColor(Color.MAGENTA);
Point[] p = MegaHunt.Status.coolPoints;
if (p != null && p.length > 0) {
for (Point p1 : p) {
if (Projection.isInViewport(p1)) {
g.fillRect(p1.x, p1.y, 1, 1);
}
}
}
g.setColor(Color.BLACK);
g.drawString("MegaHunt v1.0", 277, 320);
long runtime = (System.currentTimeMillis() - MegaHunt.Status
.getStartTime());
g.drawString("Time ran: " + format(runtime), 277, 340);
int xpGained = Skills.getXP(Skills.SKILLS.HUNTER)
- MegaHunt.Status.getStartXp();
g.drawString("Xp Gained: " + xpGained, 277, 360);
int caught = xpGained / MegaHunt.Status.getMethod().getXp();
g.drawString("Animals Caught: " + caught, 277, 380);
int caughtPerHour = (int) ((3600000.0 / (double) runtime) * caught);
g.drawString("Caught/Hr: " + caughtPerHour, 277, 400);
int xpPerHour = (int) ((3600000.0 / (double) runtime) * xpGained);
g.drawString("Xp/Hr: " + xpPerHour, 277, 420);
RSBuddyItem product = MegaHunt.Status.getMethod().getProduct();
g.drawString("Gold: " + formatNumber(caught * product.getOverall()), 277, 440);
g.drawString("G/Hr: " + formatNumber(caughtPerHour * product.getOverall()), 277, 460);
}
}
private static String formatNumber(int start) {
DecimalFormat nf = new DecimalFormat("0");
double i = start;
if (i >= 10000000) {
return nf.format((i / 1000000)) + "M";
}
if (i >= 1000) {
return nf.format((i / 1000)) + "k";
}
return "" + start;
}
private static String format(final long time) {
final StringBuilder t = new StringBuilder();
final long total_secs = time / 1000;
final long total_mins = total_secs / 60;
final long total_hrs = total_mins / 60;
final int secs = (int) total_secs % 60;
final int mins = (int) total_mins % 60;
final int hrs = (int) total_hrs % 60;
if (hrs < 10) {
t.append("0");
}
t.append(hrs);
t.append(":");
if (mins < 10) {
t.append("0");
}
t.append(mins);
t.append(":");
if (secs < 10) {
t.append("0");
}
t.append(secs);
return t.toString();
}
}