Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.18 KB | None | 0 0
  1. import java.awt.BasicStroke;
  2. import java.awt.Color;
  3. import java.awt.Font;
  4. import java.awt.Graphics;
  5. import java.awt.Graphics2D;
  6.  
  7. import org.rsbot.event.listeners.PaintListener;
  8. import org.rsbot.script.Script;
  9. import org.rsbot.script.methods.Skills;
  10. import org.rsbot.script.wrappers.RSGroundItem;
  11. import org.rsbot.script.wrappers.RSNPC;
  12. import org.rsbot.script.wrappers.RSObject;
  13. import org.rsbot.script.wrappers.RSTile;
  14. import org.rsbot.script.wrappers.RSTilePath;
  15. import org.rsbot.script.ScriptManifest;
  16.  
  17. @ScriptManifest (
  18. authors = ("Snowdroq"),
  19. version = 1.0,
  20. keywords = ("ogre, killer, fighter, castle, wars"),
  21. description = "OgreKiller By Snowdroq",
  22. name = "sqOgreKiller"
  23.  
  24. )
  25.  
  26. public class sqOgreKiller extends Script implements PaintListener {
  27.  
  28. /*
  29. * ID'S
  30. */
  31.  
  32. private final static int[] OGRE_ID = {3419, 3451, 8658};
  33. private final static int BIGBONES_ID = 532;
  34. private final static int CHEST_ID = 4483;
  35. private final static int TUNA_ID = 361;
  36. private final static int SWORDFISH_ID = 373;
  37. private final static int MONKFISH_ID = 7946;
  38. private final static int SHARK_ID = 385;
  39.  
  40. private int foodToEat = 0;
  41. private int stats[][];
  42.  
  43. private boolean OgreGUIWait = true;
  44.  
  45. private final static RSTile[] tilesToBank = {new RSTile(2499,3094),new RSTile(2492,3085), new RSTile(2487,3077),
  46. new RSTile(2474,3073),new RSTile(2464,3075), new RSTile(2459,3074),
  47. new RSTile(2457,3083),new RSTile(2456,3090),
  48. new RSTile(2443,3090),
  49. new RSTile(2444,3083)};
  50. private RSTilePath pathToBank;
  51.  
  52. private long startTime;
  53.  
  54. private int expGained = 0;
  55. private int startExp = 0;
  56. private int Banked = 0;
  57. private int bonesBanked = 0;
  58.  
  59.  
  60.  
  61.  
  62. @Override
  63. public int loop() {
  64. if(getMyPlayer().getHPPercent() < 50) {
  65. eat();
  66. }
  67.  
  68.  
  69. if(inventory.getCount(foodToEat) <= 1) {
  70. if (atBank()) {
  71. doBank();
  72. } else {
  73. walk();
  74. }
  75. } else {
  76. if(atOgres() && (foodToEat) >=1) {
  77. if(!getMyPlayer().isInCombat()) {
  78. attackOgre();
  79. sleep(500,500);
  80. pickup (BIGBONES_ID);
  81. }
  82. } else {
  83. walkR();
  84. }
  85. }
  86.  
  87.  
  88. return random(600,800);
  89.  
  90. }
  91.  
  92.  
  93.  
  94.  
  95.  
  96. final boolean atOgres() {
  97. RSNPC ogre = npcs.getNearest(OGRE_ID);
  98. if(ogre != null) {
  99. if(ogre.isOnScreen()) {
  100. return true;
  101.  
  102. }
  103.  
  104. }
  105. return false;
  106. }
  107.  
  108. boolean bones;
  109.  
  110.  
  111. private void attackOgre() {
  112. RSNPC ogre = npcs.getNearest(OGRE_ID);
  113. if(!ogre.isInCombat()) {
  114. ogre.interact("Attack");
  115. sleep(650,800);
  116. }
  117. }
  118.  
  119. private void pickup(int id) {
  120. if(groundItems.getNearest(id) != null && !inventory.isFull()) {
  121. RSGroundItem item = groundItems.getNearest(id);
  122. if(calc.tileOnScreen(item.getLocation())) {
  123. item.interact("Take " + item.getItem().getName());
  124. } else {
  125. walking.walkTileMM(groundItems.getNearest(id).getLocation());
  126.  
  127. }
  128. sleep(600,800);
  129. }
  130.  
  131. }
  132.  
  133. private void eat() {
  134. inventory.getItem(foodToEat).doClick(true);
  135. sleep(800,1000);
  136.  
  137. }
  138. OgreGUI g = new OgreGUI();
  139.  
  140.  
  141. public boolean onStart() {
  142. startExp = skills.getCurrentExp(skills.STRENGTH);
  143. pathToBank = walking.newTilePath(tilesToBank);
  144. startTime = System.currentTimeMillis();
  145.  
  146.  
  147. g.setVisible(true);
  148. while(OgreGUIWait) sleep(500);
  149.  
  150. return true;
  151. }
  152.  
  153.  
  154.  
  155.  
  156. private final void walkR() {
  157. pathToBank.reverse();
  158. pathToBank.traverse();
  159. pathToBank.reverse();
  160.  
  161. }
  162.  
  163. private final void walk() {
  164. pathToBank.traverse();
  165. }
  166.  
  167.  
  168. public void onFinish() {
  169. log("Thank You For Using Snowdroqs Ogre Killer!");
  170.  
  171. }
  172. private final boolean atBank() {
  173. RSObject bank = objects.getNearest(CHEST_ID);
  174. if(bank != null) {
  175. if(bank.isOnScreen()) {
  176.  
  177. return true;
  178. }
  179. }
  180.  
  181. return false;
  182.  
  183. }
  184.  
  185. private final void doBank() {
  186. if (bank.isOpen()) {
  187. Banked = inventory.getCount(BIGBONES_ID);
  188. bonesBanked += Banked;
  189. bank.depositAll();
  190. sleep(800,1200);
  191. bank.withdraw (foodToEat, 28);
  192. } else {
  193. bank.open();
  194. sleep(1800,2200);
  195. }
  196. }
  197.  
  198.  
  199. //START: Code generated using Enfilade's Easel
  200. private final Color color1 = new Color(153, 0, 153);
  201. private final Color color2 = new Color(0, 0, 0);
  202. private final Color color3 = new Color(255, 255, 255);
  203.  
  204. private final BasicStroke stroke1 = new BasicStroke(1);
  205.  
  206. private final Font font1 = new Font("BankGothic Lt BT", 0, 16);
  207.  
  208. //END: Code generated using Enfilade's Easel
  209.  
  210.  
  211. @Override
  212. public void onRepaint(Graphics g) {
  213.  
  214. expGained = skills.getCurrentExp(skills.STRENGTH) - startExp;
  215.  
  216. long millis = System.currentTimeMillis() - startTime;
  217. long hours = millis / (1000 * 60 * 60);
  218. millis -= hours * (1000 * 60 * 60);
  219. long minutes = millis / (1000 * 60);
  220. millis -= minutes * (1000 * 60);
  221. long seconds = millis / 1000;
  222.  
  223.  
  224. float xpsec = 0;
  225. if((minutes > 0 || hours > 0 || seconds > 0) && expGained > 0) {
  226. xpsec = ((float) expGained)/(float)(seconds + (minutes*60) + (hours*60*60));
  227. }
  228. float xpmin = xpsec * 60;
  229. float xphour = xpmin * 60;
  230.  
  231.  
  232.  
  233.  
  234. Graphics2D g1 = (Graphics2D)g;
  235. g1.setColor(color1);
  236. g1.fillRect(6, 344, 506, 129);
  237. g1.setColor(color2);
  238. g1.setStroke(stroke1);
  239. g1.drawRect(6, 344, 506, 129);
  240. g1.setFont(font1);
  241. g1.setColor(color3);
  242. g1.drawString("Snowdroqs Ogre Killer V1.0", 13, 361);
  243. g1.drawString("Runtime: " + hours + ":" + minutes + ":" + seconds, 12, 393);
  244. g1.drawString("Experience Gained: " + expGained, 250, 393);
  245. g1.drawString("Experience/h: " + (int)xphour, 250, 433);
  246. g1.drawString("Bones Banked: " + bonesBanked, 12, 433);
  247.  
  248. g.drawLine(mouse.getLocation().x - 2000, mouse.getLocation().y,
  249. mouse.getLocation().x + 2000, mouse.getLocation().y);
  250. g.drawLine(mouse.getLocation
  251.  
  252. ().x, mouse.getLocation().y - 2000,
  253.  
  254.  
  255. mouse.getLocation().x, mouse.getLocation().y + 2000);
  256.  
  257.  
  258. }class OgreGUI extends javax.swing.JFrame {
  259.  
  260. /** Creates new form OgreGUI */
  261. public OgreGUI() {
  262. initComponents();
  263. }
  264.  
  265. /** This method is called from within the constructor to
  266. * initialize the form.
  267. * WARNING: Do NOT modify this code. The content of this method is
  268. * always regenerated by the Form Editor.
  269. */
  270. @SuppressWarnings("unchecked")
  271. // <editor-fold defaultstate="collapsed" desc="Generated Code">
  272. private void initComponents() {
  273.  
  274. jLabel1 = new javax.swing.JLabel();
  275. jLabel2 = new javax.swing.JLabel();
  276. foodSelected = new javax.swing.JComboBox();
  277. startButton = new javax.swing.JButton();
  278.  
  279.  
  280. jLabel1.setFont(new java.awt.Font("BankGothic Lt BT", 1, 18)); // NOI18N
  281. jLabel1.setText("Snowdroqs Ogre Killer");
  282.  
  283. jLabel2.setText("Food:");
  284.  
  285. foodSelected.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Tuna", "Swordfish", "Monkfish", "Shark" }));
  286.  
  287. startButton.setText("Start");
  288. startButton.addActionListener(new java.awt.event.ActionListener() {
  289. public void actionPerformed(java.awt.event.ActionEvent evt) {
  290. startButtonActionPerformed(evt);
  291. }
  292. });
  293.  
  294. javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  295. getContentPane().setLayout(layout);
  296. layout.setHorizontalGroup(
  297. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  298. .addGroup(layout.createSequentialGroup()
  299. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  300. .addComponent(jLabel1)
  301. .addGroup(layout.createSequentialGroup()
  302. .addContainerGap()
  303. .addComponent(jLabel2)
  304. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  305. .addComponent(foodSelected, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)))
  306. .addContainerGap(22, Short.MAX_VALUE))
  307. .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  308. .addContainerGap(207, Short.MAX_VALUE)
  309. .addComponent(startButton)
  310. .addContainerGap())
  311. );
  312. layout.setVerticalGroup(
  313. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  314. .addGroup(layout.createSequentialGroup()
  315. .addComponent(jLabel1)
  316. .addGap(18, 18, 18)
  317. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  318. .addComponent(jLabel2)
  319. .addComponent(foodSelected, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  320. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 25, Short.MAX_VALUE)
  321. .addComponent(startButton)
  322. .addContainerGap())
  323. );
  324.  
  325. pack();
  326. }// </editor-fold>
  327.  
  328. private void startButtonActionPerformed(java.awt.event.ActionEvent e) {
  329. String chosen = foodSelected.getSelectedItem().toString();
  330. if(chosen.equals("Tuna")) {
  331. foodToEat = TUNA_ID;
  332. } else if(chosen.equals("Swordfish")) {
  333. foodToEat = SWORDFISH_ID;
  334. } else if(chosen.equals("Monkfish")) {
  335. foodToEat = MONKFISH_ID;
  336. } else {
  337. foodToEat = SHARK_ID;
  338. }
  339. OgreGUIWait = false;
  340. g.dispose();
  341. }
  342.  
  343. /**
  344. * @param args the command line arguments
  345. */
  346. public void main(String args[]) {
  347. java.awt.EventQueue.invokeLater(new Runnable() {
  348.  
  349. public void run() {
  350. new OgreGUI().setVisible(true);
  351. }
  352. });
  353. }
  354. // Variables declaration - do not modify
  355. private javax.swing.JComboBox foodSelected;
  356. private javax.swing.JLabel jLabel1;
  357. private javax.swing.JLabel jLabel2;
  358. private javax.swing.JButton startButton;
  359. // End of variables declaration
  360. }
  361. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement