Last active
August 29, 2015 14:19
-
-
Save lawdeedaw/7fcfbeaaef789c2ed45b to your computer and use it in GitHub Desktop.
LawRogueCooker
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
import java.awt.EventQueue; | |
import java.awt.event.ActionEvent; | |
import java.awt.event.ActionListener; | |
import javax.swing.JButton; | |
import javax.swing.JFrame; | |
import javax.swing.JLabel; | |
import javax.swing.JPanel; | |
import javax.swing.JTextField; | |
import javax.swing.border.EmptyBorder; | |
import java.awt.Color; | |
public class GUI extends JFrame{ | |
/** | |
* | |
*/ | |
private JFrame frame; | |
private String foodName; | |
private int antiBanLevel; | |
public String getFoodName(){ | |
return foodName; | |
} | |
public int getAntiBanLevel(){ | |
return antiBanLevel; | |
} | |
/** | |
* Launch the application. | |
*/ | |
private JPanel contentPane; | |
private static final long serialVersionUID = 1L; | |
private JTextField textField; | |
private JTextField antibanTextField; | |
public static void main(String[] args) { | |
EventQueue.invokeLater(new Runnable() { | |
public void run() { | |
try { | |
GUI window = new GUI(); | |
window.frame.setVisible(true); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
} | |
}); | |
} | |
/** | |
* Create the application. | |
*/ | |
public GUI() { | |
setBackground(new Color(51, 51, 51)); | |
setTitle("Rogue Cooker"); | |
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); | |
setBounds(100, 100, 280, 219); | |
contentPane = new JPanel(); | |
contentPane.setBackground(new Color(51, 51, 51)); | |
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); | |
setContentPane(contentPane); | |
contentPane.setLayout(null); | |
JLabel lblSelectTheArea = new JLabel("Food to cook:"); | |
lblSelectTheArea.setForeground(new Color(255, 255, 255)); | |
lblSelectTheArea.setBackground(new Color(255, 255, 255)); | |
lblSelectTheArea.setBounds(90, 18, 77, 14); | |
contentPane.add(lblSelectTheArea); | |
textField = new JTextField(); | |
textField.setBounds(90, 43, 86, 20); | |
contentPane.add(textField); | |
textField.setColumns(10); | |
JLabel lblAntiBanLvl = new JLabel("Anti ban lvl(1-5, 1 being most frequant):"); | |
lblAntiBanLvl.setForeground(Color.WHITE); | |
lblAntiBanLvl.setBounds(22, 74, 233, 14); | |
contentPane.add(lblAntiBanLvl); | |
antibanTextField = new JTextField(); | |
antibanTextField.setBounds(90, 99, 86, 20); | |
contentPane.add(antibanTextField); | |
antibanTextField.setColumns(10); | |
JButton btnStart = new JButton("Start"); | |
btnStart.setForeground(new Color(102, 102, 102)); | |
btnStart.setBackground(new Color(153, 153, 153)); | |
btnStart.addActionListener(new ActionListener() { | |
public void actionPerformed(ActionEvent e) { | |
String temp = "aw " + textField.getText(); | |
foodName = "R" + temp.toLowerCase(); | |
antiBanLevel = Integer.parseInt(antibanTextField.getText()); | |
setVisible(false); | |
} | |
}); | |
btnStart.setBounds(90, 145, 86, 23); | |
contentPane.add(btnStart); | |
} | |
} |
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
import org.dreambot.api.methods.Calculations; | |
import org.dreambot.api.methods.map.Tile; | |
import org.dreambot.api.methods.skills.Skill; | |
import org.dreambot.api.methods.tabs.Tab; | |
import org.dreambot.api.script.AbstractScript; | |
import org.dreambot.api.script.Category; | |
import org.dreambot.api.script.ScriptManifest; | |
import org.dreambot.api.utilities.Timer; | |
import org.dreambot.api.utilities.impl.Condition; | |
import org.dreambot.api.wrappers.interactive.GameObject; | |
import org.dreambot.api.wrappers.interactive.NPC; | |
import org.dreambot.api.wrappers.items.Item; | |
import org.dreambot.api.wrappers.widgets.WidgetChild; | |
import org.dreambot.api.wrappers.widgets.message.Message; | |
import java.awt.*; | |
import java.awt.image.BufferedImage; | |
import java.io.IOException; | |
import java.net.MalformedURLException; | |
import java.net.URL; | |
import javax.imageio.ImageIO; | |
@ScriptManifest(name = "Rogues Den Cooker", author = "lawdeedaw", description = "", version = 1, category = Category.COOKING) | |
public class Main extends AbstractScript { | |
private Timer t = new Timer(); | |
private String foodName; | |
private int antiBanLevel; | |
private final GUI gui = new GUI(); | |
private WidgetChild amnt = null; | |
private WidgetChild lvlUp = null; | |
private WidgetChild cookHelp = null; | |
private BufferedImage image; | |
private int burnCount; | |
private int cookCount; | |
private final Tile cookTile = new Tile(3043, 4972, 1); | |
public WidgetChild getlvlUpChild(){ | |
if(lvlUp == null){ | |
lvlUp = getWidgets().getChildWidget(233, 0); | |
} | |
return lvlUp; | |
} | |
public WidgetChild getCookHelpChild(){ | |
if(cookHelp == null){ | |
cookHelp = getWidgets().getChildWidget(307, 7); | |
} | |
return cookHelp; | |
} | |
public WidgetChild getAmntChild(){ | |
if(needToBank()){ | |
amnt = null; | |
} else if(amnt == null && needToCook()){ | |
amnt = getWidgets().getChildWidget(307, 4); | |
} | |
return amnt; | |
} | |
@Override | |
public void onStart() { | |
burnCount = 0; | |
cookCount = 0; | |
try { | |
image = ImageIO.read(new URL("http://i.imgur.com/otRed8O.png")); | |
} catch (MalformedURLException e) { | |
e.printStackTrace(); | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} | |
getSkillTracker().start(Skill.COOKING); | |
if(foodName == null){ | |
gui.setVisible(true); | |
while (gui.isVisible()) { | |
sleep(600); | |
} | |
foodName = gui.getFoodName(); | |
antiBanLevel = (gui.getAntiBanLevel() * 100); | |
t = new Timer(); | |
gui.dispose(); | |
} | |
} | |
private boolean needToBank(){ | |
return !getInventory().contains(foodName); | |
} | |
private boolean needToCook(){ | |
return getInventory().contains(foodName); | |
} | |
@Override | |
public int onLoop() { | |
GameObject fire = getGameObjects().closest("Fire"); | |
NPC banker = getNpcs().closest("Emerald Benedict"); | |
Item rawFood = getInventory().get(foodName); | |
if(!getLocalPlayer().getTile().equals(cookTile) && !needToBank()){ | |
getWalking().walk(cookTile); | |
sleep(500, 1000); | |
} | |
if(needToCook()){ | |
if(!getTabs().isOpen(Tab.INVENTORY)) | |
getTabs().open(Tab.INVENTORY); | |
rawFood.interact("Use"); | |
sleep(50, 80); | |
fire.interact("Use"); | |
sleepUntil(new Condition() { | |
public boolean verify() { | |
return getAmntChild() != null && getCookHelpChild().isVisible(); | |
} | |
}, Calculations.random(1000, 1200 )); | |
if(getAmntChild() != null && getAmntChild().interact("Cook All")){ | |
moveMouseOffScreen(); | |
sleep(1000); | |
} | |
while(!needToBank() || getlvlUpChild() == null){ | |
if(needToBank()){ | |
return Calculations.random(100, 500); | |
} | |
if(getLocalPlayer().getAnimation() == -1){ | |
antiBan(); | |
} | |
if(getlvlUpChild() != null && getlvlUpChild().isVisible()){ | |
return Calculations.random(100, 1200); | |
} | |
sleep(100, 500); | |
} | |
} | |
else if(needToBank()){ | |
if(!getBank().isOpen()){ | |
if(banker.isOnScreen() && banker != null){ | |
banker.interact("Bank"); | |
sleep(500, 750); | |
} | |
} else { | |
if(!getInventory().isEmpty()){ | |
getBank().depositAllItems(); | |
sleep(10, 80); | |
} | |
getBank().withdrawAll(foodName); | |
getBank().close(); | |
} | |
} | |
return Calculations.random(50, 300); | |
} | |
@Override | |
public void onMessage(Message message) { | |
super.onMessage(message); | |
if(message.getMessage() != null && (message.getMessage().toLowerCase().contains("succesfully cook") || message.getMessage().toLowerCase().contains("roast"))){ | |
cookCount++; | |
} | |
else if(message.getMessage() != null && message.getMessage().toLowerCase().contains("accidentally")){ | |
burnCount++; | |
} | |
} | |
private void moveMouseOffScreen(){ | |
int rando = Calculations.random(1, 3); | |
switch(rando){ | |
case 1: getMouse().moveMouseOutsideScreen(); | |
break; | |
} | |
} | |
private void antiBan(){ | |
int rando = Calculations.random(1, antiBanLevel); | |
switch(rando){ | |
case 1: getCamera().rotateToPitch(Calculations.random(350, 383)); | |
log("Anti ban activated"); | |
break; | |
case 2: getCamera().rotateToYaw(Calculations.random(399, 1200)); | |
log("Anti ban activated"); | |
break; | |
case 3: if(getMouse().isMouseInScreen()) getMouse().moveMouseOutsideScreen(); | |
break; | |
default: | |
} | |
} | |
@Override | |
public void onExit() { | |
log("bye"); | |
} | |
public void onPaint(Graphics2D g) { | |
g.drawImage(image, null, 548, 204); | |
g.setColor(Color.WHITE); | |
g.setFont(new Font("Arial", 1, 11)); | |
g.drawString("Time Running: " + t.formatTime(), 610, 315); | |
g.drawString("XP: " + getSkillTracker().getGainedExperience(Skill.COOKING) + " [" + getSkillTracker().getGainedExperiencePerHour(Skill.COOKING) + "]" + " (+" + getSkillTracker().getGainedLevels(Skill.COOKING) + ")", 615, 335); | |
g.drawString("Cooked: " + cookCount, 610, 355); | |
g.drawString("Burned: " + burnCount, 610, 375); | |
g.drawString("Anti ban lvl: " + (antiBanLevel / 100), 610, 395); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment