i fixed the code layout guys, to get it working save this code as PPStalls.groovy.
Bugs/missing functions: stealing is quite slow, cannot compete with real players
Lack of banking and/or dropping
Does not support food
if some one can add any of these into this code, i would be greatful. thx
import org.osbot.script.Script;
import org.osbot.script.ScriptManifest;
import javax.swing.JComboBox;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import java.awt.Color;
import java.awt.Graphics;
@ScriptManifest(name = "PPStalls", author="PengPhin", version = 1.0D, info = "Only Supports upto Master Farmer")
class PPStalls extends Script {
enum State {
INPUT, IDLE, ROBBING,
}
Stall[] Stalls = [
new Stall("Seed Stall", [ 7053, 634 ] as int[]), // Add new Stalls here
new Stall("Cake Stall", [ 2561, 634 ] as int[]), // Add new Stalls here
new Stall("Silk Stall", [ 2560, 634 ] as int[]), // Add new Stalls here
] as Stall[];
State state = State.INPUT;
Stall Stall = null;
void onStart() {
if (state == State.INPUT) { showInput();
}
}
int onLoop() {
switch(state) {
case State.IDLE:
return idl();
case State.ROBBING:
return steal();
}
return 1000 + gRandom(400, 800);
}
int steal() {
def Stall = closestObject(Stall.getIds());
if (Stall != null) {
if (selectEntityOption(Stall, "Steal-from")) {
return 2000 + random(200, 500);
}
}
return 1000 + random(200, 1000);
}
void onPaint(Graphics g) {
g.setColor(new Color(0.1f, 0.1f, 0.1f, 0.7f));
g.fillRect(3, 308, 513, 30);
g.setColor(Color.GREEN);
g.drawString("PengPhins Robber | Stall: ${Stall.getName()} | State: ${state}", 10, 327);
}
void showInput() {
JPanel panel = new JPanel();
String[] Stalls = new String[this.Stalls.length];
for(int i = 0; i < Stalls.length; i++) {
Stalls[i] = this.Stalls[i].getName();
}
JComboBox combo = new JComboBox(Stalls);
panel.add(combo);
int ret = JOptionPane.showConfirmDialog(null, panel, "Select Stall", JOptionPane.OK_CANCEL_OPTION);
if (ret == JOptionPane.OK_OPTION) {
Stall = this.Stalls[combo.getSelectedIndex()];
state = State.ROBBING;
} else {
showInput();
//TODO: Add Banking, Food Support
}
}
class Stall {
private final String name;
private final int[] ids;
public Stall(String name, int[] ids) {
this.name = name;
this.ids = ids;
}
public String getName() {
return name;
}
public int[] getIds() {
return ids;
}
}
}