Created
September 9, 2020 21:15
-
-
Save Osplay/8fdfb8b95e0a3b208dd5eb07dff6c557 to your computer and use it in GitHub Desktop.
Broken Nature Rune Graber
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.osplay.ConfigForm"> | |
<grid id="27dc6" binding="rootPanel" layout-manager="GridLayoutManager" row-count="13" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> | |
<margin top="0" left="0" bottom="0" right="0"/> | |
<constraints> | |
<xy x="20" y="20" width="461" height="370"/> | |
</constraints> | |
<properties/> | |
<border type="none"/> | |
<children> | |
<component id="96b7a" class="javax.swing.JCheckBox" binding="logsCheckBox" default-binding="true"> | |
<constraints> | |
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/> | |
</constraints> | |
<properties> | |
<text value="Logs"/> | |
</properties> | |
</component> | |
<component id="5f0a9" class="javax.swing.JTextField" binding="a469476TextField" default-binding="true"> | |
<constraints> | |
<grid row="1" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"> | |
<preferred-size width="150" height="-1"/> | |
</grid> | |
</constraints> | |
<properties> | |
<text value="301,308,316,326,335,379,380,382-384,393,394,397-399,418,425,426,430,431,433-440,451-459,469-476,483,497-504"/> | |
<toolTipText value="Use: 469-476 to hop in that range or use specific worlds: 469,470,471,474-476"/> | |
</properties> | |
</component> | |
<component id="36fb8" class="javax.swing.JButton" binding="setConfigButton" default-binding="true"> | |
<constraints> | |
<grid row="12" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/> | |
</constraints> | |
<properties> | |
<text value="Set Config"/> | |
</properties> | |
</component> | |
<component id="28d62" class="javax.swing.JLabel"> | |
<constraints> | |
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> | |
</constraints> | |
<properties> | |
<text value="Worlds to hop:"/> | |
</properties> | |
</component> | |
<component id="cea98" class="javax.swing.JCheckBox" binding="prayerMagicCheckBox" default-binding="true"> | |
<constraints> | |
<grid row="8" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"> | |
<preferred-size width="152" height="21"/> | |
</grid> | |
</constraints> | |
<properties> | |
<text value="Prayer Magic"/> | |
</properties> | |
</component> | |
<component id="fd3ca" class="javax.swing.JCheckBox" binding="prayerRangeCheckBox" default-binding="true"> | |
<constraints> | |
<grid row="6" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/> | |
</constraints> | |
<properties> | |
<selected value="true"/> | |
<text value="Prayer Range"/> | |
</properties> | |
</component> | |
<component id="7003c" class="javax.swing.JCheckBox" binding="checkInventoryCheckBox" default-binding="true"> | |
<constraints> | |
<grid row="7" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/> | |
</constraints> | |
<properties> | |
<text value="Ignore Checkings"/> | |
</properties> | |
</component> | |
<component id="bb9d9" class="javax.swing.JCheckBox" binding="prayerSkinDefenseHighToCheckBox"> | |
<constraints> | |
<grid row="7" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/> | |
</constraints> | |
<properties> | |
<text value="Prayer skin defense (high to low select)"/> | |
</properties> | |
</component> | |
<component id="37f29" class="javax.swing.JCheckBox" binding="hopIfPlayerAppearCheckBox" default-binding="true"> | |
<constraints> | |
<grid row="8" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/> | |
</constraints> | |
<properties> | |
<selected value="true"/> | |
<text value="Hop if player NO PK appear"/> | |
<toolTipText value="Checked = Will hop instead of exit | Unchecked = Will Trigger LogOut"/> | |
</properties> | |
</component> | |
<component id="dc026" class="javax.swing.JCheckBox" binding="randomizeWorldsCheckBox" default-binding="true"> | |
<constraints> | |
<grid row="9" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/> | |
</constraints> | |
<properties> | |
<text value="Randomize worlds"/> | |
</properties> | |
</component> | |
<component id="dcad" class="javax.swing.JCheckBox" binding="grabUnsafeRuneCheckBox" default-binding="true"> | |
<constraints> | |
<grid row="10" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/> | |
</constraints> | |
<properties> | |
<selected value="false"/> | |
<text value="Grab unsafe rune"/> | |
<toolTipText value="This rune can make script fail or be kill for NPCs!"/> | |
</properties> | |
</component> | |
<component id="6bd76" class="javax.swing.JCheckBox" binding="returnAndBankCheckBox" default-binding="true"> | |
<constraints> | |
<grid row="10" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/> | |
</constraints> | |
<properties> | |
<text value="Return and bank"/> | |
<toolTipText value="this option will make the bot return to the east bank in varrok, will reserve energy, and will not use teleport."/> | |
</properties> | |
</component> | |
<component id="6df02" class="javax.swing.JCheckBox" binding="grabAsFastYouCheckBox" default-binding="true"> | |
<constraints> | |
<grid row="11" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/> | |
</constraints> | |
<properties> | |
<text value="Grab as fast you can the rune"/> | |
<toolTipText value="Will try to evade sleeps (fast but risky only if you wanna do suicide)"/> | |
</properties> | |
</component> | |
<component id="cdae2" class="javax.swing.JTextField" binding="mirrorbroTextField" default-binding="true"> | |
<constraints> | |
<grid row="5" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"> | |
<preferred-size width="150" height="-1"/> | |
</grid> | |
</constraints> | |
<properties> | |
<text value=""/> | |
</properties> | |
</component> | |
<component id="2ab28" class="javax.swing.JLabel"> | |
<constraints> | |
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> | |
</constraints> | |
<properties> | |
<text value="Player to ignore:"/> | |
<toolTipText value="the bot will ignore this player, so you can loot it."/> | |
</properties> | |
</component> | |
<component id="ceba9" class="javax.swing.JCheckBox" binding="loopWorldsCheckBox" default-binding="true"> | |
<constraints> | |
<grid row="9" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/> | |
</constraints> | |
<properties> | |
<text value="Loop worlds"/> | |
<toolTipText value="Will start again from the start using the last list"/> | |
</properties> | |
</component> | |
<component id="c4c96" class="javax.swing.JLabel"> | |
<constraints> | |
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> | |
</constraints> | |
<properties> | |
<text value="Items to grab in the bank:"/> | |
</properties> | |
</component> | |
<component id="3c07f" class="javax.swing.JTextField" binding="textField1" default-binding="true"> | |
<constraints> | |
<grid row="3" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"> | |
<preferred-size width="150" height="-1"/> | |
</grid> | |
</constraints> | |
<properties> | |
<toolTipText value="use: Name=amout,name2=amount like: Air rune=200,Fire rune=2,Jug of wine=all"/> | |
</properties> | |
</component> | |
</children> | |
</grid> | |
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.osplay; | |
import org.osbot.rs07.api.ui.PrayerButton; | |
import javax.swing.*; | |
import java.awt.event.ActionEvent; | |
import java.awt.event.ActionListener; | |
import java.awt.event.ItemEvent; | |
import java.awt.event.ItemListener; | |
import java.util.ArrayList; | |
import java.util.Arrays; | |
import java.util.Collections; | |
public class ConfigForm extends JFrame{ | |
private JTextField a469476TextField; | |
private JCheckBox logsCheckBox; | |
private JCheckBox checkInventoryCheckBox; | |
private JButton setConfigButton; | |
private JPanel rootPanel; | |
private JCheckBox prayerMagicCheckBox; | |
private JCheckBox prayerRangeCheckBox; | |
private JCheckBox prayerSkinDefenseHighToCheckBox; | |
private JCheckBox hopIfPlayerAppearCheckBox; | |
private JCheckBox randomizeWorldsCheckBox; | |
private JCheckBox grabUnsafeRuneCheckBox; | |
private JCheckBox returnAndBankCheckBox; | |
private JCheckBox grabAsFastYouCheckBox; | |
private JTextField mirrorbroTextField; | |
private JCheckBox loopWorldsCheckBox; | |
private JTextField textField1; | |
public ConfigForm(){ | |
add(rootPanel); | |
setConfigButton.addActionListener(new ActionListener() { | |
@Override | |
public void actionPerformed(ActionEvent e) { | |
if(a469476TextField.getText().isEmpty()){ | |
JOptionPane.showMessageDialog(null, "Ooops, you don't config the world!"); | |
} | |
try{ | |
String[] names = mirrorbroTextField.getText().split(","); | |
Main.PLAYER_WHO_IGNORE = Arrays.asList(names); | |
} catch (Exception exception) { | |
exception.printStackTrace(); | |
} | |
String[] worlds = a469476TextField.getText().split(","); | |
for (String world : | |
worlds) { | |
if(world.contains("-")) { | |
String[] uglyWord = world.split("-"); | |
if(uglyWord.length >= 3){ | |
JOptionPane.showMessageDialog(null, "Ooops, wrong format! " + uglyWord.length); | |
return; | |
} | |
if(uglyWord.length == 2){ | |
int start = Integer.parseInt(uglyWord[0]); | |
int end = Integer.parseInt(uglyWord[1]); | |
for(;start < end; start++){ | |
Main.CONFIGURATION.LIST_OF_WORLDS.add(start); | |
} | |
} | |
} else { | |
Main.CONFIGURATION.LIST_OF_WORLDS.add(Integer.parseInt(world)); | |
} | |
} | |
if(randomizeWorldsCheckBox.isSelected()) { | |
Collections.shuffle(Main.CONFIGURATION.LIST_OF_WORLDS); | |
} | |
if(loopWorldsCheckBox.isSelected()){ | |
Main.CONFIGURATION.MIRROR_LIST_OF_WORLDS = Main.CONFIGURATION.LIST_OF_WORLDS; | |
Main.CONFIGURATION.LOOP_WORLDS = true; | |
} else { | |
Main.CONFIGURATION.LOOP_WORLDS = false; | |
} | |
if(!textField1.getText().isEmpty()){ | |
String[] itemsToCarryList = textField1.getText().split(","); | |
for (String item : | |
itemsToCarryList) { | |
if(item.contains("=")){ | |
String[] keyValue = item.split("="); | |
if(keyValue.length == 1){ | |
Main.CONFIGURATION.LIST_CUSTOM_EXTRACTION.add(new String[] {keyValue[0],"all"}); | |
} else { | |
Main.CONFIGURATION.LIST_CUSTOM_EXTRACTION.add(new String[] {keyValue[0],keyValue[1]}); | |
} | |
} else { | |
JOptionPane.showMessageDialog(null, "Wrong format!"); | |
return; | |
} | |
} | |
Main.CONFIGURATION.CUSTOM_EXTRACTION = true; | |
} | |
} | |
}); | |
checkInventoryCheckBox.addItemListener(new ItemListener() { | |
@Override | |
public void itemStateChanged(ItemEvent e) { | |
if(e.getStateChange() == ItemEvent.SELECTED){ | |
Main.CONFIGURATION.CHECK_INVENTORY = false; | |
Main.PRAYER = true; | |
Main.SPELL = true; | |
} else { | |
Main.CONFIGURATION.CHECK_INVENTORY = true; | |
} | |
} | |
}); | |
logsCheckBox.addItemListener(new ItemListener() { | |
@Override | |
public void itemStateChanged(ItemEvent e) { | |
if(e.getStateChange() == ItemEvent.SELECTED){ | |
Main.CONFIGURATION.REPORTS_ENABLED = true; | |
} else { | |
Main.CONFIGURATION.REPORTS_ENABLED = false; | |
} | |
} | |
}); | |
prayerMagicCheckBox.addItemListener(new ItemListener() { | |
@Override | |
public void itemStateChanged(ItemEvent e) { | |
if(e.getStateChange() == ItemEvent.SELECTED){ | |
Main.PRAYER_TYPE = PrayerButton.PROTECT_FROM_MAGIC; | |
prayerMagicCheckBox.setSelected(false); | |
prayerRangeCheckBox.setSelected(false); | |
prayerSkinDefenseHighToCheckBox.setSelected(false); | |
} | |
} | |
}); | |
prayerRangeCheckBox.addItemListener(new ItemListener() { | |
@Override | |
public void itemStateChanged(ItemEvent e) { | |
if(e.getStateChange() == ItemEvent.SELECTED){ | |
Main.PRAYER_TYPE = PrayerButton.PROTECT_FROM_MISSILES; | |
prayerMagicCheckBox.setSelected(false); | |
prayerRangeCheckBox.setSelected(false); | |
prayerSkinDefenseHighToCheckBox.setSelected(false); | |
} | |
} | |
}); | |
prayerSkinDefenseHighToCheckBox.addItemListener(new ItemListener() { | |
@Override | |
public void itemStateChanged(ItemEvent e) { | |
if(e.getStateChange() == ItemEvent.SELECTED){ | |
Main.PRAYER_TYPE = PrayerButton.STEEL_SKIN; | |
prayerMagicCheckBox.setSelected(false); | |
prayerRangeCheckBox.setSelected(false); | |
} | |
} | |
}); | |
hopIfPlayerAppearCheckBox.addItemListener(new ItemListener() { | |
@Override | |
public void itemStateChanged(ItemEvent e) { | |
if(e.getStateChange() == ItemEvent.SELECTED){ | |
Main.HOP_WORLD_PLAYER_WITHOUT_PK = true; | |
} else{ | |
Main.HOP_WORLD_PLAYER_WITHOUT_PK = false; | |
} | |
} | |
}); | |
randomizeWorldsCheckBox.addItemListener(new ItemListener() { | |
@Override | |
public void itemStateChanged(ItemEvent e) { | |
if(e.getStateChange() == ItemEvent.SELECTED){ | |
Collections.shuffle(Main.CONFIGURATION.LIST_OF_WORLDS); | |
} | |
} | |
}); | |
grabUnsafeRuneCheckBox.addItemListener(new ItemListener() { | |
@Override | |
public void itemStateChanged(ItemEvent e) { | |
if(e.getStateChange() == ItemEvent.SELECTED){ | |
Main.GRAB_UNSAFE_RUNE = true; | |
} else { | |
Main.GRAB_UNSAFE_RUNE = false; | |
} | |
} | |
}); | |
returnAndBankCheckBox.addItemListener(new ItemListener() { | |
@Override | |
public void itemStateChanged(ItemEvent e) { | |
if(e.getStateChange() == ItemEvent.SELECTED){ | |
Main.GO_BANKING = true; | |
} else { | |
Main.GO_BANKING = false; | |
} | |
} | |
}); | |
grabAsFastYouCheckBox.addItemListener(new ItemListener() { | |
@Override | |
public void itemStateChanged(ItemEvent e) { | |
if(e.getStateChange() == ItemEvent.SELECTED){ | |
Main.FAST_GRAB = true; | |
} else { | |
Main.FAST_GRAB = false; | |
} | |
} | |
}); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.osplay; | |
import org.osbot.CON; | |
import org.osbot.rs07.api.map.Area; | |
import org.osbot.rs07.api.map.Position; | |
import org.osbot.rs07.api.model.*; | |
import org.osbot.rs07.api.ui.*; | |
import org.osbot.rs07.canvas.paint.Painter; | |
import org.osbot.rs07.event.WebWalkEvent; | |
import org.osbot.rs07.utility.ConditionalSleep; | |
import org.osbot.rs07.script.Script; | |
import org.osbot.rs07.script.ScriptManifest; | |
import org.osbot.rs07.utility.Condition; | |
import javax.swing.*; | |
import java.awt.*; | |
import java.util.ArrayList; | |
import java.util.HashMap; | |
import java.util.List; | |
import java.util.Map; | |
@ScriptManifest(author = "OsPlay", name = "BrokenNRG", info = "Telegrab Nature rune in the wildness, require Wine and Runes for the spell.", logo="", version = 0.6) | |
public class Main extends Script { | |
public static Boolean PRAYER = null; | |
public static Boolean SPELL = null; | |
public static CONFIG CONFIGURATION = new CONFIG(); | |
public STATUS STATUS_BOT = null; | |
public boolean ENDED = false; | |
private boolean FORCE_EXIT = false; | |
private boolean TELEPORT = false; | |
private boolean EXECUTED = false; | |
public static boolean GRAB_UNSAFE_RUNE = false; | |
public static PrayerButton PRAYER_TYPE = PrayerButton.PROTECT_FROM_MISSILES; | |
public static boolean GO_BANKING = false; | |
public static boolean STAFF_EQUIPED = false; | |
public static boolean FAST_GRAB = false; | |
public static List<String> PLAYER_WHO_IGNORE = new ArrayList<>(); | |
public static printer TEXT_WORLD = new printer(0); | |
ConfigForm configForm = new ConfigForm(); | |
public static boolean HOP_WORLD_PLAYER_WITHOUT_PK = true; | |
@Override | |
public void onStart() throws InterruptedException { | |
getBot().addPainter(TEXT_WORLD); | |
SwingUtilities.invokeLater(new Runnable() { | |
@Override | |
public void run() { | |
configForm.setSize(500,500); | |
configForm.setTitle("BrokenNRG - OsPlay v 0.6"); | |
configForm.setVisible(true); | |
} | |
}); | |
} | |
@Override | |
public void onExit() throws InterruptedException { | |
FORCE_EXIT = true; | |
configForm.setVisible(false); | |
} | |
@Override | |
public int onLoop() throws InterruptedException { | |
if(!client.isLoggedIn()) return 2000; | |
if(FORCE_EXIT){ | |
resetConfig(); | |
stop(); | |
} | |
sendReport("Print world text?"); | |
printWorld(); | |
sendReport("Is On World?"); | |
if(!IsPlayerOnAWorld()) return 1000; | |
setStatus(); | |
sendReport("Config?"); | |
if(!checkConfiguration()) tryExit(); | |
sendReport("Check config?"); | |
if(!checkItemsRequired()) tryExit(); | |
sendReport("Go to location to grab runes?"); | |
if(!goSafeToTheGrabSpot2()) tryExit(); | |
sendReport("Try to grab?"); | |
if(!tryToGrabRunes()) tryExit(); | |
sendReport("Try to hop world?"); | |
setReflexTime(); | |
sendReport("Check if you have to bank?"); | |
if(!iHaveToBank()) tryExit(); | |
if(!hopWorld()) tryExit(); | |
return 1000; | |
} | |
private void printWorld() { | |
sendReport("Set to new world!"); | |
TEXT_WORLD.set(worlds.getCurrentWorld()); | |
} | |
private void resetConfig() { | |
Boolean PRAYER = null; | |
Boolean SPELL = null; | |
CONFIG CONFIGURATION = new CONFIG(); | |
STATUS_BOT = null; | |
ENDED = false; | |
FORCE_EXIT = false; | |
TELEPORT = false; | |
EXECUTED = false; | |
GRAB_UNSAFE_RUNE = false; | |
PRAYER_TYPE = PrayerButton.PROTECT_FROM_MISSILES; | |
GO_BANKING = false; | |
STAFF_EQUIPED = false; | |
FAST_GRAB = false; | |
PLAYER_WHO_IGNORE = new ArrayList<>(); | |
CONFIGURATION.LIST_OF_WORLDS.removeAll(CONFIGURATION.LIST_OF_WORLDS); | |
} | |
private boolean iHaveToBank() throws InterruptedException { | |
sendReport("You have to bank?"); | |
if(SPELL || !GO_BANKING) return true; | |
sendReport("traveling to safe spot to varrok!"); | |
if(!goToVarrokSafe()) return false; | |
return false; | |
} | |
private boolean goToVarrokSafe() throws InterruptedException { | |
while (true){ | |
setStatus(); | |
if(imInDanger()) return false; | |
if(FORCE_EXIT) return false; | |
switch (STATUS_BOT){ | |
case WILDERNESS_GRAB_SAFE: | |
case WILDERNESS_GRAB: | |
case WILDERNESS_MULTI_COMBAT: | |
case WILDERNESS_SOLO_COMBAT: | |
case WILDERNESS_20: | |
sendReport("You have to go to varrok!"); | |
if(!goToVarrokDitchSafe()) return false; | |
break; | |
case SAFE: | |
sendReport("You're in the safe area!"); | |
return true; | |
} | |
sleep(1000); | |
} | |
} | |
private boolean goToVarrokDitchSafe() throws InterruptedException { | |
while (true){ | |
setStatus(); | |
if(imInDanger()) return false; | |
if(FORCE_EXIT) return false; | |
if(STATUS_BOT == STATUS.SAFE) return true; | |
int x = random(3329,3335); | |
int y = myPosition().getY()-random(10,20); | |
WebWalkEvent walk = setWalkToPosition(new Position(x,y,0), true); | |
execute(walk); | |
sendReport("Executing walking!"); | |
sleep(1000); | |
while (!walk.hasFailed() && !walk.hasFinished()){ | |
setStatus(); | |
if(imInDanger()) return false; | |
if(FORCE_EXIT) return false; | |
if(STATUS_BOT == STATUS.SAFE) return true; | |
takeFood(); | |
setReflexTime(); | |
} | |
if(myPosition().getY() < 3530){ | |
sendReport("You can jump the ditch?"); | |
Entity ditch = getObjects().closest("Wilderness Ditch"); | |
if(ditch != null){ | |
ditch.interact(); | |
} | |
} | |
sleep(250); | |
} | |
} | |
private boolean checkItemsRequired() throws InterruptedException { | |
if(imInDanger()) return false; | |
if(FORCE_EXIT) return false; | |
if(!CONFIGURATION.CHECK_INVENTORY) return true; | |
while (true){ | |
if(imInDanger()) return false; | |
if(FORCE_EXIT) return false; | |
sendReport("You can spell?"); | |
if(!checkMagicSpellIsOn()) return false; | |
sleep(2000); | |
if(EXECUTED) return true; // you already execute the prayer check! | |
sendReport("You can Prayer?"); | |
if(!checkIfHavePrayer()) return false; | |
sleep(2000); | |
if(PRAYER != null && SPELL != null){ | |
return true; | |
} | |
EXECUTED = true; | |
} | |
} | |
private boolean checkIfHavePrayer() throws InterruptedException { | |
if(!waitUntilTabIsOpen(Tab.PRAYER, false)){ | |
PRAYER = null; | |
return false; | |
} | |
if(PRAYER_TYPE == PrayerButton.STEEL_SKIN){ | |
PRAYER_TYPE = getPrayerSkinOptimal(); | |
} | |
if(PRAYER_TYPE == null){ | |
PRAYER = false; | |
return true; | |
} | |
if(getPrayer().hasLevelFor(PRAYER_TYPE)){ | |
PRAYER = true; | |
return true; | |
} | |
PRAYER = false; | |
return true; | |
} | |
private boolean checkMagicSpellIsOn() throws InterruptedException { | |
sendReport("Waiting for tab!"); | |
if(!waitUntilTabIsOpen(Tab.MAGIC,false)){ | |
SPELL = false; | |
return false; | |
} | |
sendReport("Try to spell cast varrok!"); | |
if(getMagic().canCast(Spells.NormalSpells.VARROCK_TELEPORT)){ | |
sendReport("You can teleport!"); | |
TELEPORT = true; | |
} | |
if (!getMagic().canCast(Spells.NormalSpells.TELEKINETIC_GRAB)) { | |
sendReport("You can't perform TELEKINETIC GRAB"); | |
sleep(2000); | |
sendReport("Equip Staff?"); | |
if (!equipStaff()){ | |
setStatus(); | |
if(STATUS_BOT == STATUS.SAFE){ | |
goBanking(); | |
} | |
} else { | |
STAFF_EQUIPED = true; | |
} | |
sendReport("Waiting for tab!"); | |
if(!waitUntilTabIsOpen(Tab.MAGIC,false)){ | |
SPELL = false; | |
return false; | |
} | |
sendReport("You equip the staff!"); | |
if(!getMagic().canCast(Spells.NormalSpells.TELEKINETIC_GRAB)){ | |
sendReport("But you don't have law runes?"); | |
setStatus(); | |
if(STATUS_BOT != STATUS.SAFE){ | |
sendReport("Going to solo combat to varrok?"); | |
if(!goToVarrokSafe()) return false; | |
} | |
sendReport("Go banking?"); | |
if(!goBanking()) return false; | |
} | |
SPELL = true; | |
} else { | |
sendReport("You can perform TELEKINETIC GRAB."); | |
SPELL = true; | |
return true; | |
} | |
return true; | |
} | |
private boolean equipStaff() throws InterruptedException { | |
int flag = 0; | |
while (true && flag < 3){ | |
if(imInDanger()) return false; | |
if(FORCE_EXIT) return false; | |
if(!waitUntilTabIsOpen(Tab.INVENTORY,false)) return false; | |
String[] staffs = { ITEMS.AIR_STAFF, ITEMS.MYSTIC_AIR_STAFF, ITEMS.AIR_BATTLE_STAFF }; | |
for (String staff : | |
staffs) { | |
Item item = getInventory().getItem(staff); | |
if(item != null){ | |
if(!item.interact("Wield")) return false; | |
STAFF_EQUIPED = true; | |
return true; | |
} | |
} | |
STAFF_EQUIPED = false; | |
sleep(1000); | |
flag++; | |
} | |
return false; | |
} | |
private boolean waitUntilTabIsOpen(Tab tab, boolean persistInDanger) throws InterruptedException { | |
if(getTabs().isOpen(tab)) return true; | |
if(!getTabs().open(tab)){ | |
sendReport("For some reason you can't open "+ tab.name() + " tab!"); | |
return false; | |
} | |
while (!getTabs().isOpen(tab)){ | |
sleep(1000); | |
if(!persistInDanger){ | |
sendReport("Will close the tab if i'm in danger!"); | |
if(imInDanger()) return false; | |
} | |
if(FORCE_EXIT) return false; | |
} | |
return true; | |
} | |
private boolean checkConfiguration() throws InterruptedException { | |
sendReport("Checking Configuration!"); | |
while (true){ | |
if(imInDanger()) return false; | |
if(FORCE_EXIT) return false; | |
if(!getClient().isLoggedIn()) stop(); | |
if(CONFIGURATION.LIST_OF_WORLDS.size() > 0){ | |
return true; | |
} | |
if(getCombat().isAutoRetaliateOn()){ | |
getCombat().toggleAutoRetaliate(false); | |
} | |
sleep(1000); | |
} | |
} | |
private void tryExit() throws InterruptedException { | |
sendReport("EXIT TRIGGERED!"); | |
if(iHaveToIgnorePlayer()) return; | |
if(!myPlayer().isUnderAttack() && !combat.isFighting()) logOut(); | |
setPrayer(true); | |
while (client.isLoggedIn()){ | |
sendReport("Async Walk set?"); | |
WebWalkEvent walk = new WebWalkEvent(new Position(random(3329,3335),myPosition().getY()-random(10,20),0)); | |
walk.setAsync(); | |
walk.setEnergyThreshold(random(5,10)); | |
execute(walk); | |
sendReport("Walk performed?"); | |
while (!walk.hasFinished() && !walk.hasFailed()){ | |
sendReport("Set Status"); | |
setStatus(); | |
sendReport("Take food"); | |
takeFood(); | |
if(STATUS_BOT == STATUS.WILDERNESS_20){ | |
sendReport("you're win lvl 20 or less of wilderness, can you teleport?"); | |
setPrayer(false); | |
tryToTeleport(); | |
} | |
sendReport("Logout?"); | |
if(getPlayers().getAll().size() < 2) logOut(); | |
sleep(350); | |
} | |
if(myPosition().getY() < 3335 ){ | |
sendReport("you're close to the ditch, jump!"); | |
jumpTheDitch(); | |
} | |
if(STATUS_BOT == STATUS.SAFE){ | |
setPrayer(false); | |
sendReport("go banking!"); | |
goBanking(); | |
return; | |
} | |
sleep(350); | |
} | |
stop(); | |
} | |
private boolean goBanking() throws InterruptedException { | |
// TODO BANKING DEBUG | |
while (true){ | |
if(FORCE_EXIT) return false; | |
sendReport("Go banking?"); | |
if(!goToBank()) return false; | |
sendReport("Check if you have equip the staff"); | |
if(!checkIfYouHaveStaff()) return false; | |
sendReport("Check what to do?"); | |
if(!doExtractionOrDeposit()) return false; | |
return true; | |
} | |
} | |
private boolean doExtractionOrDeposit() throws InterruptedException { | |
sendReport("Deposit or Extract function?"); | |
if(getInventory().isFull() || getInventory().getItem(ITEMS.NATURE_RUNE) != null){ | |
sendReport("Deposit?"); | |
if(!goDepositBank()) return false; | |
if(!goExtractBank()) return false; | |
} else { | |
sendReport("Extract?"); | |
if(!goExtractBank()) return false; | |
} | |
return true; | |
} | |
private boolean goExtractBank() throws InterruptedException { | |
sendReport("Can open the bank?"); | |
if(!getBank().open()) return false; | |
Timing.waitCondition(() -> getBank().isOpen(), 10000); | |
if(CONFIGURATION.CUSTOM_EXTRACTION){ | |
if(!customExtraction()) return false; | |
sendReport("Is bank close?"); | |
if(!getBank().close()) return false; | |
sendReport("If you have staff equip?"); | |
equipStaff(); | |
return true; | |
} | |
sendReport("Get Air Element"); | |
if(!getAirCastItem()) return false; | |
sleep(random(1000,3000)); | |
sendReport("Get Law Element"); | |
if(!getRuneLaw()) return false; | |
sleep(random(1000,3000)); | |
sendReport("Get Fire rune"); | |
if(!getFireRune()) return false; | |
sleep(random(1000,3000)); | |
sendReport("Get Food"); | |
if(!getFood()) return false; | |
sleep(random(1000,3000)); | |
sendReport("Is bank close?"); | |
if(!getBank().close()) return false; | |
sendReport("If you have staff equip?"); | |
equipStaff(); | |
return true; | |
} | |
private boolean customExtraction() throws InterruptedException { | |
sendReport("Custom extraction!"); | |
for (String[] items: | |
CONFIGURATION.LIST_CUSTOM_EXTRACTION) { | |
sendReport("Extract: " + items[0] + " the ammount: " + items[1]); | |
if(items[1].toLowerCase().contains("all")){ | |
if(!getBank().withdrawAll(items[0])){ | |
sendReport("Can't withdraw that item!"); | |
} | |
} else { | |
if(!getBank().withdraw(items[0], Integer.parseInt(items[1]))){ | |
sendReport("Can't withdraw that item!"); | |
} | |
} | |
sleep(random(1000,3000)); | |
} | |
return true; | |
//return true; | |
} | |
private boolean getFireRune() throws InterruptedException { | |
sendReport("Is bank open?"); | |
if(!getBank().open()) return false; | |
Timing.waitCondition(() -> getBank().isOpen(), 10000); | |
sendReport("Can withdraw law rune?"); | |
if(!getBank().withdraw(ITEMS.FIRE_RUNE, 2)) return false; | |
return true; | |
} | |
private boolean checkIfYouHaveStaff() throws InterruptedException { | |
if(!waitUntilTabIsOpen(Tab.EQUIPMENT,false)) return false; | |
sleep(random(1000,3000)); | |
if(getEquipment().isWearingItem(EquipmentSlot.WEAPON, item -> item.getName().contains("air"))){ | |
sendReport("You have air equip!"); | |
STAFF_EQUIPED = true; | |
} else { | |
sendReport("You don't have air equip!"); | |
STAFF_EQUIPED = false; | |
} | |
return true; | |
} | |
private boolean getFood() throws InterruptedException { | |
sendReport("Is bank open?"); | |
if(!getBank().open()) return false; | |
Timing.waitCondition(() -> getBank().isOpen(), 10000); | |
getBank().withdrawAllButOne(item -> item.hasAction("Drink")); | |
sleep(random(1000,3000)); | |
if(getInventory().getCapacity() > 1){ | |
getBank().withdrawAllButOne(item -> item.hasAction("Eat")); | |
} | |
sleep(random(1000,3000)); | |
if(getInventory().isFull()){ | |
getBank().deposit(item->item.hasAction("Drink"),1); | |
sleep(random(1000,3000)); | |
if(getInventory().isFull()){ | |
getBank().deposit(item->item.hasAction("Eat"), 1); | |
} | |
} | |
return true; | |
} | |
private boolean getRuneLaw() throws InterruptedException { | |
sendReport("Is bank open?"); | |
if(!getBank().open()) return false; | |
Timing.waitCondition(() -> getBank().isOpen(), 10000); | |
sendReport("Can withdraw law rune?"); | |
if(!getBank().withdraw(ITEMS.LAW_RUNE, 103)) return false; | |
return true; | |
} | |
private boolean getAirCastItem() { | |
sendReport("You're already haven an staff?"); | |
if(!STAFF_EQUIPED){ | |
sendReport("Is the bank open?"); | |
if(!getBank().isOpen()) return false; | |
String[] airStaffs = {ITEMS.MYSTIC_AIR_STAFF, ITEMS.AIR_BATTLE_STAFF, ITEMS.AIR_STAFF}; | |
boolean pickedStaff = false; | |
for (String staff : | |
airStaffs) { | |
if(getBank().getItem(staff) != null){ | |
if(!getBank().withdraw(staff, 1)) continue; | |
sendReport("Picked: " + staff); | |
pickedStaff = true; | |
break; | |
} | |
} | |
if(pickedStaff) return true; | |
sendReport("You don't have runes, so you must pick air runes."); | |
if(getBank().getItem(ITEMS.AIR_RUNE) == null) return false; | |
sendReport("You can grab air runes?"); | |
if(getBank().withdraw(ITEMS.AIR_RUNE, 103)) return true; | |
return false; | |
} else { | |
return true; | |
} | |
//return false; | |
} | |
private boolean goDepositBank() throws InterruptedException { | |
sendReport("Can open the bank?"); | |
if(!getBank().open()) return false; | |
Timing.waitCondition(() -> getBank().isOpen(), 10000); | |
sendReport("Bank is open?"); | |
if(!getBank().isOpen()) return false; | |
sendReport("Deposit all items that you don't need"); | |
String[] safeItems = {ITEMS.LAW_RUNE, ITEMS.AIR_RUNE, ITEMS.AIR_BATTLE_STAFF, | |
ITEMS.AIR_STAFF, ITEMS.MYSTIC_AIR_STAFF}; | |
for (Item item : | |
getInventory().getItems()) { | |
if(item != null){ | |
if(item.hasAction("Drink") || item.hasAction("Eat")) continue; | |
for (String itemText : | |
safeItems) { | |
if(item.getName().contains(itemText)) continue; | |
} | |
sendReport("Will bank the item: " + item.getName()); | |
getBank().depositAll(item.getId()); | |
} | |
} | |
return true; | |
} | |
private boolean tryToTeleport() throws InterruptedException { | |
setStatus(); | |
if(STATUS_BOT == STATUS.SAFE) return true; | |
if(!waitUntilTabIsOpen(Tab.MAGIC, true)) return false; | |
setReflexTime(); | |
if(!getMagic().canCast(Spells.NormalSpells.VARROCK_TELEPORT)){ | |
sendReport("You can't cast the spell!"); | |
TELEPORT = false; | |
return false; | |
} | |
getMagic().castSpell(Spells.NormalSpells.VARROCK_TELEPORT); | |
return true; | |
} | |
private void takeFood() throws InterruptedException { | |
if(myPlayer().getHealthPercent() > random(75,80)) return; | |
getTabs().open(Tab.INVENTORY); | |
setReflexTime(); | |
int f = 0; | |
while (!getTabs().open(Tab.INVENTORY) && f < 5){ | |
setReflexTime(); | |
f++; | |
} | |
for (Item item : | |
getInventory().getItems()) { | |
if(item == null) continue; | |
if(item.hasAction("Eat") || item.hasAction("Drink")){ | |
item.interact(); | |
return; | |
} | |
} | |
setReflexTime(); | |
} | |
private boolean hopWorld() throws InterruptedException { | |
int worldToHop = -1; | |
if(CONFIGURATION.LIST_OF_WORLDS.size() < 1){ | |
if(CONFIGURATION.LOOP_WORLDS){ | |
CONFIGURATION.LIST_OF_WORLDS = CONFIGURATION.MIRROR_LIST_OF_WORLDS; | |
} else { | |
logOut(); | |
return false; | |
} | |
} | |
worldToHop = CONFIGURATION.LIST_OF_WORLDS.get(0); | |
CONFIGURATION.LIST_OF_WORLDS.remove(0); | |
if(FORCE_EXIT) return false; | |
if(imInDanger()) return false; | |
if(getWorlds().getCurrentWorld() == worldToHop){ | |
return hopWorld(); | |
} else { | |
getWorlds().hop(worldToHop); | |
setReflexTime(); | |
setReflexTime(); | |
} | |
printWorld(); | |
return true; | |
} | |
private boolean tryToGrabRunes() throws InterruptedException { | |
while(true){ | |
setStatus(); | |
sleep(250); | |
takeFood(); | |
if(myPosition().getX() != COORDS.TELEGRAB_SAFE.getX() && | |
myPosition().getY() != COORDS.TELEGRAB_SAFE.getY()) { | |
sendReport(myPosition().toString()); | |
sendReport(COORDS.TELEGRAB_SAFE.toString()); | |
if (!goToUnsafeGrabSpotSafe()) return false; | |
continue; | |
} | |
sendReport("Perform telegrab!"); | |
if(!grabRune()) return false; | |
if(!COORDS.TELEGRAB.contains(myPosition())) continue; | |
sleep(250); | |
return true; | |
} | |
} | |
private boolean grabRune() throws InterruptedException { | |
// TODO DEBUG GRAB RUNE! | |
while (true){ | |
if(imInDanger()) return false; | |
if(FORCE_EXIT) return false; | |
if(FAST_GRAB){ | |
sendReport("Fast Grab?"); | |
if(!grabRuneFast()) return false; | |
} else { | |
sendReport("Slow Grab?"); | |
if(!grabRuneSlow()) return false; | |
} | |
sendReport("you can't spell?"); | |
if(!SPELL) return true; | |
sendReport("There's more items in the ground?"); | |
if(getGroundItems().closest(ITEMS.NATURE_RUNE) == null || | |
!GRAB_UNSAFE_RUNE) break; | |
} | |
return true; | |
} | |
private boolean grabRuneSlow() throws InterruptedException { | |
ConditionalSleep cc = new ConditionalSleep(random(700,1000)) { | |
@Override | |
public boolean condition() throws InterruptedException { | |
if(FORCE_EXIT) return true; | |
if(imInDanger()) return true; | |
return false; | |
} | |
}; | |
while(true){ | |
while(true){ | |
if(imInDanger()) return false; | |
if(FORCE_EXIT) return false; | |
if(!SPELL) return true; | |
/*cc.sleep(); | |
if(cc.condition()) return false;*/ | |
Entity rune = null; | |
if(GRAB_UNSAFE_RUNE){ | |
sendReport("select all include unsafe rune?"); | |
rune = getGroundItems().closest(ITEMS.NATURE_RUNE); | |
} else { | |
sendReport("select only safe rune?"); | |
rune = getGroundItems().closest(COORDS.ITEM_RUNE_SAFE, ITEMS.NATURE_RUNE); | |
} | |
sendReport("Exist?"); | |
if(rune == null) return true; | |
sendReport("Is visible?"); | |
getCamera().toEntity(rune); | |
cc.sleep(); | |
if(cc.condition()) return false; | |
sendReport("Open magic tab?"); | |
waitUntilTabIsOpen(Tab.MAGIC,false); | |
if(!getMagic().canCast(Spells.NormalSpells.TELEKINETIC_GRAB)){ | |
SPELL = false; | |
return true; | |
} | |
if(!getMagic().castSpell(Spells.NormalSpells.TELEKINETIC_GRAB)) return true; | |
cc.sleep(); | |
if(cc.sleep()) return false; | |
if(!rune.interact("Cast")) return true; | |
/*cc.sleep(); | |
if(cc.sleep()) return false;*/ | |
} | |
} | |
// return false; | |
} | |
private boolean grabRuneFast() throws InterruptedException { | |
while(true){ | |
if(imInDanger()) return false; | |
if(FORCE_EXIT) return false; | |
Entity rune = null; | |
if(GRAB_UNSAFE_RUNE){ | |
sendReport("select all include unsafe rune?"); | |
rune = getGroundItems().closest(ITEMS.NATURE_RUNE); | |
} else { | |
sendReport("select only safe rune?"); | |
rune = getGroundItems().closest(COORDS.ITEM_RUNE_SAFE, ITEMS.NATURE_RUNE); | |
} | |
sendReport("Exist?"); | |
if(rune == null) return true; | |
sendReport("Is visible?"); | |
getCamera().toEntity(rune); | |
setReflexTime(); | |
sendReport("Open magic tab?"); | |
waitUntilTabIsOpen(Tab.MAGIC,false); | |
if(!getMagic().canCast(Spells.NormalSpells.TELEKINETIC_GRAB)){ | |
SPELL = false; | |
return true; | |
} | |
if(!getMagic().castSpell(Spells.NormalSpells.TELEKINETIC_GRAB)) return true; | |
if(!rune.interact()) return true; | |
sleep(250); | |
} | |
// return false; | |
} | |
private boolean goToUnsafeGrabSpotSafe() throws InterruptedException { | |
while (true){ | |
setStatus(); | |
if(imInDanger()) return false; | |
if(FORCE_EXIT) return false; | |
if(COORDS.TELEGRAB_SAFE.equals(myPosition())) return true; | |
WebWalkEvent walk = setWalkToPosition(COORDS.TELEGRAB_SAFE, false); | |
execute(walk); | |
while (!walk.hasFinished() && !walk.hasFailed()){ | |
setStatus(); | |
if(imInDanger()) return false; | |
if(FORCE_EXIT) return false; | |
if(COORDS.TELEGRAB_SAFE.equals(myPosition())) return true; | |
takeFood(); | |
sleep(600); // tick time | |
} | |
if(COORDS.TELEGRAB.contains(myPosition()) && myPosition() != COORDS.TELEGRAB_SAFE){ | |
COORDS.TELEGRAB_SAFE.interact(getBot()); | |
} | |
sleep(250); | |
} | |
} | |
private void setReflexTime() throws InterruptedException { | |
sleep(random(CONFIGURATION.MIN_REFLEX_RESPONSE,CONFIGURATION.MAX_REFLEX_RESPONSE)); | |
} | |
private WebWalkEvent setWalkToPosition(Position positionToGo, boolean safe) throws InterruptedException { | |
WebWalkEvent webWalkEvent = new WebWalkEvent(new Position(positionToGo)); | |
if(safe){ | |
webWalkEvent.setMoveCameraDuringWalking(true); | |
webWalkEvent.setEnergyThreshold(101); | |
} else { | |
webWalkEvent.setMoveCameraDuringWalking(false); | |
webWalkEvent.setEnergyThreshold(random(0,10)); | |
} | |
webWalkEvent.setBreakCondition(new Condition() { | |
@Override | |
public boolean evaluate() { | |
try { | |
if(FORCE_EXIT) return true; | |
if(imInDanger()) return true; | |
return false; | |
} catch (InterruptedException e) { | |
e.printStackTrace(); | |
return true; | |
} | |
} | |
}); | |
webWalkEvent.setAsync(); | |
return webWalkEvent; | |
} | |
private boolean goSafeToTheGrabSpot2() throws InterruptedException { | |
while (true){ | |
setStatus(); | |
if(imInDanger()) return false; | |
if(FORCE_EXIT) return false; | |
switch (STATUS_BOT){ | |
case WILDERNESS_GRAB_SAFE: | |
return true; | |
case WILDERNESS_GRAB: | |
sendReport("You're in the pre-grab area!"); | |
if(!goToUnsafeGrabSpot()) return false; | |
return true; | |
case WILDERNESS_MULTI_COMBAT: | |
sendReport("You're in multi combat area!"); | |
if(checkIfGoGrabSpotOrSoloCombat()){ | |
sendReport("Going to solo combat!"); | |
if(!goToSafeGrabSpot()) return false; | |
} else { | |
sendReport("Going to multi combat!"); | |
if(!goToUnsafeGrabSpot()) return false; | |
} | |
break; | |
case WILDERNESS_SOLO_COMBAT: | |
sendReport("You're in the solo combat area!"); | |
if(!goToSafeGrabSpot()) return false; | |
break; | |
case WILDERNESS_20: | |
sendReport("You're in the solo combat area - teleport zone!"); | |
if(!goToSafeGrabSpot()) return false; | |
break; | |
case SAFE: | |
sendReport("You're in the safe area!"); | |
if(!goToSafeWilderness()) return false; | |
break; | |
} | |
takeFood(); | |
sleep(1000); | |
} | |
} | |
private boolean goToUnsafeGrabSpot() throws InterruptedException { | |
while (true){ | |
setStatus(); | |
if(imInDanger()) return false; | |
if(FORCE_EXIT) return false; | |
if(STATUS_BOT == STATUS.WILDERNESS_GRAB || STATUS_BOT == STATUS.WILDERNESS_GRAB_SAFE) return true; | |
WebWalkEvent walk = setWalkToPosition(new Position(myPosition().getX()+random(1,5),myPosition().getY()+random(10,40),0), true); | |
execute(walk); | |
while (!walk.hasFailed() && !walk.hasFinished()){ | |
setStatus(); | |
if(imInDanger()) return false; | |
if(FORCE_EXIT) return false; | |
takeFood(); | |
setReflexTime(); | |
} | |
sleep(250); | |
} | |
} | |
private boolean checkIfGoGrabSpotOrSoloCombat() { | |
Position temporalPosition = new Position(myPosition().getX(), 3329, 0); | |
if(myPosition().distance(temporalPosition) < myPosition().distance(COORDS.TELEGRAB_SAFE) && | |
myPosition().getY() < 3822){ | |
return true; | |
} else { | |
return false; | |
} | |
} | |
private boolean goToSafeGrabSpot() throws InterruptedException { | |
while (true){ | |
setStatus(); | |
if(imInDanger()) return false; | |
if(FORCE_EXIT) return false; | |
if(STATUS_BOT == STATUS.WILDERNESS_GRAB || STATUS_BOT == STATUS.WILDERNESS_GRAB_SAFE) return true; | |
int x = random(3329,3335); | |
int y = myPosition().getY()+ random(10,20); | |
WebWalkEvent walk = setWalkToPosition(new Position(x,y,0), true); | |
execute(walk); | |
sendReport("Executing walking!"); | |
sleep(1000); | |
while (!walk.hasFailed() && !walk.hasFinished()){ | |
setStatus(); | |
if(imInDanger()) return false; | |
if(FORCE_EXIT) return false; | |
if(STATUS_BOT == STATUS.WILDERNESS_GRAB || STATUS_BOT == STATUS.WILDERNESS_GRAB_SAFE || STATUS_BOT == STATUS.SAFE) return true; | |
takeFood(); | |
setReflexTime(); | |
} | |
sleep(250); | |
} | |
} | |
private boolean goToSafeWilderness() throws InterruptedException { | |
while (true){ | |
setStatus(); | |
if(imInDanger()) return false; | |
if(FORCE_EXIT) return false; | |
if(STATUS_BOT != STATUS.SAFE) return true; | |
sendReport("Require prayer altar?"); | |
if(requirePrayerRecharge() && PRAYER){ | |
goAndRechargePrayer(); | |
} | |
sendReport("Go to the Ditch!"); | |
if(!goToTheDitch()) return false; | |
sleep(1000); | |
sendReport("Jump!"); | |
if(!jumpTheDitch()) return false; | |
sleep(1000); | |
} | |
} | |
private boolean jumpTheDitch() throws InterruptedException { | |
while (true){ | |
sleep(1000); | |
setStatus(); | |
if(FORCE_EXIT) return false; | |
if(STATUS_BOT != STATUS.SAFE) return true; | |
Entity ditch = getObjects().closest("Wilderness Ditch"); | |
if(ditch == null){ | |
sendReport("You can't reach to the Wilderness ditch!"); | |
return false; | |
} | |
if(!ditch.interact()) continue; | |
while(!getWidgets().isVisible(475,11,1) ){ | |
setStatus(); | |
if(FORCE_EXIT) return false; | |
if(STATUS_BOT != STATUS.SAFE) return true; | |
sleep(2000); | |
} | |
RS2Widget joinChatButton = getWidgets().getWidgetContainingText("Enter Wilderness"); | |
if (joinChatButton != null && STATUS_BOT == STATUS.SAFE) { | |
joinChatButton.interact("Enter Wilderness"); | |
} | |
sleep(2000); | |
} | |
} | |
private void setStatus() { | |
if(myPosition().getY() > 3822){ | |
if(COORDS.TELEGRAB_SAFE == myPosition()){ | |
STATUS_BOT = STATUS.WILDERNESS_GRAB_SAFE; | |
} else { | |
STATUS_BOT = STATUS.WILDERNESS_GRAB; | |
} | |
return; | |
} | |
if(myPosition().getY() > 3662){ | |
if(myPosition().getX() >= 3329){ | |
STATUS_BOT = STATUS.WILDERNESS_SOLO_COMBAT; | |
} else { | |
STATUS_BOT = STATUS.WILDERNESS_MULTI_COMBAT; | |
} | |
return; | |
} | |
if(myPosition().getY() > 3520){ | |
if(myPosition().getX() >= 3329){ | |
STATUS_BOT = STATUS.WILDERNESS_20; | |
} else { | |
STATUS_BOT = STATUS.WILDERNESS_MULTI_COMBAT; | |
} | |
return; | |
} | |
STATUS_BOT = STATUS.SAFE; | |
} | |
private boolean goToTheDitch() throws InterruptedException { | |
while (true){ | |
if(FORCE_EXIT) return false; | |
if(COORDS.AREA_CROSS_DITCH_VARROK.contains(myPosition())) return true; | |
WebWalkEvent walk = setWalkToPosition(COORDS.AREA_CROSS_DITCH_VARROK.getRandomPosition(), true); | |
execute(walk); | |
int flag = 0; | |
while (!myPlayer().isMoving() && flag < 5){ | |
sleep(500); | |
flag++; | |
} | |
while (!walk.hasFinished() && !walk.hasFailed() && walk.isWorking() || walk.isQueued()){ | |
sleep(2000); | |
} | |
} | |
} | |
private boolean goAndRechargePrayer() throws InterruptedException { | |
while (true){ | |
if(FORCE_EXIT) return false; | |
WebWalkEvent walk = setWalkToPosition(COORDS.AREA_PRAYER_EAST_VARROK.getRandomPosition(), true); | |
execute(walk); | |
while (!walk.hasFinished() && !walk.hasFailed()){ | |
if(FORCE_EXIT); | |
sleep(1000); | |
} | |
if(walk.hasFailed()) continue; | |
if(!COORDS.AREA_PRAYER_EAST_VARROK.contains(myPosition())) continue; | |
Entity altar = getObjects().closest("Altar"); | |
if(altar == null){ | |
sendReport("You can't reach to the altar!"); | |
return false; | |
} | |
sendReport("Interact with the altar?"); | |
if(!altar.interact()){ | |
sendReport("You can't interact with the altar!"); | |
return false; | |
} | |
while (myPlayer().isMoving()){ | |
if(FORCE_EXIT) return false; | |
sleep(1000); | |
} | |
while (skills.getStatic(Skill.PRAYER) != getPrayerCharge()){ | |
if(FORCE_EXIT) return false; | |
sleep(1000); | |
} | |
return true; | |
} | |
} | |
private boolean requirePrayerRecharge() { | |
if(PRAYER){ | |
int lvl = getPrayerCharge(); | |
if(lvl == skills.getStatic(Skill.PRAYER)) return false; | |
sendReport("Your prayer level is: " + lvl); | |
if(lvl < 40){ | |
return true; | |
} else { | |
return false; | |
} | |
} | |
return false; | |
} | |
private int getPrayerCharge(){ | |
RS2Widget prayer = getWidgets().get(160,15); | |
if(prayer == null) return -1; | |
return Integer.parseInt(prayer.getMessage()); | |
} | |
private boolean imInDanger() throws InterruptedException { | |
if(STATUS_BOT == STATUS.SAFE) return false; | |
if(iHaveToIgnorePlayer()) return false; | |
List<Player> listOfPlayers = getPlayers().getAll(); | |
listOfPlayers.remove(myPlayer()); | |
if(listOfPlayers.size() == 0) return false; | |
for (Player player : | |
listOfPlayers) { | |
if(player.getSkullIcon() == 1 || !HOP_WORLD_PLAYER_WITHOUT_PK){ | |
sendReport("Pk player found, force logOut!"); | |
return true; | |
} else { | |
if(HOP_WORLD_PLAYER_WITHOUT_PK){ | |
if(hopWorld()){ | |
return true; | |
} else { | |
return false; | |
} | |
} | |
} | |
} | |
if(myPlayer().isUnderAttack() || getCombat().isFighting()){ | |
return true; | |
} | |
return false; | |
} | |
private boolean iHaveToIgnorePlayer() { | |
List<Player> players = getPlayers().getAll(); | |
for (Player player: | |
players) { | |
if(player != null){ | |
for (String playerNameToIgnore : | |
PLAYER_WHO_IGNORE) { | |
if(player.getName().contains(playerNameToIgnore)){ | |
return true; | |
} | |
} | |
} | |
} | |
return false; | |
} | |
private boolean IsPlayerOnAWorld() { | |
if(!client.isLoggedIn() && !myPlayer().isVisible() && | |
!myPlayer().isOnScreen()) return false; | |
return true; | |
} | |
private boolean setPrayer(boolean enable) throws InterruptedException { | |
if(!waitUntilTabIsOpen(Tab.PRAYER, false)) return false; | |
if(!getPrayer().hasLevelFor(PRAYER_TYPE)){ | |
sendReport("You don't have enough prayer level!"); | |
PRAYER = true; | |
return true; | |
} | |
if(enable){ | |
if(!getPrayer().isActivated(PRAYER_TYPE)){ | |
getPrayer().set(PRAYER_TYPE, true); | |
} | |
} else { | |
if(getPrayer().isActivated(PRAYER_TYPE)){ | |
getPrayer().set(PRAYER_TYPE, false); | |
} | |
} | |
return true; | |
} | |
private PrayerButton getPrayerSkinOptimal() { | |
PrayerButton[] prayerButtons = { PrayerButton.STEEL_SKIN, PrayerButton.ROCK_SKIN, PrayerButton.THICK_SKIN }; | |
for (PrayerButton prayerSkin : | |
prayerButtons) { | |
if(getPrayer().hasLevelFor(prayerSkin)){ | |
return prayerSkin; | |
} | |
} | |
return null; | |
} | |
private void logOut() throws InterruptedException { | |
sendReport("Triggered LogOut ->"); | |
if(FORCE_EXIT) return; | |
if(myPlayer().isUnderAttack() || getCombat().isFighting()) return; | |
sendReport("Try to perform logout ->"); | |
if(getTabs().getLogoutTab().logOut()){ | |
if(!client.isLoggedIn()){ | |
FORCE_EXIT = true; | |
} | |
} | |
sleep(250); | |
return; | |
} | |
private boolean goToBank() throws InterruptedException { | |
while (true) { | |
WebWalkEvent walk = setWalkToPosition(COORDS.BANKING_EX.getRandomPosition(), true); | |
execute(walk); | |
while (!walk.hasFailed() && !walk.hasFinished()) { | |
if (FORCE_EXIT) return false; | |
sleep(2000); | |
if(COORDS.BANKING_EX.contains(myPosition())) return true; | |
} | |
if(COORDS.BANKING_EX.contains(myPosition())) return true; | |
} | |
} | |
private void sendReport(String report) { | |
if(!CONFIGURATION.REPORTS_ENABLED) return; | |
log(report); | |
} | |
enum STATUS{ | |
SAFE, | |
WILDERNESS_20, | |
WILDERNESS_SOLO_COMBAT, | |
WILDERNESS_MULTI_COMBAT, | |
WILDERNESS_GRAB, | |
WILDERNESS_GRAB_SAFE; | |
} | |
static class ITEMS{ | |
public static final String NATURE_RUNE = "Nature rune"; | |
public static final String LAW_RUNE = "Law rune"; | |
public static final String AIR_RUNE = "Air rune"; | |
public static final String FIRE_RUNE = "Fire rune"; | |
public static final String AIR_STAFF = "Staff of air"; | |
public static final String AIR_BATTLE_STAFF = "Air battlestaff"; | |
public static final String MYSTIC_AIR_STAFF = "Mystic air staff"; | |
} | |
static class COORDS { | |
//3303 y = 3859 | |
public static final Position TELEGRAB_UNSAFE = new Position(3302,3855,0); | |
public static final Position TELEGRAB_SAFE = new Position(3303,3859,0); | |
public static final Area TELEGRAB = new Area(3301,3861,3303,3859); | |
public static final Area BANKING_EX = new Area(3250,3420,3254,3422); | |
public static final Position FIRST_SAFE_SPOT = new Position(3343,3822,0); | |
public static final Position SECOND_SAFE_SPOT = new Position(3347,3662,0); | |
public static final Position SAFE_ZONE = new Position(3325,3523,0); | |
public static final Area ITEM_RUNE_SAFE = new Area(3307,3859,3308,3860); | |
public static final Area AREA_CROSS_DITCH_VARROK = new Area(3301,3518,3320,3521); | |
public static final Area AREA_PRAYER_EAST_VARROK = new Area(3253,3479,3255,3483); | |
} | |
} | |
class CONFIG{ | |
public static boolean CUSTOM_EXTRACTION = false; | |
public static boolean CHECK_INVENTORY = true; | |
public List<Integer> LIST_OF_WORLDS = new ArrayList<>(); | |
public List<Integer> MIRROR_LIST_OF_WORLDS = new ArrayList<>(); | |
public static List<String[]> LIST_CUSTOM_EXTRACTION = new ArrayList<>(); | |
public boolean LOOP_WORLDS = false; | |
public boolean REPORTS_ENABLED = true; | |
public int MIN_REFLEX_RESPONSE = 451; | |
public int MAX_REFLEX_RESPONSE = 921; | |
} | |
class printer implements Painter { | |
int world = 0; | |
@Override | |
public void onPaint(Graphics2D graphics2D) { | |
graphics2D.setFont(graphics2D.getFont().deriveFont(18.0f)); | |
graphics2D.setColor(Color.RED); | |
graphics2D.drawString("WORLD: " + this.world, 10, 20); | |
} | |
public printer(int world){ | |
this.world = world; | |
} | |
public void set(int world){ | |
this.world = world; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.osplay; | |
import java.util.function.BooleanSupplier; | |
import java.util.concurrent.TimeUnit; | |
import org.osbot.rs07.utility.ConditionalSleep; | |
/** | |
* Static utility class with various methods that are related | |
* to time / timing. | |
* | |
* @author The Viking | |
* | |
*/ | |
public class Timing | |
{ | |
/** | |
* Calculates the time, in ms, from a specific mark | |
* | |
* @param mark The initial time mark we're calculating from | |
* @return The time, in ms, from the provided mark | |
*/ | |
public static long timeFromMark(long mark) | |
{ | |
return System.currentTimeMillis() - mark; | |
} | |
/** | |
* Returns the current time in ms. Essentially just a shorter | |
* wrapper for System.currentTimeMillis() | |
* | |
* @return The current time, in ms | |
*/ | |
public static long currentMs() | |
{ | |
return System.currentTimeMillis(); | |
} | |
/** | |
* Converts a time, in ms, to a pretty String in hh:mm:ss:SSS format | |
* | |
* @param ms The time, in ms, to convert | |
* @return A string representing the current time | |
*/ | |
public static String msToString(long ms) | |
{ | |
return String.format("%02d:%02d:%02d", TimeUnit.MILLISECONDS.toHours(ms), | |
TimeUnit.MILLISECONDS.toMinutes(ms) % TimeUnit.HOURS.toMinutes(1), | |
TimeUnit.MILLISECONDS.toSeconds(ms) % TimeUnit.MINUTES.toSeconds(1)); | |
} | |
/** | |
* This method waits for a specific condition | |
* to be true within a maximum amount of time. Your | |
* basic conditional sleep. This method uses the BooleanSupplier functional interface, so it provides lambda support | |
* | |
* @param condition the condition to wait for | |
* @param cycleTime the time, in ms, between condition checks | |
* @param timeout the maximum time to wait for the condition to be true | |
* @return true if the condition was met within the threshold, or false if the timeout was exceeded | |
*/ | |
public static boolean waitCondition(BooleanSupplier condition, int cycleTime, int timeout) | |
{ | |
return new ConditionalSleep(timeout, cycleTime) | |
{ | |
@Override | |
public boolean condition() | |
{ | |
try | |
{ | |
return condition.getAsBoolean(); | |
} | |
catch(Exception e) | |
{ | |
e.printStackTrace(); | |
} | |
return false; | |
} | |
}.sleep(); | |
} | |
/** | |
* This method waits for a specific condition to be true within a maximum amount of time. Your | |
* basic conditional sleep. This method uses the BooleanSupplier functional interface, so it provides lambda support | |
* | |
* @param condition the condition to wait for | |
* @param timeout the maximum time to wait for the condition to be true | |
* @return true if the condition was met within the threshold, or false if the timeout was exceeded | |
*/ | |
public static boolean waitCondition(BooleanSupplier condition, int timeout) | |
{ | |
return waitCondition(condition, 20, timeout); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment