package theiving;
import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.map.Position;
import org.osbot.rs07.api.model.Entity;
import org.osbot.rs07.api.ui.Skill;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import java.util.concurrent.TimeUnit;
import java.awt.*;
@ScriptManifest(author = "Sherbie", info = "My first script", name = "Warrior thiever", version = 0.7, logo = "")
public class main extends Script {
private int count = 0;
private int failed = 0;
public int Lobster;
private long timeBegan = System.currentTimeMillis();
private long timeRan;
private int beginningXP;
private int currentXp;
private int xpGained;
private int xpPerHour;
private double nextLevelXp;
private double xpTillNextLevel;
private long timeTNL;
public final static Area door_tile = new Area(3287, 3172, 3287, 3271);
final int[] XP_TABLE =
{
0, 0, 83, 174, 276, 388, 512, 650, 801, 969, 1154,
1358, 1584, 1833, 2107, 2411, 2746, 3115, 3523, 3973, 4470, 5018,
5624, 6291, 7028, 7842, 8740, 9730, 10824, 12031, 13363, 14833,
16456, 18247, 20224, 22406, 24815, 27473, 30408, 33648, 37224,
41171, 45529, 50339, 55649, 61512, 67983, 75127, 83014, 91721,
101333, 111945, 123660, 136594, 150872, 166636, 184040, 203254,
224466, 247886, 273742, 302288, 333804, 368599, 407015, 449428,
496254, 547953, 605032, 668051, 737627, 814445, 899257, 992895,
1096278, 1210421, 1336443, 1475581, 1629200, 1798808, 1986068,
2192818, 2421087, 2673114, 2951373, 3258594, 3597792, 3972294,
4385776, 4842295, 5346332, 5902831, 6517253, 7195629, 7944614,
8771558, 9684577, 10692629, 11805606, 13034431, 200000000
};
private Position[] path = {
new Position(3290, 3174, 0),
new Position(3293, 3178, 0),
new Position(3288, 3181, 0),
new Position(3281, 3180, 0),
new Position(3276, 3175, 0),
new Position(3274, 3170, 0),
new Position(3270, 3166, 0),
};
private Position[] path2 = {
new Position(3270, 3166, 0),
new Position(3274, 3170, 0),
new Position(3276, 3175, 0),
new Position(3281, 3180, 0),
new Position(3288, 3181, 0),
new Position(3293, 3178, 0),
new Position(3290, 3174, 0),
};
@Override
public void onStart() {
timeBegan = System.currentTimeMillis();
beginningXP = skills.getExperience(Skill.THIEVING);
timeTNL = 0;
log("Welcome to Simple Al-Kharid Warrior Pickpocketer");
log("If you experience any issues while running this script please report them to me on the forums.");
log("Enjoy the script, gain some thieving levels!.");
}
private enum State {
BANK, STEAL, EAT, WAIT
};
private State getState() {
if(inventory.isEmptyExcept("Coins"))
return State.BANK;
Entity warrior = npcs.closest("Al-Kharid warrior");
if (warrior != null)
return State.STEAL;
if(myPlayer().getHealth() <= 30)
return State.EAT;
return State.WAIT;
}
@Override
public int onLoop() throws InterruptedException {
switch (getState()) {
case BANK:
Entity door = objects.closest(door_tile, 6837);
if (door.exists()) {
log("Opening door.");
door.interact("Open");
} else {
log("Cannot find door.");
localWalker.walkPath(path);
sleep(random(400, 650));
objects.closest("Bank booth").interact("Bank");
sleep(random(300, 900));
if (getBank().isOpen()) {
getBank().withdraw("Lobster", 10);
} else {
Entity b = objects.closest("Bank booth");
if (b != null && b.exists())
b.interact("Bank");
sleep(random(400, 600));
localWalker.walkPath(path2);
}
if (door.exists()) {
log("Opening door.");
door.interact("Open");
} else
log("Cannot find door.");
}
break;
case STEAL:
Entity warrior = npcs.closest("Al-Kharid warrior");
if(myPlayer().getHeight() > 220) {
sleep(random(5000, 7500));
failed = +1;
}
if (warrior != null) {
warrior.interact("Pickpocket");
count = +1;
sleep(random(300, 500));
}
break;
case EAT:
this.inventory.interact(this.inventory.getSlot("Lobster"), "Eat");
break;
case WAIT:
sleep(random(200, 800));
break;
} return random(200, 300);
}
@Override
public void onExit() {
log("Thanks for running my Thiever!");
}
@Override
public void onPaint(Graphics2D g) {
timeRan = System.currentTimeMillis() - this.timeBegan;
currentXp = skills.getExperience(Skill.THIEVING);
xpPerHour = (int)( xpGained / ((System.currentTimeMillis() - this.timeBegan) / 3600000.0D));
xpGained = currentXp - beginningXP;
xpTillNextLevel = nextLevelXp - currentXp;
if (xpGained >= 1)
{
timeTNL = (long) ((xpTillNextLevel / xpPerHour) * 3600000);
}
super.onPaint(g);
g.setColor(Color.WHITE);
g.drawString("Start XP: " + beginningXP, 5, 280);
g.drawString("Next Level" + ft(timeTNL), 5, 290);
g.drawString("XP Gained" + xpGained, 5, 300);
g.setColor(Color.GREEN);
g.drawString("Pockets Attepmted: " + count, 5, 310);
g.drawString(ft(timeRan), 5, 320);
g.setColor(Color.ORANGE);
g.drawString("Failed: " + failed, 5, 330);
}
private String ft(long duration)
{
String res = "";
long days = TimeUnit.MILLISECONDS.toDays(duration);
long hours = TimeUnit.MILLISECONDS.toHours(duration)
- TimeUnit.DAYS.toHours(TimeUnit.MILLISECONDS.toDays(duration));
long minutes = TimeUnit.MILLISECONDS.toMinutes(duration)
- TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS
.toHours(duration));
long seconds = TimeUnit.MILLISECONDS.toSeconds(duration)
- TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS
.toMinutes(duration));
if (days == 0) {
res = (hours + ":" + minutes + ":" + seconds);
} else {
res = (days + ":" + hours + ":" + minutes + ":" + seconds);
}
return res;
}
}
I'm a complete noob, so I bet it's terrible.. That's my whole code for it If you see anything that can be done better please let me know aha