-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVFire.java
More file actions
177 lines (145 loc) · 5.75 KB
/
VFire.java
File metadata and controls
177 lines (145 loc) · 5.75 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
import org.hexbot.api.methods.core.MethodContext;
import org.hexbot.api.methods.interactive.GroundItems;
import org.hexbot.api.util.Condition;
import org.hexbot.api.util.Time;
import org.hexbot.api.wrapper.Area;
import org.hexbot.api.wrapper.GroundItem;
import org.hexbot.api.wrapper.Tile;
import org.hexbot.script.Category;
import org.hexbot.script.Employer;
import org.hexbot.script.ScriptManifest;
import org.hexbot.script.Worker;
import javax.swing.*;
import java.awt.*;
/**
* Created by Arturo on 3/8/14.
*/
@ScriptManifest(author = "countvidal", description = "Lights logs in Alkharid Bank, start it with tinderbox equipped and logs in first bank slot.", name = "VFire", category = Category.FIREMAKING)
public class VFire extends Employer {
Area bank = new Area(new Tile(3272,3173),new Tile(3269,3161));
Tile spot = new Tile(3291,3156);
String process = "";
String logs = "";
Boolean StartScript = false;
GUI GUI;
public VFire(MethodContext context) {
super(context);
}
@Override
public void onStart() {
GUI = new GUI();
GUI.setVisible(true);
while (!StartScript) {
Time.sleep(100);
}
submit(new Bank(context),new WalkToSpot(context),new Burn(context), new WalkToBank(context));
}
private class Bank extends Worker {
public Bank(MethodContext context) {
super(context);
// TODO Auto-generated constructor stub
}
@Override
public void work() {
process = "Banking";
if(context.bank.isOpen()){
context.bank.withdraw(logs,28);
} else {
context.bank.open();
}
}
@Override
public boolean validate() {
return bank.contains(context.players.getLocal()) && context.inventory.getCount(logs) == 0;
}
}
private class Burn extends Worker {
public Burn(MethodContext context) {
super(context);
// TODO Auto-generated constructor stub
}
@Override
public void work() {
process = "Burning logs";
if(context.inventory.isItemSelected() && !context.gameObjects.getAt(context.players.getLocal().getLocation()).getName().equals("Fire")){
if(context.inventory.getSelectedItem().equals(context.inventory.getItem("Tinderbox")) && context.players.getLocal().getAnimationIndex() == -1){
context.inventory.getItem(logs).click();
Time.waitFor(new Condition() {
public boolean accept() {
return context.players.getLocal().getAnimationIndex() != -1;
}
}, 2000);
} else if(context.players.getLocal().getAnimationIndex() == -1){
context.inventory.getSelectedItem().click();
}
} else if(!context.gameObjects.getAt(context.players.getLocal().getLocation()).getName().equals("Fire")){
context.inventory.getItem("Tinderbox").click();
} else if(context.gameObjects.getAt(context.players.getLocal().getLocation()).getName().equals("Fire")){
int range = (0 - -5) + 1;
context.walking.walk(new Tile(spot.getX(), spot.getY() + (int)(Math.random() * range) + -5));
}
}
@Override
public boolean validate() {
return context.inventory.contains(logs) && !bank.contains(context.players.getLocal());
}
}
private class WalkToBank extends Worker {
public WalkToBank(MethodContext context) {
super(context);
// TODO Auto-generated constructor stub
}
@Override
public void work() {
process = "Walking to Bank";
context.walking.walk(bank.getCentralTile());
}
@Override
public boolean validate() {
return !context.inventory.contains(logs) && context.groundItems.getNearest(logs) == GroundItem.EMPTY;
}
}
private class WalkToSpot extends Worker {
public WalkToSpot(MethodContext context) {
super(context);
// TODO Auto-generated constructor stub
}
@Override
public void work() {
process = "Walking to Stop";
context.walking.walk(spot);
}
@Override
public boolean validate() {
return context.inventory.contains(logs) && context.calculations.distanceBetween(context.players.getLocal().getLocation(),spot) > 20;
}
}
public class GUI extends JFrame {
public GUI(){
initComponents();
}
private void initComponents() {
JPanel Panel = new JPanel(new BorderLayout());
String[] a = {"Logs","Oak logs","Maple logs","Willow logs","Yew logs","Magic logs"};
final JComboBox options = new JComboBox(a);
JLabel instructions = new JLabel("Select Logs");
Panel.add(instructions,"North");
Panel.add(options,"Center");
JButton start = new JButton("Start");
Panel.add(start,"South");
start.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(final java.awt.event.ActionEvent evt) {
logs = options.getSelectedItem().toString();
StartScript = true;
dispose();
}
});
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle("VFire - Simple Fire Script");
Panel.setMinimumSize(new Dimension(300,100));
Panel.setSize(300,100);
this.add(Panel);
pack();
}
}
}