Repository navigation
Expand file tree
/
Copy pathConstructionScipt.java
More file actions
262 lines (242 loc) · 9.1 KB
/
Copy pathConstructionScipt.java
File metadata and controls
262 lines (242 loc) · 9.1 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
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
package construciton;
import java.awt.Graphics;
import java.util.function.Consumer;
import org.dreambot.api.methods.Calculations;
import org.dreambot.api.methods.map.Tile;
import org.dreambot.api.methods.skills.Skill;
import org.dreambot.api.methods.widget.Widget;
import org.dreambot.api.script.Category;
import org.dreambot.api.script.ScriptManifest;
import org.dreambot.api.wrappers.interactive.GameObject;
import org.dreambot.api.wrappers.interactive.NPC;
import org.dreambot.api.wrappers.items.Item;
import base.AbstractFeaturedScript;
import base.Task;
import base.Task.TaskBody;
@ScriptManifest(author = "skengrat", name = "Construction", version = 1.0, description = "", category = Category.CONSTRUCTION)
public class ConstructionScipt extends AbstractFeaturedScript{
private boolean building = false;
private boolean gotButler = false;
private final int RING_ID_0 = 2552;
private final Tile RIMMINGTON = new Tile(2953, 3224, 0);
private Task init = new Task("Init", new TaskBody() {
@Override
public int execute(){
if(getLocalPlayer().distance(RIMMINGTON) < 10){
GameObject g = getGameObjects().closest(15478);
if(g != null){
g.interact();
conditionalSleep(() -> getDialogues().inDialogue() && getDialogues().getOptions() != null, 2000, 3000);
Tile lastTile = getLocalPlayer().getTile();
getDialogues().chooseOption(2);
conditionalSleep(()->getLocalPlayer().distance(lastTile) > 20, 3000, 4500);
if(getLocalPlayer().distance(lastTile) > 20){
GameObject g3 = getGameObjects().closest(15403);
GameObject g2 = getGameObjects().closest(13566);
if(g2 != null || g3 != null){
getWalking().walk(g2 == null ? g3 : g2);
walkingSleep();
sleep(2000);
setNextTask(build);
}
}else
stop();
}
}else
setNextTask(build);
return Calculations.random(500, 1500);
}
});
private Task build = new Task("Build", new TaskBody() {
@Override
public int execute(){
if(!gotButler){
NPC b = getNpcs().closest("Butler");
if(b != null){
b.interact();
conditionalSleep(() -> getDialogues().inDialogue(), 5000, 6000);
if(getDialogues().inDialogue())
gotButler = true;
}else{
getWalking().clickTileOnMinimap(getLocalPlayer().getTile().translate(Calculations.random(0, 10) - 5, Calculations.random(0, 10) - 5));
walkingSleep();
}
return Calculations.random(500, 1500);
}
int plankCount = getInventory().count(8778);
if(plankCount < 20){
if(plankCount < 8){
conditionalSleep(()->getNpcs().closest("Butler") != null, 2000, 2500);
}
NPC b = getNpcs().closest("Butler");
if(b != null){
// int pCount = getInventory().count(8778);
b.interact();
conditionalSleep(() -> getDialogues().inDialogue(), 5000, 6000);
String dial = getDialogues().getNPCDialogue();
log(dial);
if(dial.equals("Your goods, sir.")){
conditionalSleep(()->getDialogues().canContinue(), 1000, 1500);
getDialogues().spaceToContinue();
b.interact();
conditionalSleep(() -> getDialogues().inDialogue(), 5000, 6000);
getDialogues().chooseOption(1);
conditionalSleep(()->getDialogues().canContinue(), 1000, 1500);
getDialogues().spaceToContinue();
sleep(Calculations.random(500, 800));
getDialogues().spaceToContinue();
}
else if(dial.contains("pay me")){
conditionalSleep(()->getDialogues().canContinue(), 1000, 1500);
getDialogues().spaceToContinue();
conditionalSleep(() -> getDialogues().getOptions() != null, 500, 1000);
getDialogues().typeOption(1);
conditionalSleep(()->getDialogues().canContinue(), 1000, 1500);
getDialogues().spaceToContinue();
b.interact();
conditionalSleep(() -> getDialogues().inDialogue(), 5000, 6000);
getDialogues().chooseOption(1);
conditionalSleep(()->getDialogues().canContinue(), 1000, 1500);
getDialogues().spaceToContinue();
sleep(Calculations.random(500, 800));
}else if (getDialogues().getOptions() != null){
getDialogues().chooseOption(1);
conditionalSleep(()->getDialogues().canContinue(), 1000, 1500);
getDialogues().spaceToContinue();
sleep(Calculations.random(500, 800));
}
// if(getInventory().count(8778) != pCount){
// conditionalSleep(()->getDialogues().canContinue(), 1000, 1500);
// getDialogues().spaceToContinue();
// b.interact();
// conditionalSleep(() -> getDialogues().inDialogue(), 5000, 6000);
// getDialogues().chooseOption(1);
// conditionalSleep(()->getDialogues().canContinue(), 1000, 1500);
// getDialogues().spaceToContinue();
// }else{
// conditionalSleep(()->getDialogues().canContinue(), 1000, 1500);
// getDialogues().spaceToContinue();
// sleep(500);
// if(getDialogues().getOptionIndexContaining("5000") != -1){
// getDialogues().chooseOption(getDialogues().getOptionIndexContaining("5000"));
// }else{
// getDialogues().chooseOption(1);
// conditionalSleep(()->getDialogues().canContinue(), 1000, 1500);
// getDialogues().spaceToContinue();
// }
// }
}
}
GameObject g = getGameObjects().closest(15403);
GameObject g2 = getGameObjects().closest(13566);
Widget w = getWidgets().getWidget(458);
if(w != null){
getWidgets().getWidget(458).getChild(5).getChild(6).interact();
building = true;
}else if(getDialogues().getOptions() != null){
getDialogues().typeOption(1);
conditionalSleep(() -> getDialogues().getOptions() == null, 500, 1000);
building = false;
}else if(g != null && !building){
g.interact("Build");
conditionalSleep(() -> getWidgets().getWidget(458) != null, 500, 1000);
}else if(g2 != null){
g2.interact("Remove");
conditionalSleep(() -> getDialogues().getOptions() != null, 500, 1000);
}
return Calculations.random(100, 800);
}
});
private final Tile CW_BANK = new Tile(2439, 3092, 0);
private final Tile CW_CHEST_TILE = new Tile(2443, 3083, 0);
// private Task bank = new Task("Banking", new TaskBody() {
// @Override
// public int execute(){
// if(getLocalPlayer().distance(CW_BANK) < 10){
// getWalking().walk(CW_CHEST_TILE);
// walkingSleep();
// GameObject g = getGameObjects().closest("Bank Chest");
// if(g != null)
// if(g.interact("Use")){
// conditionalSleep(() -> getBank().isOpen(), 1000, 2500);
//
// if(!checkTeleports(RING_ID_0, null) && getBank().contains(RING_ID_0)){
// getBank().withdraw(RING_ID_0);
// conditionalSleep(() -> getInventory().contains(RING_ID_0), 800, 1200);
// }
// getBank().withdraw(8013);
// conditionalSleep(() -> (getInventory().get(8013) != null), 800, 1200);
// getBank().withdraw(8778, 24);
// conditionalSleep(() -> (getInventory().get(960) != null), 800, 1200);
//
// getBank().close();
// if(!checkTeleports(RING_ID_0, null)){
// log("No teleports in bank");
// stop();
// }
// if(getInventory().count(8778) >= 22 && getInventory().count(8013) >= 1 && getInventory().count(4820) > 10 && checkTeleports(RING_ID_0, null)){
// getInventory().get(8013).interact("Break");
// conditionalSleep(() -> TILE.distance(getLocalPlayer()) < 100, 3000, 4000);
// turnOnBuilding();
// setNextTask(build);
// getWalking().clickTileOnMinimap(TILE);
// walkingSleep();
// conditionalSleep(() -> TILE.distance(getLocalPlayer()) < 1, 2000, 5000);
// }
// }
// return Calculations.random(200, 300);
// }else if(checkTeleports(RING_ID_0, i -> i.interact("Castle Wars"))){
// conditionalSleep(() -> getLocalPlayer().distance(CW_BANK) < 4, 4000, 4500);
// getWalking().walk(CW_CHEST_TILE);
// walkingSleep();
// return Calculations.random(500, 800);
// }
//
// log("No Ring");
// stop();
// return 1;
// }
// });
private void turnOnBuilding(){
getWidgets().getWidget(548).getChild(41).interact();
sleep(Calculations.random(400, 985));
getWidgets().getWidget(261).getChild(75).interact();
sleep(Calculations.random(800, 985));
getWidgets().getWidget(370).getChild(5).interact();
sleep(Calculations.random(1002, 2000));
getWidgets().getWidget(548).getChild(57);
sleep(Calculations.random(400, 985));
}
private boolean checkTeleports(int itemID, Consumer<Item> c){
for(int i = 0; i < 16; i += 2){
if(getInventory().contains(itemID + i) || getEquipment().contains(itemID + i)){
if(getInventory().contains(itemID + i)){
getInventory().get(itemID + i).interact("Wear");
final int id = itemID + i;
conditionalSleep(() -> getEquipment().contains(id), 500, 1000);
}
if(c != null){
getWidgets().getWidget(548).getChild(58).interact();
sleep(300);
c.accept(getEquipment().get(itemID + i));
getWidgets().getWidget(548).getChild(57).interact();
sleep(300);
}
return true;
}
}
log("Has no " + itemID);
return false;
}
@Override
public void onStart(){
super.onStart();
setNextTask(init);
}
@Override
public void onPaint(Graphics g){
super.onPaint(g);
long time = getSkills().getExperienceToLevel(Skill.CONSTRUCTION);
g.drawString("exp to lvl: " + time, 10, 80);
}
}