Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*
- import org.osbot.script.Script
- import org.osbot.script.ScriptManifest
- import org.osbot.script.mouse.*
- import org.osbot.script.rs2.*
- import org.osbot.script.rs2.map.Position
- import org.osbot.script.rs2.model.GroundItem
- import org.osbot.script.rs2.model.Item
- import org.osbot.script.rs2.model.PrimaryObject
- import org.osbot.script.rs2.model.RS2Object
- import org.osbot.script.rs2.ui.*
- @ScriptManifest(name = "CoalPowerminer", author="Xerion & that1guy", version = 1.2D, info = "CoalPowerminer")
- class CoalPowerminer extends Script {
- enum State {
- START, IDLE, MINING, DROP, BANK, BANKING
- }
- private final Color color1 = new Color(0.1f, 0.1f, 0.1f, 0.7f);
- private final Color color2 = new Color(255, 0, 0);
- private final Font font1 = new Font("Calisto MT", 0, 16);
- private final Font font2 = new Font("Calisto MT", 0, 11);
- int[] pickhandle = [480,482,484,486,488,490];
- int[] coal = [ 2096,2097,11963,11964,11965,11930,11931,11932,14850,14851,14852];
- int[] items = [480,482,484,486,488,490,1265 , 1267, 1269, 1271,1273,1275,1617,1619,1621,1623]
- def timeout = null;
- def starttime = null;
- def Newantiban = null;
- def MinedOre = 0;
- boolean Antibans = true
- State state = State.START;
- PrimaryObject currentRock = null;
- void onStart() {
- starttime = System.currentTimeMillis();
- Newantiban = System.currentTimeMillis() + random(10000, 20000);
- def th = Thread.start {
- antiban()
- }
- if (client.getInventory().isFull()){
- state = State.DROP;
- }
- else { state = State.IDLE; }
- }
- int onLoop() {
- if (!randoms()){
- switch(state) {
- case State.IDLE:
- return mine();
- case State.MINING:
- return check();
- case State.DROP:
- return drop();
- }
- }
- return 1000 + gRandom(400, 800);
- }
- int mine() {
- currentRock = closestObject(coal);
- if (currentRock != null) {
- if (selectEntityOption(currentRock, "Mine")) {
- timeout = Calendar.instance.timeInMillis / 1000
- state = State.MINING;
- }
- }
- return 100;
- }
- int check(){
- if (!currentRock.exists() || !currentRock.getId() == 11435 ||timeout + 15 < Calendar.instance.timeInMillis / 1000){
- if (!client.getInventory().isFull()){
- state = State.IDLE;
- return 500 + random(100, 1000)
- }
- else {
- if (currentTab() != Tab.INVENTORY){
- openTab(Tab.INVENTORY);
- }
- state = State.DROP;
- return 500 + random(100, 1000)
- }
- }
- return 100
- }
- boolean randoms(){
- //Losing Pickhandle
- GroundItem[] list = client.currentRegion.getItems()
- for(GroundItem g : list){
- for(int i : pickhandle){
- if (i == g.getId()){
- selectEntityOption(g,"Take")
- sleep(500 + random(500,1000))
- return true
- }
- }
- }
- }
- int drop(){
- client.getInventory().dropAllExcept(items)
- state = State.IDLE;
- return 1000 + random(500,4000)
- }
- void onMessage(String message){
- if ("You manage to mine some coal." == message){
- MinedOre++
- }
- else if (message == "This rock contains coal." || message == "There is no ore currently available in this rock."){
- state = State.IDLE;
- }
- }
- void onExit(){
- Antibans = false
- }
- void onPaint(Graphics g) {
- g.setColor(color1);
- g.fillRect(1, 51, 209, 94);
- g.setFont(font1);
- g.setColor(color2);
- g.drawString("CoalPowerminer", 7, 76);
- g.setFont(font2);
- g.drawString("Time: " + format(System.currentTimeMillis() - starttime), 7, 130);
- g.drawString("Ore: Coal(${MinedOre})", 7, 100);
- g.drawString("State: ${state}", 7, 115);
- }
- String format(final long time) {
- final StringBuilder t = new StringBuilder();
- final long total_secs = time / 1000;
- final long total_mins = total_secs / 60;
- final long total_hrs = total_mins / 60;
- final int secs = (int) total_secs % 60;
- final int mins = (int) total_mins % 60;
- final int hrs = (int) total_hrs % 24;
- if (hrs < 10) {
- t.append("0");
- }
- t.append(hrs);
- t.append(":");
- if (mins < 10) {
- t.append("0");
- }
- t.append(mins);
- t.append(":");
- if (secs < 10) {
- t.append("0");
- }
- else if (secs < 0){
- t.append("0")
- }
- else{
- t.append(secs);
- }
- return t.toString();
- }
- void antiban(){
- while(Antibans){
- if (state == State.MINING && Newantiban < System.currentTimeMillis()){
- int Anti = random(0 , 3)
- switch(Anti){
- case 0:
- log("Antiban: Move mouse")
- moveMouseOutsideScreen()
- Newantiban = System.currentTimeMillis() + random(40000, 120000)
- break;
- case 1:
- log("Antiban: Move camera")
- client.moveCameraToEntity(currentRock)
- Newantiban = System.currentTimeMillis() + random(40000, 120000)
- break;
- case 2:
- log("Antiban: Open Skills tab")
- if (currentTab() != Tab.SKILLS){
- openTab(Tab.SKILLS);
- }
- Newantiban = System.currentTimeMillis() + random(40000, 120000)
- break;
- case 3:
- log("Antiban: Open Friends tab")
- if (currentTab() != Tab.FRIENDS){
- openTab(Tab.FRIENDS);
- }
- Newantiban = System.currentTimeMillis() + random(40000, 120000)
- break;
- }
- }
- Thread.sleep(1000)
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment