-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBlastFurnace.java
157 lines (132 loc) · 5.17 KB
/
BlastFurnace.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
import org.rspeer.runetek.adapter.scene.Player;
import org.rspeer.runetek.adapter.scene.SceneObject;
import org.rspeer.runetek.api.commons.Time;
import org.rspeer.runetek.api.commons.math.Random;
import org.rspeer.runetek.api.component.Bank;
import org.rspeer.runetek.api.component.tab.Equipment;
import org.rspeer.runetek.api.component.tab.Inventory;
import org.rspeer.runetek.api.movement.Movement;
import org.rspeer.runetek.api.movement.position.Area;
import org.rspeer.runetek.api.movement.position.Position;
import org.rspeer.runetek.api.scene.Players;
import org.rspeer.runetek.api.scene.SceneObjects;
import org.rspeer.script.Script;
import org.rspeer.script.ScriptMeta;
import java.util.Date;
@ScriptMeta(developer = "Sri", name = "Blast Furnace", desc = "Smithing")
public class BlastFurnace extends Script {
private static final String CONVEYOR = "Conveyor belt";
private static final String DISPENSER = "Bar dispenser";
private static final int GOLD_BAR = 2357;
private static final int GOLD_ORE = 444;
private static final int GOLD_GAUNTLETS = 776;
private static final int ICE_GLOVES = 1580;
private static final Area DEPOSIT_AREA = Area.rectangular(new Position(1942, 4965), new Position(1937, 4969));
private static final Area DISPENSER_AREA = Area.rectangular(new Position(1940, 4964), new Position(1939, 4962));
private String state = "start";
public int getRand(int low, int high) {
int highRand = org.rspeer.runetek.api.commons.math.Random.high(low, high);
int lowRand = org.rspeer.runetek.api.commons.math.Random.low(low, high);
int rand;
if (org.rspeer.runetek.api.commons.math.Random.nextInt(0, 100) < 50) {
rand = lowRand;
}
else {
rand = highRand;
}
return rand;
}
public void afterInteraction() {
Time.sleep(getRand(500, 1000));
}
public void putGoldGloves() {
if (!Equipment.contains(GOLD_GAUNTLETS)) {
if (Random.low(0, 100) > 70) {
Inventory.getFirst(GOLD_GAUNTLETS).interact("Wear");
}
}
}
public void forcePutGoldGloves() {
if (!Equipment.contains(GOLD_GAUNTLETS)) {
Inventory.getFirst(GOLD_GAUNTLETS).interact("Wear");
}
}
public boolean hasAction(String[] actions, String action) {
for(String s: actions) {
if (s.equals(action)) {
return true;
}
}
return false;
}
@Override
public void onStart() {
super.onStart();
}
@Override
public int loop() {
if (state.equals("toConveyor")) {
//Randomly put gold gloves
putGoldGloves();
if (!Players.getLocal().isAnimating() && !Players.getLocal().isMoving()) {
//Move to deposit area
Movement.walkTo(Random.nextElement(DEPOSIT_AREA.getTiles()));
}
if (DEPOSIT_AREA.contains(Players.getLocal().getPosition())) {
state = "depositConveyor";
}
}
if (state.equals("depositConveyor")) {
//putGoldGloves();
if (!Players.getLocal().isAnimating() && !Players.getLocal().isMoving()) {
SceneObject conveyor_belt = SceneObjects.getNearest("Conveyor belt");
conveyor_belt.interact("Put-ore-on");
}
if (Inventory.getCount(GOLD_ORE) == 0) {
state = "toDispenser";
}
}
if (state.equals("toDispenser")) {
if (!Players.getLocal().isAnimating() && !Players.getLocal().isMoving()) {
//Move to dispenser area
Movement.walkTo(Random.nextElement(DISPENSER_AREA.getTiles()));
}
if (hasAction(SceneObjects.getNearest("Bar dispenser").getActions(), "Take")) {
if (!Equipment.contains(ICE_GLOVES)) {
Inventory.getFirst(ICE_GLOVES).interact("Wear");
}
}
if (DISPENSER_AREA.contains(Players.getLocal().getPosition())) {
state = "takeBars";
}
}
if (state.equals("takeBars")) {
if (hasAction(SceneObjects.getNearest("Bar dispenser").getActions(), "Take")) {
if (!Equipment.contains(ICE_GLOVES)) {
Inventory.getFirst(ICE_GLOVES).interact("Wear");
}
}
SceneObjects.getNearest("Bar dispenser").interact("Take");
if (!hasAction(SceneObjects.getNearest("Bar dispenser").getActions(), "Take")) {
state = "toBank";
}
}
if (state.equals("toBank")) {
if (!Players.getLocal().isAnimating() && !Players.getLocal().isMoving()) {
if (!Bank.isOpen()) {
Bank.open();
}
}
if (Bank.isOpen()) {
Bank.depositAll(GOLD_BAR);
afterInteraction();
Bank.withdrawAll(GOLD_ORE);
afterInteraction();
Bank.close();
afterInteraction();
state = "toConveyor";
}
}
return 0;
}
}