-
Notifications
You must be signed in to change notification settings - Fork 1
/
CommunityGeneratorScript.java
268 lines (206 loc) · 7.33 KB
/
CommunityGeneratorScript.java
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
package scripts.advancedwalking.collector;
import org.tribot.api.General;
import org.tribot.api.input.Mouse;
import org.tribot.api.interfaces.Positionable;
import org.tribot.api2007.Login;
import org.tribot.api2007.Projection;
import org.tribot.api2007.types.RSObject;
import org.tribot.api2007.types.RSTile;
import org.tribot.script.ScriptManifest;
import org.tribot.script.interfaces.*;
import scripts.advancedwalking.generator.tiles.collector.collectors.RegionCollector;
import scripts.advancedwalking.generator.tiles.collector.TileCollector;
import scripts.entityselector.Entities;
import scripts.entityselector.finders.prefabs.ObjectEntity;
import scripts.lanapi.core.gui.GUI;
import scripts.lanapi.core.logging.LogProxy;
import scripts.lanapi.core.patterns.IStrategy;
import scripts.lanapi.game.concurrency.observers.inventory.InventoryListener;
import scripts.lanapi.game.helpers.ProjectionHelper;
import scripts.lanapi.game.painting.AbstractPaintInfo;
import scripts.lanapi.game.painting.PaintBuilder;
import scripts.lanapi.game.script.LANScript;
import scripts.lanapi.network.connectivity.DynamicSignatures;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.image.BufferedImage;
import java.util.HashMap;
@ScriptManifest(authors = {"Laniax"}, category = "AdvancedWalking", name = "CommunityGeneratorScript2")
public class CommunityGeneratorScript extends LANScript implements Painting, MouseActions, KeyActions, MousePainting, MouseSplinePainting, Arguments,
EventBlockingOverride, Ending, Breaking, MessageListening07, InventoryListener, DynamicSignatures {
LogProxy log = new LogProxy("CommunityGeneratorScript");
private boolean scanningTiles = true;
TileCollector collector;
GUI gui;
RSTile selected;
/**
* Return a JavaFX gui, it will automatically be shown and the script will wait until it closes.
* Return null if you don't want a GUI.
*
* @return
*/
@Override
public GUI getGUI() {
return gui = new GUI(this.getClass().getResource("gui.fxml"));
}
/**
* Return a list of all the strategies this script should perform.
*
* @return
*/
@Override
public IStrategy[] getStrategies() {
while (Login.getLoginState() != Login.STATE.INGAME)
General.sleep(500);
// Use a different tile collector in order to gather tiles in your own way
// This opens up the possibility to read from the RS cache etc and all you have to do is replace this collector.
collector = new RegionCollector();
while (scanningTiles) {
collector.collect();
}
log.info("Collected %d tiles!", collector.getTiles().size());
return null;
}
/**
* Return the notification icon for in the system tray bar.
* Return null if you don't want an icon.
*
* @return
*/
@Override
public BufferedImage getNotificationIcon() {
return null;
}
/**
* Return this script's paint logic.
* Return null if you don't want a paint.
*
* @return
*/
@Override
public AbstractPaintInfo getPaintInfo() {
return new AbstractPaintInfo() {
@Override
public Color getPrimaryColor() {
return new Color(102, 130, 142);
}
@Override
public Color getSecondaryColor() {
return new Color(102, 130, 142);
}
@Override
public boolean isScriptPremium() {
return false;
}
@Override
public boolean showReportBugButton() {
return false;
}
@Override
public PaintBuilder paintTitle() {
return new PaintBuilder().add().setText("AW Mesh Gen").end();
}
@Override
public PaintBuilder getText(long runTime) {
return new PaintBuilder().add().setText("Collecting tiles").end();
}
@Override
public void customDrawBefore(Graphics2D g) {
if (selected != null) {
if (selected.isOnScreen()) {
Polygon poly = Projection.getTileBoundsPoly(selected, 0);
if (poly != null) {
g.setColor(selectedTileColor);
g.fillPolygon(poly);
}
}
}
}
};
}
Color blackTransparent = new Color(0, 0, 0, 100);
Color selectedTileColor = new Color(255, 0, 1, 100);
Rectangle stopButton = new Rectangle(380, 300, 130, 30);
// @Override
// public void onPaint(Graphics g) {
//
// if (scanningTiles && collector != null) {
// g.setColor(blackTransparent);
// g.fillRect(stopButton.x, stopButton.y, stopButton.width, stopButton.height);
// g.setColor(Color.BLACK);
// g.drawRect(stopButton.x, stopButton.y, stopButton.width, stopButton.height);
// g.setColor(Color.WHITE);
// g.drawString("Generate", (stopButton.width / 3) + stopButton.x, (stopButton.height / 2) + stopButton.y + 5);
// g.drawString("Number of tiles: " + collector.getTiles().size(), stopButton.x, stopButton.y - 10);
//
// for (MeshTile t : collector.getTiles()) {
//
//
// if (isDoorTile(t)) {
//
//
//
// }
//
//
// }
// }
//
// }
private boolean isDoorTile(Positionable positionable) {
if (positionable == null)
return false;
RSObject object = Entities.find(ObjectEntity::new)
.actionsContains("Open", "Close")
.tileEquals(positionable)
.getFirstResult();
return object != null;
}
private boolean isStairTile(Positionable positionable) {
if (positionable == null)
return false;
RSObject object = Entities.find(ObjectEntity::new)
.actionsContains("Climb")
.tileEquals(positionable)
.getFirstResult();
return object != null;
}
@Override
public void mouseClicked(Point point, int button, boolean isBot) {
if (stopButton.contains(point.x, point.y)) {
scanningTiles = false;
}
}
public void keyReleased(int keycode, boolean is_bot) {
if (is_bot)
return;
if (keycode == KeyEvent.VK_F1) {
RSTile t = ProjectionHelper.getTileAtPoint(Mouse.getPos());
if (t == null)
return;
selected = t;
gui.<GUIController>getController().setTile(t);
}
}
/**
* The url of the server. In the following format:
* http://yourdomain.com/scripts/yourscriptname/
* <p>
* Leave null if you dont want to use dynamic signatures.
*
* @return
*/
@Override
public String signatureServerUrl() {
return null;
}
/**
* Called every 5 minutes to send data to the server. Please send the values -from the script start- and NOT from since the last call.
*
* @return A hashmap with String that equals the a Type name on the server, and the integer value of the variable.
*/
@Override
public HashMap<String, Integer> signatureSendData() {
return null;
}
}